我尝试构建一个带有配置文件的项目。
在pom.xml中,我为每个环境都有3个配置文件。例如,本地个人资料看起来像这样:
<profile>
<id>local</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<configuration>
<tasks>
<delete>
<fileset dir="${project.build.outputDirectory}/wsdl" includes="*.wsdl" />
</delete>
<copy file="src/main/resources/wsdl/WebService-LOCAL.wsdl"
tofile="${project.build.outputDirectory}/wsdl/WebService.wsdl"/>
</tasks>
</configuration>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>generate-stubs</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlUrls>
<wsdlUrl>http://localhost:8080/WebService/WebServiceBean?wsdl</wsdlUrl>
</wsdlUrls>
<packageName>com.company.WebService.ws.generated</packageName>
<extension>true</extension>
<verbose>true</verbose>
<keep>true</keep>
<catalog>${basedir}/main/resources/catalog.xml</catalog>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.jvnet.jax-ws-commons
</groupId>
<artifactId>
jaxws-maven-plugin
</artifactId>
<versionRange>
[2.2,)
</versionRange>
<goals>
<goal>wsimport</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<versionRange>
[2.1,)
</versionRange>
<goals>
<goal>unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
当我运行以下命令时:
mvn clean package -P local
该项目是成功的,但是,WebService.wsdl已复制在Target/WSDL文件夹中,但在生成的JAR文件中不复制,我仍然看到其他环境文件而不是WebService.wsdl。在构建过程中,我注意到jar文件是在环境文件副本之前生成的,我该如何在JAR文件生成之前将其复制?
将您的插件绑定到较早的阶段,而不是包装,而是在其之前。