7

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.

Marc de Verdelhan
  • 2,501
  • 3
  • 21
  • 40
  • Why are you using [Maven 2](http://maven.apache.org/maven-2.x-eol.html) and not Maven 3 ? Please update as soon as possible. Second the structure of your project looks wrong cause you have a parent which does not contain the important things like pinning plugin versions etc. You have sub module which contains these things. Furthermore you are using really old plugin versions (maven-gpg-plugin 1.1?) etc. – khmarbaise May 23 '14 at 15:12
  • @khmarbaise Because Maven 2 is provided by default by Ubuntu 12.04 LTS (which is the system I use nowadays). Do you think using Maven 3 could resolve my problem? I will take a look at plugins version. Anyway my objective is not to be up-to-date immediately but to release a version. Finally I think the interest of pinning plugin versions in the parent pom is patent if the submodules are sharing plugins, which is not the case here (except for the maven-compiler-plugin, but I put it in the parent pom). Thanks. – Marc de Verdelhan May 23 '14 at 19:11
  • The pinning of versions of plugins is one fundamental thing to make your build reproducible over different Maven versions. If Maven 2 is provided by Ubuntu it does not make sense to me using an really old stuff. If you don't share things by using your parent the strucutre you have created does not make sense more and more. – khmarbaise May 24 '14 at 13:33
  • Does this answer your question? [How to deploy child module without also deploying parent module?](https://stackoverflow.com/questions/58521838/how-to-deploy-child-module-without-also-deploying-parent-module) – sbernard Jul 04 '22 at 09:00

2 Answers2

5

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.

Marc de Verdelhan
  • 2,501
  • 3
  • 21
  • 40
1

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>"
stripybadger
  • 4,539
  • 3
  • 19
  • 26
  • 1
    Which is considered Very Bad Practise ™. Something which is dependent on snapshots should not be considered production ready. – Markus W Mahlberg May 23 '14 at 16:51
  • @Markus Yes I agree, I was surprised that the release plugin even has that option. – stripybadger May 23 '14 at 18:47
  • Thank you for your answer. Indeed, the way you put it, this sound weird. I didn't know Maven would complain it couldn't find ta4j-parent. Obviously this is not what I'm looking for. I agree with @Markus as it's a bad practice. But I didn't want to make ta4j dependent on any snapshot. I was more thinking about a Maven option to use the _effective_ pom instead of the real one ([like in the help plugin](http://maven.apache.org/plugins/maven-help-plugin/effective-pom-mojo.html) for instance) and make the parent artifact transparent. Still investigating, but thank you both. :) – Marc de Verdelhan May 23 '14 at 19:14