I am new to Quarkus and try to use it in a Maven multi module project. My project is structured as followed:
- quarkustest (pom)
- quarkustest-application (jar)
- quarkustest-backend (pom)
- quarkustest-backend-rest-api (jar)
- quarkustest-dependencies (pom)
- quarkustest-parent (pom)
The application module executes the quarkus-maven-plugin with build-goal. The quarkustest-backend-rest-api contains a simple REST controller and thus also a beans.xml in /src/main/resources/META-INF. The rest-api-module is references by the application module.
If I package the whole project with mvn package, the resulting runner-jar works as expected. However, if I try to start the project in dev mode with mvn compile quarkus:dev, I get following exception:
ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.0.0.CR2:dev (default-cli) on project quarkustest-application: Failed to run: Failed to resolve Quarkus application model: Failed to resolve dependencies for test.quarkustest:quarkustest-application:jar:1.0.0-SNAPSHOT: Could not find artifact test.quarkustest:quarkustest-backend-rest-api:jar:1.0.0-SNAPSHOT -> [Help 1]
I am not quite sure how to solve this. Is there any kind of best practice on multi module projects for Quarkus? Any obvious mistake I am doing here?
Edit 1 (relevant pom files)
quarkustest-application
<parent>
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../quarkustest-parent</relativePath>
</parent>
<artifactId>quarkustest-application</artifactId>
<dependencies>
<dependency>
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-backend-rest-api</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
quarkustest-parent
<parent>
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-dependencies</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../quarkustest-dependencies</relativePath>
</parent>
<artifactId>quarkustest-parent</artifactId>
<packaging>pom</packaging>
quarkustest-dependencies
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-dependencies</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
...
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-backend-rest-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus-plugin.version}</version>
</plugin>
</plugins>
</build>
quarkustest (aggregator)
<parent>
<groupId>test.quarkustest</groupId>
<artifactId>quarkustest-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>quarkustest-parent</relativePath>
</parent>
<artifactId>quarkustest</artifactId>
<packaging>pom</packaging>
<modules>
<module>quarkustest-dependencies</module>
<module>quarkustest-parent</module>
<module>quarkustest-backend</module>
<module>quarkustest-application</module>
</modules>
If you've never ran mvn install it might be because when you're in a subproject maven does not look in its sibling projects to resolve the dependencies, it only looks in the local maven repository which does not contain the dependency. If you have ran mvn install it might be something else at play.
Keep the quarkus-maven-plugin in the quarkustest-application and run
mvn clean install
mvn quarkus:dev -pl quarkustest-application
Now it will pick up changes in all submodules.
I was able to successfully run quarkus submodule in dev (with dependency to other module) in the following way:
Install "Quarkus Run Configs" plugin
Define new Run configuration for Quarkus
-> in VM options provide additional maven parameters in:
-Dmaven.am -Dmaven.pl=<name-of-you-quarkus-module>
In parent pom define quarkus plugin:
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus-plugin.version}</version>
</plugin>
Related
I have a lot of maven projects, which are dependent on each other.
I already have a super pom for the actual projects and this works pretty well.
Now I want to create a super pom for all my integrationtests projects. I did it the same, but every time I run maven test it failed.
[ERROR] Failed to execute goal on project *: Could not resolve
dependencies for project ::jar:0.0.1-SNAPSHOT: The following
artifacts could not be resolved: ::jar:0.0.1-SNAPSHOT,
::jar:0.0.1-SNAPSHOT, ::jar:0.0.1-SNAPSHOT, ::jar:0.0.1-SNAPSHOT: Could not find artifact *:***:jar:0.0.1-SNAPSHOT -> [Help 1]
The problem is that maven looks for jar files but my project consists of war projects. Here is my pom file:
<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>***</groupId>
<artifactId>***-parent_IntegrationTests</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>***_IntegrationTests</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<modules>
<module>../***</module>
<module>../***</module>
<module>../***</module>
<module>../***</module>
<module>../***</module>
<module>../***</module>
</modules>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
Is there a way to tell maven to use the war files instead of jars?
Edit: Sorry if it is not clear enough. I want a single maven project to run all my integrationtest projects. each one is a maven project. Therefor I want to use a pom with modules (all the integrationtest project) in it. But every integrationtest project contains dependencies to my other projects and the problem I want to fix is that maven does not find my compiled projects because it looks for jar files but my projects are war files.
You can reference WARs as dependencies by using <type>war</type> in the dependency.
I am trying to create a custom parameter less plugin by referring to create simple mojo creation instructions by apache in the below link.
https://maven.apache.org/guides/plugin/guide-java-plugin-development.html#
But I am unable to run the same using maven goal. Kindly suggest what I am missing. As I am new to maven and there aren't many tutorials on custom mavem plugin creation. Any suggestions on this topic will be helpful to me. Thanks in advance.
pom.xml
<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>sample.plugin</groupId>
<artifactId>hello-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>Sample Parameter-less Maven Plugin</name>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0</version>
</dependency>
<!-- dependencies to annotations -->
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>sample.plugin</groupId>
<artifactId>hello-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>sayhi</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
GreetingMojo.java
package sample.plugin.hello_maven_plugin;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
/**
* Says "Hi" to the user.
*
*/
#Mojo( name = "sayhi")
public class GreetingMojo extends AbstractMojo
{
public void execute() throws MojoExecutionException
{
getLog().info( "Hello, world." );
System.out.println("My first maven plugin.");
}
}
I am trying to run the pom.xml using package command and mvn install command.
Generally you shouldn't execute the plugin goal in the plugin you are trying to build. The reason you cannot build the plugin with mvn install is because you have configured maven to expect the plugin to already be built.
This section belongs in a different POM file, not the plugin POM file.
<build>
<plugins>
<plugin>
<groupId>sample.plugin</groupId>
<artifactId>hello-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>sayhi</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
After you have removed this section from the plugin POM you can run mvn install to install your plugin locally. Once installed you can re-add the section to the POM if you really wanted to, but ideally you would add it to a completely different maven project and execute maven in that project.
I am developing a spring boot project which has few modules. I have on entry point module which has main class, the other module dependencis i have added in entry point module pom.xml. When i give command mvn clean install it throws an error saying `
Failed to execute goal on project api: Could not resolve dependencies
for project com.nikesh:api:jar:1.0.0: The following artifacts could
not be resolved: com.nikesh:lib:jar:1.0.0, com.nikesh:repo:jar:1.0.0,
com.nikesh:entity:jar:1.0.0, com.nikesh:dto:jar:1.0.0,
com.nikesh:service:jar:1.0.0, com.nikesh:common:jar:1.0.0: Failure to
find com.nikesh:lib:jar:1.0.0 in https://repo.maven.apache.org/maven2
was cached in the local repository, resolution will not be reattempted
until the update interval of central has elapsed or updates are forced
-`
This is my pom.xml
<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>com.nikesh</groupId>
<artifactId>api</artifactId>
<version>1.0.0</version>
<description>api module</description>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
<start-class>com.nikesh.api.MultiModuleApp</start-class>
</properties>
<dependencies>
<dependency>
<groupId>com.nikesh</groupId>
<artifactId>lib</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.nikesh</groupId>
<artifactId>repo</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.nikesh</groupId>
<artifactId>entity</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.nikesh</groupId>
<artifactId>dto</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.nikesh</groupId>
<artifactId>service</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.nikesh</groupId>
<artifactId>common</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Please help me out resolving this issue.
You need to make sure that all sub modules are built in proper order before the main module build.
Guide to Working with Multiple Modules
The Reactor
The mechanism in Maven that handles multi-module projects is referred to as the reactor. This part of the Maven core does the following:
Collects all the available modules to build
Sorts the projects into the correct build order
Builds the selected projects in order
Because modules within a multi-module build can depend on each other, it is important that The reactor sorts all the projects in a way that guarantees any project is built before it is required.
The following relationships are honoured when sorting projects:
a project dependency on another module in the build
a plugin declaration where the plugin is another modules in the build
a plugin dependency on another module in the build
a build extension declaration on another module in the build
the order declared in the element (if no other rule
applies)
Note that only "instantiated" references are used - dependencyManagement and pluginManagement elements will not cause a change to the reactor sort order
for more info. You can refer this link for a sample multi module maven project.
I am using Eclipse Indigo. I installed the maven package on eclipse. I configured the Pom and nearly everything is fine. Just maven is not building the default folder bath
src/main/java
Here is the 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">
<modelVersion>4.0.0</modelVersion>
<groupId>TestProject</groupId>
<artifactId>TestProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.0.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.6</version>
<configuration>
<ajdtVersion>1.6</ajdtVersion>
</configuration>
</plugin>
</plugins>
</build>
</project>
I cleaned the project,installed and build it.... also I upgradet the project... the dependencies are all fine... no error at all.. why isn't the folder build ?
Eclipse's integration with maven is (to say at least) appalling. If you want to create a new project: create the pom and the folders, and then run mvn eclipse:eclipse to create the project files for eclipse. The simple solution that I've followed for a couple of years is to use the community edition of Intellij.
Aswering your second question: well... again, the integration is so poor that sometimes you'll need to close and reopen the project for eclipse to read the new changes. Most of the time, a refresh + clean project will force eclipse to read the project configuration.
I've imported my project into Eclipse (Helios + m2eclipse), and also into Netbeans (7.0) and in both IDEs one of the troubles is:
This is what I get in Netbeans when I try to build.
The project com.miCompany:myProject:1.0 (.....) has 1 error
Unresolveable build extension: Plugin
org.apache.axis2:axis2-wsdl2code-maven-plugin:1.3
or one of its dependencies could not
be resolved: Failed to collect
dependencies for
org.apache.axis2:axis2-wsdl2code-maven-plugin:jar:1.3
(): Failed to read artifact descriptor
for
org.apache.woden:woden:jar:1.0-incubating-M7b:
Could not transfer artifact
org.apache.woden:woden:pom:1.0-incubating-M7b
from/to jibx
(http://jibx.sourceforge.net/maven):
No connector available to access
repository jibx
(http://jibx.sourceforge.net/maven) of
type legacy using the available
factories
WagonRepositoryConnectorFactory ->
[Help 2]
This is what I get in Eclipse:
Project build error: Unresolveable build extension: Plugin
org.apache.axis2:axis2-wsdl2code-maven-plugin:1.3
or one of its dependencies could not
be resolved: Failed to collect
dependencies for
org.apache.axis2:axis2-wsdl2code-maven-plugin:jar:1.3
() pom.xml /myProject line 1 Maven
Problem
In Eclipse I've downloaded this: http://www.apache.org/dyn/mirrors/mirrors.cgi/axis/axis2/java/core/1.5.4/axis2-eclipse-service-plugin-1.5.4.zip unzipped and copied the file: "org.apache.axis2.eclipse.codegen.plugin_1.5.4.jar" into the directory "plugins" of my Eclipse instalation. And I still getting the same error.
I am running Netbeans over Win XP and Eclipse over Win XP and also over Mac, allways the same error.
Does somebody have any idea what can I do?
Here goes my pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>MyParent</artifactId>
<groupId>com.mycompany</groupId>
<version>1.0</version>
</parent>
<groupId>com.mycompany</groupId>
<artifactId>myModule</artifactId>
<version>1.0</version>
<name>myModule</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>src/main/java</directory>
<includes>
<include>com/mycompany/client/*.java</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>1.3</version>
<extensions>true</extensions>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2code</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>com.mycompany.client</packageName>
<wsdlFile>src/main/axis2/MyWsdl.wsdl</wsdlFile>
<outputDirectory>.</outputDirectory>
<targetResourcesFolderLocation>target/main/axis2</targetResourcesFolderLocation>
<targetSourceFolderLocation>src/main/java</targetSourceFolderLocation>
<namespaceURIs>
<namespaceURI>
<uri>http://schema.mycompany.com/Esb</uri>
<packageName>com.mycompany.services.Esbsrv.schema</packageName>
</namespaceURI>
<namespaceURI>
<uri>http://wsdl.mycompany.com/Esb</uri>
<packageName>com.mycompany.services.Esbsrv.schema</packageName>
</namespaceURI>
<namespaceURI>
<uri>http://schema.mycompany.com/Global/WSException</uri>
<packageName>com.mycompany.schema.global.wsexception</packageName>
</namespaceURI>
</namespaceURIs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!--
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.2</version>
<scope>compile</scope>
</dependency>
-->
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>1.3</version>
<scope>compile</scope>
</dependency>
<!--
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-xmlbeans</artifactId>
<version>1.3</version>
<scope>compile</scope>
</dependency>
-->
</dependencies>
</project>
Well, I can only offer suggestions as I"m not much of a maven expert, but I did just have to do this today and it was pretty straightforward for me -
set up the maven project to be eclipse friendly : mvn eclipse:eclipse
make sure eclipse can see the libs. this meant going to the projectsetup/buildpath/libraries editor in eclipse and adding the variable M2_REPO to point to your local maven repository (e.g. something like /home/nacho3d/.m2/repository)
Your error, actually, looks to me like maven can't find a dependency for axis. The specifics for that should be on the axis website,
I think you're using maven 3.0+, right?
That pom(org.apache.woden:woden:jar:1.0-incubating-M7b) isn't compatible with maven 3 yet.
If you use maven 2.2.1 to build ESB 4.3.0-03 source, then it would be successfully.
If you have the jar of the missing dependency you can:
1) deploy it on your maven repository, if you have one
2) declare the dependency in your pom with a scope of 'system': check this out
I have also faced the same problem and fixed it by following below step...
In you project directory do the command: mvn eclipse:eclipse
In eclipse project right click->Maven->Update Project.
Again right click->Maven->Disable Maven Nature
Restart eclipse.
Right click on project->Configure->Convert to Maven Project.
Finish. Error will gone.
Thanks