1
我有以下的pom.xml:Maven的,的YUICompressor,過濾器和Maven的戰爭插件:只能壓縮爲PROD
<build>
<finalName>edrive</finalName>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*xml</include>
<include>**/*properties</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>prepare</id>
<phase>prepare-package</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<warSourceDirectory>${project.build.directory}/${project.build.finalName}</warSourceDirectory>
</configuration>
</execution>
</executions>
<configuration>
<filters>
<filter>src/main/filters/filter.properties</filter>
</filters>
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
<webResources>
<resource>
<directory>${project.build.directory}/${project.build.finalName}/resources</directory>
<filtering>true</filtering>
<targetPath>resources</targetPath>
</resource>
</webResources>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
<archiveClasses>true</archiveClasses>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>prod</id>
<activation>
<property>
<name>prodEnabled</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<jswarn>false</jswarn>
<nosuffix>true</nosuffix>
<force>true</force>
<sourceDirectory>WebContent/resources</sourceDirectory>
<outputDirectory>${project.build.directory}/${project.build.finalName}/resources</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
我想有壓縮,但只有一個配置文件資源。我說,我執行
MVN乾淨的安裝的.war = -DprodEnabled真正
預期結果應該壓縮的資源。如果我執行
MVN全新安裝
,那麼資源應保持在作爲的.war是。目前的問題是,在這兩種情況下,maven war插件在篩選target和.war時將輸出置零。如何解決這個問題?