Coffee Bean
Coffee Bean

Reputation: 41

Openshift: Could not find artifact when building java application using s2i with maven multimodule from GIT Submodules

Currently having difficultly building a Maven multimodule project using GIT submodules.

Using a GIT local repo as the source for OKD/Openshift S2i build for a Java (JDK21) application on OKD 4.15. The build pulls the root Git project but then attempts to locate the POM for the GIT submodules and cannot find them in Maven Central.

My understanding is that since the mvn command in the BuildConfig (below) uses the '-am" switch it should be building dependent projects like Base.

When the BuildConfig starts it does not build the Base project modules (i.,e. artifact au.com.cs.base:api ) instead, it searches for it in the Central Maven Repo and consequently errors as it cannot be found.

Any help would be appreciated.

Below are the artifacts.

BuildConfig:

    kind: BuildConfig
    apiVersion: build.openshift.io/v1
    metadata:
      name: test3
      namespace: test
      uid: 2bae8477-2ec2-4446-9286-314ea33ed54d
      resourceVersion: '5147078'
      generation: 79
      creationTimestamp: '2024-04-15T14:38:54Z'
      labels:
        app: test3
        app.kubernetes.io/component: test3
        app.kubernetes.io/instance: test3
    spec:
      nodeSelector: null
      output:
        to:
          kind: ImageStreamTag
          name: 'test2:latest'
      resources: {}
      successfulBuildsHistoryLimit: 5
      failedBuildsHistoryLimit: 5
      strategy:
        type: Source
        sourceStrategy:
          from:
            kind: ImageStreamTag
            namespace: openshift
            name: 'openjdk-21:latest'
          env:
            - name: MAVEN_ARGS_APPEND
              value: '-pl inventory/api -am'
      postCommit: {}
      source:
        type: Git
        git:
          uri: 'ssh://somesuser@somedomain/volume1/repo/project/cybackend/backend'
          ref: master
        contextDir: inventory/api
        sourceSecret:
          name: some-ssh-key
      triggers:
        - type: GitHub
          github:
            secret: <somesecret>
        - type: Generic
          generic:
            secret: <somesecret>
        - type: ConfigChange
        - type: ImageChange
          imageChange: {}
      runPolicy: Serial
    status:
      lastVersion: 48
      imageChangeTriggers:
        - lastTriggeredImageID: 'registry.access.redhat.com/ubi9/openjdk-21@sha256:779ca5034381bd4859ea9b51c7121f28210a97aa17a6914c32255237bc578445'
          from:
            namespace: openshift
            name: 'openjdk-21:latest'
          lastTriggerTime: '2024-05-02T03:26:06Z'

Both Base and Inventory projects are structured within:

Project Structure:

Backend
|
+--+---base
   |   +---api
   |   +---core
   |   +---data
   |   +---grpc
   |   +---model
   |   +---rsocket
   |   +---service
   +---inventory
       +---api
       +---data
       +---grpc
       +---inv-rsocket
       +---model
       \---service

Note:

The OKD/Openshift Buildconfig is configured in the following YAML:

The build pods runs and executes with the following maven build command:

mvn -e -Popenshift -DskipTests -Dcom.redhat.xpaas.repo.redhatga -Dfabric8.skip=true -Djkube.skip=true --batch-mode -Djava.net.preferIPv4Stack=true -s /tmp/artifacts/configuration/settings.xml -Dmaven.repo.local=/tmp/artifacts/m2 -pl inventory/api -am package

Error experienced is:

Non-resolvable parent POM for au.com.cs.inventory:api:0.0.1-SNAPSHOT: Could not find artifact au.com.cs.base:api:pom:0.0.1-SNAPSHOT in central (https://repo1.maven.org/maven2) and 'parent.relativePath' points at wrong local POM @ line 6, column 10

Backend POM:

<project    ...>
...
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.2.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <groupId>au.com.cs</groupId>
    <artifactId>backend</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>backend</name>
    <description>Base project for Base</description>

    <modules>
        <module>base</module>
        <module>inventory</module>
....
   </modules>

    <properties>
   ...
    </properties>
   
   ...
   
     <profiles>
        <profile>
            <id>openshift</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.eclipse.jkube</groupId>
                        <artifactId>openshift-maven-plugin</artifactId>
                        <version>${jkube.version}</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>resource</goal>
                                    <goal>build</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

Base POM:

<project ...>
    <parent>
        <groupId>au.com.cs</groupId>
        <artifactId>backend</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <groupId>au.com.cs</groupId>
    <artifactId>base</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>base</name>
    <description>Base project for Base</description>

    <modules>
        <module>rsocket</module>
        <module>grpc</module>
        <module>core</module>
        <module>model</module>
        <module>data</module>
        <module>service</module>
        <module>api</module>
    </modules>
Inventory POM:
<project  ...>
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>au.com.cs</groupId>
        <artifactId>base</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../base/pom.xml</relativePath>
    </parent>
    <groupId>au.com.cs</groupId>
    <artifactId>inventory</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>inventory</name>
    <description>Inventory project for Container Sales</description>

    <modules>
        <module>api</module>
        <module>inv-rsocket</module>
        <module>model</module>
        <module>data</module>
        <module>service</module>
        <module>grpc</module>
    </modules>
</project>

API POM:

<project ...>
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>au.com.cs.base</groupId>
        <artifactId>api</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../../../base/api/pom.xml</relativePath>      <!-- lookup parent from repository -->
    </parent>

    <groupId>au.com.cs.inventory</groupId>
    <artifactId>api</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <name>api</name>
    <description>API project for Inventory</description>

TIA

Upvotes: 1

Views: 46

Answers (0)

Related Questions