-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What version of OpenRewrite are you using?
I am using Gradle plugin id("org.openrewrite.rewrite") version "7.28.0".
How are you running OpenRewrite?
In a single module Gradle project.
But I'm using a non-standard directory layout in my build.gradle.kts, because I like to keep my *Test in java/:
sourceSets {
main {
java.srcDir("java")
java.srcDir("build/generated/sources/annotationProcessor/java/main")
java.exclude("**/*Test.java")
java.exclude("**/testlib/**")
resources.srcDir("resources")
}
test {
java.srcDir("java")
java.srcDir("build/generated/sources/annotationProcessor/java/test")
java.include("**/*Test.java")
java.include("**/testlib/**")
resources.srcDir("test")
}
}What did you expect to see?
In a perfect world, the rewrite-gradle-plugin should work well with such "overlapping" source sets.
What did you see instead?
It has also sorts of problems, including:
- completely breaking
gradle test, which I have worked around by isolating into aif (hasProperty("runRewrite")) {and running itgradle rewriteRun -PrunRewrite - formatting my
mainsources but ignoring mytestsource, which I have worked around with an ugly hack
// gradle rewriteRun -PrunRewrite
// NB: The OpenRewrite Gradle plugin *BREAKS* "gradle test" in this project
// (possibly due to our joint main and test in the same java/ folder), so we
// keep it in a separate profile and only apply it when really needed:
if (hasProperty("runRewrite")) {
apply(plugin = "org.openrewrite.rewrite")
configure<org.openrewrite.gradle.RewriteExtension> {
activeRecipe("org.openrewrite.java.ShortenFullyQualifiedTypeReferences")
exclusion(".direnv/**")
exclusion(".devcontainer/**")
exclusion(".gradle/**")
exclusion(".git/**")
exclusion("typescript/**")
exclusion("build/**")
exclusion("**/*.kts")
exclusion("build.gradle.kts")
}
// Workaround for OpenRewrite ignoring the 'test' sourceSet because it shares
// the same 'java/' srcDir with 'main'. We temporarily include tests in 'main'.
sourceSets.main {
java.setExcludes(emptyList<String>())
}
configurations.named("compileOnly") {
extendsFrom(configurations.named("testImplementation").get())
}
}Are you interested in contributing a fix to OpenRewrite?
I unfortunately wouldn't have the bandwidth (time), but still wanted to let you know.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
No status