GoogleCloudPlatform / buildpacks

Builders and buildpacks designed to run on Google Cloud's container platforms
Apache License 2.0
967 stars 144 forks source link

Multimodule Maven Project - Cannot find any jar files #166

Open furlongce opened 2 years ago

furlongce commented 2 years ago

I'm using Cloud Code within IntelliJ with a multimodule maven project. I've tried a few different things and was finally able to get the project to build successfully, but only if I build the the top level parent pom.xml.

My structure is:

The problem is that once it's finished building, I see this:

image

I've tried using GOOGLE_BUILDABLE to set the module that I want to deploy explicitly but it isn't respecting it. If I just build the module that I'd like to deploy, the build fails since it's trying to resolve common and common-test from the remote m2 repository, but obviously they aren't present since they're only in my local m2.

It seems like it's searching at the root for a deployable jar, and perhaps looking in a target directory as well, but I need a way to specify which folder to start that search in. Any ideas?

jamesward commented 2 years ago

I think you are going to have to get the Maven Assembly Plugin to package up the right stuff for the root package phase. It seems like people have been able to do this, like: https://everyday.codes/java/creating-production-artifacts-in-a-multi-module-maven-project/

cranberrysoft commented 2 years ago

I would love to see support for maven modules out of the box like in Paketo buildpacks via BP_MAVEN_BUILT_MODULE https://github.com/paketo-buildpacks/maven As maven modules are very popular among Maven projects and also very useful.

I've also created another issue that could potentially solve the problem https://github.com/GoogleCloudPlatform/buildpacks/issues/189 via a generic param GOOGLE_BUILDABLE. However, somehow It was not implemented for Java.

kappratiksha commented 2 years ago

Have you tried using GOOGLE_ENTRYPOINT variable and point it to the jar file of the module you would like to use. Basically build the parent pom but point the entrypoint to your desired module. Something like this --env GOOGLE_ENTRYPOINT = "java -jar targetModule/target/xyz.jar" https://github.com/GoogleCloudPlatform/buildpacks#:~:text=java%20%2Djar%20target/myjar.jar