我在这里面临非常荒谬的问题,我有一个pom.xml
用于构建war文件的文件。我已经介绍profile
了它可以在不同的环境中使用。(dev/prod)
但是问题是当我创建构建时,它会为下面的配置文件创建正确的构建目录订购pom.xml
请协助这里有什么问题。
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<activation>
<property>
<name>lifecycle</name>
<value>prod</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<warSourceExcludes>**login.jsp</warSourceExcludes>
</configuration>
</plugin>
</plugins>
<directory>target/${lifecycle}</directory>
<finalName>testapp</finalName>
<resources>
<resource>
<directory>src/main/resources/${lifecycle}</directory>
</resource>
</resources>
</build>
</profile>
<profile>
<activation>
<property>
<name>lifecycle</name>
<value>dev</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
</plugin>
</plugins>
<directory>target/${lifecycle}</directory>
<finalName>testapp</finalName>
<resources>
<resource>
<directory>src/main/resources/${lifecycle}</directory>
</resource>
</resources>
</build>
</profile>
</profiles>
正确的构建目录应该是
如果-Dlifecycle=dev
target/dev/testapp/
如果-Dlifecycle=prod
target/prod/testapp/
但在这里我得到'target/testapp-xx.x'
为什么这是不同的行为?
触发构建的命令:mvn clean install -Dlifecycle=prod