'Not able to build a jar in google Cloud Build
I am new to google cloud, I am building an application with maven. In my maven repository I have lib folder where I have didisoft jar files.
I have added the plugins in maven to add them in the classpath. Locally, I am able to build the project but when same steps are executing on cloud build, the 'mvn clean install' fails.
POM --
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.4</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>ingka</groupId>
<artifactId>hrb2b-decom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>hrb2b-decom</name>
<description>hrb2b decommissioning project</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>24.4.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-sql-postgresql</artifactId>
<version>1.2.8.RELEASE</version>
</dependency>
<!-- <dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency> -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.didisoft</groupId>
<artifactId>pgplib</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>com.didisoft</groupId>
<artifactId>bcpg-lw-jdk15on</artifactId>
<version>1.70</version>
</dependency>
<dependency>
<groupId>com.didisoft</groupId>
<artifactId>bcprov-lw-jdk15on</artifactId>
<version>1.70</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>install-external-main</id>
<phase>clean</phase>
<configuration>
<file>${basedir}/lib/pgplib-3.2.3.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>com.didisoft</groupId>
<artifactId>pgplib</artifactId>
<version>3.2.3</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
<execution>
<id>install-external-lib1</id>
<phase>clean</phase>
<configuration>
<file>${basedir}/lib/bcpg-lw-jdk15on-1.70.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>com.didisoft</groupId>
<artifactId>bcpg-lw-jdk15on</artifactId>
<version>1.70</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
<execution>
<id>install-external-lib2</id>
<phase>clean</phase>
<configuration>
<file>${basedir}/lib/bcprov-lw-jdk15on-1.70.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>com.didisoft</groupId>
<artifactId>bcprov-lw-jdk15on</artifactId>
<version>1.70</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
---
Cloudbuild.yaml
steps:
- name: maven:3-jdk-8
entrypoint: mvn
args: ['clean','install']
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/<projectId>/first-image', '--build-arg=JAR_FILE=target/gcpbuild-0.0.1-SNAPSHOT.jar', '.']
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/<projectId>/first-image']
images: ['gcr.io/<projectId>/first-image']
Solution 1:[1]
It looks like you are missing things on the settings and pom files, you can find the instructions of how to do it here.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Pablo |