Maven:如何使用发布插件部署两个工件?

时间:2019-03-05 21:59:54

标签: maven maven-release-plugin

我的项目生成了两个jar:original-artifact-name.jarartifact-name.jar(我已经安装了阴影插件)。 我想使用mvn release:preparemvn release:perform,不仅可以部署简单的jar,还可以部署原始的jar。

到目前为止,在执行发布插件之后,我将手动调用mave deploy:file目标。如何在发布插件执行中纳入这一步骤?

编辑:这是我对maven-deploy-plugin的尝试:

<plugin>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>2.8.2</version>
    <executions>
    <execution>
      <id>deploy-nodeps</id>
        <goals>
          <goal>deploy-file</goal>
        </goals>
        <phase>deploy</phase>
        <configuration>
          <file>${basedir}/target/original-${project.artifactId}-${project.version}.jar</file>
          <groupId>${project.groupId}</groupId>
          <artifactId>${project.artifactId}</artifactId>
          <version>${project.version}</version>
          <classifier>nodeps</classifier>
          <url>${project.distributionManagement.repository.url}</url>
          <repositoryId>${project.distributionManagement.repository.id}</repositoryId>
        </configuration>
      </execution>
    </executions>
  </plugin>

出于某种原因,它正在将主jar部署在快照仓库中,而将nodeps jar部署在发行仓库中。这是我的存储库设置

<repositories>
<repository>
  <id>maven-snapshots</id>
  <url>https://repo.com/maven-snapshots</url>
</repository>
<repository>
  <id>maven-releases</id>
  <url>https://repo.com/maven-releases</url>
</repository>

1 个答案:

答案 0 :(得分:2)

如果要部署其他文件,则可以在POM中配置deploy:deploy-file目标。

  <plugin>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>3.0.0-M1</version>
    <executions>
      <execution>
        <id>deploy-bo</id>
        <goals>
          <goal>deploy-file</goal>
        </goals>
        <phase>deploy</phase>
        <configuration>
          <file>${basedir}/target/bo.jar</file>
          <pomFile>${basedir}/target/somewhere/pom-bo.xml</pomFile>
          <url>${project.distributionManagementArtifactRepository.url}</url>
          <repositoryId>${project.distributionManagementArtifactRepository.id}</repositoryId>
        </configuration>
      </execution>
  </plugin>