I have several maven projects that deploy to a nexus server. I don't like managing their versions via the pom file, and already use git tags for versioning via git-describe.
I added the git-describe maven plugin with the following config:
<plugin>
<groupId>com.lukegb.mojo</groupId>
<artifactId>gitdescribe-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<goals>
<goal>gitdescribe</goal>
</goals>
<id>git-describe</id>
<phase>initialize</phase>
<configuration>
<outputPrefix></outputPrefix>
</configuration>
</execution>
</executions>
</plugin>
and it works perfectly for mvn package runs - but when I use mvn deploy I end up seeing:
nexus/content/repositories/releases/me/botsko/project/${describe}/project-${describe}.jar
I tried to talk to the plugin author but it's been a few days and no reply.
How can I modify the plugin, or my configuration to property set the version during the deploy phase?
There may be a way to edit the plugin but I'm not familiar with how the maven plugin architecture works.
I solved the problem by writing a shell script that passes the same git-describe value to the maven deploy process:
#!/bin/sh
gitvers=`git describe`
mvn deploy -Ddescribe=$gitvers-SNAPSHOT
Just make sure you use <version>${describe}</version> or similar in the POM.
Related
We are working with Maven 3.3.9 version, and deploying to v using Maven. where we added distribution management within pom.xml and running Maven goal "mvn clean deploy". Till now everything is working fine and all the files like .pom,.jar,.xml etc are deploying to Artifactory.
Now, we got a scenario where we want to deploy only jar file and exclude all other files while deploying using Maven.
I have tried as mentioned here http://maven.apache.org/plugins/maven-deploy-plugin/examples/deploying-with-classifiers.html by using
mvn deploy -Dtypes=jar but no luck.
How to exclude files while deploying to artifactory using Maven?
I'm using maven-artifactory-plugin to deploy Maven projects to Artifactory. And it has <excludePatterns> configuration which allows to suppress deployment of files. The following config will deploy only .war file and not .pom
<plugin>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>2.6.1</version>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>publish</goal>
</goals>
<configuration>
<publisher>
<contextUrl>https://artifactory.your.company.com/artifactory</contextUrl>
<username>${artifactory.user}</username>
<excludePatterns>*.pom</excludePatterns>
<password>${artifactory.key}</password>
<repoKey>release-repo</repoKey>
<snapshotRepoKey>snapshot-repo</snapshotRepoKey>
</publisher>
</configuration>
</execution>
</executions>
</plugin>
I have a project which deploys to Maven Central via OSSRH using the Maven release and nexus-staging-maven plugins using the directions from http://central.sonatype.org/pages/ossrh-guide.html and http://central.sonatype.org/pages/apache-maven.html .
This works fine, but it often takes several hours for the artifact to be visible on Maven Central. Often we would like to make use of the deployed artifact immediately, so we end up deploying it from our local repositories to our internal Nexus server using deploy:deploy-file . This works but it is inelegant and easy to forget to do. Is there any way to make Maven deploy to an internal Nexus as well as Maven Central as part of the release process?
Note: This question is similar to, but not quite the same as, https://stackoverflow.com/questions/29019682/promote-artifact-from-internal-nexus-repository-to-maven-central
Add an additional execution to the maven-deploy-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven.deploy.plugin.version}</version>
<executions>
<execution>
<id>nexus-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<altDeploymentRepository>yourNexusRepo</altDeploymentRepository>
</configuration>
</execution>
</executions>
</plugin>
The yourNexusRepo value will look something like this:
releases::default::https://nexus.host.org/nexus/content/repositories/releases
You should be able to get the exact URL from Nexus. The part before the first :: is the repository ID.
We solved this problem by no longer using nexus-staging-maven-plugin as an extension. This is described at https://help.sonatype.com/repomanager2/staging-releases/configuring-your-project-for-deployment :
If more control is desired over when the plugins deploy goal is
activated or if Maven 2 is used, you have to explicitly deactivate the
Maven Deploy plugin and replace the Maven Deploy plugin invocation
with the Nexus Staging Maven plugin...
In our case, we disabled the default-deploy execution by setting <phase>none</phase>. Our full solution is available at https://github.com/newmediaworks/nmw-oss-parent/commit/a7377a158feded473cb2f1618449e34173c22252 which includes an additional execution of maven-deploy-plugin in the jenkins-deploy profile.
The key takeaway follows, which so far seems to behave as if extension were enabled, but does not interfere with additional maven-deploy-plugin executions:
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId><artifactId>nexus-staging-maven-plugin</artifactId>
<!--
Not using as extension, since it blocks maven-deploy-plugin in the jenkins-deploy profile:
<extensions>true</extensions>
-->
<executions>
<execution>
<!-- Manually added since nexus-staging-maven-plugin is not used as extension -->
<id>default-deploy</id><phase>deploy</phase><goals><goal>deploy</goal></goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId><artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<!-- Manually disabled since nexus-staging-maven-plugin is not used as extension -->
<id>default-deploy</id><phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
I have a multimodule project, and the last module being built is a distribution zip of the application.
core/
plugins/
plugins/logger
plugins/social
...
assemble/
I want to distribute the application in the form of Maven artifact. And I don't want to deploy the modules artifacts with it.
But the release plugin needs to run from the root (I want to do all the usual stuff like updating versions, tagging, commits these changes etc.)
What is the way to tell the release plugin which artifacts to deploy?
Note that this is different from limiting only the deploy plugin, because release plugin seems to call the deploy plugin in certain internal way. (Not sure about that.)
Seems like the Release plugin behavior was fixed and it now properly invokes deploy:deploy.
So I used my standard trick to suppress default plugin execution. Root pom.xml:
<!-- Don't deploy all artifacts. Overridden in submodules. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<executions> <execution> <id>default-deploy</id> <phase>none</phase> </execution></executions>
</plugin>
And the dist module pom.xml:
<!-- Enable deploy for this submodule. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<executions> <execution> <id>default-deploy</id> <phase>deploy</phase> </execution></executions>
</plugin>
The release:perform isn't doing that much magic. It checks out the code by the tag which was created during release:prepare. The default goal is 'deploy'. If you have specified a site within the distributionManagement of the pom.xml it'll be 'deploy site-deploy'. These steps could also be done by hand.
If you never want to deploy these artifacts (not during developerment nor release), I'd prefer the skip over using an undefined phase.
If this is only required during a release, you should specify this within a release-profile.
Is it possible to have the maven war plugin output to two different locations? I currently have the following in my pom.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
<configuration>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>
This was already existing in the POM for the gwt maven archetype, and I'm guessing this explodes everything into the webappDirectory(which the gwt plugin then uses for it development mode).
When I do a
mvn war:war
It generate a war file for me in the target directory. So, I suspect its a different plugin configuration than the one in my POM (default behaviour?). How do I override this?
I basically want to accomplish the following:
I would like to have two different resource folders "src/resources/a" and "src/resources/b" , and have one of the folders used in the exploded version (currently in my pom) and the other version used when I do a "mvn war:war"
Per this question How to execute maven plugin execution directly from command line?, Maven doesn't use pom configuration when you invoke a plugin directly (e.g. mvn war:war). Your POM config is telling Maven to run the exploded goal when the compile phase is invoked (i.e when you run mvn [phase] where phase is compile or later).
I suggest you investigate using a separate profile for exploded deployment (called eg exploded), with a different configuration of the resources plugin to copy a different resources directory. Then use mvn compile -Pexploded for the exploded version.
I am new to maven. I have product structure as following
myWebProduct
pom.xml
coreModule
webModule
htmlTestModule
The maven release plugin is defined at the company level of pom.xml file which is parent of myWebProduct. It has set release plugin run default goals of deploy and default preparationGoals clean verify install.
I want to release product in myWebProduct level which works fine except I would like to skip release the htmlTestModule. Because deploy life cycle on htmlTestModule will cause deployment of war file to remote Tomcat servers and I don’t want this happening during release.
I tried to add following in pom.xml of the htmlTestModule.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
<configuration>
<skip>true</skip>
<preparationGoals>clean validate</preparationGoals>
<goals>testCompile</goals>
</configuration>
</plugin>
But when running 'mvn release:perform' at myWebProduct. I have seen the deploy goal was still executed on htmlTestModule. Could anyone help with this?
And I also tried following on htmlTestModule:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>donotRunMe</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
Still, the deploy goal always executed in htmlTestModule.
Thanks
I think you're taking the wrong approach here. Let me explain.
The deploy phase of maven is not meant to mean deploy to a remote server or anything like this. This is meant to be deploy to a remote repository.
Hence I believe you shouldn't try to skip the deploy phase in your module, but un-tie the deployment to a remote Tomcat server from the deploy phase, by making it a specific goal for example.