【发布时间】:2012-06-25 17:08:44
【问题描述】:
我是 Maven 新手,我正在尝试将我的项目部署为战争和 jar。我很想拆分项目来做同样的事情,但是对于简单的我来说,它太大了,无法在合理的时间内完成。
我找到了maven deploy additional jar file,它建议我添加一些插件。
安装插件效果很好
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<packaging>jar</packaging>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<version>SNAPSHOT</version>
<file>
${project.build.directory}/${project.artifactId}-SNAPSHOT.jar
</file>
</configuration>
</execution>
</executions>
</plugin>
这是输出:
[INFO] [install:install-file {execution: default}]
[INFO] Installing C:\Server\example\code\server\my-project\target\my-project-SNAPSHOT.jar to C:\Users\Kyle\.m2\repository\com\example\main-project\my-project\SNAPSHOT\my-project-SNAPSHOT.jar
问题出在 maven-deploy-plugin 上。它似乎忽略了我强制它使用的 SNAPSHOT 版本:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<packaging>jar</packaging>
<generatePom>true</generatePom>
<url>${project.distributionManagement.snapshotRepository.url}</url>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<version>SNAPSHOT</version>
<!--${project.version}!="SNAPSHOT" for some reason-->
<file>${project.build.directory}/${project.artifactId}-SNAPSHOT.jar</file>
</configuration>
</execution>
</executions>
</plugin>
似乎使用了其他版本号(YYYYMMDD.HHmmSS-#)
[INFO] [deploy:deploy-file {execution: default}]
[INFO] Retrieving previous build number from remote-repository
Uploading: http://build.example.biz:8081/artifactory/libs-snapshots-local/com/example/main-project/my-project/SNAPSHOT/my-project-20120625.161551-2.jar
42993K uploaded (my-project-20120625.161551-2.jar)
我做错了什么?
【问题讨论】:
-
为什么要将战争部署为 jar ?可能我误解了你喜欢你实现的目标吗?
-
我想部署为一个战争和一个罐子:来自一个 pom 的两个工件。
-
这不是答案,因为战争档案有特定的意图,而罐子有不同的意图。一场战争将被部署到像 Tomcat 这样的东西中,但是一个不会单独部署到 tomcat 中的 jar 中。所以这种方法没有意义。
-
或者你的意思是src/main/java区域应该单独放到一个jar中?