[英]Building a multi module maven project with Skaffold and Jib
Is it possible to build a multi module maven project with skaffold and jib builder?是否可以使用 skaffold 和 jib builder 构建多模块 maven 项目?
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
. my-project-main-module
包含 Main class,并配置了 jib 插件,并依赖于my-project-lib-module
。 The lib-module
doesn't have jib configured, because no image is needed. lib-module
没有配置 jib,因为不需要图像。
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).但这是一个不同的场景,因为两个模块都会生成一个图像(通过 jib)。
Below is one of the skaffold configurations I tried:以下是我尝试过的其中一种 skaffold 配置:
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
...
When you specify a project:
, Skaffold will invoke something like:当你指定一个
project:
时,Skaffold 将调用类似的东西:
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. --also-make
会导致 Maven 根据需要重建任何依赖项(例如您的lib-module
)。
Make sure you can run the command-line above separately from Skaffold.确保您可以从 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
.检查您的
lib-module
是否作为<module>
包含在您的顶级pom.xml
中,并且您的main-module
有一个<dependency>
到您的lib-module
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.