I am using Maven to build a particular project, and within the POM I am building 3 different variants of the primary artifact using the maven shade plugin (I'm creating uber jars with various combinations of included logging frameworks). The shade plugin creates jars with alternative artifact IDs and their respective dependency-reduced-poms.
My challenge is now how to deploy these new artifacts to my remote repositories. I'm using the maven install plugin to install them to my local repo, but the maven deploy plugin requires explicit configuration of a repository URL. What I want to happen is for the plugin to adopt whichever remote repo the default deploy uses, whether its the snapshot or release repo or another repo URL that I pass in via command-line. I was hoping to find some maven property like ${project.remoterepo.url} that equated to the resolved repo. It seems silly to have to explicitly configure the remote URL when the deploy goal already does this.
Any advice appreciated. Thanks!
This is what I did to automatically select either the SNAPSHOT or RELEASE repro based on the version pattern: (I know that this is a kind of code smell but as far as the ASF is not willing to include your code for what ever reason I could solve my requirement)
<properties>
<deploy.repositoryUrl>.. url release repo ..</deploy.repositoryUrl>
<deploy.repositoryId>.. id release repo ..</deploy.repositoryId>
<deploy.repositorySnapshotUrl>.. snapshot repo ..</deploy.repositorySnapshotUrl>
<deploy.repositorySnapshotId>.. id snapshot repo ..</deploy.repositorySnapshotId>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<!-- sets the isSnapshot property to true if SNAPSHOT was used -->
<id>build-helper-regex-is-snapshot-used</id>
<phase>validate</phase>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>isSnapshot</name>
<value>${project.version}</value>
<regex>.*-SNAPSHOT</regex>
<replacement>true</replacement>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>
<!-- set the properties deploy.Url and deploy.Id during validation to
either the snapshot repository or the release repository
depending on the version pattern.-->
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source><![CDATA[
pom.properties['deploy.Url']=pom.properties['isSnapshot'].equals('true') ? pom.properties['deploy.repositorySnapshotUrl'] : pom.properties['deploy.repositoryUrl'];
pom.properties['deploy.Id']=pom.properties['isSnapshot'].equals('true') ? pom.properties['deploy.repositorySnapshotId'] : pom.properties['deploy.repositoryId'];
]]></source>
</configuration>
</execution>
</executions>
</plugin>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>DeployToArtifactory</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<url>${deploy.Url}</url>
<repositoryId>${deploy.Id}</repositoryId>
<file>target/${project.build.finalName}.${project.packaging}</file>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<packaging>jar</packaging>
<classifier>resources</classifier>
<pomFile>${project.build.directory}/pom/pom.xml</pomFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With