我是 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)
我究竟做错了什么?