You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/09/19 09:40:48 UTC

[GitHub] [iotdb] ericpai commented on pull request #7316: Generate an file COMMITID to store the current commit id when compile distribution

ericpai commented on PR #7316:
URL: https://github.com/apache/iotdb/pull/7316#issuecomment-1250796419

   Hey, there's another solution that using a native maven plugin to generate git.properties file, and read the commit hash directly to the process.
   
   server/pom.xml
   ```xml
   <plugin>
                   <groupId>pl.project13.maven</groupId>
                   <artifactId>git-commit-id-plugin</artifactId>
                   <version>4.9.10</version>
                   <executions>
                       <execution>
                           <id>get-the-git-infos</id>
                           <goals>
                               <goal>revision</goal>
                           </goals>
                           <phase>initialize</phase>
                       </execution>
                   </executions>
                   <configuration>
                       <generateGitPropertiesFile>true</generateGitPropertiesFile>
                       <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
                       <includeOnlyProperties>
                           <includeOnlyProperty>^git.commit.id.abbrev$</includeOnlyProperty>
                           <includeOnlyProperty>^git.dirty$</includeOnlyProperty>
                       </includeOnlyProperties>
                       <commitIdGenerationMode>full</commitIdGenerationMode>
                       <failOnNoGitDirectory>false</failOnNoGitDirectory>
                       <offline>true</offline>
                       <gitDescribe>
                           <dirty>-dev</dirty>
                       </gitDescribe>
                   </configuration>
               </plugin>
   ```
   
   IoTDBConstant.java
   
   ```java
   static {
       Properties prop = new Properties();
       String finalBuildInfo = "UNKNOWN";
       try {
         prop.load(IoTDBConstant.class.getResourceAsStream("/git.properties"));
         finalBuildInfo = prop.getProperty("git.commit.id.abbrev", "UNKNOWN");
         String isDirty = prop.getProperty("git.dirty", "false");
         if (isDirty.equalsIgnoreCase("true")) {
           finalBuildInfo += "-dev";
         }
       } catch (Exception e) {
         System.err.println("get git.properties error: " + e.getMessage());
       }
       BUILD_INFO = finalBuildInfo;
     }
   
     public static final String BUILD_INFO;
     public static final String VERSION_WITH_BUILD = VERSION + " (Build: " + BUILD_INFO + ")";
   ```
   
   Then we can not only find the commit info in the dir but also in the iotdb-cli.


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org