Declare generated SourceSets correctly

Allow Gradle to keep the track of the task generating the sources
KTI-1502 Fixed
This commit is contained in:
cristiangarcia
2023-12-24 00:01:59 +00:00
committed by Space Team
parent 88f7b085e6
commit 5a1fb78fcd
7 changed files with 49 additions and 73 deletions
+10 -11
View File
@@ -17,14 +17,6 @@ dependencies {
compileOnly(intellijCore())
}
sourceSets {
"main" {
projectDefault()
generatedDir()
}
"test" { none() }
}
val generatorClasspath by configurations.creating
dependencies {
@@ -59,9 +51,16 @@ val generateCheckersComponents by tasks.registering(NoDebugJavaExec::class) {
systemProperties["line.separator"] = "\n"
}
val compileKotlin by tasks
compileKotlin.dependsOn(generateCheckersComponents)
sourceSets {
"main" {
projectDefault()
java.srcDirs(generateCheckersComponents.map {
// This is required because that task is generating all the platforms too
generationRoot
})
}
"test" { none() }
}
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
apply(plugin = "idea")
+5 -9
View File
@@ -18,13 +18,6 @@ dependencies {
compileOnly(intellijCore())
}
sourceSets {
"main" {
projectDefault()
generatedDir()
}
}
val generatorClasspath by configurations.creating
dependencies {
@@ -51,8 +44,11 @@ val generateTree by tasks.registering(NoDebugJavaExec::class) {
systemProperties["line.separator"] = "\n"
}
tasks.named("compileKotlin") {
dependsOn(generateTree)
sourceSets {
"main" {
projectDefault()
java.srcDir(generateTree)
}
}
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
+7 -11
View File
@@ -20,14 +20,6 @@ dependencies {
optInToUnsafeDuringIrConstructionAPI()
sourceSets {
"main" {
projectDefault()
generatedDir()
}
"test" {}
}
val generatorClasspath by configurations.creating
dependencies {
@@ -54,9 +46,13 @@ val generateTree by tasks.registering(NoDebugJavaExec::class) {
systemProperties["line.separator"] = "\n"
}
val compileKotlin by tasks
compileKotlin.dependsOn(generateTree)
sourceSets {
"main" {
projectDefault()
java.srcDirs(generateTree)
}
"test" {}
}
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
kotlinOptions {
@@ -188,11 +188,10 @@ class NamedNativeInteropConfig implements Named {
interopStubs = project.sourceSets.create(interopStubsName)
configuration = project.configurations.create(interopStubs.name)
project.tasks.getByName(interopStubs.getTaskName("compile", "Kotlin")) {
dependsOn genTask
kotlinOptions.freeCompilerArgs = ["-Xskip-prerelease-check"]
}
interopStubs.kotlin.srcDirs generatedSrcDir
interopStubs.kotlin.srcDir(project.tasks.named(genTask.name).map { generatedSrcDir })
project.dependencies {
add interopStubs.getApiConfigurationName(), project(path: ':kotlin-native:Interop:Runtime')
@@ -1,5 +1,3 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
description = "Kotlin Mock Runtime for Tests"
plugins {
@@ -22,15 +20,6 @@ dependencies {
builtins(project(":core:builtins"))
}
sourceSets {
"main" {
java.apply {
srcDir(layout.buildDirectory.dir("src"))
}
}
"test" {}
}
val copySources by task<Sync> {
val stdlibProjectDir = file("$rootDir/libraries/stdlib/jvm")
@@ -53,7 +42,12 @@ val copySources by task<Sync> {
into(layout.buildDirectory.dir("src"))
}
sourceSets {
"main" {
java.srcDir(copySources)
}
"test" {}
}
tasks.compileKotlin {
dependsOn(copySources)
@@ -4,18 +4,17 @@ plugins {
val copyrightDirectory = project.layout.buildDirectory.dir("copyright")
sourceSets {
"main" {
kotlin.srcDir("src")
resources.srcDir(copyrightDirectory)
}
}
dependencies {
api("org.jetbrains.kotlin:kotlin-stdlib:$bootstrapKotlinVersion")
api("org.jetbrains.kotlin:kotlin-reflect:$bootstrapKotlinVersion")
}
val copyCopyrightProfile by tasks.registering(Copy::class) {
from("$rootDir/.idea/copyright")
into(copyrightDirectory)
include("apache.xml")
}
tasks {
compileKotlin {
compilerOptions {
@@ -23,16 +22,6 @@ tasks {
}
}
val copyCopyrightProfile by registering(Copy::class) {
from("$rootDir/.idea/copyright")
into(copyrightDirectory)
include("apache.xml")
}
processResources {
dependsOn(copyCopyrightProfile)
}
register<JavaExec>("run") {
group = "application"
mainClass = "generators.GenerateStandardLibKt"
@@ -55,4 +44,11 @@ tasks {
classpath = sourceSets.main.get().runtimeClasspath
args = listOf("$rootDir")
}
}
}
sourceSets {
"main" {
kotlin.srcDir("src")
resources.srcDir(copyCopyrightProfile)
}
}
+6 -10
View File
@@ -19,14 +19,6 @@ dependencies {
testRuntimeOnly(libs.junit.jupiter.engine)
}
sourceSets {
"main" {
projectDefault()
generatedDir()
}
"test" { projectDefault() }
}
testsJar()
projectTest(jUnitMode = JUnitMode.JUnit5) {
@@ -60,8 +52,12 @@ val generateTree by tasks.registering(NoDebugJavaExec::class) {
systemProperties["line.separator"] = "\n"
}
tasks.named("compileKotlin") {
dependsOn(generateTree)
sourceSets {
"main" {
projectDefault()
java.srcDir(generateTree)
}
"test" { projectDefault() }
}
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {