-
Notifications
You must be signed in to change notification settings - Fork 12
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
Plugin doesn't support projects that use both Kotlin and Java #39
Comments
This is correct. Reason is that on |
This is the snippet that I've been using utilizing the Gradle Kotlin DSL: tasks.register<Cpd>("cpdKotlin") {
language = "kotlin"
exclude { it.file.extension.contains("java") }
allprojects.forEach { project ->
project.plugins.withType<JavaBasePlugin> {
project.convention.getPlugin<JavaPluginConvention>().sourceSets.configureEach {
allJava.srcDirTrees.forEach { this@register.source(it) }
}
}
}
} It would be nice if the plugin could detect mixed kotlin/java projects automatically and auto-generate the correct tasks for you. |
That looks good from first view. Does it work for you? |
This does work well for me. I've embedded it in my own build.
🤔 Would be awesome! |
Hi @JLLeitschuh, thought about it but unfortunately without any clear result. Only thing I can currently think of is to create a mapping and create I have no clue if a lot people use this plugin for multiple languages, however some kind of auto detection could be a nice improvement... |
Would it possible to provide an example using Gradle groovy DSL? |
@grushler the one to one translation of example above would be import de.aaschmid.gradle.plugins.cpd.Cpd
task cpdKotlin(type: Cpd) {
language = "kotlin"
exclude { it.file.extension.contains("java") }
allprojects.forEach { project ->
project.plugins.withType(JavaBasePlugin) { plugin ->
project.sourceSets.forEach { ss -> ss.allJava.forEach { rootProject.cpdKotlin.source(it) } }
}
}
} Disclaimer: not tested with a Kotlin project actually but don't hesitate to complain if it does not ;-) Note: The |
Thank you @aaschmid . I tested the provided code, but get below error (added with stacktrace) -
So I changed the exclude code and tried again - Btw, my folder structure something like this - |
@grushler Another working way should be: task cpdKotlin(type: Cpd) {
language = "kotlin"
source = allprojects*.file("src/main/kotlin")
} It's a bit ugly because it hard-codes |
Thanks @aaschmid. That helps though there is a hardcoded path but seems to be ok to use as we usually never change the path. I will try out printing the source and verify if the location is being picked up as needed. |
@JLLeitschuh any further thoughts on this? |
@aaschmid sorry, this is no longer a project I'm actively using. I've left the company I was working for that was using it. |
Ok, so I will close this but anyone can reopen as soon as this is an issue anymore... |
I have quite a few projects that are slowly being migrated from Java to Kotlin.
There doesn't seem to be a good way to support linting both Kotlin and Java since you can only specify one
language
.The text was updated successfully, but these errors were encountered: