-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JCP is not Gradle clean aware #43
Comments
could you try construction, may be it can help clean {
delete 'preprocessed-path'
} |
also I saw some examples where guys recommend to use construction for tasks outputs.upToDateWhen { false } |
I think |
Okay nice! It works :) thanks! For future reference, I'll put some examples for projects with Kotlin and Scala code (using gradle kts): val kotlinMainSources = kotlin.sourceSets.main.get().kotlin.sourceDirectories
val preprocessMain by tasks.creating(JcpTask::class) {
sources.set(kotlinMainSources)
clearTarget.set(true)
fileExtensions.set(listOf("kt"))
vars.set(Versions.versionMap)
outputs.upToDateWhen { target.get().exists() }
}
tasks.compileKotlin {
dependsOn(preprocessMain)
outputs.upToDateWhen {
preprocessMain.outcomingFiles.files.isEmpty()
}
doFirst {
kotlin {
sourceSets {
main {
kotlin.setSrcDirs(listOf(preprocessMain.target.get()))
}
}
}
}
doLast {
kotlin {
sourceSets {
main {
kotlin.setSrcDirs(kotlinMainSources)
}
}
}
}
} val scalaMainSources = sourceSets.main.get().scala.sourceDirectories
val preprocessMain by tasks.creating(JcpTask::class) {
sources.set(scalaMainSources)
clearTarget.set(true)
fileExtensions.set(listOf("scala"))
vars.set(Versions.versionMap)
outputs.upToDateWhen { target.get().exists() }
}
tasks.compileScala {
dependsOn(preprocessMain)
outputs.upToDateWhen {
preprocessMain.outcomingFiles.files.isEmpty()
}
doFirst {
scala {
sourceSets {
main {
scala.setSrcDirs(listOf(preprocessMain.target.get()))
}
}
}
}
doLast {
scala {
sourceSets {
main {
scala.setSrcDirs(scalaMainSources)
}
}
}
}
} Edit: Updated so IntelliJ plays nice by only temporarily changing the source folders. |
Version 7.0.5, Gradle 7.4
Currently, the default target of the
preprocess
task is "build/java-comment-preprocessor/preprocess". This is inside the build folder, which gets deleted entirely when running theclean
task. However, if I runpreprocess
again after a clean, I get> Task :core:preprocess UP-TO-DATE
, after which, the preprocess folder won't be regenerated anymore.Currently, my solution is to enable
clearTarget
and move the target outside of the build folder so it survives aclean
and clears itself. This is not ideal, however.The text was updated successfully, but these errors were encountered: