Such contriction will not work. The problem is in the way compiler plugin is instantiated: compiler environment is created, and them the same instance is reused for test-compiler, sticking to the existing plugin configuration. Execution does not get a new instance of as far as can see.

That is why I had to enhance the configuration of compiler plugin - 2.1-SNAPSHOT now accepts the "test" set of parameters; see http://jira.codehaus.org/browse/MCOMPILER-83

Thanks,
Oleg

mlorenzi wrote:
Milos Kleint wrote:
well, I suppose the question was if configuring just the testCompile
execution doesn't work.
I suppose having a general config at sourcelevel 1.4 and then specific
one for testCompile execution shall work.


I've the same problem and I've tried this way too, but it seems it doesnt
work.
I've reduced it in a very simple pom with something like this (for example to configure compiler version 1.4 as default but 1.5 for test
compile):

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <compilerVersion>1.4</compilerVersion>
        </configuration>
        <executions>
          <execution>
            <id>xxx</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <compilerVersion>1.5</compilerVersion>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

if I try a clean test -X I see in the log that the general configuration is
used and the one in the execution is simply ignored:

[DEBUG]   (f) compilerVersion = 1.4
...
[DEBUG] -- end configuration --
[INFO] [compiler:compile]

[DEBUG]   (f) compilerVersion = 1.4
[DEBUG] -- end configuration --
[INFO] [compiler:testCompile]

I've a more complex situation in real projects where I need to configure the
compilation for integration tests with a java 1.5 compiler keeping the 1.4
for the application sources, but I'm not able to do (same problem).
Is there something wrong with my configuration or it is a bug?
Attached is the sample pom which I used for the test.
http://www.nabble.com/file/p20379248/foo-pom.zip foo-pom.zip

Reply via email to