Jenkins: custom jar dependency issue - maven

I'm creating a jar through a project and copied the jar to c:\mylib\test-automation-library-0.0.1-SNAPSHOT.jar
<groupId>com.mycompany.taf</groupId>
<artifactId>test-automation-library</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Test Automation Library</name>
<description>Test Automation Library</description>
<url>http://maven.apache.org</url>
Now, I'm running the test scripts through Jenkins.In the Jenkins job of test scripts, I included the following pre-build step install the library:
install:install-file
-Dfile=c:\mylib\test-automation-library-0.0.1-SNAPSHOT.jar
-DgroupId=com.mycompany.taf
-DartifactId=test-automation-library
-Dversion=0.0.1
-Dpackaging=jar
This installs the jar to maven local repository (where are the scripts are supposed to run) and build is successful in the POM file of the test-scripts, I included the following dependency for the above library:
<dependency>
<groupId>com.mycompany.taf</groupId>
<artifactId>test-automation-library</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
If I do maven install (of the test-scripts project) through Jenkins, I'm hitting the following error:
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.mycompany.taf:test-automation-library:jar:0.0.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
Is it something wrong with the dependency? I tried the with all different options and also googled it, but was not able to figured out what the problem was. I'm really blocked here. any help/pointers are greatly appreciated.
Thanks in advance.
Rams.

Rams,
Your command reads:
install:install-file
-Dfile=c:\mylib\test-automation-library-0.0.1-SNAPSHOT.jar
-DgroupId=com.mycompany.taf
-DartifactId=test-automation-library
-Dversion=0.0.1
-Dpackaging=jar
Your version number is missing the -SNAPSHOT qualifier.
Hope that helps.

#333kenshin, this is continuation to my previous comment to your question.
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) # test-automation-library ---
[INFO] Installing C:\Program Files (x86)\Jenkins\workspace\AmzonPOCTest1\test-automation- library\target\test-automation-library-0.0.1-SNAPSHOT.jar to C:\Windows\system32\config\systemprofile\.m2\repository\com\mycompany\taf\test-automation-library\0.0.1-SNAPSHOT\test-automation-library-0.0.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.938 s
[INFO] Finished at: 2014-10-23T03:38:39-07:00`enter code here`
[INFO] Final Memory: 23M/122M
[INFO] ------------------------------------------------------------------------ enter code here
FYI: I logged into my windows PC non-admin user. I believe it does not matter.

Related

Maven: compilation module fails

I've these modules into my pom.xml:
<modules>
<module>rep-digital-common</module>
<module>rep-digital-api</module>
</modules>
So, rep-digital-common contains common classes rep-digital-api module needs.
When I compile them using
$ mvn clean compile
...
[INFO] rep-digital-common ................................. SUCCESS [ 7.571 s]
[INFO] rep-digital-api .................................... SUCCESS [ 17.988 s]
However, when I perform:
$ mvn -pl rep-digital-api clean package
it fails:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.345 s
[INFO] Finished at: 2018-08-28T12:29:19+02:00
[INFO] Final Memory: 58M/140M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project rep-digital-api: Compilation failure: Compilation failure:
[ERROR] /home/jcabre/projectes/repo-digital/rep-digital-api/src/main/java/net/gencat/transversal/repositori/digital/document/service/DocumentService.java:[29,65] cannot find symbol
[ERROR] symbol: class ContentStatus
ContentStatus symbol is located on rep-digital-common. I don't quite figure out what's going wrong.
Obviously, rep-digital-common is added as a rep-digital-api dependency:
<dependency>
<groupId>net.gencat.transversal.repositori.digital</groupId>
<artifactId>rep-digital-common</artifactId>
</dependency>
Any ideas?
Executing mvn clean compile or mvn clean package don't add the built artifacts in the local repository.
To add built artifacts in the local repository you have to use mvn clean install.
Note that as actually you build a reactor project, it works because the reactor provides dependencies needed to each current module to build.
On the other hand, as you compile rep-digital-api alone, the reactor will not help you :
mvn -pl rep-digital-api clean package
and so the compilation can only fail as rep-digital-common classes are not resolvable.

Jenkins fails to parse POM with variables

tl;dr: mvn clean install works as expected, but Jenkins is not able to resolve variables in child poms.
We have a project with a main pom and multiple sub poms. It seems to fail in the sub pom with the variable ${project.version} not being resolved (see the error message below and scroll to its end).
Main 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>group</groupId>
<artifactId>artifact</artifactId>
<version>1.0.0.0-SNAPSHOT</version>
...
</project>
Sub pom:
<parent>
<groupId>group</groupId>
<artifactId>artifact</artifactId>
<version>${project.version}</version>
<relativePath>../pom.xml</relativePath>
</parent>
mvn clean install on the console works flawlessly:
[INFO] Installing /path/to/jenkins/workspace/Project/pom.xml to /path/to/.m2/repository/de/project/1.0.0.0-SNAPSHOT/project-1.0.0.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
...
[INFO] PROJECT 1.0.0.0-SNAPSHOT - EAR project ........... SUCCESS [ 5.038 s]
[INFO] PROJECT 1.0.0.0-SNAPSHOT - Aggregator project ........ SUCCESS [ 0.156 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:03 min
[INFO] Finished at: 2016-09-20T12:58:03+02:00
[INFO] Final Memory: 104M/1088M
[INFO] ------------------------------------------------------------------------
Jenkins fails to parse the pom and produces the following error:
Parsing POMs
ERROR: Failed to parse POMs
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Failure to transfer my.package:project:pom:${project.version} from http://mynexus.com/content/groups/default was cached in the local repository, resolution will not be reattempted until the update interval of nexus-default has elapsed or updates are forced. Original error: Could not transfer artifact my.package:project:pom:${project.version} from/to nexus-default (http://mynexus.com/content/groups/default): Illegal character in path at index 78: http://mynexus.com/content/groups/default/my/package/project/${project.version}/panda-${project.version}.pom and 'parent.relativePath' points at wrong local POM # line 26, column 10
What has to be changed so that Jenkins can parse the pom file aswell?
The linked question states that maven would not be able to parse the child's properties as they wouldn't exist. The maven logs above show that this is not the case.
The information above is redacted. Typos are not the reason for this issue.
I fixed it by use Freestyle project Job instead of Maven project Job. Run native maven command in shell or locally didn't have this problem.
A similar error:
JENKINS-23846

Add External JAR in Maven Dependency

I am trying to add external JAR file tigase-muc in a maven based project tigase-server in eclipse IDE.
I have tried following method
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
[INFO] Scanning for projects...
[INFO]
[INFO] Building Tigase XMPP Server 5.1.0 5.2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3:install-file (default-cli) # tigase-server ---
[INFO] Installing /home/haider/Downloads/tigase-muc-2.2.0.jar to /
home/haider/.m2/repository/tigase/tigase-muc/2.2.0/tigase-muc-2.2.0.jar
[INFO] --------------
[INFO] BUILD SUCCESS
[INFO] -------------
[INFO] Total time: 0.791s
[INFO] Finished at: Mon Aug 05 18:06:48 PKT 2013
[INFO] Finished at: Mon Aug 05 18:06:48 PKT 2013
[INFO] ----------------------
From above BUILD SUCCESS message i assume that JAR file is correctly added , but when i add following dependency in POM file
<dependency>
<groupId>tigase</groupId>
<artifactId>tigase-xmltools</artifactId>
<version>3.3.6</version>
<scope>compile</scope>
</dependency>
It give me following error Missing artifact tigase:tigase-muc. This message clearly indicate that it didn't get the JAR file that i am referring in dependency
You Contribution will be highly appreciated THANKS
It looks like it installs the Jar like this: [INFO] Installing /home/haider/Downloads/tigase-muc-2.2.0.jar to /
home/haider/.m2/repository/tigase/tigase-muc/2.2.0/tigase-muc-2.2.0.jar
As maven works, its group id is resolved to be ''tigase'', artifactId is ''tigase-muc'', version is ''2.2.0''
So this is right.
Now, I've took a look on tigase:tigase-xmltools:3.3.6 available here
It doesn't define any dependency at all.
So it looks like this would happen even if you don't specify this dependency :)
I would suggest you to run mvn dependency:tree to see where does this dependency comes from
Hope this helps
A more complete error message would help narrow down what's gone wrong. The artifact you installed should be resolvable via the following dependency:
<dependency>
<groupId>tigase</groupId>
<artifactId>tigase-muc</artifactId>
<version>2.2.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
You're reference tigase-xmltools which I'm assuming has a dependency on tigase-muc.
My guess is tigase-xmltools might have dependency on the actual pom of tigase-muc, which you don't have despite having the jar. Seeing the full error message and the pom of tigase-xmltools.
Installing the file with -DgeneratePom=true might help.
Well, if you have added the jar in maven dependencies, then it should be added in Maven Dependencies automatically.
Do you get any specific error while building the project? if yes then can you please share the error trace.
Also have a look at Maven Dependency Scope
Also, verify your local maven repository - M2_HOME\tigase\tigase-xmltools\3.3.6\ and check if the jar is installed here properly.
You can install external jars in local repository.
Here is a blog -
http://findnerd.com/list/view/External-Dependencies-in-Maven-Project/3501/
Hope this would help you.
My solution is use the embed lib repo:
and add local lib:
<dependencies>
<dependency>
<groupId>ok</groupId>
<artifactId>comet4j-tomcat7</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>lib</id>
<name>lib</name>
<url>file://${basedir}/lib</url>
</repository>
</repositories>

Redeploy existing Nexus artifact to Weblogic

I have a Hudson build job that builds a Maven project, and redeploys the resulting artifact to Nexus and to a remote Weblogic instance for testing. I'm trying to create a separate job that would deploy the same artifact to another Weblogic instance, but to do so without recompiling the project and making a new WAR. The rationale here is, the bits already exist and were tested in the development environment, and only if that passes can they be promoted to the development-integration environment. Is this possible?
So far, I have tried:
1) using the existing POM and on the command line and declaring mvn deploy wls:undeploy wls:deploy - This deploys the project WAR to the new environment but also builds the project from scratch. The deploy goal also replaces the previously built project artifact (a snapshot) in Nexus, which makes sense.
2) Tried creating a new POM where the artifact from the previous build is a dependency, and the wls-maven-plugin is the only plugin declared. Running mvn wls:deploy here also fails, for different reasons.
Is there a way to perform such a deployment in a concise manner that I'm missing? Am I using the wrong mechanism (Maven) for this? Should I be using a more procedure based language like Ant? Any insight would be greatly appreciated. (Also if more information is required, please let me know!)
Edit: The redeployment succeeds if the built artifact is locally available in the target directory, and that location is referenced by the properties file. According to the documentation on Oracle's website that parameter can either be local or GAV coordinates. If I use GAV coordinates to pull the artifact directly from Nexus and then push it out to the remote Weblogic, I get the following Maven error:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MyWebApp 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- wls-maven-plugin:12.1.1.0:redeploy (default-cli) # MyWebApp-deploy-DIT ---
[INFO] ++====================================================================++
[INFO] ++ wls-maven-plugin: redeploy ++
[INFO] ++====================================================================++
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.480s
[INFO] Finished at: Wed Mar 20 10:19:22 EDT 2013
[INFO] Final Memory: 4M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.oracle.weblogic:wls-maven-plugin:12.1.1.0:redeploy (default-cli) on project MyWebApp-deploy-DIT: Invalid file. Please provide an existing fully qualified path of the file. -> [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.
[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/MojoExecutionException
For completeness, I'm also posting the POM I'm using to perform option #2:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>MyWebApp</name>
<parent>
<groupId>org.myorg.maven</groupId>
<artifactId>MyOrg-Parent</artifactId>
<version>2.0</version>
</parent>
<groupId>org.myorg.apps</groupId>
<artifactId>MyWebApp-deploy-DIT</artifactId>
<version>0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<drools.version>5.4.0.Final</drools.version>
<REGION>DEV</REGION>
<MyWebApp_LOGDIR>.</MyWebApp_LOGDIR>
<webapp.jsp.dir>src/main/webapp/WEB-INF/jsp</webapp.jsp.dir>
<buildMsgJsp>buildMsg.jsp</buildMsgJsp>
<DEPLOYMENT_NAME>MyWebApp</DEPLOYMENT_NAME>
<MIDDLEWARE_HOME>/ci/oracle/middleware</MIDDLEWARE_HOME>
<WLS_ADMIN_HOST>lncibd008</WLS_ADMIN_HOST>
<WLS_PORT>7001</WLS_PORT>
<STAGE>true</STAGE>
<!--<SOURCE>${project.build.directory}/MyWebApp-3.7-SNAPSHOT.war</SOURCE>-->
<SOURCE>org.myorg.apps:MyWebApp:war:3.7-SNAPSHOT</SOURCE>
<WLS_TARGETS>server1</WLS_TARGETS>
</properties>
<dependencies>
<dependency>
<groupId>org.myorg.apps</groupId>
<artifactId>MyWebApp</artifactId>
<version>3.7-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.oracle.weblogic</groupId>
<artifactId>wls-maven-plugin</artifactId>
<version>12.1.1.0</version>
<configuration>
<weblogicHome>wlserver_12.1</weblogicHome>
<upload>true</upload>
<remote>true</remote>
<stage>${STAGE}</stage>
<verbose>true</verbose>
<userConfigFile>wlsconfig/${WLS_ADMIN_HOST}${WLS_PORT}.config</userConfigFile>
<userKeyFile>wlsconfig/${WLS_ADMIN_HOST}${WLS_PORT}.key</userKeyFile>
<adminurl>http://${WLS_ADMIN_HOST}:${WLS_PORT}</adminurl>
<targets>${WLS_TARGETS}</targets>
<source>${SOURCE}</source>-->
<name>${DEPLOYMENT_NAME}</name>
<middlewareHome>C:\Oracle\Middleware</middlewareHome>
</configuration>
</plugin>
</plugins>
</build>
</project>
As you can see I have a commented-out and a GAV . Local one succeeds, GAV fails with the above error.

maven can't find archetype in my repository

I'm trying to create my own maven archetype. For now, I'm going through this tutorial [here][1] without success. I'm able to build the archetype project okay, but when I try to generate a project from that archetype I get the error below. Maven can't seem to find the archetype I created. Can any one spot my problem? Is there some other recomended tutorial for createing a maven archetype? Thanks.
Maven version 3.0.3
Build Error:
AR3Y35-LAPTOP:EclipseWS Albert$ mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeGroupId=com.myarch.archetypes -DarchetypeArtifactId=component-archetype -DinteractiveMode=false
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.0:generate (default-cli) # standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.0:generate (default-cli) # standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.0:generate (default-cli) # standalone-pom ---
[INFO] Generating project in Batch mode
[WARNING] Specified archetype not found.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.389s
[INFO] Finished at: Fri Sep 23 02:33:55 PDT 2011
[INFO] Final Memory: 7M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.0:generate (default-cli) on project standalone-pom: The desired archetype does not exist (com.myarch.archetypes:component-archetype:1.0) -> [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.
[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
AR3Y35-LAPTOP:EclipseWS Albert$
prototype 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.myarch.templates</groupId>
<artifactId>component-template</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
<name>${group}</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
archetype.xml
<archetype xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0 http://maven.apache.org/xsd/archetype-1.0.0.xsd">
<id>component-archetype</id>
<sources>
<source>src/main/java/App.java</source>
</sources>
<testSources>
<source>src/test/java/AppTest.java</source>
</testSources>
<allowPartial>true</allowPartial>
</archetype>
For using a customized archetype, there has to be an entry made in the archetype-catalog.xml file which resides in the .m2/repository/archetype-catalog.xml in your home directory. For doing so, you need to install the archetype by using the following command:
mvn install archetype:update-local-catalog
After that, you will be able to use your new archetype while creating a new Maven project with the mvn archetype:generate command.
I needed to include -DarchetypeVersion={my.archetype.version} in the mvn archetpe:generate command
In my case the problem was that:
- update-local-catalog goal created file ~/.m2/repository/archetype-catalog.xml
- generate goal searches for file ~/.m2/archetype-catalog.xml
copying the file was a workaround. Not sure how I've fixed this. Sure now with maven 3.5.4 everything is ok.
It's telling you :
[WARNING] Specified archetype not found.
Did you install your archetype with
mvn install
before trying to use it ?
Executing the mvn install resolves the problem, after executing that from idea the problem got resolved.
From my own experience, You have to search for your groupId is accessible in the below link or not
http://repo.maven.apache.org/maven2/archetype-catalog.xml
I found out I had typo error then I've got error.

Resources