Generate and update changelog.md after mvn release:perform - maven

I would like to generate, update changelog.md and commit to Bitbucket repository after mvn release:perform is done.
In angular, it has #semantic-release/git, #semantic-release/commit-analyzer, #semantic-release/release-notes-generator, #semantic-release/npm, #semantic-release/changelog, #semantic-release/exec. Is there anything similar in maven release?
pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<tagNameFormat>v#{project.version}</tagNameFormat>
<checkModificationExcludes>
<checkModificationExclude>pom.xml</checkModificationExclude>
</checkModificationExcludes>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>release</id>
<url>https://nexus.../.../release/</url>
</repository>
</distributionManagement>
<properties>
<project.scm.id>my-scm-server</project.scm.id>
</properties>
<scm>
<connection>scm:git:https://user#bitbucket.org/user/comutils.git</connection>
<developerConnection>scm:git:https://user#bitbucket.org/user/comutils.git</developerConnection>
<tag>HEAD</tag>
</scm>

You can use maven-semantic-release which will generate release notes using Angular style commit messages for Maven projects in the same way as you would do with npm projects.
The documentation suggests how to publish to Maven Central, but you can save some hassle by publishing to Github packages.

Related

Maven deploy plugin disable redeployment

Is it possible to disable redeployment just from pom level via deployment plugin configuration?
Im trying to prevent redeployment of few artifacts in artifactory but dont want to set this globaly (i know it should be dole globaly, but im just a user of that artifactory and it is not up to me to decide).
Thats why i was wondering if it is posible to configure my artifacts poms to fail if deployment would in fact mean redeployment of non SNAPSHOT version.
Maven used: 3.6.1
There is no parameter for deploy:deploy to achieve this. There are two workarounds to prevent unintentional deploying at least:
1. deploy:deploy <skip>
<properties>
<skipDeploy>true</skipDeploy>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<skip>${skipDeploy}</skip>
</configuration>
</plugin>
</plugins>
</build>
Deploy with:
mvn deploy -DskipDeploy=false
2. Deploy to local TEMP by default, use profile to really deploy
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>local-dummy-repo</id>
<name>local dummy repository to prevent unintentional re-deploying</name>
<url>file://${env.TEMP}/maven-dummy-repo</url>
<layout>default</layout>
</repository>
</distributionManagement>
<profiles>
<profile>
<id>deploy</id>
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>repo</id>
<name>real repository</name>
<url>scheme://authority/path</url>
<layout>default</layout>
</repository>
</distributionManagement>
</profile>
</profiles>
Deploy with:
mvn deploy -Pdeploy

How to create own Maven Repository?

I want to know, how to create my own dependency to use my code in other projects.
I were following tutorial.
I`ve tried to create project with simple class as Maven Project.
I did clean-package. Created github repository. Added my project there with "target" package.
in pom.xml i added
<properties>
<java.version>1.8</java.version>
<github.global.server>github</github.global.server>
<github.maven-plugin>0.12</github.maven-plugin>
</properties>
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Temporary Staging Repository</name>
<url>file://${project.build.directory}/mvn-repo</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo</altDeploymentRepository>
</configuration>
</plugin>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>${github.maven-plugin}</version>
<configuration>
<message>Maven artifacts for ${project.version}</message>
<noJekyll>true</noJekyll>
<outputDirectory>${project.build.directory}/mvn-repo</outputDirectory>
<branch>refs/heads/mvn-repo</branch>
<includes><include>**/*</include></includes>
<repositoryName>GITHUB_NAME_REPOSITORY</repositoryName>
<repositoryOwner>MY_GITHUB_NICKNAME</repositoryOwner>
</configuration>
<executions>
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
after in root of .m2 directory i created settings.xml with:
<settings>
<servers>
<server>
<id>github</id>
<username>[username]</username>
<password>[password]</password>
</server>
</servers>
</settings>
did again clean+package and pushed to github.
after trying to use dependency - not found.
in github repo no mvn-repo branch
I haven't used the new GitHub repositories yet, but what work quite well so far:
private, single machine usage: mvn install -> the artifact will be installed in your local Maven repository and can be referenced by any other project on the same machine
Open Source, multiple machines/ developers: mvn deploy to Maven Central. See the documentation for more information about configuration and involved steps.
Closed Source, multiple machines/ developers: mvn deploy to your own Maven Repository manager such as Nexus (configure the distributionManagement accordingly)
That said, it's a best practice to use your own Maven Repository Manager in all 3 cases and define a single group.
From the Maven default lifecycle documentation:
package: take the compiled code and package it in its distributable format, such as a JAR.
install: install the package into the local repository, for use as a dependency in other projects locally.
deploy: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.

Commit multiple files with maven scm plugin

I want to git commit two files in different folders with maven scm plugin (v1.9.4). Eg: abc/p.json and xyz\p.json. I dont want to commit any other files such as other/p.json
According to the documentation for the chekin goal, a comma separated list such as abc/p.json,xyz/p.json should work. But it ends up commiting all the files.
I am using the scm:checkin goal with the maven release plugin's <preparationGoals> configuration.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven.release.plugin.version}</version>
<configuration>
<preparationGoals>
clean verify
scm:checkin -DpushChanges=false -Dmessage="[maven-release-plugin] Update version text"
-Dincludes="abc/p.json,xyz/p.json"
</configuration>
</plugin>
How do I commit just the abc/p.json and xyz/p.json files?
I was able to get a list of files checked in by creating a profile, similar to:
<profile>
<id>commit-changed-files</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<configuration>
<includes>file1,file2,file3,file4</includes>
<message>[maven-release-plugin] commit changed files</message>
<pushChanges>false</pushChanges><!-- because I use git -->
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
And then, in the release plugin configuration:
<preparationGoals>-Pcommit-changed-files clean scm:add scm:checkin</preparationGoals>
<completionGoals>-Pcommit-changed-files clean scm:add scm:checkin</completionGoals>
Reference: formatter-m2e-configurator's pom.xml

No SCM URL was provided to perform the release from

I am trying to use maven release plugin and after that automate this using nexus.
Here is my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ozge.net</groupId>
<artifactId>com.ozge.net</artifactId>
<version>1.1- snapshot</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<tagBase>svn://local/exekuce/com.ozge.net</tagBase>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<scm>
<tag>HEAD</tag>
<connection>scm:svn:svn://[svnusername]:[svn password]#local/exekuce/com.ozge.net</connection>
<developerConnection>scm:svn:svn://[svnusername]:[svn password]#local/exekuce/com.ozge.net</developerConnection>
<url>scm:svn:svn://[svnusername]:[svn password]#local/exekuce/com.ozge.net</url>
</scm>
<distributionManagement>
<repository>
<id>OzgeRelease</id>
<url>http://localhost:8081/nexus/content/repositories/OzgeRelease</url>
</repository>
</distributionManagement>
</project>
after I ran the command mvn release:perform on command prompt
it says
No SCM URL was provided to perform the release from
I believe I provided.
Anybody here tried to maven-subversion-nexus-hudson for automating builds?
Try to perform release:clean first.
mvn release:clean
Then try again.

Maven SCM Plugin: Git SSH provider not found

I'm having a problem using the Maven SCM plugin with Git. I cannot get the plugin to work at all because it says the provider is not found. It gives me the following error when I run mvn scm:tag:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-scm-plugin:1.9:tag
(default-cli) on project hello-world-service-minimal: Cannot run tag command :
Can't load the scm provider. No such provider: 'git:ssh://git#git-eng.REDACTED.com'
. -> [Help 1]
My pom.xml looks like the following:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>net.REDACTED</groupId>
<artifactId>hello-world-service-minimal</artifactId>
<version>1.0.13</version>
<packaging>pom</packaging>
<name>hello-world-service</name>
<properties>
<lang.java.source>1.7</lang.java.source>
<lang.java.target>1.7</lang.java.target>
<dep.junit>4.11</dep.junit>
</properties>
<scm>
<developerConnection>scm:git:ssh://git#git-eng.REDACTED.com|PROJECT_NAME/hello-world-service-minimal.git</developerConnection>
<url>scm:git:http://git-eng.REDACTED.com/PROJECT_NAME/hello-world-service-minimal/tree/master</url>
</scm>
<distributionManagement>
<repository>
<id>dev.release</id>
<url>file:${project.build.directory}/repository/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9</version>
<configuration>
<tag>${project.artifactId}-${project.version}</tag>
</configuration>
</plugin>
</plugins>
</build>
</project>
Anyone have any idea how to fix this? This is driving me crazy. I can't figure out what I am doing wrong at all.
The <url> tag is for a regular browsable URL. You need a <connection> tag (<connection> is for read access, <developerConnection> is for write access):
<scm>
<connection>scm:git:ssh://git#git-eng.REDACTED.com|PROJECT_NAME/hello-world-service-minimal.git</connection>
<developerConnection>scm:git:ssh://git#git-eng.REDACTED.com|PROJECT_NAME/hello-world-service-minimal.git</developerConnection>
<url>http://git-eng.REDACTED.com/PROJECT_NAME/hello-world-service-minimal/tree/master</url>
</scm>
See the Maven POM Reference for more information.

Resources