Skip to content

Commit

Permalink
Shade and package relocate checkstyle to simplify loading its configu…
Browse files Browse the repository at this point in the history
…ration classes
  • Loading branch information
sambsnyd committed Oct 11, 2024
1 parent 79b78ba commit 9df8e66
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions rewrite-java/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
id("org.openrewrite.build.language-library")
id("org.openrewrite.build.shadow")
}

val antlrGeneration by configurations.creating {
Expand All @@ -18,6 +21,15 @@ tasks.register<JavaExec>("generateAntlrSources") {
classpath = antlrGeneration
}

// Only need checkstyle for the classes that we use to load its configuration files
val checkstyle = configurations.create("checkstyle")
configurations.named("compileOnly").configure {
extendsFrom(checkstyle)
}
configurations.named("testImplementation").configure {
extendsFrom(checkstyle)
}

dependencies {
api(project(":rewrite-core"))
api(project(":rewrite-yaml"))
Expand All @@ -28,7 +40,8 @@ dependencies {

antlrGeneration("org.antlr:antlr4:4.11.1")
implementation("org.antlr:antlr4-runtime:4.11.1")
compileOnly("com.puppycrawl.tools:checkstyle:9.+") { // Pinned to 9.+ because 10.x does not support Java 8: https://checkstyle.sourceforge.io/#JRE_and_JDK
// Pinned to 9.+ because 10.x does not support Java 8: https://checkstyle.sourceforge.io/#JRE_and_JDK
checkstyle("com.puppycrawl.tools:checkstyle:9.+") {
isTransitive = false
}
compileOnly(project(":rewrite-test"))
Expand All @@ -46,9 +59,6 @@ dependencies {
implementation("org.ow2.asm:asm-util:latest.release")

testImplementation("org.yaml:snakeyaml:latest.release")
testImplementation("com.puppycrawl.tools:checkstyle:9.+") { // Pinned to 9.+ because 10.x does not support Java 8: https://checkstyle.sourceforge.io/#JRE_and_JDK
isTransitive = false
}
testImplementation(project(":rewrite-test"))
testImplementation(project(":rewrite-java-test"))
testRuntimeOnly(project(":rewrite-java-17"))
Expand Down Expand Up @@ -76,3 +86,9 @@ tasks.withType<Javadoc> {
// 1 error
exclude("**/JavaParser**", "**/ChangeMethodTargetToStatic**", "**/J.java")
}

tasks.named<ShadowJar>("shadowJar").configure {
dependsOn(checkstyle)
configurations = listOf(checkstyle)
relocate("com.puppycrawl.tools.checkstyle", "org.openrewrite.tools.checkstyle")
}

0 comments on commit 9df8e66

Please sign in to comment.