Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to release a Maven submodule without releasing the parent POM?

I am the maintainer of a Java library (ta4j, which provides functions for technical analysis). On my repository, the different modules are mavenized and I am trying to release one of them.

Maven architecture

The Maven architecture of this project is:

ta4j-parent
  |__ ta4j
  |__ ta4j-examples

ta4j-parent

I added this pom.xml only to share some properties (licenses, issueManagement, etc.) between ta4j and ta4j-examples, and for future dependencyManagement. I don't want to release this artifact (as it's useless for the users of my library).

ta4j

This pom.xml has ta4j-parent as its parent. It contains what is necessary to release the ta4j artifact, which is the only useful (It is the only source module of the library itself) module for my library.

ta4j-examples

This artifact contains standalone main classes which shows examples of usage of ta4j. I don't want to release it.

For now this pom.xml only contains the dependencies of the examples.

Release

As I want to release only the ta4j module, I went to the ./ta4j/ta4j subdirectory and ran the following command:

mvn release:prepare -Darguments=-Dgpg.passphrase="<my key secret>"

...which returned:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building ta4j
[INFO]    task-segment: [release:prepare] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [release:prepare {execution: default-cli}]
[INFO] Verifying that there are no local modifications...
[INFO]   ignoring changes on: **/pom.xml.backup, **/release.properties, **/pom.xml.branch, **/pom.xml.next, **/pom.xml.releaseBackup, **/pom.xml.tag
[INFO] Executing: /bin/sh -c cd /home/user/workspace/ta4j/ta4j && git status
[INFO] Working directory: /home/user/workspace/ta4j/ta4j
[INFO] Checking dependencies and plugins for snapshots ...
There are still some remaining snapshot dependencies.
: Do you want to resolve them now? (yes/no) no: : no
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Can't release project due to non released dependencies :
    eu.verdelhan:ta4j-parent:pom:0.4-SNAPSHOT
in project 'ta4j' (eu.verdelhan:ta4j:jar:0.4-SNAPSHOT)
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Thu May 22 21:50:50 CEST 2014
[INFO] Final Memory: 23M/293M
[INFO] ------------------------------------------------------------------------

The release plugin does not want to release the ta4j module. It considers I should release a snapshot dependency first: ta4j-parent. BUT, as I previously said, I don't want the parent to be released (... because it's useless for everyone).

So how could I release the ta4j module and only the ta4j module?

Note: the Maven version I use is Apache Maven 2.2.1 (Java 1.7).

Thanks.

Edit 2014-06-02

I edited the question as I considered that my main problem was to release a child module without releasing its parent. Whether snapshot or not makes no difference.

like image 286
Marc de Verdelhan Avatar asked May 23 '14 14:05

Marc de Verdelhan


Video Answer


2 Answers

After several days of research, I did not find a way to make the parent POM transparent.

I finally chose to also release the parent module. Even if it is (theoritically) useless I noticed it is a common practice for that kind of projects.

I am pretty disappointed that it seems there is no such feature (like to include the parent POM in the child POM) with Maven. But I will change the accepted answer if someone can find a way to do that in the future.

like image 160
Marc de Verdelhan Avatar answered Sep 30 '22 19:09

Marc de Verdelhan


This sounds a bit weird, because if anyone referenced ta4j in maven, then maven would complain that it couldn't find ta4j-parent, unless you made that available too. And if you are going to make the parent available, then better to give it a release version than a snapshot version.

That said, you could tell maven to ignore snapshots by setting the ignoreSnapshots property, i.e.

mvn release:prepare -DignoreSnapshots=true -Darguments=-Dgpg.passphrase="<my key secret>"
like image 33
stripybadger Avatar answered Sep 30 '22 18:09

stripybadger