diff --git a/build.gradle.kts b/build.gradle.kts index 339664556..79b1e7fa1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -60,11 +60,10 @@ spotless { kotlinGradle { ktfmt(libs.ktfmt.get().version).googleStyle() } } -val testPluginClasspath by - configurations.registering { - isCanBeResolved = true - description = "Plugins used in integration tests could be resolved in classpath." - } +val testPluginClasspath by configurations.registering { + isCanBeResolved = true + description = "Plugins used in integration tests could be resolved in classpath." +} val testKit by sourceSets.creating val testKitImplementation by configurations.getting diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 65ff22f83..f62582123 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -27,7 +27,7 @@ pluginPublish = { module = "com.gradle.publish:plugin-publish-plugin", version.r androidx-gradlePluginLints = "androidx.lint:lint-gradle:1.0.0-alpha05" # Dummy to get renovate updates, the version is used in rootProject build.gradle with spotless. -ktfmt = "com.facebook:ktfmt:0.61" +ktfmt = "com.facebook:ktfmt:0.62" junit-bom = "org.junit:junit-bom:6.0.3" assertk = "com.willowtreeapps.assertk:assertk:0.28.1" diff --git a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt index 852ebcc79..68d23bc75 100644 --- a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt +++ b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt @@ -636,8 +636,9 @@ class RelocationTest : BasePluginTest() { val originalModule = KotlinModuleMetadata.read(requireResourceAsStream(originalModuleFilePath).readBytes()) - val relocatedModule = - outputShadowedJar.use { KotlinModuleMetadata.read(it.getBytes(relocatedModuleFilePath)) } + val relocatedModule = outputShadowedJar.use { + KotlinModuleMetadata.read(it.getBytes(relocatedModuleFilePath)) + } assertThat(relocatedModule.version.toString()).isEqualTo("2.2.0") assertThat(originalModule.version.toString()).isEqualTo("2.2.0") diff --git a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/TransformersTest.kt b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/TransformersTest.kt index 540a7c2d5..e85c711e5 100644 --- a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/TransformersTest.kt +++ b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/TransformersTest.kt @@ -144,8 +144,9 @@ class TransformersTest : BaseTransformerTest() { runWithSuccess(shadowJarPath) - val actualFileBytes = - outputShadowedJar.use { jar -> jar.getStream(PLUGIN_CACHE_FILE).use { it.readAllBytes() } } + val actualFileBytes = outputShadowedJar.use { jar -> + jar.getStream(PLUGIN_CACHE_FILE).use { it.readAllBytes() } + } assertThat(actualFileBytes.contentHashCode()).all { // Hash of the original plugin cache file. isNotEqualTo(-2114104185) diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/DependencyFilter.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/DependencyFilter.kt index 9a0208a4d..93291853a 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/DependencyFilter.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/DependencyFilter.kt @@ -112,11 +112,9 @@ public interface DependencyFilter : Serializable { it == resolvedDependency.moduleGroup || resolvedDependency.moduleGroup.matches(it.toRegex()) } ?: true - val nameMatch = - name.let { - it == resolvedDependency.moduleName || - resolvedDependency.moduleName.matches(it.toRegex()) - } + val nameMatch = name.let { + it == resolvedDependency.moduleName || resolvedDependency.moduleName.matches(it.toRegex()) + } val versionMatch = version?.let { // Version like `1.0.0+1` can't be converted to regex directly because `+` is a special diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt index 1267dc6e3..913d12e36 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt @@ -64,12 +64,11 @@ import org.gradle.language.base.plugins.LifecycleBasePlugin @CacheableTask public abstract class ShadowJar : Jar() { private val dependencyFilterForMinimize = MinimizeDependencyFilter(project) - private val shadowDependencies = - project.provider { - // Find shadow configuration here instead of get, as the ShadowJar tasks could be registered - // without Shadow plugin applied. - project.configurations.findByName(ShadowBasePlugin.CONFIGURATION_NAME) ?: project.files() - } + private val shadowDependencies = project.provider { + // Find shadow configuration here instead of get, as the ShadowJar tasks could be registered + // without Shadow plugin applied. + project.configurations.findByName(ShadowBasePlugin.CONFIGURATION_NAME) ?: project.files() + } init { group = LifecycleBasePlugin.BUILD_GROUP @@ -98,34 +97,30 @@ public abstract class ShadowJar : Jar() { public open val minimizeJar: Property = objectFactory.property(false) @get:Classpath - public open val toMinimize: ConfigurableFileCollection = - objectFactory.fileCollection { - minimizeJar.map { - if (it) (dependencyFilterForMinimize.resolve(configurations.get()) - apiJars) - else emptySet() - } + public open val toMinimize: ConfigurableFileCollection = objectFactory.fileCollection { + minimizeJar.map { + if (it) (dependencyFilterForMinimize.resolve(configurations.get()) - apiJars) else emptySet() } + } @get:Classpath - public open val apiJars: ConfigurableFileCollection = - objectFactory.fileCollection { - minimizeJar.map { if (it) project.getApiJars() else emptySet() } - } + public open val apiJars: ConfigurableFileCollection = objectFactory.fileCollection { + minimizeJar.map { if (it) project.getApiJars() else emptySet() } + } @get:InputFiles @get:PathSensitive(PathSensitivity.RELATIVE) - public open val sourceSetsClassesDirs: ConfigurableFileCollection = - objectFactory.fileCollection { - minimizeJar.map { - if (it) { - project.sourceSets.map { sourceSet -> - sourceSet.output.classesDirs.filter(File::isDirectory) - } - } else { - emptySet() + public open val sourceSetsClassesDirs: ConfigurableFileCollection = objectFactory.fileCollection { + minimizeJar.map { + if (it) { + project.sourceSets.map { sourceSet -> + sourceSet.output.classesDirs.filter(File::isDirectory) } + } else { + emptySet() } } + } /** [ResourceTransformer]s to be applied in the shadow steps. */ @get:Nested @@ -148,10 +143,9 @@ public abstract class ShadowJar : Jar() { /** Final dependencies to be shadowed. */ @get:Classpath - public open val includedDependencies: ConfigurableFileCollection = - objectFactory.fileCollection { - dependencyFilter.zip(configurations) { df, cs -> df.resolve(cs) } - } + public open val includedDependencies: ConfigurableFileCollection = objectFactory.fileCollection { + dependencyFilter.zip(configurations) { df, cs -> df.resolve(cs) } + } /** * Enables auto relocation of packages in the dependencies. diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ResourceTransformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ResourceTransformer.kt index 53e72a671..845e02c7f 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ResourceTransformer.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ResourceTransformer.kt @@ -49,8 +49,9 @@ public interface ResourceTransformer : Named { @JvmStatic public fun Class.create(objectFactory: ObjectFactory): T { // If the constructor takes a single ObjectFactory, inject it in. - val constructor = - constructors.find { it.parameterTypes.singleOrNull() == ObjectFactory::class.java } + val constructor = constructors.find { + it.parameterTypes.singleOrNull() == ObjectFactory::class.java + } return if (constructor != null) { objectFactory.newInstance(this@create) } else { diff --git a/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/relocation/RelocatorsTest.kt b/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/relocation/RelocatorsTest.kt index 50a49fd22..cfd9a65d4 100644 --- a/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/relocation/RelocatorsTest.kt +++ b/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/relocation/RelocatorsTest.kt @@ -43,11 +43,10 @@ class RelocatorsTest { private companion object { val primitiveTypes = setOf('B', 'C', 'D', 'F', 'I', 'J', 'S', 'Z') - val primitiveTypePatterns = - primitiveTypes.map { - // Methods like `void method(boolean arg1, org.package.ClassA arg2)` - Arguments.of("(${it}Lorg/package/ClassA;)V", "(${it}Lshadow/org/package/ClassA;)V") - } + val primitiveTypePatterns = primitiveTypes.map { + // Methods like `void method(boolean arg1, org.package.ClassA arg2)` + Arguments.of("(${it}Lorg/package/ClassA;)V", "(${it}Lshadow/org/package/ClassA;)V") + } @JvmStatic fun signaturePatternsProvider() =