I have 3 maven projects. Project1, Project2 & Project3.
Project3 depends on Project1 & Project2 and Project2 depends on Project1.
For this I have added this in Project2 pom.xml file
<modelVersion>4.0.0</modelVersion>
<groupId>Project2</groupId>
<artifactId>Project2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>Project1</groupId>
<artifactId>Project1</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
My pom.xml for Project3 is -
<modelVersion>4.0.0</modelVersion>
<groupId>Project3</groupId>
<artifactId>Project3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>Project1</groupId>
<artifactId>Project1</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>Project2</groupId>
<artifactId>Project2</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
In the project 3 I have added testng.xml file to run the test. Now If I run this testng.xml file then all my test cases are running successfully.
I have included testng.xml file in the pom file below dependencies to run testng test using maven -
<build>
<!-- Source directory configuration -->
<sourceDirectory>src</sourceDirectory>
<plugins>
<!-- Following plugin executes the testng tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<!-- Suite testng xml file to consider for test execution -->
<suiteXmlFiles>
<suiteXmlFile>Tng1.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<!-- Compiler plugin configures the java version to be used for compiling the code -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
Even these tests are running when I am trying to run this using Maven Test. But when I tried to run this using jenkins then it fails and shows below error.
[WARNING] The POM for Project1:Project1:jar:0.0.1-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for Project2:Project2:jar:0.0.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.476 s
[INFO] Finished at: 2015-08-25T15:16:56+05:30
[INFO] Final Memory: 13M/114M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project Project3: Could not resolve dependencies for project Project3:Project3:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: Project1:Project1:jar:0.0.1-SNAPSHOT, Project2:Project2:jar:0.0.1-SNAPSHOT: Could not find artifact Project1:Project1:jar:0.0.1-SNAPSHOT -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
Please Help !!!
Related
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project in Jenkins build with error message
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # projectname---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 21 source files to C:\Program Files (x86)\Jenkins\workspace\projectname\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.958 s
[INFO] Finished at: 2020-07-30T14:53:55+05:45
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Projectname: Compilation failure: Compilation failure:
[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[JENKINS] Archiving C:\Program Files (x86)\Jenkins\workspace\projectname\pom.xml to projectnamegroup/projectname/0.0.1-SNAPSHOT/projectname-0.0.1-SNAPSHOT.pom
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
channel stopped
Finished: FAILURE
POM Details
<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>projectnameworkgroup</groupId>
<artifactId>projectnameframework</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>projecnameautomation</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>MYtestNG.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.sikuli/sikuli-api -->
<dependency>
<groupId>org.sikuli</groupId>
<artifactId>sikuli-api</artifactId>
<version>1.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.assertthat/selenium-shutterbug -->
<dependency>
<groupId>com.assertthat</groupId>
<artifactId>selenium-shutterbug</artifactId>
<version>0.9.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.opencsv/opencsv -->
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-clean-plugin -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/ -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>mvntestngrepo.read</id>
<url>https://github.com/abc/projectname</url>
</repository>
</repositories>
</project>
Looking for solution. Please give your valuable solution.Thank you
Used version Details
Looks like maven-compiler-plugin has default 5 source and target options.
You must set explicit values to that options.
Something like this:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
I have a simple maven project with multi modules (only one for the moment) for Spring Boot microservices
In the root folder the pom.xml contains
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>be.demo.microservices</groupId>
<artifactId>master</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>hello-service</module>
</modules>
</project>
In the hello-service folder, the pom.xml contains
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>be.demo.microservices</groupId>
<artifactId>hello-service</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<docker.image.prefix>springio</docker.image.prefix>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<imageTags>
<imageTag>${project.version}</imageTag>
<imageTag>latest</imageTag>
</imageTags>
<baseImage>openjdk:8-jdk-alpine</baseImage>
<entryPoint>["sh","-c","java -Djava.security.egd=file:/dev/./urandom -jar /${project.build.finalName}.jar"]</entryPoint>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
</project>
When building the project with mvn clean package docker:build I have
...
[INFO] --- spring-boot-maven-plugin:2.0.1.RELEASE:repackage (default) # hello-service ---
[INFO]
[INFO] --- docker-maven-plugin:1.0.0:build (default-cli) # hello-service ---
[INFO] Using authentication suppliers: [ConfigFileRegistryAuthSupplier]
[INFO] Copying D:\dev\microservices\demo\hello-service\target\hello-service-1.0.0-SNAPSHOT.jar -> D:\dev\microservices\demo\hello-service\target\docker\hello-service-1.0.0-SNAPSHOT.jar
[INFO] Building image springio/hello-service
Step 1/3 : FROM openjdk:8-jdk-alpine
---> 224765a6bdbe
Step 2/3 : ADD /hello-service-0.0.1-SNAPSHOT.jar //
---> 259b1622e107
Step 3/3 : ENTRYPOINT ["sh","-c","java -Djava.security.egd=file:/dev/./urandom -jar /hello-service-1.0.0-SNAPSHOT.jar"]
---> Running in e86870c47b6a
Removing intermediate container e86870c47b6a
---> 847840116367
ProgressMessage{id=null, status=null, stream=null, error=null, progress=null, progressDetail=null}
Successfully built 847840116367
Successfully tagged springio/hello-service:latest
[INFO] Built springio/hello-service
[INFO] Tagging springio/hello-service with 1.0.0-SNAPSHOT
[INFO] Tagging springio/hello-service with latest
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building master 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # master ---
[INFO]
[INFO] --- docker-maven-plugin:1.0.0:build (default-cli) # master ---
[INFO] Using authentication suppliers: [ConfigFileRegistryAuthSupplier]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] hello-service ...................................... SUCCESS [ 9.881 s]
[INFO] master ............................................. FAILURE [ 0.102 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.650 s
[INFO] Finished at: 2018-04-18T13:33:49+02:00
[INFO] Final Memory: 54M/520M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default-cli) on project master: Exception caught: Must specify baseImage if dockerDirectory is null -> [Help 1]
[ERROR] .....
So the service is packaged, the image is built but I don't understand why in the master pom maven is trying to build an image even if there is no docker plugin inside it ?
By default this docker-maven-plugin is bind with maven's package build phase.
Check following link bind-docker-commands-to-maven-phases
You can skip Docker goals bound to Maven phases with:
-DskipDockerBuild to skip image build
-DskipDockerTag to skip image tag
-DskipDockerPush to skip image push
-DskipDocker to skip any Docker goals
I have a mavenized project and when I try to do a release, I get the below error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4
.2:prepare (default-cli) on project SimpleWeb: Unable to check for local modific
ations
[ERROR] Provider message:
[ERROR] SVN status failed.
[ERROR] Command output:
[ERROR] svn: '' is not a working copy
I have the below questions:
How is the scm configuration is given in POM file
If the communication to scm should happen through https, how can we configure the certificate on the client side
The release should happen from branch or trunk
My scm configuration is as follows:
<scm>
<connection>scm:svn:https://domain.com/svn/New_FW/CI_POC/SimpleWeb/trunk</connection>
<developerConnection>scm:svn:https://domain.com/svn/New_FW/CI_POC/SimpleWeb/trunk</developerConnection>
<url>https://domain.com/svn/New_FW/CI_POC/SimpleWeb/trunk</url>
</scm>
My maven release plugin configuration is as follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.3</version>
<configuration>
<providerImplementations>
<svn>javasvn</svn>
</providerImplementations>
<username>${scm.username}</username>
<password>${scm.password}</password>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.code.maven-scm-provider-svnjava</groupId>
<artifactId>maven-scm-provider-svnjava</artifactId>
<version>1.14</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.2</version>
<dependencies>
<dependency>
<groupId>com.google.code.maven-scm-provider-svnjava</groupId>
<artifactId>maven-scm-provider-svnjava</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
<configuration>
<providerImplementations>
<svn>javasvn</svn>
</providerImplementations>
<tagBase>https://domain-inc.com/svn/New_FW/CI_POC/SimpleWeb/tags</tagBase>
<mavenExecutorId>forked-path</mavenExecutorId>
</configuration>
</plugin>
I am struck here and cant move ahead. Please help/guide me in resolving the issue. When I run the same by configuring the Maven Release Plugin in Jenkins I get a different error as: "svn: Authentication required". Why is this difference.
On Windows Jenkins slave I have same issue with multi maven project.
For fix it I added:
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
...
<configuration>
<commitByProject>true</commitByProject>
...
</configuration>
...
Upon running mvn install glassfish:deploy I run into the following problems
[...]
[ERROR] Failed to execute goal org.glassfish.maven.plugin:maven-glassfish-plugin:2.1:deploy (default-cli) on project post-build-pom: Execution default-cli of goal org.glassfish.maven.plugin:maven-glassfish-plugin:2.1:deploy failed: Plugin o rg.glassfish.maven.plugin:maven-glassfish-plugin:2.1 or one of its dependencies could not be resolved: Failed to collect dependencies for org.glassfish.maven.plugin:maven-glassfish-plugin:jar:2.1 (): Failed to read artifact descriptor for org.apache.maven:maven-plugin-api:jar:3.0-SONATYPE-688946: Failure to find org.apache.maven:maven-parent:pom:9-SNAPSHOT in http://maven-repository/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of internal-repository has elapsed or updates are forced -> [Help 1]
[...]
My mvn -v looks like this:
Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: C:\Users\rob\apache-maven-3.0.4\bin\..
Java version: 1.6.0_37, vendor: Sun Microsystems Inc.
Java home: C:\Programme\Java\jdk1.6.0_37\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Futhermore my nexus-repository runs on http://maven-repository .
EDIT: The plugin-part from pom.xml looks like this:
<plugin>
<groupId>org.glassfish.maven.plugin</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
<version>2.1</version>
<configuration>
<user>admin</user>
<adminPassword>adminadmin</adminPassword>
<glassfishDirectory>c:\development\glassfish-v2.1.1-b31g</glassfishDirectory>
</configuration>
</plugin>
you're not the only one facing problems there :)
there seems to be even official bug report for that: http://java.net/jira/browse/GLASSFISH-14411
As a workaround suggested here: http://jira.codehaus.org/browse/MNG-4843
you should override the plugin dependencies in your project with proper versions.
Following should solve your problem:
<build>
<plugins>
<plugin>
<groupId>org.glassfish.maven.plugin</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
<version>2.1</version>
<configuration>
<user>admin</user>
<adminPassword>adminadmin</adminPassword>
<glassfishDirectory>c:\development\glassfish-v2.1.1-b31g</glassfishDirectory>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>3.0-alpha-2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.0.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
Of course you need to provide all the configuration required, but it's another topic covered by: http://maven-glassfish-plugin.java.net/examples/complete.html
I find another way to solve this:
copy file "C:\Users\< current user >\.m2\repository\org\apache\maven\maven-parent\11\maven-parent-11.pom"
to
"C:\Users\< current user >\.m2\repository\org\apache\maven\maven-parent\11-SNAPSHOT\"
and rename it to "maven-parent-11-SNAPSHOT.pom"
I'm trying to run junitreport task in Ant in Ant in Maven:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions combine.children="append">
<execution>
<id>reporting</id>
<phase>compile</phase><!--post-integration-test-->
<goals><goal>run</goal></goals>
<configuration>
<target>
<ant antfile="${basedir}/../tools/report/buildReports.xml">
<!--<property name="reports.dest.dir" value=""/>-->
<target name="reports"/>
</ant>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-antunit</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b2</version>
</dependency>
</dependencies>
</plugin>
However, I am getting this:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (reporting) on project jboss-as-testsuite-integration: An Ant BuildException has occured: The following error occurred while executing this line:
[ERROR] /home/ondra/work/AS-7/ozizka-as7/testsuite/tools/report/buildReports.xml:42: Problem: failed to create task or type junitreport
[ERROR] Cause: the class org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator was not found.
[ERROR] This looks like one of Ant's optional components.
[ERROR] Action: Check that the appropriate optional JAR exists in
[ERROR] -ANT_HOME/lib
[ERROR] -the IDE Ant configuration dialogs
What should I add?
Oops. The class really wasn't present - it was in ant-junit. So the needed dependency is:
<dependency>
<groupId>ant</groupId>
<artifactId>ant-junit</artifactId>
<version>1.6.5</version>
</dependency>