首页 > 解决方案 > Maven deploy:file 步骤:自动部署到快照或发布存储库

问题描述

我有以下部分pom.xml

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

<distributionManagement>
  <snapshotRepository>
      <id>maven-snapshots</id>
      <name>Snapshot Repository</name>
      <url>https://artifactory.com/maven-snapshots</url>
  </snapshotRepository>
  <repository>
      <id>maven-releases</id>
      <name>Release Repository</name>
      <url>https://artifactory.com/maven-releases</url>
  </repository>
</distributionManagement>

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.1.1</version>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <relocations>
            <relocation>
              <pattern>com.google</pattern>
              <shadedPattern>com.shaded.google</shadedPattern>
            </relocation>
            <relocation>
              <pattern>io.netty</pattern>
              <shadedPattern>hidden.io.netty</shadedPattern>
            </relocation>
          </relocations>
          <shadedArtifactAttached>false</shadedArtifactAttached>
        </configuration>
      </execution>
    </executions>
  </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>

当我运行该mvn deploy:file文件时,该文件将始终上传到发布存储库中,并且(我认为)问题是<repository>插件的标签指向project.distributionManagement.repository.url. 同时,我无法指出它,project.distributionManagement.snapshotRepository因为我希望部署目标取决于 pom 的版本。如何在部署插件的运行中实现这种灵活性?

标签: mavenmaven-deploy-plugin

解决方案


推荐阅读