4

I have the following sections in my 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>

and

 <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>

When I run the mvn deploy:file the file is going to be uploaded always in the release repository and (I think) the problem is that the <repository> tag of the plugin points to project.distributionManagement.repository.url. At the same time, I cannot make it point to the project.distributionManagement.snapshotRepository because I would like that the deployment destination depends on the version of the pom. How can I achieve such flexibility in the run of the deploy plugin?

alexlipa
  • 1,131
  • 2
  • 12
  • 27
  • No need to configure maven-deploy-plugin separately just use `mvn clean deploy` Furthermore your configuration about repositories in your pom should be done with your settings.xml file instead.cause otherwise you need to do that in each project... – khmarbaise Mar 07 '19 at 10:56
  • 1
    I want to use `deploy:file` to upload some specific additional files – alexlipa Mar 07 '19 at 12:09
  • Does not make sense. What kind of additional files are you talking about? – khmarbaise Mar 07 '19 at 12:10
  • I want to deploy 2 jars. The one I am using here is not the default artifact but it is an additional one – alexlipa Mar 07 '19 at 12:14
  • Where is it coming from ? is being built? Where is it located? – khmarbaise Mar 07 '19 at 12:20
  • it is being produced by the `package` step – alexlipa Mar 07 '19 at 17:09
  • Then is does not make sense to make that via deploy-file...The package you mean the package life cycle of Maven. If it is created during the package life cycle it should work out of the box doing `mvn clean deploy`... – khmarbaise Mar 08 '19 at 09:14
  • it is produced by the `maven-shade-plugin`. I added the snippet for it – alexlipa Mar 08 '19 at 12:31
  • If you simply change ` true` it will be deployed automatically and you can removed the whole configuration for maven-deploy-plugin:deploy-file ... – khmarbaise Mar 08 '19 at 17:24
  • 1
    @khmarbaise the question has sense. There is a plugin called `maven-deploy-plugin`, so it means that it can be used to add additional files or customize the upload phase. – Alessandro C May 01 '20 at 16:46

0 Answers0