我正在使用 buildnumber-maven-plugin 将最新 github 提交中的内部版本号添加到生成的战争的名称中:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warName>${project.artifactId}-${buildNumber}</warName>
<webResources>
<resource>
<directory>${project.basedir}/src/main/webapp/WEB-INF</directory>
<filtering>true</filtering>
<targetPath>WEB-INF</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<shortRevisionLength>6</shortRevisionLength>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<war>target/${project.artifactId}-${buildNumber}.war</war>
<webApp>
<contextPath>/hope</contextPath>
<descriptor>${basedir}/target/WEB-INF/web.xml</descriptor>
</webApp>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
这正确地创建了一个带有提交 ID 前 6 个字符的 .war 文件,并且在运行时也可以正常工作mvn jetty:run
;但是,当我运行时mvn jetty:run-war
,我得到以下输出:
[INFO] Webapp assembled in [160 msecs]
[INFO] Building war: /home/jon/Projects/hope/hope/hope-web/target/hope-web-b242c0.war
[INFO]
[INFO] --- maven-site-plugin:3.3:attach-descriptor (attach-descriptor) @ hope-web ---
[INFO]
[INFO] <<< jetty-maven-plugin:9.0.5.v20130815:run-war (default-cli) @ hope-web <<<
[INFO]
[INFO] --- jetty-maven-plugin:9.0.5.v20130815:run-war (default-cli) @ hope-web ---
[INFO] Configuring Jetty for project: Website
[INFO] Context path = /hope
[INFO] Tmp directory = /home/jon/Projects/hope/hope/hope-web/target/tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
2013-10-29 12:49:34.920:INFO:oejs.Server:main: jetty-9.0.5.v20130815
2013-10-29 12:49:34.934:WARN:oejw.WebInfConfiguration:main: Web application not found /home/jon/Projects/hope/hope/hope-web/target/hope-web-${buildNumber}.war
2013-10-29 12:49:34.934:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.m.p.JettyWebAppContext@c638285{/hope,null,null}{/home/jon/Projects/hope/hope/hope-web/target/hope-web-${
buildNumber}.war}
java.io.FileNotFoundException: /home/jon/Projects/hope/hope/hope-web/target/hope-web-${buildNumber}.war
因此,即使该过程使用提交 ID 构建 .war 文件,jetty 也会查找具有 buildnumber 插件属性名称的 war 文件。
如何配置这些插件以相互配合?