apache / apache/maven

[MNG-6885] Profile-scope properties

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

Description

**[Arseniy Tashoyan](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=tashoyan)** opened **[MNG-6885](https://issues.apache.org/jira/browse/MNG-6885?redirect=false)** and commented

If a property is set in one profile, then another profile cannot change it. It would be good to have profile-scope properties.
Usage scenario: cross-compilation for different Scala versions (2.11 and 2.12).
POM file:

```xml

4.0.0
com.example
scala-example
jar
1.0-SNAPSHOT


UNDEFINED


scala-common

true




org.apache.maven.plugins
maven-antrun-plugin
1.8


tasks-scala-${scala.version}
generate-resources

run














scala-2.11

true


2.11


scala-2.12

true


2.12

```

In this POM file we have one common task declaration for both Scala versions: 2.11 and 2.12. Two specific profiles define the 'scala.version' property. The execution id of the plugin includes the property: 'tasks-scala-${scala.version}', hence unique. So theoretically we could build our project in one run for both Scala versions.
However, in the output of 'mvn package' we see only one plugin execution:

```none
[INFO] --- maven-antrun-plugin:1.8:run (tasks-scala-2.12) @ profile-example ---
[INFO] Executing tasks

main:
[exec] Scala version: 2.12
```

This is because the property 'scala.version' is globally set to '2.12'. It does not take different values for two different profiles. Therefore we need to run separately:

```none
mvn -P scala-2.11 goals...
mvn -P scala-2.12 goals...
```

This feature could give same user experience as with Sbt cross builds.

---

**Affects:** 3.6.3

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.