在我的项目的POM父文件中,我有一个这样的配置文件定义了一些对这个项目有用的配置(这样我就无法摆脱这个父POM):
<profile>
<id>wls7</id>
...
<build>
<plugins>
<!-- use java 1.4 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<fork>true</fork>
<source>1.4</source>
<target>1.4</target>
<meminitial>128m</meminitial>
<maxmem>1024m</maxmem>
<executable>%${jdk14.executable}</executable>
</configuration>
</plugin>
</plugins>
</build>
...
</profile>
Run Code Online (Sandbox Code Playgroud)
但在我的项目中,我只想覆盖maven-compiler-plugin的配置,以便使用jdk5而不是jdk4来编译测试类.
这就是我在项目的POM中完成此部分的原因:
<profiles>
<profile>
<id>wls7</id>
<activation>
<property>
<name>jdk</name>
<value>4</value>
</property>
</activation>
<build>
<directory>target-1.4</directory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>my-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<fork>true</fork>
<executable>${jdk15.executable}</executable>
<compilerVersion>1.5</compilerVersion>
<source>1.5</source>
<target>1.5</target>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
...
</profiles>
Run Code Online (Sandbox Code Playgroud)
它不起作用......
我甚至试图在我的POM的常规插件部分中覆盖配置(我的意思是,不是针对特定的配置文件,而是针对我的整个POM).
可能是什么问题呢 ?
澄清我的一些要求:
它只是一个继承问题(扩展或覆盖一个配置文件,一个来自上层POM的配置)所以我认为应该可以使用Maven 2.