Skip to content
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

Destination dir of compileJava changed too eagerly if Kotlin plugin applied #100

Closed
tlinkowski opened this issue Aug 10, 2019 · 2 comments
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@tlinkowski
Copy link
Collaborator

I have a project where the Kotlin plugin is applied but there are no main Kotlin sources (only test Kotlin sources). However, applying this module plugin causes the destination directory of compileJava to be changed to that of compileKotlin which breaks my build.

The culprit in this plugin resides here:

// https://github.com/java9-modularity/gradle-modules-plugin/issues/45
helper().findTask(COMPILE_KOTLIN_TASK_NAME, AbstractCompile.class)
.ifPresent(compileKotlin -> javaCompile.setDestinationDir(compileKotlin.getDestinationDir()));

And this is how I worked around this problem in my project:
https://github.com/tlinkowski/tlinkowski-superpom/blob/4a692ac44ba0a78dd838aacdb7055e50112f6dbf/subprojects/my-superpom-gradle-plugin/src/main/kotlin/pl/tlinkowski/gradle/my/superpom/internal/plugin/EagerDestinationDirModificationFixPlugin.kt#L51-L67

To sum up, it seems to me that it'd be safest if this plugin changed the destination dir of compileJava only if:

  • compileKotlin is present (like now), and
  • there are some sources in src/main/kotlin, and
  • there's only module-info.java in src/main/java
@paulbakker
Copy link
Collaborator

What was the reason to change the java compile output in the first place?

@tlinkowski
Copy link
Collaborator Author

So that during the compilation of module-info.java, the Java compiler sees the packages exported by Kotlin (otherwise, javac complains on the first exports clause, claiming there's no such package).

However, in #99 and #101, we've established that we won't be changing the destination dir of compileJava (or any other task) at all. Instead, we'll add the destination dirs to modulepath (for compilation), or produce a special "merged" dir with outputs (for run/test).

@tlinkowski tlinkowski added the bug Something isn't working label Aug 24, 2019
@tlinkowski tlinkowski added this to the 1.6.0 milestone Aug 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants