Is it possible to build a multi module maven project with skaffold and jib builder?
My project structure:
my-project-parent-module
- my-project-main-module
- my-project-lib-module
my-project-main-module
contains the Main class, and has the jib plugin configured, and has a dependency on my-project-lib-module
.
The lib-module
doesn't have jib configured, because no image is needed.
The documentation has an example of a multimodule skaffold:
build:
artifacts:
- image: image1 # jib artifact
jib:
fromImage: image2
requires:
- image: image2
- image: image2 # base image artifact
But this is a different scenario, because both modules produce an image (via jib).
Below is one of the skaffold configurations I tried:
apiVersion: skaffold/v2beta29
kind: Config
metadata:
name: my-project
build:
local:
push: false
artifacts:
- image: my-image-name
context: ./
jib:
project: com.example:my-project-main-module
...
CodePudding user response:
When you specify a project:
, Skaffold will invoke something like:
mvn --projects com.example:my-project-main-module --also-make jib:build
This will be executed from the context directory. The --also-make
causes Maven to rebuild any dependencies (like your lib-module
) as necessary.
Make sure you can run the command-line above separately from Skaffold. Check that your lib-module
is included as a <module>
in your top-level pom.xml
, and that your main-module
has a <dependency>
to your lib-module
.