Skip to content

Commit

Permalink
Fixing task dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Virtlink committed Apr 16, 2024
1 parent 4de8129 commit 228a913
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ open class Spoofax2LanguagePlugin : Plugin<Project> {
from(project.zipTree("$unpackSpoofaxLanguageDir/target/metaborg/stratego.jar"))
exclude("META-INF")
}

val copyMainTask = project.tasks.register<Copy>("copyMainResources") {
dependsOn(unpackSpoofaxLanguageTask)
into(project.the<SourceSetContainer>()["main"].java.outputDir)
Expand All @@ -159,9 +160,16 @@ open class Spoofax2LanguagePlugin : Plugin<Project> {
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<Copy>("copyTestResources") {
dependsOn(unpackSpoofaxLanguageTask)
into(project.the<SourceSetContainer>()["test"].java.outputDir)
Expand All @@ -170,6 +178,9 @@ open class Spoofax2LanguagePlugin : Plugin<Project> {
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) }
}
}
}
1 change: 1 addition & 0 deletions core/spoofax.compiler/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 228a913

Please sign in to comment.