File tree Expand file tree Collapse file tree 4 files changed +31
-13
lines changed
build-plugins/build-support
src/main/kotlin/aws/sdk/kotlin/gradle/dsl Expand file tree Collapse file tree 4 files changed +31
-13
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ repositories {
2020dependencies {
2121 // make our custom lint rules available to the buildscript classpath
2222 runtimeOnly(project(" :ktlint-rules" )) {
23- // Ensure that kotlin-compiler-embeddable isn't included in the buildscript classpath in consuming modules
23+ // Ensure that kotlin-compiler-embeddable isn't included in the buildscript classpath
2424 exclude(group = " org.jetbrains.kotlin" , module = " kotlin-compiler-embeddable" )
2525 }
2626
@@ -40,7 +40,26 @@ gradlePlugin {
4040 }
4141}
4242
43+ val generateKtlintVersion by tasks.registering {
44+ // generate the version of the runtime to use as a resource.
45+ // this keeps us from having to manually change version numbers in multiple places
46+ val resourcesDir = layout.buildDirectory.dir(" resources/main/aws/sdk/kotlin/gradle/dsl" ).get()
47+
48+ val versionCatalog = rootProject.file(" gradle/libs.versions.toml" )
49+ inputs.file(versionCatalog)
50+
51+ val versionFile = file(" $resourcesDir /ktlint-version.txt" )
52+ outputs.file(versionFile)
53+
54+ val version = libs.ktlint.cli.ruleset.core.get().version
55+ sourceSets.main.get().output.dir(resourcesDir)
56+ doLast {
57+ versionFile.writeText(" $version " )
58+ }
59+ }
60+
4361tasks.withType<KotlinCompile > {
62+ dependsOn(generateKtlintVersion)
4463 compilerOptions {
4564 jvmTarget.set(JvmTarget .JVM_1_8 )
4665 freeCompilerArgs.add(" -opt-in=kotlin.RequiresOptIn" )
Original file line number Diff line number Diff line change @@ -18,21 +18,23 @@ import org.gradle.language.base.plugins.LifecycleBasePlugin
1818fun Project.configureLinting (lintPaths : List <String >) {
1919 verifyRootProject { " Kotlin SDK lint configuration is expected to be configured on the root project" }
2020
21+ val ktlintVersion = object {} // Can't use Project.javaClass because that's using the Gradle classloader
22+ .javaClass
23+ .getResource(" ktlint-version.txt" )
24+ ?.readText()
25+ ? : error(" Missing ktlint-version.txt" )
26+
2127 val ktlint by configurations.creating
2228
2329 dependencies {
24- val ktlintVersion = " 1.3.0"
2530 ktlint(" com.pinterest.ktlint:ktlint-cli:$ktlintVersion " ) {
2631 attributes {
27- attribute(Bundling .BUNDLING_ATTRIBUTE , objects.named(Bundling .EXTERNAL ))
32+ attribute(Bundling .BUNDLING_ATTRIBUTE , objects.named(Bundling .SHADOWED ))
2833 }
29-
30- // Ensure that kotlin-compiler-embeddable isn't included in the buildscript classpath in consuming modules
31- exclude(group = " org.jetbrains.kotlin" , module = " kotlin-compiler-embeddable" )
3234 }
3335 }
3436
35- // add the buildscript classpath which should pickup our custom ktlint-rules (via runtimeOnly dep on this plugin)
37+ // add the buildscript classpath which should pick up our custom ktlint-rules (via runtimeOnly dep on this plugin)
3638 // plus any custom rules added by consumer
3739 val execKtlintClasspath = ktlint + buildscript.configurations.getByName(" classpath" )
3840
Original file line number Diff line number Diff line change @@ -49,11 +49,8 @@ val ktlint by configurations.creating
4949dependencies {
5050 ktlint(libs.ktlint.cli) {
5151 attributes {
52- attribute(Bundling .BUNDLING_ATTRIBUTE , objects.named(Bundling .EXTERNAL ))
52+ attribute(Bundling .BUNDLING_ATTRIBUTE , objects.named(Bundling .SHADOWED ))
5353 }
54-
55- // Ensure that kotlin-compiler-embeddable isn't included in the buildscript classpath
56- exclude(group = " org.jetbrains.kotlin" , module = " kotlin-compiler-embeddable" )
5754 }
5855
5956 ktlint(project(" :ktlint-rules" ))
Original file line number Diff line number Diff line change 11[versions ]
2- ktlint = " 1.5 .0"
2+ ktlint = " 1.3 .0"
33smithy-version = " 1.53.0"
44smithy-gradle-plugin-version = " 1.1.0"
55junit-version = " 5.10.1"
@@ -16,4 +16,4 @@ smithy-gradle-base-plugin = { module = "software.amazon.smithy.gradle:smithy-bas
1616junit-jupiter = { module = " org.junit.jupiter:junit-jupiter" , version.ref = " junit-version" }
1717
1818[plugins ]
19- plugin-publish = { id = " com.gradle.plugin-publish" , version = " 1.2.1" }
19+ plugin-publish = { id = " com.gradle.plugin-publish" , version = " 1.2.1" }
You can’t perform that action at this time.
0 commit comments