Anonymous pom.xml in release

I have artifacts that are built and released using Maven. The original armfact pom.xml file contains the usual project information (artifactId, name, etc.) and dependencies. It's great. But pom.xml also contains personal information such as SCM URLs, developer names, or the parent artifact.

Is there a way to tell Maven to create a cleaned pom.xml so that the artifact can be published publicly without destroying technically relevant information such as dependencies?

Neither the SCM URLs, nor the list of developers, nor the existence of a parent pump (which is used only for DepMgmt and other metafile definitions) are relevant to users of the artifact, so I believe that I could be removed from the released pom.xml

The pom.xml file, both in the repository manager and in Archiva and packaged in a jar artifact file, contains this information. I assume Maven is just copying all of this.

Summarizing:

I have:

<project> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>my-artifact</artifactId> <scm> <connection>scm:svn:http://buildmachine/org.example/my-artifact/trunk</connection> <developerConnection>scm:svn:http://buildmachine/org.example/my-artifact/trunk</developerConnection> <url>http://buildmachine/org.example/my-artifact/trunk</url> </scm> <dependencies> <dependency> ... </dependency> </dependencies> 

I want to:

 <project> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>my-artifact</artifactId> <dependencies> <dependency> ... </dependency> </dependencies> 
+4
source share
3 answers

I do not know the perfect solution to your problem, but some things can be done. These are hacks, but they can help.
Firstly, external private information from pom (e.g. scm, developer names, etc.). For scm metadata, this would be:

 <scm> <connection>${my.scm.connection}</connection> <developerConnection>${my.scm.developerConnection}</developerConnection> <url>${my.scm.url}</url> </scm> 

Secondly, move the properties to the settings file by placing them in the profile. In the settings file, you can also "hide" your company repository. If you need to share profiles / settings.xml files with other partners, try using the global settings file with mvn -gs path_to_global_settings or prepare a general Maven installation with these settings.
The pom parent section, unfortunately, must remain intact.

+3
source

The release plugin does not have built-in support for this, as far as I know. Two possibilities come to mind:

Option 1:

  • Do not include pom in your banks - you can control this using the "archive" parameter in the jar . <archive><addMavenDescriptor>false</addMavenDescriptor></archive>
  • Write a program to highlight elements that you do not want in the published POM. You have to do this between release: preparation and release: execute, which will probably only work if you have SCM support for changing tags after creating or modifying under a different tag / branch, and then let go: do it .

I think option 1 is yucky.

Option 2:

  • try using the prepareGoals parameter in the release plugin. If you can write pom manipulation as maven actions, perhaps it will be done like this.

I think option 2 is harder.

If none of this works, you will probably have to use something like release: stage and do a manual scan, but you still want to exclude the POM from the contents of the jar.

+1
source

You will create your own archetype for this and publish it to the public. Then your users can get the archetype and customize their own project based on your archetype.

The archetype is a very simple plugin containing the prototype of the project you want to create.

To create a new project based on the archetype, you need to call the mvn archetype:generate target, as shown below:

  mvn archetype:generate \ -DarchetypeGroupId=<archetype-groupId> \ -DarchetypeArtifactId=<archetype-artifactId> \ -DarchetypeVersion=<archetype-version> \ -DgroupId=<my.groupid> \ -DartifactId=<my-artifactId> 
0
source

All Articles