Skip to content

Commit

Permalink
Update bootstrapped Gr8 (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin authored Nov 25, 2024
1 parent 419611a commit 67c6957
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 38 deletions.
63 changes: 33 additions & 30 deletions gr8-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,59 +1,61 @@
@file:Suppress("UnstableApiUsage")

import com.gradleup.librarian.gradle.librarianModule
import com.gradleup.gr8.FilterTransform
import com.gradleup.librarian.gradle.Librarian

plugins {
id("org.jetbrains.kotlin.jvm")
id("java-gradle-plugin")
id("com.gradleup.gr8")
}

val shadeConfiguration: Configuration = configurations.create("shade")
val classpathConfiguration: Configuration = configurations.create("gr8Classpath")
val filteredClasspathDependencies: Configuration = configurations.create("filteredClasspathDependencies") {
attributes {
attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, FilterTransform.artifactType)
}
}

filteredClasspathDependencies.extendsFrom(configurations.getByName("compileOnly"))


dependencies {
add("shade", project(":gr8-plugin-common")) {
// Because we only allow stripping the gradleApi from the classpath, we remove
exclude("dev.gradleplugins", "gradle-api")
}
compileOnly("dev.gradleplugins:gradle-api:6.7")
add("gr8Classpath", "dev.gradleplugins:gradle-api:6.7") {
implementation(project(":gr8-plugin-common"))
compileOnly("dev.gradleplugins:gradle-api:6.7") {
/**
* Classpath type already present: org.apache.tools.ant.IntrospectionHelper$4
*/
exclude("org.apache.ant")
}

registerTransform(FilterTransform::class) {
from.attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, "jar")
to.attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, FilterTransform.artifactType)

parameters.excludes = listOf(".*/impldep/META-INF/versions/.*")
}
}

configurations.getByName("compileOnly").extendsFrom(shadeConfiguration)


if (true) {
gr8 {
val shadowedJar = create("plugin") {
configuration("shade")
removeGradleApiFromApi()

val shadowedJar = create("default") {
addProgramJarsFrom(configurations.getByName("runtimeClasspath"))
addProgramJarsFrom(tasks.getByName("jar"))
addClassPathJarsFrom(filteredClasspathDependencies)

proguardFile("rules.pro")
classPathConfiguration("gr8Classpath")
stripGradleApi(true)

r8Version("887704078a06fc0090e7772c921a30602bf1a49f")
systemClassesToolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

// The java-gradle-plugin adds `gradleApi()` to the `api` implementation but it contains some JDK15 bytecode at
// org/gradle/internal/impldep/META-INF/versions/15/org/bouncycastle/jcajce/provider/asymmetric/edec/SignatureSpi$EdDSA.class:
// java.lang.IllegalArgumentException: Unsupported class file major version 59
// So remove it
val apiDependencies = project.configurations.getByName("api").dependencies
apiDependencies.firstOrNull {
it is FileCollectionDependency
}.let {
apiDependencies.remove(it)
}

replaceOutgoingJar(shadowedJar)
}
} else {
configurations.named("implementation").configure {
extendsFrom(shadeConfiguration)
}
}

gradlePlugin {
Expand All @@ -68,4 +70,5 @@ gradlePlugin {
}
}

librarianModule()
Librarian.module(project)

2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
gradle-api = "dev.gradleplugins:gradle-api:6.7"
r8 = "com.android.tools:r8:8.5.35"
librarian = "com.gradleup.librarian:librarian-gradle-plugin:0.0.8-SNAPSHOT-ba3e33fb6601dae9ea75e1ef75aa9b46bf640b74"
gr8-published = "com.gradleup:gr8-plugin:0.10"
gr8-published = "com.gradleup:gr8-plugin:0.10.1-SNAPSHOT-419611ab01f5e9a24bf42ce1ffba9228b4eec8a8"
gradle-publish = "com.gradle.publish:plugin-publish-plugin:0.15.0"
kgp = "org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.20"
vespene = "net.mbonnin.vespene:vespene-lib:0.6.1"
Expand Down
7 changes: 0 additions & 7 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,3 @@ include(":gr8-plugin")
include(":gr8-plugin-external")
include(":gr8-plugin-common")

/**
* We need Java <= 17 until we update the embedded gr8
* See https://issuetracker.google.com/u/2/issues/365578411
*/
check(JavaVersion.current() <= JavaVersion.VERSION_17) {
"This project needs to be run with Java 17 or lower (found: ${JavaVersion.current()})."
}

0 comments on commit 67c6957

Please sign in to comment.