I recently moved to maven project and since then I found adding dependencies very difficult. Before that I just needed to download the jar and add to library folder .
Now I am searching flash-selenium.jar dependency but I failed to find any. So I added it manually in my C:.m2\repository\org\seleniumhq\selenium\flash-selenium folder but still it is giving error. So how can I use this jar in my maven project?Its a request to people those have 1500 points here , could you please create a label for selenium flash related problems. Thanks
There's no flash-selenium dependency in maven central, but there are other artifacts like:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium</artifactId>
<version>2.0rc2</version>
</dependency>
the complete list:
http://search.maven.org/#search|ga|1|selenium
Maybe some of this fits what you need.
Related
I am writing one utility job in java to download JSON files from particular URL of Gitlab account and further process them according to requirement. I tried to do same using java-gitlab-api dependency. However, even after including below maven dependency,
I get error as :
Missing artifact org.gitlab:java-gitlab-api:jar:1.1.8-
The import org.gitlab cannot be resolved.
Maven dependency I am using is :
<dependency>
<groupId>org.gitlab</groupId>
<artifactId>java-gitlab-api</artifactId>
<version>1.1.8-SNAPSHOT</version>
</dependency>
I tried to update, clean maven project but nothing worked. Anyone has an idea of how can I rectify issues and download files from gitlab account.
Use appropriate maven java-gitlab-api version(s). There is most recent version is available too.
https://mvnrepository.com/artifact/org.gitlab/java-gitlab-api/1.1.8
https://mvnrepository.com/artifact/org.gitlab/java-gitlab-api
<!-- https://mvnrepository.com/artifact/org.gitlab/java-gitlab-api -->
<dependency>
<groupId>org.gitlab</groupId>
<artifactId>java-gitlab-api</artifactId>
<version>1.1.8</version>
</dependency>
I have tried to search web for the problem I am facing but maybe I am not asking google the right question so here I am.
I am using IntelliJ IDEA for my multi-module project. For one of my modules, one of the class file is using a static import -
import static javax.ws.rs.core.Response.Status.Family.familyOf;
Being a big project, there are a lot of dependencies downloaded from internal repo but for some reason IntelliJ refuses to use the dependency "javax.ws.rs-api-2.0" instead it is using "jersey-core-1.8". Because of this it is throwing a compilation error saying Cannot find symbol "familyof".
I looked into Response.java from both the dependencies and found that jersey dependency does not have familyof method while javax.ws.rs-api-2.0 has it but IntelliJ doesnt use this dependency. How do I fix this problem. Most of the developers in my team are using Eclipse and they do not have this problem. I am trying to get used to IntelliJ IDE but cant seem to figure a way out of this. Any help in this regard is much appreciated.
PS - This issue does not occur in Eclipse IDE.
I could resolve this issue by following the below mentioned steps -
Goto "Open Module Settings" Command+Down arrow key
Select Dependencies tab
Search for the above two dependencies in the list
Move "javax.ws.rs-api-2.0" dependency up to ensure this dependency is above "jersey-core-1.8" dependency.
I don't think this is a permanent solution but it seemed to work. if someone with in-depth knowledge of Java/Mave/IntelliJ has an answer to this question that would be great!
You may be able to get the right result every time with Maven by shuffling around the dependencies in the pom.xml, and make sure the dependency you want to take precedence is declared first in the list of dependencies. yes, the order in which the dependencies are declared in pom.xml matters !
Then, if all of you are using the same Maven version, you should have a consistent result.
How does Maven choose between two versions of a same dependency?
As explained here, Maven chooses the first met dependency that's why it works when you change the order of the dependency in the pom.
How to find Maven dependencies conflicts?
In a terminal, in the pom folder :
mvn dependency:tree -Dverbose | grep "conflict"
will give you all the dependencies in conflict in your project.
With Eclipse IDE, click on the pom and on the Dependency hierarchy tab. Then, fill the Filter field with a dependency. On the left side, you will see the conflicts (like with mvn dependendy:tree, with filtered results) and on the right side, the dependencies chosen.
With IntelliJ, the documentation of IntelliJ can help you. There is a diagram view to find the conflicts.
How to resolve Maven dependencies conflicts?
Add dependencyManagement tag in the pom to tell Maven which dependency you want
Example :
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>
<dependencies>
</dependencyManagement>
Change the order of the dependency in the pom
Add an exclusion of the dependency
Example :
<dependency>
<groupId>com.my.groupid</groupId>
<artifactId>my-artifact-id</artifactId>
<version>1.2.2</version>
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
</exclusions>
</dependency>
Why is there a difference between IntelliJ and Eclipse?
You can add a dependency to a module without adding it to the pom as explained in the documentation of IntelliJ. It's probably possible with other IDE.
IntelliJ IDEA lets you add a Maven dependency to your project. We recommend that you specify the dependency inside your POM. Dependencies that you set up manually inside IntelliJ IDEA module settings will be discarded on the next Maven project import.
The Maven plugin in Eclipse (M2Eclipse) may load dependencies differently compared to mvn
Please, read the documentation of IntelliJ to configure the project dependencies easily.
I need to add the package "uk.ac.shef.wit.simmetrics.similaritymetrics"
to my maven project but I am not able to find any remote repository which contains it. I have to add it via dependency to the project, but not successful yet.
-I already added the jar file to the referenced library but in that wat I get the following error:
package uk.ac.shef.wit.simmetrics.similaritymetrics does not exist.
-Adding it through following dependency to the Pom.xml also does not help
<dependency>
<groupId>uk.ac.shef.wit</groupId>
<artifactId>simmetrics</artifactId>
version>1.6.2</version>
<scope>system</scope>
<systemPath>LocalPath\simmetrics-1.6.2.jar</systemPath>
</dependency>
Any help is appreciated!!
If this is a small project that you intend to only build locally or on a few machines then the simplest way is follow directions at the site below to add a 3rd party jar. Those instructions will help you install it in your local repository. You will need to do that for all machines that you intend to run the build on.
https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
If you plan to run it on many machines then the best thing to do is to install the artifact to your own private repository. If that is the case then I suggest you create a project for it in version control. Then upload the file as part of that project.
I appear to be the current maintainer of Simmetrics. You can add this dependency to your pom file.
<dependency>
<groupId>com.github.mpkorstanje</groupId>
<artifactId>simmetrics-core</artifactId>
<version>4.0.1</version>
</dependency>
Simmetrics has been given a much needed serious overhaul since 1.6.2. You may have to adjust your code accordingly. For source code and documentation see https://github.com/Simmetrics/simmetrics
I have built a non-maven project to display crystal reports with all necessary jars imported to the lib folder.
But, when I try to find the dependencies to add the same jars into my pom.xml for a maven project, I was not able to look it up online.
How can I find the crystal report dependencies for a maven project ? How to determine groupId and artifact for the crystal jar?
Below is the snapshot of jars I am looking for. Please suggest.
I tried looking into this link in the SCN but couldn't find much details.
You can specify your local jars as maven dependency using "system" scope
<dependency>
<groupId>group.id</groupId>
<artifactId>artifact</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${lib.path}/some_1.0.jar</systemPath>
</dependency>
define 'lib.path' in properties
Below are two solutions : One is pointing to local jars with system scope and the other is deploying the jars into m2. I felt the second solution more reliable.
First solution: I followed the link here ; but couldn't get it entirey working. So changed the scope to system and pointed to the local jars and was able to finally access the classes.
Please see below for the pom.xml
<dependency>
<groupId>com.sap.crystalReports</groupId>
<artifactId>CrystalCommon2</artifactId>
<version>1.0.0-RT</version>
<scope>system</scope>
<systemPath>${lib.path}/CrystalCommon2.jar</systemPath>
</dependency>
.....
Second solution is, from the comment in the question above, I came up with the idea of deploying all the crystal jars, one by one, which I downloaded on my local into my local m2 repository.
mvn deploy:deploy-file -DgroupId=com.crystalruntime.sdk -DartifactId=JDBInterface
-Dversion=1.5 -Dfile= point-to-the-jar-location-on your-local\JDBInterface.jar
-Dpackaging=jar -Durl=file://point-to-local-m2 repository
groupId, artifactId,version- can be modified, but it is good to keep consistency and readability, with the names chosen.
Run this command on any/all the jars that you want to install into m2. I then updated the project and did another clean build and was able to successfully run then application.
Also, I did remove the system scope from the pom.xml
<scope>system</scope>
<systemPath>${lib.path}/JDBInterface.jar</systemPath>
and modified it according to :
<dependency>
<groupId>com.crystalruntime.sdk</groupId>
<artifactId>JDBInterface</artifactId>
<version>1.5</version>
</dependency>
This made more sense to me, to use in the maven project.
This is the link I followed for reference.
How do I take a jar file that I have and add it to the dependency system in maven 2? I will be the maintainer of this dependency and my code needs this jar in the class path so that it will compile.
You'll have to do this in two steps:
1. Give your JAR a groupId, artifactId and version and add it to your repository.
If you don't have an internal repository, and you're just trying to add your JAR to your local repository, you can install it as follows, using any arbitrary groupId/artifactIds:
mvn install:install-file -DgroupId=com.stackoverflow... -DartifactId=yourartifactid... -Dversion=1.0 -Dpackaging=jar -Dfile=/path/to/jarfile
You can also deploy it to your internal repository if you have one, and want to make this available to other developers in your organization. I just use my repository's web based interface to add artifacts, but you should be able to accomplish the same thing using mvn deploy:deploy-file ....
2. Update dependent projects to reference this JAR.
Then update the dependency in the pom.xml of the projects that use the JAR by adding the following to the element:
<dependencies>
...
<dependency>
<groupId>com.stackoverflow...</groupId>
<artifactId>artifactId...</artifactId>
<version>1.0</version>
</dependency>
...
</dependencies>
You can also specify a dependency not in a maven repository. Could be usefull when no central maven repository for your team exist or if you have a CI server
<dependency>
<groupId>com.stackoverflow</groupId>
<artifactId>commons-utils</artifactId>
<version>1.3</version>
<scope>system</scope>
<systemPath>${basedir}/lib/commons-utils.jar</systemPath>
</dependency>
Actually, on investigating this, I think all these answers are incorrect. Your question is misleading because of our level of understanding of maven. And I say our because I'm just getting introduced to maven.
In Eclipse, when you want to add a jar file to your project, normally you download the jar manually and then drop it into the lib directory. With maven, you don't do it this way. Here's what you do:
Go to mvnrepository
Search for the library you want to add
Copy the dependency statement into your pom.xml
rebuild via mvn
Now, maven will connect and download the jar along with the list of dependencies, and automatically resolve any additional dependencies that jar may have had. So if the jar also needed commons-logging, that will be downloaded as well.
I'd do this:
add the dependency as you like in your pom:
<dependency>
<groupId>com.stackoverflow...</groupId>
<artifactId>artifactId...</artifactId>
<version>1.0</version>
</dependency>
run mvn install it will try to download the jar and fail. On the process, it
will give you the complete command of installing the jar with the error message. Copy that command and run it! easy huh?!
I'll assume that you're asking how to push a dependency out to a "well-known repository," and not simply asking how to update your POM.
If yes, then this is what you want to read.
And for anyone looking to set up an internal repository server, look here (half of the problem with using Maven 2 is finding the docs)