Including QRGen in pom.xml - maven

I'm developing app in spring + hibernate in maven and I need to make QR codes so
I've found this tutorial http://viralpatel.net/blogs/create-qr-codes-java-servlet-qr-code-java/
In that tutorial following libs are in use:
xzing and qrgen (net.glxn.qrgen)
I've added in pom.xml dependency on xzing and its running but qrgen needs his own repo so
I've included repository like on that page: http://kenglxn.github.com/QRGen/ :
but it seems that http://kenglxn.github.com/QRGen/repository is down
Anyone knows new (or exact) repo address or could tell me what I'm doing wrong

version 1.2 is now available from maven central http://search.maven.org/#artifactdetails%7Cnet.glxn%7Cqrgen%7C1.2%7Cjar
please use:
<dependency>
<groupId>net.glxn</groupId>
<artifactId>qrgen</artifactId>
<version>1.2</version>
</dependency>

Basically you have a third party JAR that is not available in a (public) repository. Best would be if you had a company wide repository that you use as proxy. It is quite easy to set up Nexus for this task. Then you can import the JAR to that repository (e.g. Nexus has a default "3rd party library" repository setting). If you don't have such a repository you need to import the JAR to your local repository but this restricts successfull builds to your machine - obviously not what you want when you use Maven. See here for the syntax for a local import.
Of course you could set up a network drive as a company wide repo, some think this is easier than setting up Nexus or any other repo server. Trust me, it is not worth it, do it the right way from the beginning.

Related

How to fix The POM for XXX:jar:1.0 is missing, no dependency information available

