Maven release plugin adding trunk folder under release tag for release:prepare goal - maven

My SCM connection information:
<scm>
<connection>scm:svn:https://repo/project/trunk</connection>
<developerConnection>scm:svn:https://repo/project/trunk</developerConnection>
</scm>
My release plugin configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<tag>RC</tag>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</plugin>
Now when I run mvn release:prepare, instead of committing my tagged release under tags/RC, it does tags/RC/trunk. How do I stop it from adding trunk under RC?

Brian, you may be the victim of Maven's incomplete release:rollback feature. See my question on StackOverflow and the answer to it. If your tag already exists, Subversion (not Maven) will think you want to copy trunk inside the existing tag. Delete the tag and it will work - once. Try again and you'll get RC/trunk. Try yet again and you'll get an error from Subversion.
The solution is to svn delete the tag before you try to copy to it - we do this successfully from Maven during release:perform, by binding a couple of plugins to the deploy phase.
Basically:
Let release:prepare do its thing, create a tag with a unique name.
Bind org.codehaus.mojo:exec-maven-plugin:exec to the deploy phase to make it run during release:perform. Configure it to call svn delete <path to RC tag>.
Bind maven-scm-plugin:branch to deploy in order to create the tag fresh using Maven's SCM plugin.
This works for us and it has the added benefit that it gives us the unique tags too for reference. Worst case, you can ignore these tags.

Related

How to combine the Maven Release Plugin with Nexus Staging Plugin?

I'm releasing an open source project to Maven Central, and I wanted to combine the Maven Release Plugin with the Nexus Staging Plugin, but don't know how.
The Maven Release Plugin performs all I need:
the git checks,
git repository tag,
git next iteration versioning,
check out,
build,
deploy, (<-- This is the one I would like to change)
and git branch restore.
All this automation means I can perform a release with a single command line. Awesome.
The only caveat here is that the deploy task above merely delivers the JARs to Maven Central Repository, but does not publish them. I still need to log in to the Maven Central web site, find the release, click on "Close"... wait a few minutes... not ready yet... wait a couple of minutes... check again... oh, it's ready... finally click on "Release". I don't like this manual, error-prone task.
The Nexus Staging Plugin, on the other hand, does the "Close" + "Release" automatically. However, it doesn't do anythine else, like the list of steps described above.
Is there any way I could replace the "deploy" section above with the "Nexus Staging Plugin" instead?
How silly of me. It's incredible how closer you get to an answer when you go through the process of formulating the question.
The solution was very simple. Just by adding the Nexus Staging Plugin to the pom.xml automatically replaces the default "deploy" step.
This is my pom.xml section for the Nexus Staging Plugin:
<!-- Nexus Staging -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
Nothing special, as you see. With this, calling the Maven Release Plugin automatically uses the Nexus Staging Plugin, instead of the default deployment.
$ mvn -B release:prepare && mvn release:perform
Fully automated from beginning to end: Git release + Maven Central publishing in one go.
Cheers!

Can't find my Staging Repository

I am a newbie trying to deploy artifacts to maven central for the first time. I followed the directions to configure maven to deploy to a staging repository. The maven build reports success. When I go to look for my staging repository, I don't see it. When I search for my artifact by searching for "markgrand" the artifact is found.
The group ID is com.markgrand, so I am expecting to see a staging repository with a names that begins with "commarkgrand-", but there is none. What am I doing wrong?
It's been awhile, so I do not remember the exact detail. The problem was that I had told the maven plugin to do too much. I think i had a step in there to close the thing, which made it no longer a candidate for deployment. Here is the staging plugin XML that is working for me:
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
</configuration>
</plugin>

Maven build fails at site default-deploy

I have been struggling to fix my maven build issue from last 2 days with no success almost. Can you please help me on this?
I have a parent pom.xml which looks like
<distributionmanagement>
Repository...
Snapshot
<site>
site config here..
</site>
</distributionmanagement>
In child pom.xml, which I wrote works fine if I do 'mvn install'. tar file is created and appears in project/target folder. Looks good so far...
When I do release the problem comes. The good thing is, it goes well till end - creates tar, uploads tar into my svn repository.. but after that maven is trying to read parent pom.xml and error comes while running "maven-site-plugin:default-deploy" and then "BUILD FAILURE"
What I'm thinking is - since tar is created and uploaded into subversion repository creating site & deploying is not required for us. How can I say to maven that once tar is created don't do anything and that's the end point for me. In other words - don't run anything 'site' related stuff for me?
=========================
UPDATE
I have my release plugin config as below
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<tagBase></tagBase>
</configuration>
</plugin>
we actually do release from our batch file which consists of mvn statements like below -
call mvn clean
call mvn install
call mvn -B release:prepare -DdryRun=true -DscmCommentPrefix="somecomment"
call mvn -B release:clean
call mvn -B release:prepare -DscmCommentPrefix="somecomment"
call mvn -B release:perform -DscmCommentPrefix="somecomment"
Can you please suggest me now?
You should change the maven-release-plugin configuration no to do an site-deploy which is default like the following:
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<goals>deploy</goals>
</configuration>
</plugin>
Or if creating site & deploying is really not required (as you say in your question), you could just remove the <distributionManagement> section. According to the docs default goals are "either deploy or deploy site-deploy, if the project has a <distributionManagement>/<site> element".
http://maven.apache.org/maven-release/maven-release-plugin/perform-mojo.html

Why is the maven project info reports plugin creating a superfluous folder?

When I run mvn site, the maven-project-info-reports-plugin is creating a folder in my project base folder called "${project.basedir}". My plugin is defined like so with no extra configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>${version.maven-project-info-reports-plugin}</version>
</plugin>
When this happens, the site generation gives me a warning:
[WARNING] The repository url 'file://${project.basedir}' is invalid -
Repository 'studio.repository' will be blacklisted.
Why is this oddly-named folder being created, and how can I prevent it from being created? What other configuration can I look at that might be related to this plugin?
UPDATE (the plugin is version 2.2, the latest as far as I know as of this writing)
There is a (dated) discussion in maven mailing list which looks related. The issue seems to be due to using repository mirrors.
You would want to try with the latest version of the plugin, as well as the workaround suggested, which is to set <dependencyLocationEnabled> to false.

Generate javadoc in maven and then upload via scp?

I have Maven javadoc plugin working nicely right now, but I do not know how to add it to the remote directory via scp.
How do I transfer the javadoc files via scp, but AFTER they have been generated? Can this automatically happen when I call site:site?
Thanks!
maven-javadoc-plugin doesn't attach to any phase/goal by default, you need configure it manually in pom.xml.
See Generate Javadocs As Part Of Project Reports:
To generate javadocs as part of the site generation, you should add the Javadoc Plugin in the section of your pom:
<project>
...
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
<configuration>
...
</configuration>
</plugin>
</plugins>
...
</reporting>
...
</project>
When you execute mvn site, the javadocs will be generated and included in the generated site. A link to the javadocs will be added in the Project Reports menu.
Alternatively, if you use maven-release-plugin, javadoc generation (and upload) is automatically handled by default, see here:
The following delvierables are created and deployed to local and remoted repositories after the execution of the release:perform goal has finished.
artifact id-version.jar
The binaries for the current release of the project.
artifact id-version-javadoc.jar
The javadoc explaining the current functionality of the classes within the current release.
artifact id-version-source.jar
The source code revisions used to build the current release of the project.
artifact id-version.pom
The contents of the pom.xml file used to create the current release of the project.
If you want to attach javadoc generation to some phase/goal other than site, check out How to deploy Javadoc jar file?

Resources