Add External JAR in Maven Dependency - maven

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>

Related

JOOQ Plugin in Maven pom.xml file

I'm trying to build the example given on the official JOOQ git repo here. The maven pom.xml file contains the following plugin for JOOQ:
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${org.jooq.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<jdbc>
<driver>${db.driver}</driver>
<url>${db.url}</url>
<user>${db.username}</user>
<password>${db.password}</password>
</jdbc>
<generator>
<target>
<packageName>com.learnd.jooq.db</packageName>
<directory>src/main/java</directory>
</target>
</generator>
</configuration>
</execution>
</executions>
</plugin>
However I'm not managing to mvn compile, the project, and I'm getting the following output because of the${org.jooq.version} variable in the <version> tag. But whenever I've seen this plugin inserted, I've seen it done this way, even here.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.jooq:jooq-spring-example:jar:3.10.0-SNAPSHOT
[WARNING] 'version' contains an expression but should be a constant. # org.jooq:jooq-spring-example:${org.jooq.version}, /home/lukec/Desktop/jOOQ-spring-example/pom.xml, line 8, column 14
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jOOQ Spring Example 3.10.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.jooq:jooq-codegen-maven:jar:3.10.0-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.213 s
[INFO] Finished at: 2017-09-18T03:47:16+02:00
[INFO] Final Memory: 6M/150M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.jooq:jooq-codegen-maven:3.10.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact org.jooq:jooq-codegen-maven:jar:3.10.0-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.
[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/PluginResolutionException
Can anyone help me with this? Cheers.
Its most likely because Maven cant find the jOOQ-codegen-maven 3.10.0-SNAPSHOT version in your local .m2. I checked the link from your question and I see the spring project and its dependent project jOOQ-codegen-maven in this link, https://github.com/jOOQ/jOOQ/blob/master/jOOQ-codegen-maven/pom.xml, so import this and build it, so that this version gets into your local .m2. And I see jOOQ-codegen-maven project has a parent jooq-parent, so you will probably need to build that as well for the dependencies to get resolved.
Once you have built and run jOOQ-codegen-maven and jooq-parent successfully, your local .m2 should have these dependencies, try building jooq-spring-example again and now the 3.10.0-SNAPSHOT dependencies should be resolved properly.
The above should most likely fix the issue but in case if it doesn't work, you could possibly try using the version from central, https://mvnrepository.com/artifact/org.jooq/jooq-codegen-maven/3.9.5 and see if that helps build your spring example.
There's no official release of 3.10.x jooq-codegen-maven plugin.
https://mvnrepository.com/artifact/org.jooq/jooq-codegen-maven
You should try using any one of them found in the above link.
I believe that the code gen 3.10.0-SNAPSHOT has yet to be released, along with the rest of the 3.10.0-SNAPSHOT.
If you need the functionality that has been developed and are comforatable using a library that has not been released yet,
git clone https://github.com/jOOQ/jOOQ
then run
mvn install
To build jooq 3.10.0-SNAPSHOT to your local repository. The example should run on your local machine. Beware that it will not work elsewhere (EX: jenkins machine).
If you do not feel comfortable using this unreleased code, use the latest published published published release version's example:
https://github.com/jOOQ/jOOQ/tree/version-3.9.0-branch/jOOQ-examples/jOOQ-spring-example
As the dependency graph expects 3.10.0-SNAPSHOT.

Jenkins: custom jar dependency issue

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.

Maven Could not resolve dependencies for hadoop project

I wanted to build the sample projects from hadoop book but I got "Could not resolve dependencies error".
Here is my Error during build:
[INFO] Building Chapter 2: MapReduce 3.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.apache.hadoop:hadoop-core:jar:0.23.10 is missing, no dependency information available
[WARNING] The POM for org.apache.hadoop:hadoop-test:jar:0.23.10 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Chapter 2: MapReduce .............................. FAILURE [1.409s]
[INFO] Hadoop: The Definitive Guide, Example Code ........ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.819s
[INFO] Finished at: Wed May 14 12:19:14 EEST 2014
[INFO] Final Memory: 6M/67M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project ch02: Could not resolve dependencies for project com.hadoopbook:ch02:jar:3.0: The following artifacts could not be resolved: org.apache.hadoop:hadoop-core:jar:0.23.10, org.apache.hadoop:hadoop-test:jar:0.23.10: Failure to find org.apache.hadoop:hadoop-core:jar:0.23.10 in https://repository.apache.org/content/repositories/releases/ was cached in the local repository, resolution will not be reattempted until the update interval of apache.releases has elapsed or updates are forced -> [Help 1]
and here is my pom.xml for ch02 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.hadoopbook</groupId>
<artifactId>hadoop-meta</artifactId>
<version>3.0</version>
<relativePath>../hadoop-meta/pom.xml</relativePath>
</parent>
<groupId>com.hadoopbook</groupId>
<artifactId>ch02</artifactId>
<packaging>jar</packaging>
<version>3.0</version>
<name>Chapter 2: MapReduce</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
</dependency>
</dependencies>
</project>
Any idea how can I build this code using maven and what the problem is ?
Thanks
What's happening is that Maven can't find the what it is looking for in the remote repository. So when it reaches out to Apache's Maven repository it's just not finding the resources for version 0.23.10 hadoop-test.
Particularly line #8 of the pom file in the question <relativePath>../hadoop-meta/pom.xml</relativePath> is directing Maven to look at hadoop-meta/pom.xml. On line #48 through #50 you'll see the specification for the hadoop-test repository:
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-test</artifactId>
<version>${hadoop.version}</version>
That ${hadoop.version} is the value that you specify in your maven command, ie 0.23.10.
So then maven goes out to the Apache repo and looks for hadoop-test v0.23.10, which isn't present. So then Maven falls over.
Now if you used a version that is present in the hadoop-test, or if you altered the pom files so that hadoop-test isn't a dependency.
I had this problem as well, it turned out it was because of NetBeans adding something to my pom.xml file. Double check nothing was added since previous successful deployments.

Unable to build sonar project. Error: Cannot find parent: org.codehaus.sonar:sonar

Trying to build our java app using sonar for analysis. We are behind a firewall so no access to maven repo1. We do have a internal corp Artifactory for third party artifacts and a project Artifactory for our local stuff. I am the SCM guy in charge of our build server, not a developer. That said the application with junit tests builds fine. We have two goals clean install. The sonar server is 3.5.1 and the port set to 8080 instead of 9000 This is in our pom.
<profile>
<id>sonarJsEnabled</id>
<properties>
<srcDir>src/main/static</srcDir>
<sonar.exclusions>libs/**/*,DSTCore/**/*,test/**/*</sonar.exclusions>
<maven.test.skip>true</maven.test.skip>
<sonar.language>js</sonar.language>
<sonar.branch>js</sonar.branch>
</properties>
</profile>
<profile>
<id>sonarHtmlEnabled</id>
<properties>
<srcDir>src/main/static</srcDir>
<sonar.language>web</sonar.language>
<sonar.branch>web</sonar.branch>
<sonar.web.fileExtensions>html,xhtml,jspf,jsp</sonar.web.fileExtensions>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- SERVER ON A REMOTE HOST -->
<sonar.host.url>http://10.226.xx.xx:8080</sonar.host.url>
</properties>
</profile>
and this:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>1.0-beta-2</version>
</plugin>
We add sonar:sonar When we build manually or with Bamboo we get this output.
C:\sonartest>mvn sonar:sonar
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'sonar'.
[INFO] org.apache.maven.plugins: checking for updates from EnterpriseArchitectureRepo
[INFO] org.codehaus.mojo: checking for updates from EnterpriseArchitectureRepo
[INFO] artifact org.codehaus.mojo:sonar-maven-plugin: checking for updates from EnterpriseArchitectureRepo
[INFO] Ignoring available plugin update: 2.0 as it requires Maven version 3.0
[INFO] Ignoring available plugin update: 2.0-beta-2 as it requires Maven version 3.0
[INFO] Ignoring available plugin update: 2.0-beta-1 as it requires Maven version 3.0
[INFO] ------------------------------------------------------------------------
[INFO] Building fundTrader
[INFO] task-segment: [sonar:sonar] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [sonar:sonar {execution: default-cli}]
[INFO] Sonar host: http://10.226.xx.xx:8080
[INFO] Sonar version: 3.5.1
[INFO] Execute: org.codehaus.sonar:sonar-maven-plugin:3.5.1:sonar
Downloading: http://repository.corp.net:8080/artifactory/libs-release/org/codehaus/sonar/sonar/3.5.1/sonar-3.5.1.pom
[INFO] Unable to find resource 'org.codehaus.sonar:sonar:pom:3.5.1' in repository EnterpriseArchitectureRepo (http://repository.corp.net:8080/artifactory/libs-release)
...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Can not execute Sonar
Embedded error: Unable to build project for plugin 'org.codehaus.sonar:sonar-maven-plugin': Cannot find parent: org.codehaus.sonar:sonar for project: null:sonar-maven-plugin:maven-plugin:null for project null:sonar-maven-plugin:maven-plugin:null
Unable to download the artifact from any repository
Any help would be greatly apreciated.
I looks like the sonar-3.5.1.pom is not found. Consider adding Bintray's jcenter remote repository to your Artifactory (it has much more artifacts than Maven Center).
The simplest way to do it is to import the jcenter configuration from an Artifactory instance at repo.jfrog.org.
Just click on the Import -> Load and select jcenter from the list of loaded repository configurations.

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.

Resources