0

I have bunch of projects. All of them must have the same version = branch directory name("7.15.0" for example).

To achieve that, i make one parent pom with code:

<version>${branch}</version>
<properties>
    <branch>${project.file.parentFile.parentFile.parentFile.name}</branch>
</properties>

Most of my projects and subprojects are in directories, where ../.. is branch directory. Their poms contains this:

<parent>
    <groupId>parentPomGroupId</groupId>
    <artifactId>parentPomArtifactId</artifactId>
    <version>${branch}</version>
</parent>

But not all projects is on the same level, so i must control and check where they is, and if needed add to their pom correct branch path:

<properties>
    <branch>${project.file.parentFile.parentFile.name}</branch>
</properties>

also when project builds, in the log i see :

[INFO] Building appcore-utils ${project.file.parentFile.parentFile.name}

If i set constant in branch - log contains version. Tell me please, how can i resolve property "branch" only once in my parent pom? So if i use ${branch} in child project, it resolves to constant, which already calculated in parent pom. Or maybe there is another way to use branch directory name in version of projects?

cynepnaxa
  • 1,024
  • 1
  • 14
  • 30

1 Answers1

1

I don't think that the goal you're trying to achieve is valid in terms of the current (3.1+) maven. The version tag now should be filled with a constant despite the fact that a while ago it could be possible to use an expression there as described in Maven version with a property , look at the last comment by @JanPeta. BTW the solution by Frederic Close doesn't work anymore (for maven-3.1.1 installed in my system).

Alternatively you can change the version of the artifacts generated in your project, and I have a working solution for that (instead of taking version from a directory name, I use git describe... output) but it's really, really ugly and now I think it's not worth the time I spent fixing all the issues with this approach.

Community
  • 1
  • 1
user3159253
  • 16,836
  • 3
  • 30
  • 56