From f6cbc14937a0a5c51d80a9e8e98d42f90ad65824 Mon Sep 17 00:00:00 2001 From: Jasmine Karthikeyan <25208576+jaskarth@users.noreply.github.com> Date: Thu, 14 Sep 2023 13:18:40 +0100 Subject: [PATCH] Improve plugin jar-in-jar --- build.gradle | 10 ++++++++-- plugins/idea-not-null/gradle.properties | 1 + plugins/kotlin/build.gradle | 3 ++- plugins/kotlin/gradle.properties | 1 + plugins/scala/gradle.properties | 1 + 5 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 plugins/idea-not-null/gradle.properties create mode 100644 plugins/kotlin/gradle.properties create mode 100644 plugins/scala/gradle.properties diff --git a/build.gradle b/build.gradle index 26099f55c8..8c23782d1f 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ import org.jetbrains.java.decompiler.build.JasmCompile plugins { id 'jacoco' - id 'com.github.johnrengelman.shadow' version '7.1.2' + id 'com.github.johnrengelman.shadow' version '8.1.1' id 'org.jetbrains.kotlin.jvm' version '1.6.21' id("io.github.gradle-nexus.publish-plugin") version '1.3.0' } @@ -17,6 +17,7 @@ apply plugin: 'maven-publish' apply plugin: 'signing' allprojects { + apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'java' ext.isArm = System.getProperty('os.arch') == 'aarch64' @@ -253,7 +254,12 @@ def allJar = tasks.register('allJar', Jar) {allJar -> } subprojects.each { - allJar.from(it.tasks.named(it.plugins.hasPlugin('com.github.johnrengelman.shadow') ? 'shadowJar' : 'jar').get().outputs) { + // Check if gradle.properties has 'does_shadow=true', and use the shadowJar configuration if so + Task buildTask = it.tasks.named("true".equals(it.does_shadow) ? 'shadowJar' : 'jar').get() + // Make sure the task is defined as a dependency + dependsOn buildTask + // Relocate the jar into META-INF/plugins + allJar.from(buildTask.outputs) { into 'META-INF/plugins/' } } diff --git a/plugins/idea-not-null/gradle.properties b/plugins/idea-not-null/gradle.properties new file mode 100644 index 0000000000..0d22531f6d --- /dev/null +++ b/plugins/idea-not-null/gradle.properties @@ -0,0 +1 @@ +does_shadow=false \ No newline at end of file diff --git a/plugins/kotlin/build.gradle b/plugins/kotlin/build.gradle index a744443f9c..d906f1f5f1 100644 --- a/plugins/kotlin/build.gradle +++ b/plugins/kotlin/build.gradle @@ -1,9 +1,10 @@ plugins { - id 'com.github.johnrengelman.shadow' id 'java' id 'org.jetbrains.kotlin.jvm' } +apply plugin: 'com.github.johnrengelman.shadow' +apply plugin: 'java' apply plugin: 'maven-publish' group = 'org.vineflower' diff --git a/plugins/kotlin/gradle.properties b/plugins/kotlin/gradle.properties new file mode 100644 index 0000000000..1dcb5305f3 --- /dev/null +++ b/plugins/kotlin/gradle.properties @@ -0,0 +1 @@ +does_shadow=true \ No newline at end of file diff --git a/plugins/scala/gradle.properties b/plugins/scala/gradle.properties new file mode 100644 index 0000000000..0d22531f6d --- /dev/null +++ b/plugins/scala/gradle.properties @@ -0,0 +1 @@ +does_shadow=false \ No newline at end of file