Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8e3f16d
Update embedded Kotlin to 1.7.0
eskatos Jun 16, 2022
fad7a0d
Fix KotlinCompiler, now requires defining the JDK_HOME
eskatos Jun 16, 2022
71d7272
Update to Kotlin 1.7.0 in documentation snippets/samples
eskatos Jun 16, 2022
0096fd4
Update to Kotlin 1.7.0 in compatibility matrix
eskatos Jun 16, 2022
7255751
Update to Kotlin-Test framework 1.7.0 in test suites
eskatos Jun 16, 2022
3dc95e7
Update to Kotlin 1.7.0 in integration tests
eskatos Jun 16, 2022
e7704b5
Update to Kotlin 1.7.0 in build init plugin
eskatos Jun 16, 2022
1fb68b1
Update gradle-api-extensions generated jar hash
eskatos Jun 16, 2022
cd87840
Revert "Update to Kotlin 1.7.0 in build init plugin"
eskatos Jun 16, 2022
8a201a4
Skip KotlinDslMultiProjectJvmApplicationInitIntegrationTest on embedd…
eskatos Jun 16, 2022
6fd93dc
Fix Kotlin scripts compilation on Java >= 18
eskatos Jun 17, 2022
edb1607
Polish GeneratePrecompiledScriptPluginAccessors
eskatos Jun 17, 2022
918b6ec
Bump :kotlin-dsl-plugins to 2.4.0
eskatos Jun 17, 2022
5f752c9
Bump :kotlin-dsl-plugins to 2.4.1
eskatos Jun 24, 2022
2f3a85c
Replace broken sample by new one
eskatos Jun 28, 2022
f5cdc8b
Temporarily skip test
eskatos Jun 30, 2022
f3c28a7
Upgrade kotlinx-metadata-jvm to 0.5.0
eskatos Jun 30, 2022
7a6dcdc
Bump to Kotlin 1.7.10
eskatos Jul 12, 2022
ff917cb
Fix deprecated use of kotlinx-metadata
eskatos Jul 12, 2022
75b758e
Upgrade to Kotlin 1.7.10 in build init plugin
eskatos Jul 12, 2022
77b378f
Unskip test
eskatos Jul 12, 2022
467bcc9
Skip kotlin-jvm + java-gradle-plugin smoke test on Kotlin 1.5 as broken
eskatos Jul 12, 2022
a260765
Remove outdated workaround for https://github.com/gradle/gradle/issue…
eskatos Jul 12, 2022
9d36e80
Fix deprecated API usage in :kotlin-dsl-plugins build script
eskatos Jul 12, 2022
d5b50f9
Bump :kotlin-dsl-plugins version
eskatos Jul 12, 2022
7345001
Fix Gradleception check and prepare for wrapper upgrade
eskatos Jul 12, 2022
28afb1a
Remove unused constructor parameter in CacheMissMonitorBuildService
eskatos Jul 12, 2022
d2d2540
Remove leftover comment
eskatos Jul 12, 2022
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
11 changes: 9 additions & 2 deletions build-logic-commons/gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ java {
dependencies {
compileOnly("com.gradle:gradle-enterprise-gradle-plugin:3.10.3")

implementation("org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:2.3.3")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21")
// TODO remove and keep 1.7 only once wrapper is updated
if (KotlinVersion.CURRENT.isAtLeast(1, 7)) {
implementation("org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:2.4.1")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
} else {
implementation("org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:2.3.3")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21")

}
implementation("org.gradle.kotlin:gradle-kotlin-dsl-conventions:0.8.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.SetProperty
import org.gradle.api.services.BuildService
import org.gradle.api.services.BuildServiceParameters
Expand All @@ -23,9 +22,9 @@ import org.gradle.tooling.events.OperationCompletionListener
import org.gradle.tooling.events.task.TaskFinishEvent
import org.gradle.tooling.events.task.TaskSuccessResult
import java.util.concurrent.atomic.AtomicBoolean
import javax.inject.Inject

abstract class CacheMissMonitorBuildService @Inject constructor(objects: ObjectFactory) : BuildService<CacheMissMonitorBuildService.Params>, OperationCompletionListener {

abstract class CacheMissMonitorBuildService : BuildService<CacheMissMonitorBuildService.Params>, OperationCompletionListener {
val cacheMiss: AtomicBoolean = AtomicBoolean(false)

interface Params : BuildServiceParameters {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ class MemberFlagsKmPropertyExtensionVisitor(

private
val kmPropertyExtensionVisitor = object : JvmPropertyExtensionVisitor() {
override fun visit(fieldSignature: JvmFieldSignature?, getterSignature: JvmMethodSignature?, setterSignature: JvmMethodSignature?) {

override fun visit(jvmFlags: Flags, fieldSignature: JvmFieldSignature?, getterSignature: JvmMethodSignature?, setterSignature: JvmMethodSignature?) {
when (jvmSignature) {
fieldSignature?.asString() -> onMatch(predicate(fieldFlags))
getterSignature?.asString() -> onMatch(predicate(getterFlags))
Expand Down
2 changes: 1 addition & 1 deletion build-logic/build-platform/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dependencies {
api("org.codenarc:CodeNarc:3.0.1")
api("org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r")
api("org.javassist:javassist:3.27.0-GA")
api("org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.4.1")
api("org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.5.0")
api("org.jsoup:jsoup:1.15.1")
api("org.junit.jupiter:junit-jupiter:5.8.2")
api("org.junit.vintage:junit-vintage-engine:5.8.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class ExternalModulesExtension {

val groovyVersion = "3.0.11"
val configurationCacheReportVersion = "1.1"
val kotlinVersion = "1.6.21"
val kotlinVersion = "1.7.10"

fun futureKotlin(module: String) = "org.jetbrains.kotlin:kotlin-$module:$kotlinVersion"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ plugins {
// --- Enable automatic generation of API extensions -------------------
val apiExtensionsOutputDir = layout.buildDirectory.dir("generated-sources/kotlin")

val publishedKotlinDslPluginVersion = "2.3.3" // TODO:kotlin-dsl
val publishedKotlinDslPluginVersion = "2.4.1" // TODO:kotlin-dsl

tasks {
val generateKotlinDependencyExtensions by registering(GenerateKotlinDependencyExtensions::class) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ configurations.transitiveSourcesElements {
tasks {
withType<KotlinCompile>().configureEach {
configureKotlinCompilerForGradleBuild()
if (name == "compileTestKotlin") {
// Make sure the classes dir is used for test compilation (required by tests accessing internal methods) - https://github.com/gradle/gradle/issues/11501
classpath = sourceSets.main.get().output.classesDirs + classpath - files(tasks.jar)
}
}

codeQuality {
Expand Down
5 changes: 5 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,11 @@
<sha256 value="ba63ebb9e874a798510b5888a159622ef4e4d59f82e54d755ddcf5e60bf1257f" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.gradle.kotlin" name="gradle-kotlin-dsl-plugins" version="2.4.1">
<artifact name="gradle-kotlin-dsl-plugins-2.4.1.jar">
<sha256 value="24d7f385cdffff81648f11098688fd0a2f1986c5286364183c08958927e5307d" origin="Artifact is not signed"/>
</artifact>
</component>
<component group="org.gradle.kotlin" name="plugins" version="1.3.6">
<artifact name="plugins-1.3.6.jar">
<sha256 value="bdce53a751fdb27af6608039df81214ba22d902ed4169540a3daeb5828c99cad" origin="Artifact is not signed"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ groovy=3.0.11
guava=31.1-jre
junit-jupiter=5.8.2
junit=4.13.2
kotlin=1.6.21
kotlin=1.7.10
scala-library=2.13.8
scala-xml=1.2.0
scala=2.13
Expand Down
6 changes: 4 additions & 2 deletions subprojects/docs/src/docs/userguide/compatibility.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// Copyright 2019 the original author or authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -44,9 +45,9 @@ For older Gradle versions, please see the table below which Java version is supp

[[kotlin]]
== Kotlin
Gradle is tested with Kotlin 1.3.72 through 1.6.21.
Gradle is tested with Kotlin 1.3.72 through 1.7.10.

Gradle plugins written in Kotlin target Kotlin 1.4 for compatibility with Gradle and Kotlin DSL build scripts, even though the embedded Kotlin runtime is Kotlin 1.6.
Gradle plugins written in Kotlin target Kotlin 1.4 for compatibility with Gradle and Kotlin DSL build scripts, even though the embedded Kotlin runtime is Kotlin 1.7.

.Embedded Kotlin version
|===
Expand All @@ -67,6 +68,7 @@ Gradle plugins written in Kotlin target Kotlin 1.4 for compatibility with Gradle
| 7.2 | 1.5.21 | 1.4
| 7.3 | 1.5.31 | 1.4
| 7.5 | 1.6.21 | 1.4
| 7.6 | 1.7.10 | 1.4
|===

== Groovy
Expand Down
28 changes: 23 additions & 5 deletions subprojects/docs/src/docs/userguide/jvm/toolchains.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,33 @@ Any tasks that can be configured with a path to a Java executable, or a Java hom

While you will not be able to wire a toolchain tool directly, they all have metadata that gives access to their full path or to the path of the Java installation they belong to.

For example, you can configure the executable for a Kotlin compile tasks as follows:
For example, you can configure the `java` executable for a task as follows:

====
include::sample[dir="snippets/java/toolchain-kotlin/groovy/",files="build.gradle[tags=compiler-kotlin]"]
include::sample[dir="snippets/java/toolchain-kotlin/kotlin/",files="build.gradle.kts[tags=compiler-kotlin]"]
include::sample[dir="snippets/java/toolchain-config-task/groovy/",files="build.gradle[tags=java-executable]"]
include::sample[dir="snippets/java/toolchain-config-task/kotlin/",files="build.gradle.kts[tags=java-executable]"]
====

Similarly, doing `compiler.get().executablePath` would give you the full path to `javac` for the given toolchain.
Please note however that this may realize (and provision) a toolchain eagerly.
Another example, you can configure the _Java Home_ for a task as follows:

====
include::sample[dir="snippets/java/toolchain-config-task/groovy/",files="build.gradle[tags=java-home]"]
include::sample[dir="snippets/java/toolchain-config-task/kotlin/",files="build.gradle.kts[tags=java-home]"]
====

Yet another example, you can configure the Java _compiler_ executable for a task as follows:

====
include::sample[dir="snippets/java/toolchain-config-task/groovy/",files="build.gradle[tags=java-compiler]"]
include::sample[dir="snippets/java/toolchain-config-task/kotlin/",files="build.gradle.kts[tags=java-compiler]"]
====

[WARNING]
====
The examples above use tasks with `RegularFileProperty` and `DirectoryProperty` properties which allow lazy configuration.

Doing respectively `launcher.get().executablePath`, `launcher.get().metadata.installationPath` or `compiler.get().executablePath` instead will give you the full path for the given toolchain but note that this may realize (and provision) a toolchain eagerly.
====

[[sec:auto_detection]]
== Auto detection of installed toolchains
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ group = 'com.example.platform'
dependencies {
constraints {
api('com.android.tools.build:gradle:4.1.1')
api('org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.6.21')
api('org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.6.21')
api('org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.7.10')
api('org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.10')
api('org.springframework.boot:org.springframework.boot.gradle.plugin:2.4.0')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ group = "com.example.platform"
dependencies {
constraints {
api("com.android.tools.build:gradle:4.1.1")
api("org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.6.21")
api("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.6.21")
api("org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.7.10")
api("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.10")
api("org.springframework.boot:org.springframework.boot.gradle.plugin:2.4.0")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

plugins {
id "org.jetbrains.kotlin.jvm" version "1.6.21"
id "org.jetbrains.kotlin.jvm" version "1.7.10"
}

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

plugins {
kotlin("jvm") version "1.6.21"
kotlin("jvm") version "1.7.10"
}

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import javax.inject.Inject

plugins {
id 'java-base'
}


abstract class TaskThatRequiresJavaExecutable extends DefaultTask {

@Internal
abstract RegularFileProperty getJavaExecutable()

@Inject
protected abstract ExecOperations getExecOps()

@TaskAction
void action() {
def outputBytes = new ByteArrayOutputStream()
execOps.exec {
executable = javaExecutable.get().asFile.absolutePath
args = ["-version"]
standardOutput = outputBytes
errorOutput = outputBytes
}
assert outputBytes.toString("UTF-8").contains("version \"11"):
"unexpected '${javaExecutable.get().asFile.absolutePath} -version' output"
}
}

tasks.register("sampleTask", TaskThatRequiresJavaExecutable)


abstract class TaskThatRequiresJavaHome extends DefaultTask {

@Internal
abstract DirectoryProperty getJavaHome()

@Inject
protected abstract ExecOperations getExecOps()

@TaskAction
void action() {
def outputBytes = new ByteArrayOutputStream()
def javaExecutable = javaHome.file("bin/java")
execOps.exec {
executable = javaExecutable.get().asFile.absolutePath
args = ["-version"]
standardOutput = outputBytes
errorOutput = outputBytes
}
assert outputBytes.toString("UTF-8").contains("version \"11"):
"unexpected '${javaExecutable.get().asFile.absolutePath} -version' output"
}
}

tasks.register("anotherSampleTask", TaskThatRequiresJavaHome)


abstract class TaskThatRequiresJavaCompiler extends DefaultTask {

@Internal
abstract RegularFileProperty getJavaCompilerExecutable()

@Inject
protected abstract ExecOperations getExecOps()

@TaskAction
void action() {
def outputBytes = new ByteArrayOutputStream()
execOps.exec {
executable = javaCompilerExecutable.get().asFile.absolutePath
args = ["-version"]
standardOutput = outputBytes
errorOutput = outputBytes
}
assert outputBytes.toString("UTF-8").contains("javac 11"):
"unexpected '${javaCompilerExecutable.get().asFile.absolutePath} -version' output"
}
}

tasks.register("yetAnotherSampleTask", TaskThatRequiresJavaCompiler)


// tag::java-executable[]
// tag::java-home[]
def launcher = javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(11))
}
// end::java-executable[]
// end::java-home[]


// tag::java-executable[]

tasks.named('sampleTask') {
javaExecutable = launcher.map { it.executablePath }
}
// end::java-executable[]


// tag::java-home[]

tasks.named('anotherSampleTask') {
javaHome = launcher.map { it.metadata.installationPath }
}
// end::java-home[]


// tag::java-compiler[]
def compiler = javaToolchains.compilerFor {
languageVersion.set(JavaLanguageVersion.of(11))
}

tasks.named('yetAnotherSampleTask') {
javaCompilerExecutable = compiler.map { it.executablePath }
}
// end::java-compiler[]
Loading