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

module-info not always compiled at the right time in mixed projects #107

Closed
mikehearn opened this issue Aug 28, 2019 · 4 comments · Fixed by #109
Closed

module-info not always compiled at the right time in mixed projects #107

mikehearn opened this issue Aug 28, 2019 · 4 comments · Fixed by #109
Assignees
Labels
bug Something isn't working
Milestone

Comments

@mikehearn
Copy link

I have a project with mixed compilation, as I'm building a library I'd like to be usable on Java 8 as well.

It has two Gradle submodules and top level code at the root project, which depends on both the submodules.

Running gradle clean build fails because javac can't find the submodules when compiling module-info.java for the top level module. But if I run gradle com.r3.noise.noisejava:compileModuleInfoJava com.r3.noise.box:compileModuleInfoJava to force the submodule tasks to run, then I can build just fine until next time I clean. So it seems there's a build dependency missing somewhere.

I've attached the output of gradle -i clean build

problem.log

@tlinkowski
Copy link
Collaborator

Thanks for your report, Mike!

Unfortunately, I'm unable to reproduce your problem on my own project, where I also have a mixedJavaRelease(8) project (unij-api) depending on another mixedJavaRelease(8) project (unij-service-api). In this setup, calling both gradle clean build as well as gradle clean compileJava works fine.

Could you compare your build.gradle files with mine and report the differences, or perhaps share your files (or at least relevant parts of them)?

@mikehearn
Copy link
Author

Can I email you the project?

@tlinkowski
Copy link
Collaborator

Yes. You can find my e-mail address at https://tlinkowski.pl/

@tlinkowski
Copy link
Collaborator

Thanks for your patience, Mike.

I verified the problem on the project you sent me - this is indeed a bug in our plugin as well as a quirk of Gradle (which tries to build the root project as early as possible, it seems)

Since we're not setting proper dependencies between compileModuleInfoJava compile tasks, in your case, :compileModuleInfoJava is run before :com.r3.noise.noisejava:compileModuleInfoJava and :com.r3.noise.container:compileModuleInfoJava, and should be run after them.

I'll have to think about how to fix this.


For now, I'm afraid you need to set these dependencies manually as a workaround:

  • build.gradle in com.r3.noise.container:
def noisejava = project(":com.r3.noise.noisejava")
noisejava.afterEvaluate {
    tasks.compileModuleInfoJava.dependsOn(noisejava.tasks.compileModuleInfoJava)
}
  • build.gradle in com.r3.noise:
def container = project(":com.r3.noise.container")
container.afterEvaluate {
    tasks.compileModuleInfoJava.dependsOn(container.tasks.compileModuleInfoJava)
}

Let me know if that helps.

PS. With the workaround, I get error: package com.southernstorm.noise.protocol does not exist, but I guess it's some custom dependency that I don't have, right?

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
2 participants