简体   繁体   English

使用 Skaffold 和 Jib 构建多模块 maven 项目

[英]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.

相关问题 Jib 始终在 Gradle 多项目上执行 - Jib is always executed on a Gradle multi-project 离线使用 jib maven 插件构建 docker 容器的问题 - Problem with using jib maven plugin offline for building docker container ClassNotFoundException - 在构建图像时使用 BitBucket 管道中的 jib-maven-plugin 将其推送到 GCR - ClassNotFoundException - when building the image & push it to GCR using jib-maven-plugin in BitBucket pipeline 使用 jib 构建多个项目 - using jib for multiple project build java maven docker jib 发布端口失败 - java maven docker jib published port fails 使用 Jib 获取特定版本的图像(Maven、Docker、testcontainers) - Getting a specific version of an image with Jib (Maven, Docker, testcontainers) 如何使用 maven jib 插件创建多层图像 - How to create muttilayer image using maven jib plugin jib-maven-plugin: 如何解决运行扩展错误 - jib-maven-plugin: How to solve running extension error 使用 jib 对 gradle 项目进行 dockerize 时图像引用注册表无效 - Invalid image reference registry when using jib to dockerize gradle project golang项目是否有任何替代JIB,它使用dockerfile创建docker图像 - Is there any alternative of JIB for golang project, which creates the docker image withour using dockerfile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM