quarkus dependency not in lib folder - quarkus

Quarkus noob question.
Quarkus version: 2.3.1.Final
After building (with mvn package), I can see all my projects jar files in target/quarkus-app/lib/main. eg. uk.co.mycompany.my-project1-0.0.1-SNAPSHOT.jar, uk.co.mycompany.my-project2-0.0.1-SNAPSHOT.jar, etc.
I can also see a lot of other dependencies, which I'm assuming is gathered from the projects pom files.
However, when I add a new dependency, in this case jakarta.ws.rs-api, I can't see it under the lib folder.
I've tried an mvn clean package but it just results in the same jar files as before.
How does quarkus build the list of jars? Where does it get them from?
EDIT
Child project 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>com.mycompany</groupId>
<artifactId>mycompany-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>mycompany-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
</project>
Building project pom excerpt
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>2.3.1.Final</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
</plugin>

Related

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M1:test (default-test) on project

I have just created a Spring Boot Maven Application with Kotlin and MongoDB in IntelliJ. The Maven command build mvn clean install fails to run maven-surefire-plugin tests and generates error SurefireBooterForkException:
Error while executing forked tests.Error while executing process.Cannot run program "/bin/sh": error=2, No such file or directoryorg.apache.maven.surefire.shade.common.org.apache.maven.shared.utils.cli.CommandLineException: Error while executing process.
My pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<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.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.project</groupId>
<artifactId>project-backend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>project-backend</name>
<description>Backend for project</description>
<properties>
<java.version>11</java.version>
<kotlin.version>1.6.10</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${project.parent.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
I have tried the following:
mvn clean install -U or right-click on "project" Go to "Maven" >> "Update"
Enabling the system classloader in maven-surefire-plugin
I'm new to Spring Boot, Maven and IntelliJ.
UPDATE:
I added the following to maven-surefire-plugin:
<configuration>
<forkCount>0</forkCount>
</configuration>
Then the Maven build is successful. Why is this working??
Probably it's just a bug, as said here.
As documentation says
The parameter forkCount defines the maximum number of JVM processes that maven-surefire-plugin will spawn concurrently to execute the tests.
So, to resolve the issue, try to choose another JDK or downgrade your JDK or use the solution you specified.

how to deploy spring boot app with external jar and jar packaging

My application is running on localhost successfully ,but When I deploy my application on AWS server ,it is unable to run online. I have an external JAR of paytm-checksum-2.0 . What should I do for deployment of my Spring Boot application with external JAR?
I have converted into my application to one jar file but I am unable to deploy it...
File pom.xml is
<?xml version="1.0" encoding="UTF-8"?>
<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.3.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>Spring-payment-integration</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Spring-payment-integration</name>
<description>Payment integration with paytm</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I do not see see this custom jar in your pom.xml, you might have added it to your IDE configurations(or any other method which only works locally) so although it might work locally on remote this jar won't be present and you won't be able to reference it.
From what I see this is the official jar: https://github.com/Paytm-Payments/Paytm_Web_Sample_Kit_Java/tree/master/Java%20Kit%201.8
However, it does not seem to be there on the paytm artifacts hosted on maven: https://mvnrepository.com/artifact/com.paytm. So you have 2 options now:
Add the jar to a nexus repo, or to a public repo(like maven) and reference it from there, this is quite complicated(https://www.baeldung.com/install-local-jar-with-maven/)
You can package this custom jar with your springboot jar.
a. Add it to your project location.<file>${basedir}/dependencies/PaytmChecksum.jar</file>
b. Now add this to your pom
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>install-Transformation lib</id>
<phase>clean</phase>
<configuration>
<file>${basedir}/dependencies/PaytmChecksum.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>org.paytm</groupId>
<artifactId>paytmchecksum</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
c. Clean the project mvn clean
d. Now reference the file using
<dependency>
<groupId>org.paytm</groupId>
<artifactId>paytmchecksum</artifactId>
<version>1.0</version>
</dependency>
e. build it using mvn clean install
The packaged jar will now contain your Paytm jar.

Transitive dependencies are not visible?

I have customModule which is dependant on user-portal app. user-portal is dependent on util module
Here are the relevant POM's
customModule 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>parent-build</artifactId>
<groupId>com.myComp.user</groupId>
<version>1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>customModule</groupId>
<artifactId>dbunit</artifactId>
<dependencies>
<dependency>
<groupId>com.myComp.user</groupId>
<artifactId>user-portal</artifactId>
<version>1.15</version>
<scope>compile</scope>
<type>war</type>
</dependency>
</dependencies>
</project>
user-portal POM having utils as dependency
<dependencies>
<dependency>
<groupId>com.myComp.user.utils</groupId>
<artifactId>utils</artifactId>
<version>1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
But utils classes are not visible under customModule. I am not sure why transitive dependencies/classes are not visible here ?
When depending to war packaging, classes inside the war is not visible. You should add <attachClasses>true</attachClasses> to your war plugin in user-portal project. This will produce both war and a jar with the classes.
In the dependent project you should depend to <classifier>classes</classifier> instead of war.
inside user-portal pom.xml
<build>
...
<plugins>
...
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
...
</plugins>
...
</build>
customModule pom.xml
<dependency>
<groupId>com.myComp.user</groupId>
<artifactId>user-portal</artifactId>
<version>1.15</version>
<classifier>classes</classifier>
</dependency>
As a side note, default scope is compile you don't have to specify it.
Source = https://pragmaticintegrator.wordpress.com/2010/10/22/using-a-war-module-as-dependency-in-maven/

Maven dependencies not downloading for MRunit

I am new to Maven. I have created a Java Project for MRunit testing and converted it into Maven Project. I have added below dependencies into pom.xml file.
However I don't see the Maven Dependencies folder or any downloads from the internet into the project. Please guide me.
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MRUnitTest</groupId>
<artifactId>MRUnitTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<dependencies>
<dependency>
<groupId>org.apache.mrunit</groupId>
<artifactId>mrunit</artifactId>
<version>0.9.0-incubating</version>
<classifier>hadoop1</classifier>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
You will not find org.apache.mrunit with classifier hadoop1. remove the classifier property and the maven command
The dependencies are at the wrong place. Move it outside the build/plugin block, i.e
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MRUnitTest</groupId>
<artifactId>MRUnitTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.mrunit</groupId>
<artifactId>mrunit</artifactId>
<version>0.9.0-incubating</version>
<classifier>hadoop1</classifier>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
<build>
....
</build>
</project>
The classifier us fine according to mrunit doc. But you are selecting hadoop 1 with it.

How do I execute maven plugin for parent module only?

So I created this small maven plugin, that would connect to the database server and create all the tables I need for the project. Thing is, that the project consists of multiple modules and I want the plugin to be defined in the parent one. Yet it needs to be executed only once, not separately for each module. I thought that adding "<inherited>false</inherited>" to the plugin configuration would be enough, but apparently it's not.
Here's the pom of my parent project:
<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
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>rpg</groupId>
<artifactId>rpg-build</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>rpg-build</name>
<modules>
<module>../rpg-web</module>
<module>../rpg-service</module>
<module>../rpg-commons</module>
<module>../rpg-maven-plugin</module>
</modules>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.9</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>rpg.maven.plugin</groupId>
<artifactId>rpg-maven-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<inherited>false</inherited>
</plugin>
</plugins>
<finalName>${artifactId}</finalName>
</build>
</project>
Answered in comments:
You should add #aggregator annotation to your plugin's mojo. – Andrew
Logvinov Apr 1 '13 at 12:40

Resources