What you can do is define two profiles , one per JDK used. Each profile will be activated for which the JDK is used:
<profiles> <profile> <id>profile-for-jdk1.4</id> <activation> <activeByDefault>false</activeByDefault> <jdk>1.4</jdk> </activation> <build> <finalName>myBuild-jdk1.4</finalName> </build> </profile> <profile> <id>profile-for-jdk1.5</id> <activation> <activeByDefault>false</activeByDefault> <jdk>1.5</jdk> </activation> <build> <finalName>myBuild-jdk1.5</finalName> </build> </profile> </profiles>
Then, in each profile, you define a specific <finalName> that will be used to indicate the generated JAR file.
Thus, if you create an application using JDK 1.4, the generated JAR will be called myBuild-jdk1.4.jar .
If your final package is built using assembly, you can simply modify the internal <build> block inside the profiles to customize the assembly plugin (e.g. <finalName> ).
Regarding your comment: indeed, this procedure will require two separate assemblies on Maven, since you need to recompile the entire project when changing the JDK version. One of the conditions of Maven2 is that one project = one artifact. You want to have one project with two artifacts.
Ultimately, one solution is to use Hudson to build your application, and especially the matrix of this tool, which allows you to run multiple assemblies with different parameters, in your case JDK.
romaintaz Jun 22 '10 at 10:26 2010-06-22 10:26
source share