Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ 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."
extendsFrom(configurations.compileOnly)
}
val testPluginClasspath =
configurations.register("testPluginClasspath") {
isCanBeResolved = true
description = "Plugins used in integration tests could be resolved in classpath."
extendsFrom(configurations.compileOnly)
}

val testKit by sourceSets.creating
val testKitImplementation by configurations.getting
val testKit = sourceSets.register("testKit")
val testKitImplementation = configurations.named("testKitImplementation")

configurations.configureEach {
when (name) {
Expand Down Expand Up @@ -177,7 +178,7 @@ testing.suites {
withType<JvmTestSuite>().configureEach {
useJUnitJupiter(libs.junit.bom.map { checkNotNull(it.version) })
dependencies {
implementation(testKit.output)
implementation(testKit.get().output)
implementation(libs.assertk)
}
targets.configureEach {
Expand Down Expand Up @@ -213,7 +214,7 @@ gradlePlugin {

// This part should be placed after testing.suites to ensure the test sourceSets are created.
kotlin.target.compilations {
val main by getting
val main = getByName("main")
getByName("functionalTest") {
// Import main and its classpath as dependencies and establish internal visibility.
associateWith(main)
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ configure the upstream.
=== "Kotlin"

```kotlin
val testJar by tasks.registering(Jar::class) {
val testJar = tasks.register<Jar>("testJar") {
manifest {
attributes["Description"] = "This is an application JAR"
}
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/dependencies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ configuration.
=== "Kotlin"

```kotlin
val nonJar by configurations.creating
val nonJar = configurations.create("nonJar")

// This is necessary to make the dependencies in `nonJar` available at compile time.
// If you don't need that, you can skip this step.
Expand Down
4 changes: 2 additions & 2 deletions docs/custom-tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ the output.
=== "Kotlin"

```kotlin
val testShadowJar by tasks.registering(com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar::class) {
val testShadowJar = tasks.register<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("testShadowJar") {
description = "Create a combined JAR of project and test dependencies"

archiveClassifier = "test"
Expand Down Expand Up @@ -64,7 +64,7 @@ source code. This is accomplished by creating a custom [`ShadowJar`][ShadowJar]
=== "Kotlin"

```kotlin
tasks.registering(com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar::class) {
val dependencyShadowJar = tasks.register<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("dependencyShadowJar") {
description = "Create a shadow JAR of all dependencies"
archiveClassifier = "dep"
configurations = project.configurations.runtimeClasspath.map { listOf(it) }
Expand Down
4 changes: 2 additions & 2 deletions docs/kotlin-plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ automatically configure additional tasks for bundling the shadowed JAR for its `
mainClass = "myapp.MainKt"
}
sourceSets {
val commonMain by getting {
val commonMain = getByName("commonMain") {
dependencies {
implementation("io.ktor:ktor-client-core:$ktorVersion")
}
}
val jvmMain by getting {
val jvmMain = getByName("jvmMain") {
dependencies {
implementation("io.ktor:ktor-client-okhttp:$ktorVersion")
}
Expand Down
2 changes: 1 addition & 1 deletion docs/publishing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ It is possible to publish a custom [`ShadowJar`][ShadowJar] task's output via th
id("com.gradleup.shadow")
}

val testShadowJar by tasks.registering(com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar::class) {
val testShadowJar = tasks.register<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("testShadowJar") {
description = "Create a combined JAR of project and test dependencies"
archiveClassifier = "tests"
from(sourceSets.test.map { it.output })
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.0-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ dependencyResolutionManagement {

rootProject.name = "shadow"

enableFeaturePreview("NO_IMPLICIT_LOOKUP_IN_PARENT_PROJECTS")

enableFeaturePreview("STABLE_CONFIGURATION_CACHE")
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.jengelman.gradle.plugins.shadow.snippet

import com.github.jengelman.gradle.plugins.shadow.testkit.assertNoDeprecationWarnings
import com.github.jengelman.gradle.plugins.shadow.testkit.enableNoExplicitLookupInParentProjects
import com.github.jengelman.gradle.plugins.shadow.testkit.gradleRunner
import java.nio.file.Path
import java.util.jar.JarOutputStream
Expand Down Expand Up @@ -48,6 +49,7 @@ sealed class SnippetExecutable : Executable {
}
include ':api', ':main'
rootProject.name = 'snippet'
$enableNoExplicitLookupInParentProjects
enableFeaturePreview 'TYPESAFE_PROJECT_ACCESSORS'
"""
.trimIndent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar.Companion.SHAD
import com.github.jengelman.gradle.plugins.shadow.testkit.JarPath
import com.github.jengelman.gradle.plugins.shadow.testkit.assertNoDeprecationWarnings
import com.github.jengelman.gradle.plugins.shadow.testkit.commonGradleArgs
import com.github.jengelman.gradle.plugins.shadow.testkit.enableNoExplicitLookupInParentProjects
import com.github.jengelman.gradle.plugins.shadow.testkit.gradleRunner
import com.github.jengelman.gradle.plugins.shadow.testkit.requireResourceAsPath
import com.github.jengelman.gradle.plugins.shadow.transformers.ResourceTransformer
Expand Down Expand Up @@ -178,6 +179,7 @@ abstract class BasePluginTest {
buildCache {
$buildCacheBlock
}
$enableNoExplicitLookupInParentProjects
enableFeaturePreview 'TYPESAFE_PROJECT_ACCESSORS'
$endBlock
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import kotlin.io.path.Path
import kotlin.io.path.absolutePathString
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
import org.gradle.util.GradleVersion

private val testKitDir by lazy {
val gradleUserHome =
Expand All @@ -20,6 +21,15 @@ val testGradleVersion: String by lazy {
?: error("TEST_GRADLE_VERSION system property is not set.")
}

// TODO: this could be inlined after bumping the min Gradle requirement to 9.6 or above.
val enableNoExplicitLookupInParentProjects: String
get() =
when {
GradleVersion.version(testGradleVersion) >= GradleVersion.version("9.6.0") ->
"enableFeaturePreview 'NO_IMPLICIT_LOOKUP_IN_PARENT_PROJECTS'"
else -> ""
}
Comment thread
Goooler marked this conversation as resolved.

val commonGradleArgs =
setOf(
"--configuration-cache",
Expand Down