Maven deploy:file步骤:自动部署到快照或发布存储库

时间:2019-03-07 09:34:03

标签: maven maven-deploy-plugin

我的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的版本。如何在deploy插件的运行中实现这种灵活性?

0 个答案:

没有答案