Maven deploy Release Note as artifact

0 votes

Requirement: Upload (deploy) an additional file (a text format release note file) along with jar/war to nexus.

Possible Solution: Use maven deploy plugin as below:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <executions>
                <execution>
                    <phase>deploy</phase>
                    <goals>
                        <goal>deploy-file</goal>
                    </goals>
                    <configuration>
                        <packaging>RELEASENOTE.MD</packaging>
                        <generatePom>false</generatePom>
                        <url>${project.distributionManagement.repository.url}</url>
                        <artifactId>${project.artifactId}</artifactId>
                        <groupId>${project.groupId}</groupId>
                        <version>${project.version}</version>
                        <file>RELEASENOTE.MD</file>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Problems:

  1. RELEASENOTE.MD file is optional. The file should be deployed only if it is present. The above solution throws an error if the file is not present.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file (default) on project ...\RELEASENOTE.MD not found.

  1. Need an option to specify file name by regex (example: *RELEASENOTE.MD). maven deploy plugin does not accept regex.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file (default) on project ...*RELEASENOTE.MD not found.

How can these two problems be circumvented?

Jun 22, 2018 in DevOps Tools by Damon Salvatore
• 5,510 points
47 views

1 answer to this question.

0 votes

The following solution will do the trick:

<profiles>
    <profile>
        <id>add-release-note</id>
        <activation>
            <file><exists>RELEASENOTE.MD</exists></file>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>3.0.0</version>
                    <executions>
                        <execution>
                            <id>attach-artifacts</id>
                            <phase>package</phase>
                            <goals>
                                <goal>attach-artifact</goal>
                            </goals>
                            <configuration>
                                <artifacts>
                                    <artifact>
                                        <file>RELEASENOTE.MD</file>
                                        <type>MD</type>
                                        <classifier>RELEASENOTE</classifier>
                                    </artifact>
                                </artifacts>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
Below are the two changes I have made in the above code.
  • maven-deploy-plugin within profile activation works too. However, it poses a difficulty for release/snapshot build parameterization due to its <url> tag. build-helper-maven-plugin is a simpler solution

  • Filename regex can be handled through a wrapper shell build script

I hope the above explanation would be helpful for you.

answered Jun 22, 2018 by Atul
• 10,240 points

Related Questions In DevOps Tools

+4 votes
2 answers

Jenkins not showing Maven Release Plugin

Make your project type Maven Project. This ...READ MORE

answered Oct 11, 2018 in DevOps Tools by Hannah
• 15,040 points
764 views
0 votes
1 answer

running comands as non-root user while using docker-maven plugin

Docker needs root access therefore maven commands ...READ MORE

answered Apr 30, 2018 in DevOps Tools by ajs3033
• 7,280 points
554 views
0 votes
1 answer

How to deploy kafka cluster on cloud?

You can run kafka in both ways ...READ MORE

answered Jun 14, 2018 in DevOps Tools by DareDev
• 6,810 points
57 views
0 votes
1 answer

How to download the latest minor version of nexus artifact using REST?

If you're using nexus 2.x, you can ...READ MORE

answered Jun 27, 2018 in DevOps Tools by ajs3033
• 7,280 points
387 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
175 views
0 votes
1 answer
0 votes
1 answer

Maven deploy “Release Note” as artifact

Using both @SpaceTrucker and @khmarbaise, came up with the following ...READ MORE

answered Jun 19, 2018 in DevOps Tools by Atul
• 10,240 points
153 views
0 votes
1 answer

How to deploy Liberty packaged server automatic delivery

Here is a concept regarding your query. It ...READ MORE

answered Jul 11, 2018 in DevOps Tools by Atul
• 10,240 points
43 views