首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用buildnumber-maven-plugin和jetty-maven-plugin

使用buildnumber-maven-plugin和jetty-maven-plugin
EN

Stack Overflow用户
提问于 2013-10-29 12:57:49
回答 1查看 495关注 0票数 1

我使用buildnumber-maven-plugin将最新github提交的版本号添加到生成的war名称中:

代码语言:javascript
复制
<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时,我得到了以下输出:

代码语言:javascript
复制
[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

因此,即使该进程使用commit id构建.war文件,jetty仍会查找一个带有buildnumber插件属性名称的war文件。

我如何配置这些插件来彼此工作呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-28 05:10:22

琼恩,

我不确定这是否有可能。

jetty:run目标将引发并行构建执行,以确保构建了war (即mojo有@execute phase="package")。pom中的${buildNumber}被替换为分叉执行。它似乎不能替代运行jetty plugin的执行(假设它的计算方式与第二次运行相同)。不知道为什么,但是如果我修改jetty-maven-plugin以打印MavenProject已知的所有属性,表示它的执行,buildNumber就不存在了。但是,它存在于分叉MavenProject所表示的属性上。可能需要问一下构建编号maven-plugin项目的内容吗?

顺便说一下,我甚至尝试通过设置:${project.artifactId}-${buildNumber}来稍微更改您的示例。

这意味着您可以从maven-war插件设置中删除。我希望它也能为jetty插件设置执行值,但没有这样的运气。

干杯简

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19658883

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档