From 306ba36b0e9ed64dff85f319a4c8a277ff465e6c Mon Sep 17 00:00:00 2001 From: Paul King Date: Sun, 5 Jan 2025 19:02:17 +1000 Subject: [PATCH] GROOVY-11190: Jakarta EE 9 compatibility for groovy-servlet (add javax classifier for backwards compatibility) --- subprojects/groovy-servlet/build.gradle | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/subprojects/groovy-servlet/build.gradle b/subprojects/groovy-servlet/build.gradle index e3f747924f3..81613e0d756 100644 --- a/subprojects/groovy-servlet/build.gradle +++ b/subprojects/groovy-servlet/build.gradle @@ -1,3 +1,5 @@ +import org.apache.groovy.gradle.JarJarTask + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -37,3 +39,27 @@ dependencies { testImplementation projects.groovyJson testImplementation projects.groovyTest } + +tasks.register("javaxJar", JarJarTask) { + def jarjar = tasks.named("jarjar", JarJarTask) + it.dependsOn(jarjar) + it.from.set(jarjar.flatMap { it.outputFile }) + it.patterns = [ + 'jakarta.servlet.**': 'javax.servlet.@1' + ] + it.createManifest = false + it.outputFile.set(layout.buildDirectory.file( + tasks.named('jar', Jar).map { jar -> + "libs/${jar.archiveBaseName.get()}-${jar.archiveVersion.get()}-javax.jar" + } + )) +} + +afterEvaluate { + def javaxJarTask = tasks.javaxJar + def mavenPublish = extensions.findByName(PublishingExtension.NAME) as PublishingExtension + mavenPublish?.publications.each { + it.artifact(javaxJarTask.outputs.files.singleFile) { classifier = "javax" } + } + tasks.matching { it.group == PublishingExtension.NAME }.configureEach { dependsOn(javaxJarTask) } +}