We tried to build our project(Spring Boot 2.0.3 with Maven 3.3.9 dependency management)Jenkins Tool(Linux environment).Its saying build failure showing the following message in console "The POM for org.actus:ACTUS-Core-1.0:jar:1.0 is missing, no dependency information available".ACTUS is our custom java library developed by us and its in the local repository also.
This is the first time we started using Jenkins Tool. There are some other modules which depends on this same ACTUS jar.Those are also failing.I have searched for solution on internet.Some people said,make changes to settings.xml file.But in our development machine ,we cant find any such type of settings.xml file(in .m2)
remaining all dependencies are normal spring boot dependencies only.This is the only one external or custom jar.Using mvn install, we kept in maven local repo.
<dependency>
<groupId>org.actus</groupId>
<artifactId>ACTUS-Core-1.0</artifactId>
<version>1.0</version>
</dependency>
I will try to explain as much I can to solve your problem. I hope you are looking for settings.xml to update your maven Nexus repository. If you don't know about nexus repository, it's kind of public repo where you will get all open source dependency.
In your case, from your organization, you should have a private nexus repository and upload ACTUS-Core jar to there.
Then update your settings.xml file to use your company nexus repository. (Please check comments, it will be available in M2_HOME location)
So while you execute mvn install automatically it will upload in your private repository.
Now, in your pom.xml mention the same nexus repository. (It's optional)
Then, in your Jenkins script, you have updated this nexus repo.
So, the key point is you should have your own repo to upload ACTUS-Core jar and need to access the same while you building in Jenkin tool.
OR ELSE
If you find all the above activities in pain / not possible then I can suggest a short cut solution.
Create a lib folder under your project name ( same hierarchy as src) then add your ACTUS-Core.jar and commit that file along with your source code.
Then, update your pom file like below. It will work.
<dependency>
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<version>11.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/fileName.jar</systemPath>
</dependency>

selenium-central-framework in pom.xml

I am not able to find any hint about the issue that I am facing and hence posting my question here. Please apologize if it is something silly.
I have some working experience in selenium webdriver. However in my new project, I was asked to use an existing Selenium framework.
In the pom.xml, I am seeing the below dependency (I have edited xxx to avoid displaying the company name)
<dependencies>
<dependency>
<groupId>com.xxxqa.selenium</groupId>
<artifactId>selenium-central-framework</artifactId>
<version>2.0.18</version>
</dependency>
Question :
I couldn't understand from where that dependancy was taken from ?
Solution Tried :
I have tried searching in the maven repository still couldn't find
anything related to "selenium-central-framework"
I have checked the dependencies of selenium RC, but they seems to be different from the one that is present above.
I have researched whether any local jars were used and were linked
as dependancy. However I understand from maven repository, local
repositories will be linked with the tag "systemPath"
<dependency>
<groupId>ldapjdk</groupId>
<artifactId>ldapjdk</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${basedir}\src\lib\ldapjdk.jar</systemPath>
</dependency>
</dependencies>
Note that the depedency used in my project doesn't have the tag "systemPath".
Is there anyway the external repositories could be added without mentioning systemPath ??
Please help, what could be that dependency ? How to find more information about it. Thanks a ton for your help.
I suggest you one of these approaches:
Jar file
If you have access to the jar file called : selenium-central-framework-2.0.18.jar, open a command line pointing to the folder of this jar and execute:
mvn install:install-file \
-Dfile=selenium-central-framework-2.0.18.jar \
-DgroupId=com.xxxqa.selenium \
-DartifactId=selenium-central-framework \
-Dversion=2.0.18 -Dpackaging=jar
Source code file
If you have the source code of : selenium-central-framework-2.0.18.jar, open a command line pointing to the folder of this source code and execute:
mvn clean install
After one of these approaches, selenium-central-framework-2.0.18.jar will be available in you local maven repository ($HOME/.m2) and your other java maven projects will be ready to use it as dependency:
<dependency>
<groupId>com.xxxqa.selenium</groupId>
<artifactId>selenium-central-framework</artifactId>
<version>2.0.18</version>
</dependency>
This is a workaround if you don't have a server to host an artifact repository management server like :
https://www.sonatype.com/nexus-repository-sonatype
https://www.jfrog.com/confluence/display/RTF/Maven+Repository
Explanation
Almost all free, public, safe, useful and cool java libraries are hosted in https://mvnrepository.com . So any person in the world can use it in their maven project with this piece in their pom.xml:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
But in some cases, publish your source code to https://mvnrepository.com is not an option:
Oracle Driver. This driver (.jar) can only be downloaded from the official Oracle page. Private source code like IBM, Microsfot,etc
Source code of your company that should not be public.
Some super cool library that is only in github but not in the maven central repository.
So in this cases, the best and scalable solution is host and configure some artifact repository management server like :
https://www.sonatype.com/nexus-repository-sonatype
https://www.jfrog.com/confluence/display/RTF/Maven+Repository
This platforms are an emulation of https://mvnrepository.com . So with a minimal configuration:
You can host your special or private jars
Your maven projects could use this jars with the standrad xml dependency in pom.xml.
If you don't have a server to implement one of these platforms, the previous approaches could help you and get the same results

WebLogic client jar

I want to use Java with JMX to monitor WebLogic. I need to use wlclient.jar which is provided into WebLogic lib directory.
Is there any maven repository which I can use to download the wlclient.jar?
The only way that I found is to manually import the jar file into my repository but this is not a option for me.
Another alternative is to create an in-project repository. This makes your project truly portable. This method is similar to the 'Use Dependency with system scope' mentioned by A. Di Matteo, except that it has the added benefit of being able to use any scope (and not just 'system').
I had the same issue as you, using a jar which was not available in Maven Central and after exploring all of the possible options, I settled on the in-project repository which I believe is better that system-scoping a dependency since it frees you to choose the scope.
Steps to do this:
Create a sub-directory called 'lib' in your project
Add this lib as a repository in your pom
<repositories>
<repository>
<id>lib</id>
<name>In Project Repo</name>
<url>file://${basedir}/lib</url>
</repository>
</repositories>
Install the artefact to your lib directory:
mvn install:install-file -Dfile=myArtifact.jar -DgroupId=x.y.z -DartifactId=${artifactId} -Dversion=${version} -Dpackaging=jar -DgeneratePom=true
And, finally use the dependency like you would use any other dependency
<dependencies>
....
<dependency>
<groupId>x.y.z</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</dependency>
</dependencies>
If you can't find the jar in any Maven repository, you could apply any of the following actions, depending on your needs:
Internal Maven Repository
If you don't have an internal repository (like Artifactory or Nexus), normally used in companies as internal maven cache/proxy/point-of-control, but could also be an option to install it and run it locally.
You could then upload the library there, providing Maven GAV (GroupId, ArtifactId, Version) and make Maven pointing to it as a repository (for your, for your CI server if any, for your colleagues if any). You can then add the library as standard maven dependency.
This solution has longer set-up, but better maintainability.
Install the library in local cache
You could use the Maven Install Plugin and install the library to your local cache, as shown by this official example.
Basically, you could run the following command:
mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=path-to\wlclient.jar -DgroupId=weblogic -DartifactId=wlclient -Dversion=1.0.0 -Dpackaging=jar
It will copy the library to your local Maven cache with standard Maven GAV. However, as above, you should make sure to replicate the same set up on any CI server and any team mate machine as well. You can then add the library as standard maven dependency.
This solution has quicker set-up, but lower maintainability though.
Both solutions however affect the portability of your build (build would fail if someone tries to build it outside of your company network or team).
Use dependency with system scope
You can have the jar as part of your project and point at it via the system scope for that dependency.
<dependency>
<groupId>weblogic</groupId>
<artifactId>wlclient</artifactId>
<version>1.0.0</version>
<systemPath>${basedir}/path/to/library/wlclient-1.0.0.jar</systemPath>
<scope>system</scope>
</dependency>
You should rename the jar though in order to be compliant with Maven conventions.
This solution is more portable, requires much less set-up, but again it needs to be maintained and requires a check-in of the concerned library as part of your versioned project (some may strongly disagree on this practice).

How to properly add a external library manually to a nexus local repository

I am trying to deploy an application using a local repository that is running through nexus.
What is the proper procedure to add manually an external jar library file?
I've tried to do it using the Nexus 3rd party repository but I am afraid that I am doing something wrong because I cannot use this library when I code.
What are the proper fields that I must use to fill the GAV definition?
Thank you.
Ok I am answering my own question to help others with similar problems.
I used custom maven coordinates in the GAV definition.
For example I used
groupId : com.thirdparty.vaadin
artifactId : vaadin-autocomplete
version : 1.0.0
Then all I had to do was to add these coordinates as a dependency to my project.
So I just added the following code to my pom.xml file.
<dependency>
<groupId>com.thirdparty.vaadin</groupId>
<artifactId>vaadin-autocomplete</artifactId>
<version>1.0.0</version>
</dependency>

How do I get OAuth's java client library with maven?

I'm trying to follow this guide here http://www.ibm.com/developerworks/web/library/wa-oauthsupport/index.html which gives information on how to use the OAuth client library provided by OAuth and HTTPClient 4 to authenticate your connection. I am working on a Java Swing CLIENT, NOT a OAuth PROVIDER.
OAuth provides a client library here on this page http://oauth.net/code/
I'm talking about the one marked by "A Java library and examples were contributed by John Kristian, Praveen Alavilli and Dirk Balfanz." which points to an SVN repository http://oauth.googlecode.com/svn/code/java/core/
I do not understand how to incorporate this library into my Eclipse project. I would like to just be able to add a maven dependency because it's so clean and works so well. I don't see coordinates readily available, and when I look at http://oauth.googlecode.com/svn/code/java/pom.xml I see the following coordinates but they don't work when I run the Maven build with the coordinates, and I get a "Missing artifact net.oauth:oauth-parent:jar:20100601" error in Eclipse's integrated Maven 3 pom.xml manager. I thought the entire point of Mavenizing a project was so that you could use its coordinates to pull it in.
<dependency>
<groupId>net.oauth</groupId>
<artifactId>oauth-parent</artifactId>
<version>20100601</version>
<packaging>pom</packaging>
</dependency>
I've tried the follow dependency after snooping around on the maven repository, and it didn't have all the classes/interfaces/etc I needed.
<dependency>
<groupId>net.oauth.core</groupId>
<artifactId>oauth</artifactId>
<version>20100527</version>
</dependency>
Is this the wrong way to incorporate this project? Is it not truly mavenized in a way that makes it easy to share? If I can't use Maven, what's the best path to follow to include this library into my project?
This is a bit of a repeat of How to include oauth library in Eclipse? but that question doesn't address the Maven aspect of it at all.
The OAUth libs doesn't seem to be available in Maven Central, so you have to add the following repository either to your settings.xml or to your pom.xml:
<repository>
<id>oauth</id>
<name>OAuth Repository</name>
<url>http://oauth.googlecode.com/svn/code/maven</url>
</repository>
I actually found the way to make it work with exactly your version of oauth-parent:
Create a directory and enter it:
mkdir oauth && cd oauth
Checkout code for your version:
svn co http://oauth.googlecode.com/svn/code/java/
Enter checked out directory (java), compile and deploy jars yourself:
cd java && mvn source:jar install
After that your dependency will work:
<dependency>
<groupId>net.oauth</groupId>
<artifactId>oauth-parent</artifactId>
<version>20100601</version>
<packaging>pom</packaging>
</dependency>

Resources