apache / apache/maven

[MNG-6578] revision property not resolved when the root module isn't the ancestor of a submodule

Open
#8,670 2 comments 0 reactions 0 assignees View on GitHub
enhancement priority:major
Dominant language
Java
Stars
5.3k
Forks
3.1k
Avg merge
20h 42m
Merged PRs (30d)
297

Description

**[Rik Schaaf](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=rikschaaf)** opened **[MNG-6578](https://issues.apache.org/jira/browse/MNG-6578?redirect=false)** and commented

Consider the following structure:

There is an external parent pom (lets call it external:ext-pom:1.0)

In my project I have the following module structure:

```java
rootmodule
|_submodule-bom
|_submodule-parent
|_submodule-child
```

These are the contents of the poms:

rootmodule/pom.xml:

```java

external
ext-pom
1.0

demo
rootmodule
${revision}
pom


submodule-child
submodule-parent


1.0.0-SNAPSHOT




org.codehaus.mojo
flatten-maven-plugin
...
```

submodule-parent/pom.xml:

```java

external
ext-pom
1.0

demo
submodule-parent
${revision}
pom
```

submodule-child/pom.xml:

```java

demo
submodule-parent
${revision}
../submodule-parent

submodule-child
pom
```

When building the rootmodule with ```
mvn clean install

```

I get the following build log:
```java
[INFO] Reactor Summary:
[INFO]
[INFO] submodule-parent ${revision} ....................... SUCCESS [ 0.025 s]
[INFO] submodule-child ${revision} ........................ SUCCESS [ 1.024 s]
[INFO] rootmodule 1.0.0-SNAPSHOT ........... SUCCESS [ 0.493 s]
```

Note how the versions of the child and parent aren't defined, because they aren't a direct or indirect child of the root module. Also the created jar files now have as version null.

I know that you can supply the commandline variable -Drevision=1.0.0-SNAPSHOT or put it in the .mvn/maven.config file, but I would prefer to be able to set the version number in the pom instead.

Since ${revision} is a specially treated variable, it would be nice if the revision property (and the 2 other accompanying properties) would be inherited by submodules, even if they do not have the project root as an ancestor.

Alternatively it could be implemented by being able to specify in the \ section that you want to propagate properties to the submodules, like for instance:

```

true

submodule-child
submodule-parent

```

Either solution or a different solution alltogether would be fine.

---

**Affects:** 3.5.0, 3.6.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.