GoogleContainerTools / GoogleContainerTools/skaffold
How to set local maven dependency using buildpacks
- Dominant language
- Go
- Stars
- 15.9k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
### Actual behavior
I'm building my images using `pack` cli:
pack build fhir-mongo --builder paketobuildpacks/builder:base --path target/hes-mpi-fhir-mongodb-service-0.0.1-SNAPSHOT.jar
This is my project structure:
```
.
├── hes-mpi-fhir-mongodb
│ ├── deployment.yaml
│ ├── pom.xml
│ ├── skaffold.yaml
│ └── src
└── hes-spring-boot-core <<< dependency requiered by hes-mpi-fhir-mongodb
├── pom.xml
└── src
```
As you can see, I managing two maven projects.
My host building steps are:
```
$ hes-spring-boot-core > mvn clean install
$ hes-mpi-fhir-mongodb > mvn clean package
```
I mean, I first install `hes-spring-boot-core` into local repository and then I build `hes-mpi-fhir-mongodb`:
My `skaffold.yml` file is:
```yaml
apiVersion: skaffold/v2beta26
kind: Config
metadata:
name: hes-mpi-fhir-mongodb
build:
artifacts:
- image: pom-xml-image
buildpacks:
builder: paketobuildpacks/builder:base
profiles:
- name: dev
deploy:
kustomize:
paths: ["kustomize/dev"]
```
I'm getting this message, when I'm trying to build image:
```
...
[builder] Running "/layers/google.java.maven/maven/bin/mvn clean package --batch-mode -DskipTests -Dhttp.keepAlive=false --quiet"
[builder] [ERROR] Failed to execute goal on project hes-mpi-fhir-mongodb-service: Could not resolve dependencies for project cat.gencat.catsalut.hes.mpi.fhir:hes-mpi-fhir-mongodb-service:jar:0.0.1-SNAPSHOT: Could not find artifact cat.gencat.catsalut.hes:hes-spring-boot-core:jar:1.0.6 in central (https://repo.maven.apache.org/maven2)
```
It's getting me that maven builder is not able to find artifact `cat.gencat.catsalut.hes:hes-spring-boot-core:jar:1.0.6`.
This error doesn't appear when I perform above `pack cli` command!
How can I add this project as a dependency?
I've took a look on documentation. There are some fields that are messing me:
> `dependencies`: file dependencies that skaffold should watch for both rebuilding and file syncing for this artifact.
> Artifact Dependency: You can define dependency on other artifacts using the requires keyword. This can be useful to specify another artifact image as the builder or runImage.
I'm using skaffold `v1.35.1`.
### Information
- Skaffold version: 1.35.1
- Operating system:
- Installed via: skaffold.dev
- Contents of skaffold.yaml:
```yaml
apiVersion: skaffold/v2beta26
kind: Config
metadata:
name: hes-mpi-fhir-mongodb
build:
artifacts:
- image: pom-xml-image
context: target/hes-mpi-fhir-mongodb-service-0.0.1-SNAPSHOT.jar
buildpacks:
builder: paketobuildpacks/builder:base
dependencies:
paths:
- "target/hes-mpi-fhir-mongodb-service-0.0.1-SNAPSHOT.jar"
# requires:
# - image: core
profiles:
- name: dev
deploy:
kustomize:
paths: ["kustomize/dev"]
```
Also I've tried to build two images and set "core" image as requirement, but problem arises:
```
apiVersion: skaffold/v2beta26
kind: Config
metadata:
name: hes-mpi-fhir-mongodb
build:
artifacts:
- image: core
context: ../hes-spring-boot-core
buildpacks:
builder: paketobuildpacks/builder:base
env:
- "BP_MAVEN_BUILD_ARGUMENTS=install"
- image: pom-xml-image
# context: target/hes-mpi-fhir-mongodb-service-0.0.1-SNAPSHOT.jar
buildpacks:
builder: paketobuildpacks/builder:base
dependencies:
paths:
- "target/hes-mpi-fhir-mongodb-service-0.0.1-SNAPSHOT.jar"
requires:
- image: core
profiles:
- name: dev
deploy:
kustomize:
paths: ["kustomize/dev"]
```
Contributor guide
Assessment
This issue has not been assessed yet.