Any help?
Thanks,
Sahoo
--- Begin Message ---
Hi Milos,
Milos Kleint wrote:
Sahoo wrote:
(Resending as I am on the users alias now. I have also put a
reference to a similar unsolved question from the past)
Hi,
I want to pass different options to maven-compiler-plugin during compile
and testCompile goals. Let's say, I want to set source level as 1.4 for
all my src/main/java code and set source level as 1.5 for my test
sources. How do I do it? I found someone having similar requirements
in the past [1], but there is no mention of a working solution yet.
Thanks,
Sahoo
[1]
http://mail-archives.apache.org/mod_mbox/maven-users/200609.mbox/[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
what about something like this?
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler
-plugin</artifactId>
<configuration>
<compilerVersion>${sourceLevel}</compilerVersion>
<source>${sourceLevel}</source>
<target>${sourceLevel}</target>
</configuration>
<executions>
<execution>
<id>compile-tests</id>
<phase>process-test-sources</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<source>${testSourceLevel}</source>
<target>${testSourceLevel}</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<sourceLevel>1.4</sourceLevel>
<testSourceLevel>1.5</testSourceLevel>
</properties>
Regards
Milos Kleint
Thanks for your timely response. Your suggestion seems to work, but I
think there is something else which is contributing to the success here.
*I see maven-compiler-plugin:testCompile goal is invoked twice*. The
first time it uses our execution configuration, where as the second time
around, it uses the default configuration. Since the test sources are
already compiled during first execution, they are not compiled second
time around. See the output below:
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Compiling 1 source file to /tmp/my-app/target/classes
[INFO] [compiler:testCompile {execution: compile-tests}]
[INFO] Compiling 1 source file to /tmp/my-app/target/test-classes
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
Thanks,
Sahoo
--- End Message ---
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]