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

jib Gradle plugin multiProject build doesn't pull in subproject dependencies #1776

Closed
mustafashabib opened this issue Jun 14, 2019 · 8 comments

Comments

@mustafashabib
Copy link

Description of the issue:

I have a project laid out like so:

root
|
|build.gradle.kts
|settings.gradle.kts
|web/
    |build.gradle.kts
    |src/
        |main/
             |java....(etc)
|data/
    |build.gradle.kts
    |src/
        |main/
             |java....(etc)

settings.gradle.kts lists out the subprojects (web, data, etc).
The root build.gradle.kts has a dependency on implementation(project("web")) and is set up to do the jib build
The web build.gradle.kts has a dependency on implementation(project("data"))

root build.gradle.kts:

jib {

        configurations {
            container {
                mainClass = "myApp.ClassName" 
                args = listOf("server")
                ports = listOf("8080")
                jvmFlags = listOf("-server", "-Djava.awt.headless=true", "-XX:+UseG1GC", "-XX:MaxGCPauseMillis=100", "-XX:+UseStringDeduplication")
            }
        }
    }

When I run the jibDockerBuild task I get a runnable container but it is missing the data dependency. Somehow the web jar is included meaning it was built and compiled properly but the data dependency used by it isn't included in /app/libs in the container so it fails to startup.

Expected behavior:

For my container to contain all dependencies of web which is the dependency my root project expresses.

Steps to reproduce:

Make a minimal project structure as described above and run ./jibDockerBuild and you should see this behavior.

@mustafashabib
Copy link
Author

Also note that if I run the run task provided by the application plugin, it includes all dependencies as expected and works.

@loosebazooka
Copy link
Member

Someone else was having a similar issue. #1745, are you using the springboot plugin by any chance?

@loosebazooka
Copy link
Member

loosebazooka commented Jun 14, 2019

Also can you include the build steps that are being triggered when you run with the --console=plain option?

@loosebazooka
Copy link
Member

another thing that could help us: are you using the java-library plugin?

@mustafashabib
Copy link
Author

@loosebazooka Thank you. It looks like it's the same issue described here. My data subproject is using the java-library plugin.

I can either have my main project jib task depend on jar for every subproject or, if there's a way to include subprojects into the jib class path so they get picked up and added to /app/classes in the container and someone can show me how to do so, that'd be awesome.

@loosebazooka
Copy link
Member

So I don't know how exactly java-library works - and why the behavior would be so different than just java. It's going to have to be something we investigate. If you have any clues that would be helpful. But in the meantime I guess you're going to have to use the workaround.

@mustafashabib
Copy link
Author

@loosebazooka Thanks for the tips. I've modified my dependent projects to use the java plugin instead of java-library and it seems to pull everything into the container as expected so I'll close this for now, but def. something wild going on with the java-library plugin and jib.

@mustafashabib
Copy link
Author

https://discuss.gradle.org/t/when-should-we-use-java-plugin-and-when-java-library-plugin/25377/2

implies that if you do continue using the java-library plugin then you'd need to use api on all the dependencies you use within that library to put them on the classpath.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants