Results 1 to 20 of 28
- 10-27-2012, 02:34 AM #1
Member
- Join Date
- Dec 2010
- Posts
- 16
- Rep Power
- 0
- 10-27-2012, 09:12 AM #2
Member
- Join Date
- Jun 2012
- Location
- Remscheid, Germany
- Posts
- 57
- Rep Power
- 0
Re: Several Compilations in one POM.xml
You can add more than one source directory (build-helper-plugin) and compile all that sourcefiles at once. The other (typical) possibility is to make multiple submodules and compile them all on themselfs but to use dependencies.
- 10-27-2012, 09:52 AM #3
Member
- Join Date
- Dec 2010
- Posts
- 16
- Rep Power
- 0
Re: Several Compilations in one POM.xml
I may not compile them all at once - the intermediate step examines the class files of the first translation (using reflection) and only then generates Java files for the supposed second translation. Is the other way you propose about multi-module/aggregation? I will appreciate if you give me a top-level example of POM structure for this case. Both at step 1 and step 3 maven-compiler-plugin is supposed to be executed. Step 2 is my own plugin (let it be my-own-plugin). How dependencies of steps 1-2-3 should be depicted so that maven does not toss the order?
- 10-27-2012, 01:58 PM #4
Member
- Join Date
- Jun 2012
- Location
- Remscheid, Germany
- Posts
- 57
- Rep Power
- 0
Re: Several Compilations in one POM.xml
You use one parent module and 2 submodules. First you compile the module containing the classes you want to inspect later on. The second module has the first as a dependency so that maven know in which order to build the modules. In the second module you examine classes and generate the source in the generate-sources goal and compile them using the standard compile phase. The build-helper-plugin will be used to tell maven the sourcepath of the generated sources.
- 10-28-2012, 12:35 AM #5
Member
- Join Date
- Dec 2010
- Posts
- 16
- Rep Power
- 0
Re: Several Compilations in one POM.xml
I think that is doable but seems to require to change all the current directory structure. It is regrettable because it would impact existing ant files. It seems that one small feature currently absent in maven could help - the pom files would better have been permitted other names than hardcore pom.xml and accordingly the <module> element would be permitted to contain pom files names besides directories only.
- 10-28-2012, 06:20 AM #6
Member
- Join Date
- Dec 2010
- Posts
- 16
- Rep Power
- 0
Re: Several Compilations in one POM.xml
Good news - I tried setting three poms in one and the same directory, so name of pom file works:
In my pom.xml:
<modules>
<module>pom1.xml</module>
<module>pom2.xml</module>
</modules>
And when I run mvn install and I see that pom1.xml is executed. But pom2.xml - not!
- 10-28-2012, 10:26 AM #7
Member
- Join Date
- Jun 2012
- Location
- Remscheid, Germany
- Posts
- 57
- Rep Power
- 0
Re: Several Compilations in one POM.xml
just show up your poms.
- 10-28-2012, 02:55 PM #8
Member
- Join Date
- Dec 2010
- Posts
- 16
- Rep Power
- 0
Re: Several Compilations in one POM.xml
__________ pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" ...>
<modelVersion>4.0.0</modelVersion>
<groupId>org.codehaus.mojo</groupId>
<artifactId>my-parent</artifactId>
<version>2.0</version>
<packaging>pom</packaging>
<modules>
<module>pom1.xml</module>
<module>pom2.xml</module>
<module>pom3.xml</module>
</modules>
</project>
__________ pom1.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" ... >
<modelVersion>4.0.0</modelVersion>
<groupId>com.hybridjava</groupId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>project1</artifactId>
<build>
<sourceDirectory>.</sourceDirectory>
<outputDirectory>classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5</version>
<configuration>
<includes>
<include>pojos\com\HybridJava\Sample\*.java</include>
<include>pages\com\HybridJava\Sample\*_PS.java</include>
<include>widgets\com\HybridJava\Sample\*_WS.java </include>
<include>widgets\com\HybridJava\Lib\*_WS.java</include>
</includes>
<compilerArguments>
<classpath>..\lib\HybridJava.jar;..\lib\HybridJava _rt.jar;..\lib\servlet-2_3-fcs-classfiles.jar;classes</classpath>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>org.apache.maven.plugins</id>
<url>http://maven.apache.org/plugins</url>
</pluginRepository>
</pluginRepositories>
</project>
__________ pom2.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" ... >
<modelVersion>4.0.0</modelVersion>
<groupId>com.hybridjava</groupId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>project2</artifactId>
<build>
<plugins>
<plugin>
<groupId>com.hybridserverpages</groupId>
<artifactId>hybridjava-compiler-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>sayhi</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.hybridserverpages</groupId>
<artifactId>hybridjava-compiler-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.hybridjava</groupId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>project1</artifactId>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
<id>com.hybridjava</id>
<url>http://hybridjava.com/maven2</url>
</pluginRepository>
<pluginRepository>
<id>org.apache.maven.plugins</id>
<url>http://maven.apache.org/plugins</url>
</pluginRepository>
</pluginRepositories>
</project>
_________ pom3.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" ... >
<modelVersion>4.0.0</modelVersion>
<groupId>com.hybridjava</groupId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>project3</artifactId>
<build>
<sourceDirectory>.</sourceDirectory>
<outputDirectory>classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<phase>install</phase>
</execution>
</executions>
<configuration>
<includes>
<include>gen\com\HybridJava\Sample\*_P.java</include>
</includes>
<compilerArguments>
<classpath>..\lib\HybridJava.jar;..\lib\HybridJava _rt.jar;..\lib\servlet-2_3-fcs-classfiles.jar;classes</classpath>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.hybridjava</groupId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>project2</artifactId>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
<id>org.apache.maven.plugins</id>
<url>http://maven.apache.org/plugins</url>
</pluginRepository>
</pluginRepositories>
</project>
- 10-28-2012, 02:58 PM #9
Member
- Join Date
- Dec 2010
- Posts
- 16
- Rep Power
- 0
Re: Several Compilations in one POM.xml
[INFO] Reactor Build Order:
[INFO]
[INFO] project1
[INFO] project2
[INFO] project3
[INFO] my-parent
Then project1 and project2 work but project3 - as if it does not exist.
- 10-28-2012, 04:10 PM #10
Re: Several Compilations in one POM.xml
Why do they call it rush hour when nothing moves? - Robin Williams
- 11-02-2012, 07:42 PM #11
Member
- Join Date
- Dec 2010
- Posts
- 16
- Rep Power
- 0
- 11-02-2012, 08:20 PM #12
Member
- Join Date
- Jun 2012
- Location
- Remscheid, Germany
- Posts
- 57
- Rep Power
- 0
Re: Several Compilations in one POM.xml
Please show the log of the build process (sorry missed the thread). At least in pom3.xml change the compilers phase to compile... you cannot compile while installing the artifacts.
- 11-04-2012, 04:41 PM #13
Member
- Join Date
- Dec 2010
- Posts
- 16
- Rep Power
- 0
Re: Several Compilations in one POM.xml
changed the phase to "compile" but it did not help.
C:\Users\admin\Desktop\Root\MavenTest\Test>cmd /k mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] project1
[INFO] project2
[INFO] project3
[INFO] my-parent
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building project1 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ project1 ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\admin\Desktop\Root\MavenTest\Test\src\mai n\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5:compile (default-compile) @ project1 ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 17 source files to C:\Users\admin\Desktop\Root\MavenTest\Test\classes
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ project1 ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\admin\Desktop\Root\MavenTest\Test\src\tes t\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5:testCompile (default-testCompile) @ project1 ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ project1 ---
[INFO] No tests to run.
[INFO] Surefire report directory: C:\Users\admin\Desktop\Root\MavenTest\Test\target\ surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ project1 ---
[INFO] Building jar: C:\Users\admin\Desktop\Root\MavenTest\Test\target\ project1-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ project1 ---
[INFO] Installing C:\Users\admin\Desktop\Root\MavenTest\Test\target\ project1-0.0.1-SNAPSHOT.jar to C:\Users\admin\.m2\repository\com\hybridjava\proje ct1\0.0.1-SNAPSHOT\project1-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\Users\admin\Desktop\Root\MavenTest\Test\pom1.xm l to C:\Users\admin\.m2\repository\com\hybridjava\proje ct1\0.0.1-SNAPSHOT\project1-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building project2 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ project2 ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\admin\Desktop\Root\MavenTest\Test\src\mai n\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ project2 ---
[INFO] No sources to compile
[INFO]
[INFO] --- hybridjava-compiler-plugin:1.0-SNAPSHOT:sayhi (default) @ project2 ---
[INFO] Hello HybridJava compiler!
... ... ... Then only outpot from pom2 follows,
- 11-04-2012, 07:43 PM #14
Member
- Join Date
- Jun 2012
- Location
- Remscheid, Germany
- Posts
- 57
- Rep Power
- 0
Re: Several Compilations in one POM.xml
and project2 finalizes with success?
- 11-04-2012, 08:30 PM #15
Member
- Join Date
- Dec 2010
- Posts
- 16
- Rep Power
- 0
Re: Several Compilations in one POM.xml
yes, sure.
- 11-04-2012, 08:33 PM #16
Member
- Join Date
- Dec 2010
- Posts
- 16
- Rep Power
- 0
Re: Several Compilations in one POM.xml
In general I do not (now) quite well understand how the maven goals may be used otherwise than from a command line. I would (yesterday) expect that using goals we may force the order of executions. Now can not find any examples of cross-using goals.
- 11-04-2012, 09:50 PM #17
Member
- Join Date
- Jun 2012
- Location
- Remscheid, Germany
- Posts
- 57
- Rep Power
- 0
Re: Several Compilations in one POM.xml
crossusing goals?
- 11-04-2012, 10:19 PM #18
Member
- Join Date
- Dec 2010
- Posts
- 16
- Rep Power
- 0
Re: Several Compilations in one POM.xml
I recall that in classic make (ant) nodes depend on other nodes. Make defines the order of build. I though before that goals in maven serve to depict such dependencies and same way may control the order of steps..
- 11-04-2012, 10:40 PM #19
Member
- Join Date
- Jun 2012
- Location
- Remscheid, Germany
- Posts
- 57
- Rep Power
- 0
Re: Several Compilations in one POM.xml
You have a cleanly defined lifecycle which is executed in order, there's nothing like depending goals / phases.
- 11-04-2012, 11:36 PM #20
Member
- Join Date
- Dec 2010
- Posts
- 16
- Rep Power
- 0
Re: Several Compilations in one POM.xml
Clearly defined as non-flexible. If I want two compilations one after another then I am advised to use two <execution> elements. Compilations will happen one after another. So far I do not see how to push some additional step of my own between those two compilations.


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks