|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
maven-antrun-plugin: Java classes don't compile after an Ant taskMy project generates source code using the XTC parser generator
(http://cs.nyu.edu/rgrimm/xtc/). XTC doesn't have a Maven plugin that I'm aware of, so I'm trying to build the parser using an Ant Java task, like so: <plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <phase>generate-sources</phase> <configuration> <tasks> <mkdir dir="${project.build.directory}/generated-sources/main/java/" /> <java classpath="lib/xtc.jar" classname="xtc.parser.Rats"> <arg line="-in ${project.build.sourceDirectory}" /> <arg line="-out ${project.build.directory}/generated-sources/main/java/" /> <arg path="${project.build.sourceDirectory}/Dot.rats" /> </java> </tasks> <sourceRoot> ${project.build.directory}/generated-sources/main/java </sourceRoot> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> The details of what XTC does aren't important: the end result is that the above generates Dot.java and places it in target/generated-sources/main/java. It works fine. The problem is that, with this plugin element in my pom.xml, none of the Java files in the project get compiled. In a project generated using "mvn archetype:create -DgroupId=foo -DartifactId=bar", if I run "mvn compile" without the plugin element, I get: $ mvn compile [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building bar [INFO] task-segment: [compile] [INFO] ------------------------------------------------------------------------ [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] [INFO] Compiling 1 source file to /home/chris/src/tests/maven/project1/bar/target/classes [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1 second [INFO] Finished at: Wed Jul 01 18:57:08 EDT 2009 [INFO] Final Memory: 6M/67M [INFO] ------------------------------------------------------------------------ Whereas with the plugin element invoking XTC, I get (after a "mvn clean"): $ mvn compile [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building bar [INFO] task-segment: [compile] [INFO] ------------------------------------------------------------------------ [INFO] [antrun:run {execution: default}] [INFO] Executing tasks [mkdir] Created dir: /home/chris/src/tests/maven/project1/bar/target/generated-sources/main/java Rats! Parser Generator, v. 1.14.2, (C) 2004-2008 Robert Grimm Processing /home/chris/src/tests/maven/project1/bar/src/main/java/Dot.rats ... The XTC process is not failing, AFAICT. I've tried other kinds of Ant tasks and they don't interfere with Java compilation. For example, if I replace the task element above with an echo task <tasks> <mkdir dir="${project.build.directory}/generated-sources/main/java/" /> <echo file="${project.build.directory}/generated-sources/main/java/Dot.java"> public class Dot { } </echo> </tasks> I get $ mvn compile [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building bar [INFO] task-segment: [compile] [INFO] ------------------------------------------------------------------------ [INFO] [antrun:run {execution: default}] [INFO] Executing tasks [INFO] Executed tasks [INFO] Registering compile source root /home/chris/src/tests/maven/project1/bar/target/generated-sources/main/java [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] [INFO] Compiling 2 source files to /home/chris/src/tests/maven/project1/bar/target/classes [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2 seconds [INFO] Finished at: Wed Jul 01 19:03:34 EDT 2009 [INFO] Final Memory: 7M/79M [INFO] ------------------------------------------------------------------------ Obviously there's something I'm not understanding about how Maven executes the java task. Is there something simple that I'm doing wrong? Is there an alternative way to accomplish this task that I should try (perhaps a more "Maven-native" way)? The full pom.xml is attached. Regards, Chris <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>foo</groupId> <artifactId>bar</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>bar</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>xtc</groupId> <artifactId>xtc</artifactId> <version>1.14.2</version> <scope>system</scope> <systemPath>${basedir}/lib/xtc.jar</systemPath> </dependency> </dependencies> <build> <plugins> <!-- Run Rats! on some files --> <plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <phase>generate-sources</phase> <configuration> <tasks> <mkdir dir="${project.build.directory}/generated-sources/main/java/" /> <java classpath="lib/xtc.jar" classname="xtc.parser.Rats"> <arg line="-in ${project.build.sourceDirectory}" /> <arg line="-out ${project.build.directory}/generated-sources/main/java/" /> <arg path="${project.build.sourceDirectory}/Dot.rats" /> </java> <!-- <echo file="${project.build.directory}/generated-sources/main/java/Dot.java"> --> <!-- public class Dot { } --> <!-- </echo> --> </tasks> <sourceRoot> ${project.build.directory}/generated-sources/main/java </sourceRoot> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: maven-antrun-plugin: Java classes don't compile after an Ant taskyou need to use buildhelper-maven-plugin to attach the generated-sources
directory. Maven does not know that you've generated additional sources. Most/all of the source generator maven plugins will add the generated-sources/pluginname folder as an additional source path... buildhelper is there to allow you to achieve the same from outside of a plugin. also, the convention would be to put your code in ${project.build.directory}/generated-sources/xtc/ and not ${project.build.directory}/generated-sources/main/java/ It's no biggie, and it probably will not cause any issues.. unless you hit the maximum path lengths of windows 2009/7/2 Christopher L Conway <cconway@...> > My project generates source code using the XTC parser generator > (http://cs.nyu.edu/rgrimm/xtc/). XTC doesn't have a Maven plugin that > I'm aware of, so I'm trying to build the parser using an Ant Java > task, like so: > > <plugin> > <artifactId>maven-antrun-plugin</artifactId> > <executions> > <execution> > <phase>generate-sources</phase> > <configuration> > <tasks> > <mkdir > dir="${project.build.directory}/generated-sources/main/java/" /> > <java classpath="lib/xtc.jar" classname="xtc.parser.Rats"> > <arg line="-in ${project.build.sourceDirectory}" /> > <arg line="-out > ${project.build.directory}/generated-sources/main/java/" /> > <arg path="${project.build.sourceDirectory}/Dot.rats" /> > </java> > </tasks> > <sourceRoot> > ${project.build.directory}/generated-sources/main/java > </sourceRoot> > </configuration> > <goals> > <goal>run</goal> > </goals> > </execution> > </executions> > </plugin> > > The details of what XTC does aren't important: the end result is that > the above generates Dot.java and places it in > target/generated-sources/main/java. It works fine. > > The problem is that, with this plugin element in my pom.xml, none of > the Java files in the project get compiled. In a project generated > using "mvn archetype:create -DgroupId=foo -DartifactId=bar", if I run > "mvn compile" without the plugin element, I get: > > $ mvn compile > [INFO] Scanning for projects... > [INFO] > ------------------------------------------------------------------------ > [INFO] Building bar > [INFO] task-segment: [compile] > [INFO] > ------------------------------------------------------------------------ > [INFO] [resources:resources] > [INFO] Using default encoding to copy filtered resources. > [INFO] [compiler:compile] > [INFO] Compiling 1 source file to > /home/chris/src/tests/maven/project1/bar/target/classes > [INFO] > ------------------------------------------------------------------------ > [INFO] BUILD SUCCESSFUL > [INFO] > ------------------------------------------------------------------------ > [INFO] Total time: 1 second > [INFO] Finished at: Wed Jul 01 18:57:08 EDT 2009 > [INFO] Final Memory: 6M/67M > [INFO] > ------------------------------------------------------------------------ > > Whereas with the plugin element invoking XTC, I get (after a "mvn clean"): > > $ mvn compile > [INFO] Scanning for projects... > [INFO] > ------------------------------------------------------------------------ > [INFO] Building bar > [INFO] task-segment: [compile] > [INFO] > ------------------------------------------------------------------------ > [INFO] [antrun:run {execution: default}] > [INFO] Executing tasks > [mkdir] Created dir: > /home/chris/src/tests/maven/project1/bar/target/generated-sources/main/java > Rats! Parser Generator, v. 1.14.2, (C) 2004-2008 Robert Grimm > Processing /home/chris/src/tests/maven/project1/bar/src/main/java/Dot.rats > ... > > The XTC process is not failing, AFAICT. > > I've tried other kinds of Ant tasks and they don't interfere with Java > compilation. For example, if I replace the task element above with an > echo task > > <tasks> > <mkdir > dir="${project.build.directory}/generated-sources/main/java/" /> > <echo > file="${project.build.directory}/generated-sources/main/java/Dot.java"> > public class Dot { } > </echo> > </tasks> > > I get > > $ mvn compile > [INFO] Scanning for projects... > [INFO] > ------------------------------------------------------------------------ > [INFO] Building bar > [INFO] task-segment: [compile] > [INFO] > ------------------------------------------------------------------------ > [INFO] [antrun:run {execution: default}] > [INFO] Executing tasks > [INFO] Executed tasks > [INFO] Registering compile source root > /home/chris/src/tests/maven/project1/bar/target/generated-sources/main/java > [INFO] [resources:resources] > [INFO] Using default encoding to copy filtered resources. > [INFO] [compiler:compile] > [INFO] Compiling 2 source files to > /home/chris/src/tests/maven/project1/bar/target/classes > [INFO] > ------------------------------------------------------------------------ > [INFO] BUILD SUCCESSFUL > [INFO] > ------------------------------------------------------------------------ > [INFO] Total time: 2 seconds > [INFO] Finished at: Wed Jul 01 19:03:34 EDT 2009 > [INFO] Final Memory: 7M/79M > [INFO] > ------------------------------------------------------------------------ > > Obviously there's something I'm not understanding about how Maven > executes the java task. Is there something simple that I'm doing > wrong? Is there an alternative way to accomplish this task that I > should try (perhaps a more "Maven-native" way)? > > The full pom.xml is attached. > > Regards, > Chris > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > |
|
|
Re: maven-antrun-plugin: Java classes don't compile after an Ant taskI don't think I was clear in my original message: the problem is that none of my Java classes are being compiled, not even the pre-existing, non-generated ones. Also, the problem does not occur with the echo Ant task. In that case, all of the Java classes do get compiled, both the pre-existing classes and the generated class. The sourceRoot element of the plugin configuration adds the generated sources to the source path. The problem seems to be more specifically with the java Ant task, which somehow seems to prevent Maven from continuing on to compile the Java classes. Thanks, Chris |
|
|
Re: maven-antrun-plugin: Java classes don't compile after an Ant taskFunny story. I tried replacing the Ant task with a Maven plugin, by writing a RatsMojo class that invokes xtc.parser.Rats directly and replacing the plugin element above with
<plugin> <groupId>edu.nyu.xtc</groupId> <artifactId>maven-xtc-plugin</artifactId> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>rats</goal> </goals> <configuration> <inputDirectory>${project.build.sourceDirectory}</inputDirectory> <outputDirectory> ${project.build.directory}/generated-sources/main/java</outputDirectory> <grammarFile>${project.build.sourceDirectory}/Dot.rats</grammarFile> </configuration> </execution> </executions> </plugin> It does the exact same thing: it runs Rats! then terminates without compiling *any* of the Java files in the project. RatsMojo.java is attached. -Chris RatsMojo.java
|
|
|
Re: maven-antrun-plugin: Java classes don't compile after an Ant taskThe problem seems to be that Rats! calls System.exit() (or similar), terminating the JVM. I would have thought that Ant would wrap this (the java task is copied over from a build.xml and it doesn't terminate the Ant build), but the following works by forcing the Rats! process into a separate JVM:
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.1</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>exec</goal> </goals> </execution> </executions> <configuration> <executable>java</executable> <arguments> <argument>-classpath</argument> <argument>${basedir}/lib/xtc.jar</argument> <argument>xtc.parser.Rats</argument> <argument>-in</argument> <argument>${project.build.sourceDirectory}</argument> <argument>-out</argument> <argument>${project.build.directory}/generated-sources/main/java/</argument> <argument>${project.build.sourceDirectory}/Dot.rats</argument> </arguments> </configuration> </plugin> -Chris
|
|
|
Re: maven-antrun-plugin: Java classes don't compile after an Ant taskA simple fork=yes would have done the job.
On Fri, Jul 3, 2009 at 12:01 PM, clconway<cconway@...> wrote: > > The problem seems to be that Rats! calls System.exit() (or similar), > terminating the JVM. I would have thought that Ant would wrap this (the java > task is copied over from a build.xml and it doesn't terminate the Ant > build), but the following works by forcing the Rats! process into a separate > JVM: > > <plugin> > <groupId>org.codehaus.mojo</groupId> > <artifactId>exec-maven-plugin</artifactId> > <version>1.1</version> > <executions> > <execution> > <phase>generate-sources</phase> > <goals> > <goal>exec</goal> > </goals> > </execution> > </executions> > <configuration> > <executable>java</executable> > <arguments> > <argument>-classpath</argument> > <argument>${basedir}/lib/xtc.jar</argument> > <argument>xtc.parser.Rats</argument> > <argument>-in</argument> > <argument>${project.build.sourceDirectory}</argument> > <argument>-out</argument> > > <argument>${project.build.directory}/generated-sources/main/java/</argument> > <argument>${project.build.sourceDirectory}/Dot.rats</argument> > </arguments> > </configuration> > </plugin> > > -Chris > > > clconway wrote: >> >> Funny story. I tried replacing the Ant task with a Maven plugin, by >> writing a RatsMojo class that invokes xtc.parser.Rats directly and >> replacing the plugin element above with >> >> <plugin> >> <groupId>edu.nyu.xtc</groupId> >> <artifactId>maven-xtc-plugin</artifactId> >> <executions> >> <execution> >> <phase>generate-sources</phase> >> <goals> >> <goal>rats</goal> >> </goals> >> <configuration> >> >> <inputDirectory>${project.build.sourceDirectory}</inputDirectory> >> <outputDirectory> >> ${project.build.directory}/generated-sources/main/java</outputDirectory> >> >> <grammarFile>${project.build.sourceDirectory}/Dot.rats</grammarFile> >> </configuration> >> </execution> >> </executions> >> </plugin> >> >> It does the exact same thing: it runs Rats! then terminates without >> compiling *any* of the Java files in the project. >> >> RatsMojo.java is attached. >> >> -Chris >> http://www.nabble.com/file/p24314823/RatsMojo.java RatsMojo.java >> >> >> clconway wrote: >>> >>> My project generates source code using the XTC parser generator >>> (http://cs.nyu.edu/rgrimm/xtc/). XTC doesn't have a Maven plugin that >>> I'm aware of, so I'm trying to build the parser using an Ant Java >>> task, like so: >>> >>> <plugin> >>> <artifactId>maven-antrun-plugin</artifactId> >>> <executions> >>> <execution> >>> <phase>generate-sources</phase> >>> <configuration> >>> <tasks> >>> <mkdir >>> dir="${project.build.directory}/generated-sources/main/java/" /> >>> <java classpath="lib/xtc.jar" >>> classname="xtc.parser.Rats"> >>> <arg line="-in ${project.build.sourceDirectory}" /> >>> <arg line="-out >>> ${project.build.directory}/generated-sources/main/java/" /> >>> <arg path="${project.build.sourceDirectory}/Dot.rats" >>> /> >>> </java> >>> </tasks> >>> <sourceRoot> >>> ${project.build.directory}/generated-sources/main/java >>> </sourceRoot> >>> </configuration> >>> <goals> >>> <goal>run</goal> >>> </goals> >>> </execution> >>> </executions> >>> </plugin> >>> >>> The details of what XTC does aren't important: the end result is that >>> the above generates Dot.java and places it in >>> target/generated-sources/main/java. It works fine. >>> >>> The problem is that, with this plugin element in my pom.xml, none of >>> the Java files in the project get compiled. In a project generated >>> using "mvn archetype:create -DgroupId=foo -DartifactId=bar", if I run >>> "mvn compile" without the plugin element, I get: >>> >>> $ mvn compile >>> [INFO] Scanning for projects... >>> [INFO] >>> ------------------------------------------------------------------------ >>> [INFO] Building bar >>> [INFO] task-segment: [compile] >>> [INFO] >>> ------------------------------------------------------------------------ >>> [INFO] [resources:resources] >>> [INFO] Using default encoding to copy filtered resources. >>> [INFO] [compiler:compile] >>> [INFO] Compiling 1 source file to >>> /home/chris/src/tests/maven/project1/bar/target/classes >>> [INFO] >>> ------------------------------------------------------------------------ >>> [INFO] BUILD SUCCESSFUL >>> [INFO] >>> ------------------------------------------------------------------------ >>> [INFO] Total time: 1 second >>> [INFO] Finished at: Wed Jul 01 18:57:08 EDT 2009 >>> [INFO] Final Memory: 6M/67M >>> [INFO] >>> ------------------------------------------------------------------------ >>> >>> Whereas with the plugin element invoking XTC, I get (after a "mvn >>> clean"): >>> >>> $ mvn compile >>> [INFO] Scanning for projects... >>> [INFO] >>> ------------------------------------------------------------------------ >>> [INFO] Building bar >>> [INFO] task-segment: [compile] >>> [INFO] >>> ------------------------------------------------------------------------ >>> [INFO] [antrun:run {execution: default}] >>> [INFO] Executing tasks >>> [mkdir] Created dir: >>> /home/chris/src/tests/maven/project1/bar/target/generated-sources/main/java >>> Rats! Parser Generator, v. 1.14.2, (C) 2004-2008 Robert Grimm >>> Processing >>> /home/chris/src/tests/maven/project1/bar/src/main/java/Dot.rats ... >>> >>> The XTC process is not failing, AFAICT. >>> >>> I've tried other kinds of Ant tasks and they don't interfere with Java >>> compilation. For example, if I replace the task element above with an >>> echo task >>> >>> <tasks> >>> <mkdir >>> dir="${project.build.directory}/generated-sources/main/java/" /> >>> <echo >>> file="${project.build.directory}/generated-sources/main/java/Dot.java"> >>> public class Dot { } >>> </echo> >>> </tasks> >>> >>> I get >>> >>> $ mvn compile >>> [INFO] Scanning for projects... >>> [INFO] >>> ------------------------------------------------------------------------ >>> [INFO] Building bar >>> [INFO] task-segment: [compile] >>> [INFO] >>> ------------------------------------------------------------------------ >>> [INFO] [antrun:run {execution: default}] >>> [INFO] Executing tasks >>> [INFO] Executed tasks >>> [INFO] Registering compile source root >>> /home/chris/src/tests/maven/project1/bar/target/generated-sources/main/java >>> [INFO] [resources:resources] >>> [INFO] Using default encoding to copy filtered resources. >>> [INFO] [compiler:compile] >>> [INFO] Compiling 2 source files to >>> /home/chris/src/tests/maven/project1/bar/target/classes >>> [INFO] >>> ------------------------------------------------------------------------ >>> [INFO] BUILD SUCCESSFUL >>> [INFO] >>> ------------------------------------------------------------------------ >>> [INFO] Total time: 2 seconds >>> [INFO] Finished at: Wed Jul 01 19:03:34 EDT 2009 >>> [INFO] Final Memory: 7M/79M >>> [INFO] >>> ------------------------------------------------------------------------ >>> >>> Obviously there's something I'm not understanding about how Maven >>> executes the java task. Is there something simple that I'm doing >>> wrong? Is there an alternative way to accomplish this task that I >>> should try (perhaps a more "Maven-native" way)? >>> >>> The full pom.xml is attached. >>> >>> Regards, >>> Chris >>> >>> <project xmlns="http://maven.apache.org/POM/4.0.0" >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 >>> http://maven.apache.org/maven-v4_0_0.xsd"> >>> <modelVersion>4.0.0</modelVersion> >>> <groupId>foo</groupId> >>> <artifactId>bar</artifactId> >>> <packaging>jar</packaging> >>> <version>1.0-SNAPSHOT</version> >>> <name>bar</name> >>> <url>http://maven.apache.org</url> >>> <dependencies> >>> <dependency> >>> <groupId>junit</groupId> >>> <artifactId>junit</artifactId> >>> <version>3.8.1</version> >>> <scope>test</scope> >>> </dependency> >>> <dependency> >>> <groupId>xtc</groupId> >>> <artifactId>xtc</artifactId> >>> <version>1.14.2</version> >>> <scope>system</scope> >>> <systemPath>${basedir}/lib/xtc.jar</systemPath> >>> </dependency> >>> </dependencies> >>> <build> >>> <plugins> >>> <!-- Run Rats! on some files --> >>> <plugin> >>> <artifactId>maven-antrun-plugin</artifactId> >>> <executions> >>> <execution> >>> <phase>generate-sources</phase> >>> <configuration> >>> <tasks> >>> <mkdir >>> dir="${project.build.directory}/generated-sources/main/java/" /> >>> <java classpath="lib/xtc.jar" >>> classname="xtc.parser.Rats"> >>> <arg line="-in ${project.build.sourceDirectory}" /> >>> <arg line="-out >>> ${project.build.directory}/generated-sources/main/java/" /> >>> <arg path="${project.build.sourceDirectory}/Dot.rats" >>> /> >>> </java> >>> <!-- <echo >>> file="${project.build.directory}/generated-sources/main/java/Dot.java"> >>> --> >>> <!-- public class Dot { } --> >>> <!-- </echo> --> >>> </tasks> >>> <sourceRoot> >>> ${project.build.directory}/generated-sources/main/java >>> </sourceRoot> >>> </configuration> >>> <goals> >>> <goal>run</goal> >>> </goals> >>> </execution> >>> </executions> >>> </plugin> >>> </plugins> >>> </build> >>> </project> >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscribe@... >>> For additional commands, e-mail: users-help@... >>> >> >> > > -- > View this message in context: http://www.nabble.com/maven-antrun-plugin%3A-Java-classes-don%27t-compile-after-an-Ant-task-tp24300991p24325361.html > Sent from the Maven - Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: maven-antrun-plugin: Java classes don't compile after an Ant taskYou are right. fork="true" in the Ant java task works too. But this was not necessary in the original Ant build script. Is there an explanation in the documentation of why antrun behaves differently?
-Chris
|
|
|
Re: maven-antrun-plugin: Java classes don't compile after an Ant taskNot obviously to me. fork defaults to false in ant 1.7.1, so I would
have expected the same. On Fri, Jul 3, 2009 at 12:49 PM, clconway<cconway@...> wrote: > > You are right. fork="true" in the Ant java task works too. But this was not > necessary in the original Ant build script. Is there an explanation in the > documentation of why antrun behaves differently? > > -Chris > > > > bimargulies wrote: >> >> A simple fork=yes would have done the job. >> >> On Fri, Jul 3, 2009 at 12:01 PM, clconway<cconway@...> wrote: >>> >>> The problem seems to be that Rats! calls System.exit() (or similar), >>> terminating the JVM. I would have thought that Ant would wrap this (the >>> java >>> task is copied over from a build.xml and it doesn't terminate the Ant >>> build), but the following works by forcing the Rats! process into a >>> separate >>> JVM: >>> >>> <plugin> >>> <groupId>org.codehaus.mojo</groupId> >>> <artifactId>exec-maven-plugin</artifactId> >>> <version>1.1</version> >>> <executions> >>> <execution> >>> <phase>generate-sources</phase> >>> <goals> >>> <goal>exec</goal> >>> </goals> >>> </execution> >>> </executions> >>> <configuration> >>> <executable>java</executable> >>> <arguments> >>> <argument>-classpath</argument> >>> <argument>${basedir}/lib/xtc.jar</argument> >>> <argument>xtc.parser.Rats</argument> >>> <argument>-in</argument> >>> <argument>${project.build.sourceDirectory}</argument> >>> <argument>-out</argument> >>> >>> <argument>${project.build.directory}/generated-sources/main/java/</argument> >>> <argument>${project.build.sourceDirectory}/Dot.rats</argument> >>> </arguments> >>> </configuration> >>> </plugin> >>> >>> -Chris >>> >>> >>> clconway wrote: >>>> >>>> Funny story. I tried replacing the Ant task with a Maven plugin, by >>>> writing a RatsMojo class that invokes xtc.parser.Rats directly and >>>> replacing the plugin element above with >>>> >>>> <plugin> >>>> <groupId>edu.nyu.xtc</groupId> >>>> <artifactId>maven-xtc-plugin</artifactId> >>>> <executions> >>>> <execution> >>>> <phase>generate-sources</phase> >>>> <goals> >>>> <goal>rats</goal> >>>> </goals> >>>> <configuration> >>>> >>>> <inputDirectory>${project.build.sourceDirectory}</inputDirectory> >>>> <outputDirectory> >>>> ${project.build.directory}/generated-sources/main/java</outputDirectory> >>>> >>>> <grammarFile>${project.build.sourceDirectory}/Dot.rats</grammarFile> >>>> </configuration> >>>> </execution> >>>> </executions> >>>> </plugin> >>>> >>>> It does the exact same thing: it runs Rats! then terminates without >>>> compiling *any* of the Java files in the project. >>>> >>>> RatsMojo.java is attached. >>>> >>>> -Chris >>>> http://www.nabble.com/file/p24314823/RatsMojo.java RatsMojo.java >>>> >>>> >>>> clconway wrote: >>>>> >>>>> My project generates source code using the XTC parser generator >>>>> (http://cs.nyu.edu/rgrimm/xtc/). XTC doesn't have a Maven plugin that >>>>> I'm aware of, so I'm trying to build the parser using an Ant Java >>>>> task, like so: >>>>> >>>>> <plugin> >>>>> <artifactId>maven-antrun-plugin</artifactId> >>>>> <executions> >>>>> <execution> >>>>> <phase>generate-sources</phase> >>>>> <configuration> >>>>> <tasks> >>>>> <mkdir >>>>> dir="${project.build.directory}/generated-sources/main/java/" /> >>>>> <java classpath="lib/xtc.jar" >>>>> classname="xtc.parser.Rats"> >>>>> <arg line="-in ${project.build.sourceDirectory}" /> >>>>> <arg line="-out >>>>> ${project.build.directory}/generated-sources/main/java/" /> >>>>> <arg path="${project.build.sourceDirectory}/Dot.rats" >>>>> /> >>>>> </java> >>>>> </tasks> >>>>> <sourceRoot> >>>>> ${project.build.directory}/generated-sources/main/java >>>>> </sourceRoot> >>>>> </configuration> >>>>> <goals> >>>>> <goal>run</goal> >>>>> </goals> >>>>> </execution> >>>>> </executions> >>>>> </plugin> >>>>> >>>>> The details of what XTC does aren't important: the end result is that >>>>> the above generates Dot.java and places it in >>>>> target/generated-sources/main/java. It works fine. >>>>> >>>>> The problem is that, with this plugin element in my pom.xml, none of >>>>> the Java files in the project get compiled. In a project generated >>>>> using "mvn archetype:create -DgroupId=foo -DartifactId=bar", if I run >>>>> "mvn compile" without the plugin element, I get: >>>>> >>>>> $ mvn compile >>>>> [INFO] Scanning for projects... >>>>> [INFO] >>>>> ------------------------------------------------------------------------ >>>>> [INFO] Building bar >>>>> [INFO] task-segment: [compile] >>>>> [INFO] >>>>> ------------------------------------------------------------------------ >>>>> [INFO] [resources:resources] >>>>> [INFO] Using default encoding to copy filtered resources. >>>>> [INFO] [compiler:compile] >>>>> [INFO] Compiling 1 source file to >>>>> /home/chris/src/tests/maven/project1/bar/target/classes >>>>> [INFO] >>>>> ------------------------------------------------------------------------ >>>>> [INFO] BUILD SUCCESSFUL >>>>> [INFO] >>>>> ------------------------------------------------------------------------ >>>>> [INFO] Total time: 1 second >>>>> [INFO] Finished at: Wed Jul 01 18:57:08 EDT 2009 >>>>> [INFO] Final Memory: 6M/67M >>>>> [INFO] >>>>> ------------------------------------------------------------------------ >>>>> >>>>> Whereas with the plugin element invoking XTC, I get (after a "mvn >>>>> clean"): >>>>> >>>>> $ mvn compile >>>>> [INFO] Scanning for projects... >>>>> [INFO] >>>>> ------------------------------------------------------------------------ >>>>> [INFO] Building bar >>>>> [INFO] task-segment: [compile] >>>>> [INFO] >>>>> ------------------------------------------------------------------------ >>>>> [INFO] [antrun:run {execution: default}] >>>>> [INFO] Executing tasks >>>>> [mkdir] Created dir: >>>>> /home/chris/src/tests/maven/project1/bar/target/generated-sources/main/java >>>>> Rats! Parser Generator, v. 1.14.2, (C) 2004-2008 Robert Grimm >>>>> Processing >>>>> /home/chris/src/tests/maven/project1/bar/src/main/java/Dot.rats ... >>>>> >>>>> The XTC process is not failing, AFAICT. >>>>> >>>>> I've tried other kinds of Ant tasks and they don't interfere with Java >>>>> compilation. For example, if I replace the task element above with an >>>>> echo task >>>>> >>>>> <tasks> >>>>> <mkdir >>>>> dir="${project.build.directory}/generated-sources/main/java/" /> >>>>> <echo >>>>> file="${project.build.directory}/generated-sources/main/java/Dot.java"> >>>>> public class Dot { } >>>>> </echo> >>>>> </tasks> >>>>> >>>>> I get >>>>> >>>>> $ mvn compile >>>>> [INFO] Scanning for projects... >>>>> [INFO] >>>>> ------------------------------------------------------------------------ >>>>> [INFO] Building bar >>>>> [INFO] task-segment: [compile] >>>>> [INFO] >>>>> ------------------------------------------------------------------------ >>>>> [INFO] [antrun:run {execution: default}] >>>>> [INFO] Executing tasks >>>>> [INFO] Executed tasks >>>>> [INFO] Registering compile source root >>>>> /home/chris/src/tests/maven/project1/bar/target/generated-sources/main/java >>>>> [INFO] [resources:resources] >>>>> [INFO] Using default encoding to copy filtered resources. >>>>> [INFO] [compiler:compile] >>>>> [INFO] Compiling 2 source files to >>>>> /home/chris/src/tests/maven/project1/bar/target/classes >>>>> [INFO] >>>>> ------------------------------------------------------------------------ >>>>> [INFO] BUILD SUCCESSFUL >>>>> [INFO] >>>>> ------------------------------------------------------------------------ >>>>> [INFO] Total time: 2 seconds >>>>> [INFO] Finished at: Wed Jul 01 19:03:34 EDT 2009 >>>>> [INFO] Final Memory: 7M/79M >>>>> [INFO] >>>>> ------------------------------------------------------------------------ >>>>> >>>>> Obviously there's something I'm not understanding about how Maven >>>>> executes the java task. Is there something simple that I'm doing >>>>> wrong? Is there an alternative way to accomplish this task that I >>>>> should try (perhaps a more "Maven-native" way)? >>>>> >>>>> The full pom.xml is attached. >>>>> >>>>> Regards, >>>>> Chris >>>>> >>>>> <project xmlns="http://maven.apache.org/POM/4.0.0" >>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>>>> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 >>>>> http://maven.apache.org/maven-v4_0_0.xsd"> >>>>> <modelVersion>4.0.0</modelVersion> >>>>> <groupId>foo</groupId> >>>>> <artifactId>bar</artifactId> >>>>> <packaging>jar</packaging> >>>>> <version>1.0-SNAPSHOT</version> >>>>> <name>bar</name> >>>>> <url>http://maven.apache.org</url> >>>>> <dependencies> >>>>> <dependency> >>>>> <groupId>junit</groupId> >>>>> <artifactId>junit</artifactId> >>>>> <version>3.8.1</version> >>>>> <scope>test</scope> >>>>> </dependency> >>>>> <dependency> >>>>> <groupId>xtc</groupId> >>>>> <artifactId>xtc</artifactId> >>>>> <version>1.14.2</version> >>>>> <scope>system</scope> >>>>> <systemPath>${basedir}/lib/xtc.jar</systemPath> >>>>> </dependency> >>>>> </dependencies> >>>>> <build> >>>>> <plugins> >>>>> <!-- Run Rats! on some files --> >>>>> <plugin> >>>>> <artifactId>maven-antrun-plugin</artifactId> >>>>> <executions> >>>>> <execution> >>>>> <phase>generate-sources</phase> >>>>> <configuration> >>>>> <tasks> >>>>> <mkdir >>>>> dir="${project.build.directory}/generated-sources/main/java/" /> >>>>> <java classpath="lib/xtc.jar" >>>>> classname="xtc.parser.Rats"> >>>>> <arg line="-in ${project.build.sourceDirectory}" /> >>>>> <arg line="-out >>>>> ${project.build.directory}/generated-sources/main/java/" /> >>>>> <arg path="${project.build.sourceDirectory}/Dot.rats" >>>>> /> >>>>> </java> >>>>> <!-- <echo >>>>> file="${project.build.directory}/generated-sources/main/java/Dot.java"> >>>>> --> >>>>> <!-- public class Dot { } --> >>>>> <!-- </echo> --> >>>>> </tasks> >>>>> <sourceRoot> >>>>> ${project.build.directory}/generated-sources/main/java >>>>> </sourceRoot> >>>>> </configuration> >>>>> <goals> >>>>> <goal>run</goal> >>>>> </goals> >>>>> </execution> >>>>> </executions> >>>>> </plugin> >>>>> </plugins> >>>>> </build> >>>>> </project> >>>>> >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: users-unsubscribe@... >>>>> For additional commands, e-mail: users-help@... >>>>> >>>> >>>> >>> >>> -- >>> View this message in context: >>> http://www.nabble.com/maven-antrun-plugin%3A-Java-classes-don%27t-compile-after-an-Ant-task-tp24300991p24325361.html >>> Sent from the Maven - Users mailing list archive at Nabble.com. >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscribe@... >>> For additional commands, e-mail: users-help@... >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@... >> For additional commands, e-mail: users-help@... >> >> >> > > -- > View this message in context: http://www.nabble.com/maven-antrun-plugin%3A-Java-classes-don%27t-compile-after-an-Ant-task-tp24300991p24325869.html > Sent from the Maven - Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free embeddable forum powered by Nabble | Forum Help |