【发布时间】:2013-05-16 12:54:43
【问题描述】:
我有一个 Maven 项目,我已经集成了 webstart-maven-plugin。 jnlp 被生成,我想通过将它部署到码头来测试它,但还没有找到任何码头目标来实现这一点。有没有一种自动化的方法来测试 jnlp?
【问题讨论】:
标签: java maven java-web-start maven-jetty-plugin
我有一个 Maven 项目,我已经集成了 webstart-maven-plugin。 jnlp 被生成,我想通过将它部署到码头来测试它,但还没有找到任何码头目标来实现这一点。有没有一种自动化的方法来测试 jnlp?
【问题讨论】:
标签: java maven java-web-start maven-jetty-plugin
我一直在使用webstart-maven-plugin,直到我意识到它只是填充了一个 jnlp 模板并复制了 jar 文件。
现在,我使用静态 jnlp(存储在 src/main/webapp/applet)和 maven-dependency-plugin 来复制 jar:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>applet-copy</id>
<phase>process-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>applet.group.id</groupId>
<artifactId>applet-artifact-id</artifactId>
<version>x.y.z</version>
<type>jar</type>
<destFileName>applet.jar</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/web-resources/applet</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
它实际上将小程序复制到target/web-resources/applet。然后我只需要将这个目录作为网络资源添加到jetty-maven-plugin:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.9.v20130131</version>
<configuration>
<stopKey>STOP</stopKey>
<stopPort>9999</stopPort>
<scanIntervalSeconds>5</scanIntervalSeconds>
<webAppConfig>
<contextPath>/${project.artifactId}</contextPath>
<resourceBases>
<resourceBase>${project.build.directory}/web-resources</resourceBase>
</resourceBases>
</webAppConfig>
</configuration>
</plugin>
并将其添加到战争中:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<webResources>
<resource>
<directory>${project.build.directory}/web-resources</directory>
</resource>
</webResources>
</configuration>
</plugin>
希望对你有帮助。
顺便可以找到更多关于jetty-maven-plugin配置on this page的信息。
【讨论】: