Maven plugin: Skipped dependency module missing from service image
See original GitHub issueEnvironment:
- Jib version: 2.6.0
- Build tool: Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
- JVM: 14.0.2, AdoptOpenJDK
- OS: Linux 5.4.0-52-generic amd64
Description of the issue:
Building images from the root folder of a multi-module project, I don’t get functional images: during container startup, the JVM can not find classes from the (skipped) common
module
Expected behavior:
Images are functional, i.e. include all dependencies (even if they were marked to “skip” for Jib).
Steps to reproduce:
- Maven project with three modules
common
,serviceA
,serviceB
; the latter two depend oncommon
(viadependencyManagement
in the root POM). - Configure Jib in the root pom.
- Run
mvn compile jib:dockerBuild
jib-maven-plugin
Configuration:
Root:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>${jib.version}</version>
<configuration>
<skip>true</skip>
<from>
<image>gcr.io/distroless/java:11</image>
</from>
<to>
<image>my-service-${project.artifactId}</image>
</to>
</configuration>
</plugin>
serviceA
, serviceB
:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
Additional Information:
Without <skip>
, building in the root folder fails because common
doesn’t have a “main” class:
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:2.5.2:build (default-cli) on project commons: Main class was not found, perhaps you should add a
mainClass
configuration to jib-maven-plugin
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Maven Multi-module dependency package not found
I figured it out. The rest-client-microservice is a Spring Boot project and uses the following plugin:
Read more >fabric8io/fabric8-maven-plugin
Default Enrichers will create a default Service and Deployment (DeploymentConfig for OpenShift) when no other resource objects are provided.
Read more >Developing and compiling your Quarkus applications with ...
The Quarkus Maven repository contains many of the dependencies that Java developers typically use to build their applications. This procedure ...
Read more >Apache Maven Dependency Plugin – Usage
If not set, the plugin will attempt to resolve it from the project dependencies and then the dependencyManagement section.
Read more >Maven Artifactory Plugin - JFrog - JFrog Documentation
The plugin's invocation phase is validate by default and we recommend you don't change it so the plugin is called as early as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It should. Not sure what’s going on.
You need
-am
(--also-make
) too. That is,mvn -am -pl serviceA clean package jib:dockerBuild
.We have a multi-module example, which I think is configured a little bit different than yours. Worth taking a look.
Let us know if you have any questions. If you have a reproducible sample, we can take a look too.
Maybe? We do have this in
serviceA/pom.xml
:Does Maven not resolve this to the sibling module? 🤷♂️
Thanks.
So, if I were to run
mvn -pl serviceA clean package jib:dockerBuild
, it wouldn’t work either becausecommons
would silently be forgotten? Ugn…-pl commons,serviceA
it is, but that’s … sad.Anyway, it seems that by issue is with Maven, not Jib. Thanks for your help!