nastra commented on PR #5186:
URL: https://github.com/apache/iceberg/pull/5186#issuecomment-1175971053

   I have a minimal example with the below diffset that produces a 
`my-git-file.properties` in the **root folder** of the project (note that this 
file isn't added to jars):
   
   ```
   $ git diff
   diff --git a/build.gradle b/build.gradle
   index c6395fa9d..91d654f1a 100644
   --- a/build.gradle
   +++ b/build.gradle
   @@ -34,6 +34,7 @@ buildscript {
        classpath 'me.champeau.jmh:jmh-gradle-plugin:0.6.6'
        classpath "com.github.alisiikh:gradle-scalastyle-plugin:3.4.1"
        classpath 'com.palantir.gradle.revapi:gradle-revapi:1.7.0'
   +    classpath 
"com.gorylenko.gradle-git-properties:gradle-git-properties:2.4.1"
      }
    }
    
   @@ -42,8 +43,19 @@ plugins {
    }
    
    try {
   -  // apply this plugin in a try-catch block so that we can handle cases 
without .git directory
   +  // apply these plugins in a try-catch block so that we can handle cases 
without .git directory
      apply plugin: 'com.palantir.git-version'
   +  apply plugin: "com.gorylenko.gradle-git-properties"
   +
   +  gitProperties {
   +    // this produces a git properties file in the root of the project
   +    gitPropertiesName = "my-git-file.properties"
   +    gitPropertiesResourceDir = file("$project.rootDir")
   +  }
    } catch (Exception e) {
      project.logger.error(e.getMessage())
    }
   nastra@nastra-datastax-pc:~/Development/workspace/iceberg$ ./gradlew clean 
generateGitProperties
   
   BUILD SUCCESSFUL in 3s
   25 actionable tasks: 24 executed, 1 from cache
   nastra@nastra-datastax-pc:~/Development/workspace/iceberg$ find . -name 
"my-git-file.properties"
   ./my-git-file.properties
   ```
   I think what's unclear to me is whether this file is something that we'd 
want to add to every single jar (since that would actually make sense imo to 
have some git info in jars) or whether we just want to generate a single 
properties file in the root of the project.
   
   In case we want to add the properties file to the root and to every single 
jar, then this minimal example does the job:
   ```
   $ git diff
   diff --git a/build.gradle b/build.gradle
   index c6395fa9d..16e39bfb3 100644
   --- a/build.gradle
   +++ b/build.gradle
   @@ -34,6 +34,7 @@ buildscript {
        classpath 'me.champeau.jmh:jmh-gradle-plugin:0.6.6'
        classpath "com.github.alisiikh:gradle-scalastyle-plugin:3.4.1"
        classpath 'com.palantir.gradle.revapi:gradle-revapi:1.7.0'
   +    classpath 
"com.gorylenko.gradle-git-properties:gradle-git-properties:2.4.1"
      }
    }
    
   @@ -42,8 +43,15 @@ plugins {
    }
    
    try {
   -  // apply this plugin in a try-catch block so that we can handle cases 
without .git directory
   +  // apply these plugins in a try-catch block so that we can handle cases 
without .git directory
      apply plugin: 'com.palantir.git-version'
   +  apply plugin: "com.gorylenko.gradle-git-properties"
   +
   +  gitProperties {
   +    // this produces a git properties file in the root of the project
   +    gitPropertiesName = "my-git-file.properties"
   +    gitPropertiesResourceDir = file("$project.rootDir")
   +  }
    } catch (Exception e) {
      project.logger.error(e.getMessage())
    }
   @@ -72,6 +80,7 @@ allprojects {
    subprojects {
      apply plugin: 'nebula.dependency-recommender'
      apply plugin: 'java-library'
   +  apply plugin: "com.gorylenko.gradle-git-properties"
    
      configurations {
        testImplementation.extendsFrom compileOnly
   @@ -149,6 +158,11 @@ subprojects {
          exceptionFormat "full"
        }
      }
   +
   +  gitProperties {
   +    // this produces a git properties file in the root of each jar
   +    gitPropertiesName = "my-git-file.properties"
   +  }
    }
   ```
   ```
   $ find . -name "my-git-file.properties"
   ./core/build/resources/main/my-git-file.properties
   ./aliyun/build/resources/main/my-git-file.properties
   ./my-git-file.properties
   ./parquet/build/resources/main/my-git-file.properties
   ./orc/build/resources/main/my-git-file.properties
   ./data/build/resources/main/my-git-file.properties
   ./bundled-guava/build/resources/main/my-git-file.properties
   ./flink/v1.15/flink-runtime/build/resources/main/my-git-file.properties
   ./flink/v1.15/flink/build/resources/main/my-git-file.properties
   ./flink/build/resources/main/my-git-file.properties
   ./spark/v3.3/spark-runtime/build/resources/main/my-git-file.properties
   ./spark/v3.3/spark/build/resources/main/my-git-file.properties
   ./spark/v3.3/spark-extensions/build/resources/main/my-git-file.properties
   ./spark/build/resources/main/my-git-file.properties
   ./dell/build/resources/main/my-git-file.properties
   ./hive-runtime/build/resources/main/my-git-file.properties
   ./aws/build/resources/main/my-git-file.properties
   ./api/build/resources/main/my-git-file.properties
   ./hive-metastore/build/resources/main/my-git-file.properties
   ./mr/build/resources/main/my-git-file.properties
   ./arrow/build/resources/main/my-git-file.properties
   ./common/build/resources/main/my-git-file.properties
   ./nessie/build/resources/main/my-git-file.properties
   ./gcp/build/resources/main/my-git-file.properties
   ./pig/build/resources/main/my-git-file.properties
   ```
   
   Given that we don't specify which info we want, the full content of the file 
looks like this:
   ```
   git.branch=error-prone-warnings-core-module
   git.build.host=nastra-datastax-pc
   [email protected]
   git.build.user.name=Eduard Tudenhoefner
   git.build.version=0.14.0-SNAPSHOT
   git.closest.tag.commit.count=661
   git.closest.tag.name=release-base-0.13.0
   git.commit.id=fa8d8c5880202be71e4986091d1621d291ae01cf
   git.commit.id.abbrev=fa8d8c5
   git.commit.id.describe=release-base-0.13.0-661-gfa8d8c5-dirty
   git.commit.message.full=Core\: Fix ErrorProne Warnings\n
   git.commit.message.short=Core\: Fix ErrorProne Warnings
   git.commit.time=2022-07-05T10\:44\:45+0200
   [email protected]
   git.commit.user.name=Eduard Tudenhoefner
   git.dirty=true
   git.remote.origin.url=https\://github.com/apache/iceberg.git
   git.tags=
   git.total.commit.count=2919
   ```


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to