首先使用一个pom.xml我用maven-jar-plugin创建一个jar文件并用maven-jarsigner-plugin签名,然后我用maven-assembly-plugin创建一个tar.gz包,复制jar文件和其他必要的文件到tar.gz.仅仅因为只有tar.gz包对我来说足够了,我只想要tar.gz包来部署远程存储库。当我运行“mvn deploy”命令时,正在部署jar和tar.gz包。是否有任何方法可以不将jar文件部署到远程存储库。
答案 0 :(得分:1)
我尝试了你的建议。它不适用于maven-deploy-plugin,但它适用于maven-install插件。这是我的pom.xml的相对部分:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${project.build.directory}/${project.build.finalName}-dev.tar.gz</file>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<packaging>tar.gz</packaging>
<version>${project.version}</version>
<classifier>dev</classifier>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<url>http://repo/artifactory/snapshots</url>
<file>${project.build.directory}/${project.build.finalName}-dev.tar.gz</file>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<packaging>tar.gz</packaging>
<version>${project.version}</version>
<classifier>dev</classifier>
</configuration>
</execution>
</executions>
</plugin>
maven-install-plugin只将tar.gz文件安装到本地存储库,但maven-deploy-plugin将tar.gz和jar文件部署到远程存储库。我认为这种行为可能是maven-deploy-plugin的错误。
答案 1 :(得分:0)
默认情况下,Maven Deploy插件will deploy all the artifacts attached to your project or module,即您的 .jar 和 tar.gz 文件。
deploy:deploy
用于自动安装工件,其pom以及特定项目生成的附加工件。
您可以跳过deploy:deploy
目标并配置个性化deploy:deploy-file
目标,例如:
<build>
...
<plugins>
...
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip> <!-- Skip the default deploy -->
</configuration>
<executions>
<!-- Deploy our tar.gz -->
<execution>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<file>${project.build.directory}/${project.build.finalName}.tar.gz</file>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<packaging>tar.gz</packaging>
<version>${project.version}</version>
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
您必须配置<file>
才能使用生成的 tar.gz 文件。