You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2025/03/21 10:32:06 UTC

(groovy) branch master updated: minor refactor: remove some gradle warnings

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

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 951698a00e minor refactor: remove some gradle warnings
951698a00e is described below

commit 951698a00e1b2b45de5942242950426cfc48fe2b
Author: Paul King <pa...@asert.com.au>
AuthorDate: Fri Mar 21 20:31:58 2025 +1000

    minor refactor: remove some gradle warnings
---
 build-logic/src/main/groovy/org.apache.groovy-base.gradle  |  2 +-
 .../main/groovy/org/apache/groovy/gradle/JarJarTask.groovy | 14 +++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/build-logic/src/main/groovy/org.apache.groovy-base.gradle b/build-logic/src/main/groovy/org.apache.groovy-base.gradle
index 8be3e653d8..c95012f9d9 100644
--- a/build-logic/src/main/groovy/org.apache.groovy-base.gradle
+++ b/build-logic/src/main/groovy/org.apache.groovy-base.gradle
@@ -179,6 +179,7 @@ tasks.withType(Jar).configureEach { jar ->
 }
 
 tasks.register('jarjar', JarJarTask) {
+    String projectName = project.name
     from = jar.archiveFile
     repackagedLibraries.from configurations.runtimeClasspath.incoming.artifactView {
         componentFilter { component ->
@@ -209,7 +210,6 @@ tasks.register('jarjar', JarJarTask) {
     outputFile = tasks.named('jar').flatMap { layout.buildDirectory.file("libs/${it.archiveBaseName.get()}-${it.archiveVersion.get()}${(it.archiveClassifier.get() && it.archiveClassifier.get() != 'raw') ? '-' + it.archiveClassifier.get() : ''}.jar") }
 
     withManifest {
-        String projectName = project.name
         String autoModName = "org.apache.${projectName.replace('-','.')}"
         attributes('Automatic-Module-Name': autoModName, 'Bundle-Name': "Groovy module: $projectName")
         groovyLibrary.configureManifest(it, excludedFromManifest)
diff --git a/build-logic/src/main/groovy/org/apache/groovy/gradle/JarJarTask.groovy b/build-logic/src/main/groovy/org/apache/groovy/gradle/JarJarTask.groovy
index 4859830934..c49ef67a0e 100644
--- a/build-logic/src/main/groovy/org/apache/groovy/gradle/JarJarTask.groovy
+++ b/build-logic/src/main/groovy/org/apache/groovy/gradle/JarJarTask.groovy
@@ -56,6 +56,10 @@ class JarJarTask extends DefaultTask {
     @Classpath
     final ConfigurableFileCollection jarjarToolClasspath = project.objects.fileCollection()
 
+    final protected osgi = project.rootProject.extensions.osgi
+
+    final protected String projectName = project.name
+
     @InputFiles
     @Classpath
     @Optional
@@ -119,7 +123,7 @@ class JarJarTask extends DefaultTask {
         String tstamp = Date.parse('yyyy-MM-dd HH:mm', '1980-02-01 00:00').getTime().toString()
 
         // Step 1: create a repackaged jar
-        project.ant {
+        ant.with {
             taskdef name: 'jarjar', classname: 'com.eed3si9n.jarjar.JarJarTask', classpath: jarjarToolClasspath.asPath
             jarjar(jarfile: tmpJar, filesonly: true, modificationtime: tstamp) {
                 zipfileset(src: from.get(), excludes: (untouchedFiles + excludes).join(','))
@@ -153,7 +157,7 @@ class JarJarTask extends DefaultTask {
         }
 
         // Step 2: update the archive with a class index and any untouched files
-        project.ant.jar(destfile: outputFile, index: true, modificationtime: tstamp, update: true) {
+        ant.jar(destfile: outputFile, index: true, modificationtime: tstamp, update: true) {
             if (untouchedFiles) {
                 zipfileset(src: from.get(), includes: untouchedFiles.join(','))
             }
@@ -161,15 +165,15 @@ class JarJarTask extends DefaultTask {
 
         // Step 3: generate an OSGi manifest referencing the repackaged classes
         if (createManifest) {
-            def mf = project.rootProject.extensions.osgi.osgiManifest {
-                symbolicName = project.name
+            def mf = osgi.osgiManifest {
+                symbolicName = this.projectName
                 instruction 'Import-Package', '*;resolution:=optional'
                 classesDir = tmpJar
             }
             manifestTweaks*.execute(mf)
             mf.writeTo(manifestFile)
 
-            project.ant.zip(destfile: outputFile, modificationtime: tstamp, update: true) {
+            ant.zip(destfile: outputFile, modificationtime: tstamp, update: true) {
                 zipfileset(dir: manifestFile.parent, includes: manifestFile.name, prefix: 'META-INF')
             }
         }