i'm kinda new to maven after coming from a simple yet uncouth ant world.
<dependencies>
<dependency>
<groupId>com.foo.bar.EPT</groupId>
<artifactId>EPTUtils</artifactId>
<version>1.2.9-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
I'm looking for a maven command to specifically update this version to 1.2.14-SNAPSHOT. I've tried
mvn -DallowSnapshots=true versions:use-latest-snapshots -Dincludes=com.foo.bar.*
but that didn't update what i had in my local repo.
Change
<version>1.2.9-SNAPSHOT</version>
to
<version>1.2.14-SNAPSHOT</version>
in the pom.xml of your Maven project. Then build the project.
mvn clean test package
Maven will download the dependency and store it in your local ~/.m2 repository.
Edit: Also see How do I tell Maven to use the latest version of a dependency? for more information about Maven and latest versions.
Edit 2: You can use the Versions Maven Plugin that as goals that can help you with that.
Related
I am trying to upgrade to Selenum 4.0.0-alpha-6 (same issue happens also with version 3.141.59) which seems to be available in Maven repository. I tried first to add this dependency to my pom.xml:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0-alpha-6</version>
</dependency>
The version appears red in IntelliJ which for some reason sees 3.12.0 as the last available version. I know what version IntelliJ sees because I can hit CTRL-space inside the <version> tag.
Running mvn install also complains that the version is not available. So my first question is why do Intellij and Maven not see the latest versions of Selenium?
I reverted to downloading the jar file directly from mvnrepository (that is from here) and adding it to my local repository as follows:
mvn install:install-file -Dfile=selenium-java-4.0.0-alpha-6.jar
-DgroupId=org.seleniumhq.selenium -DartifactId=selenium-java
-Dversion=4.0.0-alpha-6 -Dpackaging=jar -DgeneratePom=true
The jar appears now in my local repo, the Maven dependency does not appear red anymore, but all Selenium-related references in my project appear red. Examining the downloaded jar file reveals that it contains no Java classes:
C:\Development\Java\Selenium>jar tf selenium-java-4.0.0-alpha-6.jar
META-INF/
META-INF/MANIFEST.MF
META-INF/versions/9/
META-INF/versions/9/module-info.class
Any idea what I am missing?
Update: I have added a small project in GitHub that demonstrates the problem. The pom just has the Selenium dependency.
Just running mvn install results in the error below. So this is not just a problem with IntelliJ:
[ERROR] Failed to execute goal on project MySeleniumProject: Could not resolve dependencies for project com.my:MySeleniumProject:jar:1.0-SNAPSHOT: Failed to collect dependencies for [org.seleniumhq.selenium:selenium-java:jar:3.141.59 (compile)]: Failed to read artifact descriptor for org.seleniumhq.selenium:selenium-ja
va:jar:3.141.59: Could not transfer artifact org.seleniumhq.selenium:selenium-java:pom:3.141.59 from/to central (http://repo.maven.apache.org/maven2): Failed to
transfer file: http://repo.maven.apache.org/maven2/org/seleniumhq/selenium/selenium-java/3.141.59/selenium-java-3.141.59.pom. Return code is: 501 , ReasonPhras
e:HTTPS Required.
Try use stable older version
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
Check also, if you have other errors in pom, and have proper java version
I think your project is correct and problem is with maven configuration. Use commandline to see what maven version you have? maven -v. Try use mvn dependency:resolve on the project - from command line
The problem is resolved by upgrading maven. I had Maven 3.0.5, and uprading to 3.6.3 resolved the dependency successfully.
IntelliJ Maven pom.xml I get the following message:
Dependency org.xerial:sqlite-jdbc:3.8.11.1 not found.
How can I fix my problem? This is the only dependency in my pom.xml which doesn't work.
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.8.11.1</version>
</dependency>
after testing in a new Maven Test Project, it works now in my main projec. Thank
Check correctness artifact properties as group artifact and version, if they correct this mean your artifact is not in maven central repo you need manually add new repository in you pom.xml where this artifact present. If you artifact in maven central try to load them manually if you use maven not bundled in intellij install
-> open console in idea with alt + f12 then type mvn dependency:resolve
update
your artifact in central repo, https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc/3.8.11.1
Sometimes i meet this bug in Idea (Idea does not see this dependency because it does not indexed by Idea or something like this, version of artifact highlight red but it is only idea deal) add manually this dependency or try to recheck (clear caches) and all will be work.
I have a maven dependency which requires org\drools\drools-compiler 4.0.3 (drools-compiler 4.0.3 is not mentioned in my pom.xml but gets downloaded as a dependency). Now I am trying to integrate Drools framework with Spring. This requires me to use drools-spring 5.4.0.Final jar. Hence I have added the below pom entry.
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-spring</artifactId>
<version>5.4.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.4.0.Final</version>
</dependency>
Now when I run a mvn clean install , I see the dependency drools-spring and corresponding dependencies (drools-compiler 5.4,drools core 5.4) getting downloaded, but however after doing mvn eclipse:eclipse, I still dont find the new dependencies showing up under maven dependencies in Eclipse classpath. In fact I still see the old 4.0.3 version under dependencies for drools-compiler and drools-core. I have tried an eclipse restart. Doesnt help either. How do I show the new 5.4 version jar instead of the 4.0.3 ?
As you mentioned you are using eclipse i will suggest to use maven eclipse plugin from eclipse market place.
When you will add maven plugin from eclipse you will able to see a Maven menu item when you will right click on the maven project then inside that menu you will able to see Update Maven project click on that.
If you do not want to do above two steps run the below command with -U.
Check below
mvn eclipse:eclipse -U
OR
mvn install -U
OR
mvn clean -U
See Maven: The Complete Reference, 6.1.11. Downloading and Verifying Dependencies or mvn --help:
-U,--update-snapshots Forces a check for missing
releases and updated snapshots on
remote repositories
Maven command with
I figured out I was adding the pom entries in the wrong pom.xml. Ideally the pom entries should be present in the service impl pom.xml.
This might be a naive question, so pardon me but I am new to maven.
I want to build a jar of project present on github. The project has a pom.xml file and additionally mentions in
Installation Note:
Releases are distributed on Maven central:
<dependency>
<groupId>some_grp_id</groupId>
<artifactId>all</artifactId>
<version>1.1.2</version>
<type>pom</type>
</dependency>
Am I suppose to add above in the existing pom.xml file ??
I an cloning the project on my desktop and then executing "mvn package".
If you want to simply use the library then you only have to add the above dependency to your pom.xml. Maven is doing all the rest for you (downloading the .jar-file).
If you really want to use the source code you have to do a
mvn install
on the checked out code. And also have to include the dependency in your own pom.xml.
I'm new to maven, sorry for nub question: need to build maven project using my version of artifact instead of the one from repo.
More detailed:
I downloaded jboss sources from github and built them using maven 3. It was great! I need to do some changes in jboss dependancy called "picketbox". Now it is an artifact in jboss's "pom.xml".
I built my own version of picketbox in my_picketbox.jar file. How can I tell maven to use my .jar instead of the one from repo?
Maybe I'm missing something but if you explicitly renamed the artifact then it will just be a matter of replacing picketbox with my_picketboxin the relevant JBoss POM-file(s).
<dependency>
<groupId>...</groupId>
<artifactId>my_picketbox</artifactId>
<version>...</version>
</dependency>
And of course, you make sure your artifact is in your local repo by mvn install'ing it.
Cheers,
i would install the jar file using the maven-install plugin.
http://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html
First, install your version of Picketbox into your local Maven repository. If your custom version is a Maven project, you can do that by running
mvn install
If your custom Picketbox version is not a Maven project, install the Jar itself into your local Maven repository like this:
mvn install:install-file -Dfile=my_picketbox.jar -DgroupId=org.picketbox -DartifactId=my_picketbox -Dversion=2.3 -Dpackaging=jar
Then change the version of Picketbox that JBoss depends on by adding this snippet to the pom.xml file of the JBoss project you're building (replace the existing dependency on pocketbox with this one):
<dependency>
<groupId>org.picketbox</groupId>
<artifactId>my_picketbox</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>xxx</groupId>
<artifactId>xxx</artifactId>
<version>x.x.x</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/xxxx.jar</systemPath>
</dependency>
This allows you to reference libaries that are not stored localy rather than maven central.
Maven takes what has been specified in POM files; mind you, that the POM including the dependency you wrote about can be buried very deeply, not even within the sources you downloaded.
Search your project tree for the artifact in question and replace its version number to your version. If this does not help, do as Nils says in the other answer, but remember to install the artifact in the original version (you may have to find it first in your local repository and remove it).