This is an automated email from the ASF dual-hosted git repository.

mdedetrich pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-pekko-grpc.git


The following commit(s) were added to refs/heads/main by this push:
     new 9438c173 Derive gradle plugin version from sbt
9438c173 is described below

commit 9438c1736c864101a6c052a26db49fe2412a33d1
Author: Matthew de Detrich <[email protected]>
AuthorDate: Mon Aug 7 18:20:20 2023 +0200

    Derive gradle plugin version from sbt
---
 .github/workflows/build-test.yml                     | 16 ++++------------
 .github/workflows/publish-nightly.yml                |  2 +-
 gradle-plugin/build.gradle                           | 20 ++++++++++++++------
 .../apache/pekko/grpc/gradle/PekkoGrpcPlugin.groovy  | 10 ++--------
 plugin-tester-java/settings.gradle                   |  2 +-
 5 files changed, 22 insertions(+), 28 deletions(-)

diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml
index cfd50219..eb1efb82 100644
--- a/.github/workflows/build-test.yml
+++ b/.github/workflows/build-test.yml
@@ -31,14 +31,6 @@ jobs:
       - name: Cache Coursier cache
         uses: coursier/cache-action@v6
 
-      #- name: FOSSA policy check
-      #  if: ${{ github.event_name != 'pull_request' || 
github.event.pull_request.head.repo.full_name == 'apache/incubator-pekko-grpc' 
}}
-      #  run: |-
-      #    curl -H 'Cache-Control: no-cache' 
https://raw.githubusercontent.com/fossas/spectrometer/master/install.sh | bash
-      #    fossa analyze && fossa test
-      #  env:
-      #    FOSSA_API_KEY: "${{secrets.FOSSA_API_KEY}}"
-
       - name: Binary-compatibility check
         run: |-
           cp .jvmopts-ci .jvmopts
@@ -143,7 +135,7 @@ jobs:
 
       - name: Gather version
         run: |-
-          echo `git describe --tags | sed -e 
"s/v\(.*\)-\([0-9][0-9]*\).*/\\1-\\2-/"``git rev-parse HEAD | head 
-c8`-SNAPSHOT > ~/.version
+          echo `sbt --no-colors --error 'set aggregate := false; print 
version' | xargs` > ~/.version
           cat ~/.version
 
       - name: Cache local Gradle repository
@@ -167,12 +159,12 @@ jobs:
       - name: Test Gradle Java ${{ matrix.SCALA_VERSION }}
         run: |-
           cd plugin-tester-java
-          ./gradlew clean test --console=plain --info --stacktrace 
-Dpekko.grpc.project.version=$(cat ~/.version | sed -e s/-SNAPSHOT//)
+          ./gradlew clean test --console=plain --info --stacktrace 
-Dpekko.grpc.project.version=$(cat ~/.version)
 
       - name: Test Gradle Scala ${{ matrix.SCALA_VERSION }}
         run: |-
           cd plugin-tester-scala
-          ./gradlew clean test --console=plain --info --stacktrace 
-Dpekko.grpc.project.version=$(cat ~/.version | sed -e s/-SNAPSHOT//)
+          ./gradlew clean test --console=plain --info --stacktrace 
-Dpekko.grpc.project.version=$(cat ~/.version)
 
       - name: Stop Gradle Daemon
         # as suggested in 
https://github.com/actions/cache/blob/main/examples.md#java---gradle
@@ -199,7 +191,7 @@ jobs:
 
       - name: Gather version
         run: |-
-          echo `git describe --tags | sed -e 
"s/v\(.*\)-\([0-9][0-9]*\).*/\\1-\\2-/"``git rev-parse HEAD | head 
-c8`-SNAPSHOT > ~/.version
+          echo `sbt --no-colors --error 'set aggregate := false; print 
version' | xargs` > ~/.version
           cat ~/.version
 
       - name: Cache local Maven repository
diff --git a/.github/workflows/publish-nightly.yml 
b/.github/workflows/publish-nightly.yml
index ce010fdd..c7b37be9 100644
--- a/.github/workflows/publish-nightly.yml
+++ b/.github/workflows/publish-nightly.yml
@@ -32,7 +32,7 @@ jobs:
           NEXUS_PW: ${{ secrets.NEXUS_PW }}
 
       - name: Publish Gradle Plugin to Apache Nexus Repository
-        run: cd gradle-plugin && ./gradlew properties -q | awk '/^version:/ 
{print $2}' && ./gradlew publishToSonatype
+        run: cd gradle-plugin && ./gradlew publishToSonatype
         env:
           NEXUS_USER: ${{ secrets.NEXUS_USER }}
           NEXUS_PW: ${{ secrets.NEXUS_PW }}
diff --git a/gradle-plugin/build.gradle b/gradle-plugin/build.gradle
index 52829982..623ce2a6 100644
--- a/gradle-plugin/build.gradle
+++ b/gradle-plugin/build.gradle
@@ -2,17 +2,25 @@ plugins {
   id 'groovy'
   id 'java-gradle-plugin'
   id 'maven-publish'
-  id 'com.palantir.git-version' version '0.10.1'
   id 'io.github.gradle-nexus.publish-plugin' version '1.0.0'
 }
 
 group = "org.apache.pekko"
-// https://github.com/palantir/gradle-git-version/issues/97
 
-def tag = "git describe 
--tags".execute().text.substring(1).split("-g")[0].replace("\n", "")
-def finalVersion = (tag == versionDetails().lastTag.substring(1)) ? tag : 
tag.reverse().reverse() + "-" + versionDetails().gitHash.substring(0, 8)
-
-version = finalVersion
+def getVersionFromParentSbtBuild() {
+    ByteArrayOutputStream os = new ByteArrayOutputStream()
+    String parentDir = project.rootDir.getParentFile().getPath()
+    exec {
+        workingDir parentDir
+        commandLine 'sbt', '--no-colors', '--error', 'set aggregate := false; 
print version'
+        standardOutput os
+    }
+    os.close()
+    String finalVersion = os.toString().trim()
+    project.logger.info("Derived gradle version from parent sbt build: 
$finalVersion")
+    return finalVersion
+}
+version = getVersionFromParentSbtBuild()
 
 gradlePlugin {
   plugins {
diff --git 
a/gradle-plugin/src/main/groovy/org/apache/pekko/grpc/gradle/PekkoGrpcPlugin.groovy
 
b/gradle-plugin/src/main/groovy/org/apache/pekko/grpc/gradle/PekkoGrpcPlugin.groovy
index c6330d06..12dfb5ca 100644
--- 
a/gradle-plugin/src/main/groovy/org/apache/pekko/grpc/gradle/PekkoGrpcPlugin.groovy
+++ 
b/gradle-plugin/src/main/groovy/org/apache/pekko/grpc/gradle/PekkoGrpcPlugin.groovy
@@ -21,14 +21,8 @@ class PekkoGrpcPlugin implements Plugin<Project> {
 
     Project project
 
-    // workaround for test projects, when one only needs to tests a new plugin 
version without rebuilding dependencies.
-    String getBaselineVersion(String pluginVersion) {
-        def pv = System.getProperty("pekko.grpc.baseline.version", 
pluginVersion)
-        if (VersionNumber.parse(pv).qualifier) {
-            pv + "-SNAPSHOT"
-        } else {
-            pv
-        }
+    static String getBaselineVersion(String pluginVersion) {
+        System.getProperty("pekko.grpc.baseline.version", pluginVersion)
     }
 
     @Override
diff --git a/plugin-tester-java/settings.gradle 
b/plugin-tester-java/settings.gradle
index ff115d5b..f8ec5e0b 100644
--- a/plugin-tester-java/settings.gradle
+++ b/plugin-tester-java/settings.gradle
@@ -1,7 +1,7 @@
 pluginManagement {
   repositories {
     mavenLocal()
-    gradlePluginPortal()
+    mavenCentral()
   }
   plugins {
     id 'org.apache.pekko.grpc.gradle' version 
"${System.getProperty('pekko.grpc.project.version')}"


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

Reply via email to