diff --git a/core/spoofax.compiler.gradle.spoofax2/src/main/kotlin/mb/spoofax/compiler/gradle/spoofax2/plugin/Spoofax2LanguagePlugin.kt b/core/spoofax.compiler.gradle.spoofax2/src/main/kotlin/mb/spoofax/compiler/gradle/spoofax2/plugin/Spoofax2LanguagePlugin.kt index 9c0122d82..1b9a56c48 100644 --- a/core/spoofax.compiler.gradle.spoofax2/src/main/kotlin/mb/spoofax/compiler/gradle/spoofax2/plugin/Spoofax2LanguagePlugin.kt +++ b/core/spoofax.compiler.gradle.spoofax2/src/main/kotlin/mb/spoofax/compiler/gradle/spoofax2/plugin/Spoofax2LanguagePlugin.kt @@ -151,6 +151,7 @@ open class Spoofax2LanguagePlugin : Plugin { from(project.zipTree("$unpackSpoofaxLanguageDir/target/metaborg/stratego.jar")) exclude("META-INF") } + val copyMainTask = project.tasks.register("copyMainResources") { dependsOn(unpackSpoofaxLanguageTask) into(project.the()["main"].java.outputDir) @@ -159,9 +160,16 @@ open class Spoofax2LanguagePlugin : Plugin { into(".") { with(strategoCopySpec) } } } - project.tasks.getByName(JavaPlugin.CLASSES_TASK_NAME).dependsOn(copyMainTask) - project.tasks.getByName(JavaPlugin.JAR_TASK_NAME).dependsOn(copyMainTask) - project.tasks.getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(copyMainTask) + project.pluginManager.withPlugin("java") { + project.tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME) { dependsOn(copyMainTask) } + project.tasks.named(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME) { dependsOn(copyMainTask) } + project.tasks.named(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME) { dependsOn(copyMainTask) } + } + project.pluginManager.withPlugin("kotlin-kapt") { + project.tasks.named("kaptGenerateStubsTestKotlin") { dependsOn(copyMainTask) } + project.tasks.named("kaptTestKotlin") { dependsOn(copyMainTask) } + } + val copyTestTask = project.tasks.register("copyTestResources") { dependsOn(unpackSpoofaxLanguageTask) into(project.the()["test"].java.outputDir) @@ -170,6 +178,9 @@ open class Spoofax2LanguagePlugin : Plugin { into(".") { with(strategoCopySpec) } } } - project.tasks.getByName(JavaPlugin.TEST_CLASSES_TASK_NAME).dependsOn(copyTestTask) + + project.pluginManager.withPlugin("java") { + project.tasks.named(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME) { dependsOn(copyTestTask) } + } } } diff --git a/core/spoofax.compiler/build.gradle.kts b/core/spoofax.compiler/build.gradle.kts index a7c1b72fc..66688d5ed 100644 --- a/core/spoofax.compiler/build.gradle.kts +++ b/core/spoofax.compiler/build.gradle.kts @@ -78,6 +78,7 @@ val generateVersionPropertiesTask = tasks.register("generateVersionProperties") } tasks.compileJava.configure { dependsOn(generateVersionPropertiesTask) } tasks.compileTestJava.configure { dependsOn(generateVersionPropertiesTask) } +tasks.processResources.configure { dependsOn(generateVersionPropertiesTask) } // Custom properties class that does not write the current date, fixing incrementality. class NonShittyProperties : Properties() {