[ 
https://issues.apache.org/jira/browse/MNG-6608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16792409#comment-16792409
 ] 

Hervé Boutemy commented on MNG-6608:
------------------------------------

how would a variable change anything? The merge would happen on the variable 
line instead of the project.version line, but the issue would be the same.

And in your example, you're exactly proving why a variable opens unwanted use: 
it permits to play with profiles, which is not really something good for 
setting version.
But if you really want to try out, your can use special properties: see 
https://blog.soebes.de/blog/2017/04/02/maven-pom-files-without-a-version-in-it/

Notice that there is one use case that could perhaps be supported in the 
future: in the case of multi-module build, it should be feasible to avoid 
putting the version in modules, and let only the version in parent pom. This 
way, the merge would only happen on parent pom, but not others. The idea is 
well known, but requires incompatible changes at pom.xml level, which would 
wreck havoc in Central, then currently not really planned...
some have documented how to use revision to do something like that: 
https://www.igorkromin.net/index.php/2015/11/08/getting-around-mavens-parent-child-project-version-dependency-issue/

> Why can't project.version in pom.xml be set as a variable?
> ----------------------------------------------------------
>
>                 Key: MNG-6608
>                 URL: https://issues.apache.org/jira/browse/MNG-6608
>             Project: Maven
>          Issue Type: New Feature
>          Components: Design, Patterns & Best Practices
>    Affects Versions: 3.6.0
>            Reporter: chenxiaoyong
>            Priority: Major
>
> we need modify project.version in pom.xml  when we merge source code from 
> develope branch to master branch in git. it‘s troublesome!
> Why can't project.version in pom.xml be set as a variable?
> for example:
> {code:xml}
> <project ... >
>     <modelVersion>4.0.0</modelVersion>
>     <groupId>org.example</groupId>
>     <artifactId>example</artifactId>
>     <version>${project-version}</version>
>     <packaging>jar</packaging>
>     <properties>
>         <project-version>1.0.0-SNAPSHOT</project-version>
>     </properties>
>     <profiles>
>         <profile>
>             <!-- snapshot -->
>             <id>dev</id>
>             <properties>
>                 <profiles.active>dev</profiles.active>
>                 <project-version>1.0.0-SNAPSHOT</project-version>
>             </properties>
>             <activation>
>                 <activeByDefault>true</activeByDefault>
>             </activation>
>         </profile>
>         <profile>
>             <!-- RELEASE -->
>             <id>release</id>
>             <properties>
>                 <profiles.active>release</profiles.active>
>                 <project-version>1.0.0-RELEASE</project-version>
>             </properties>
>         </profile>
>     </profiles>
>   
> </project>
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to