dalbani commented on PR #1656:
URL: https://github.com/apache/maven/pull/1656#issuecomment-2958261026

   Thanks for keeping the old behaviour with 
`maven.build.allowExpressionInEffectiveProjectVersion`, as I'm using a setup 
based on `versions-maven-plugin` to dynamically replace `${revision}`.
   As in:
   ```xml
   <?xml version="1.0" encoding="UTF-8"?>
   <project xmlns="http://maven.apache.org/POM/4.0.0";
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
       <modelVersion>4.0.0</modelVersion>
       <groupId>com.example.app</groupId>
       <artifactId>app</artifactId>
       <version>${revision}</version>
   
       <properties>
           <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
           
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
           <java.version>21</java.version>
           
<maven.build.allowExpressionInEffectiveProjectVersion>true</maven.build.allowExpressionInEffectiveProjectVersion>
           <maven.compiler.source>${java.version}</maven.compiler.source>
           <maven.compiler.target>${java.version}</maven.compiler.target>
       </properties>
   
       <build>
           <finalName>${project.artifactId}</finalName>
   
           <plugins>
               <plugin>
                   <groupId>io.github.git-commit-id</groupId>
                   <artifactId>git-commit-id-maven-plugin</artifactId>
                   <version>9.0.2</version>
                   <executions>
                       <execution>
                           <goals>
                               <goal>revision</goal>
                           </goals>
                           <phase>initialize</phase>
                       </execution>
                   </executions>
                   <configuration>
                       <abbrevLength>8</abbrevLength>
                       <commitIdGenerationMode>full</commitIdGenerationMode>
                       
<generateGitPropertiesFile>true</generateGitPropertiesFile>
                   </configuration>
               </plugin>
           </plugins>
       </build>
   
       <profiles>
           <profile>
               <id>set-version</id>
   
               <build>
                   <plugins>
                       <plugin>
                           <groupId>org.codehaus.mojo</groupId>
                           <artifactId>versions-maven-plugin</artifactId>
                           <version>2.18.0</version>
                           <executions>
                               <execution>
                                   <goals>
                                       <goal>set</goal>
                                   </goals>
                                   <phase>initialize</phase>
                               </execution>
                           </executions>
                           <configuration>
                               <generateBackupPoms>false</generateBackupPoms>
                           </configuration>
                       </plugin>
                   </plugins>
               </build>
           </profile>
       </profiles>
   </project>
   ```
   
   Which I can then use as:
   ```sh
   if [ $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH ]; then
     NEW_VERSION='${git.total.commit.count}'
   else
     NEW_VERSION=${CI_COMMIT_REF_SLUG}-SNAPSHOT
   fi
   ./mvnw --activate-profiles set-version --define newVersion=${NEW_VERSION} 
initialize
   ./mvnw source:jar deploy
   ```
   
   That way, I can let `git-commit-id-maven-plugin` calculate the version 
without any `git` command in my CI environment.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to