I have a multi module maven project with a parent POM which defines a few common dependencies as part of the dependency management as follows:
<dependency>
<groupId>com.example</groupId>
<artifactId>example-commons-core</artifactId>
<version>(1.2,)</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-commons-logging</artifactId>
<version>(1.3,)</version>
</dependency>
I have added this version format to avoid permanently update versions in the POM, when a new version of the core library is created.
My problem is that by each maven build, maven will check up all repositories for new version for each dependency I got following log entries:
Downloading from snapshots: https://example.com/repository/snapshots/com.example/example-commons-core/maven-metadata.xml
Downloading from release: https://example.com/repository/release/com.example/example-commons-core/maven-metadata.xml
Downloading from 3rdparty: https://example.com/repository/3rdparty/com.example/example-commons-core/maven-metadata.xml
Downloading from central: https://repo1.maven.org/maven2/com.example/example-commons-core/maven-metadata.xml
My question is can I do the checks for example monthly?
How to avoid that maven tries to check my own dependencies on maven central repository?
The modern way to solve the problem is to avoid version ranges but use the versions maven plugin (like versions:use-latest-releases).
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.
I configured a Jenkins to deploy the artifact to Jfrog (community). This is what I want to have and instead what I have.
I have a spring-boot maven project "maven-example" with version 0.0.1-SNAPSHOT.
Jenkins, due to the git push, start the building using the Build Environment : Maven3-Artifactory Integration
4.In Build : Invoke artifactory Maven and used clean install goals
All seems to be ok. The artifact is published to my local artifact repository but when I browse it, I see the jar with date appended like in this picture
In a 2nd spring-boot project which depends on the maven-example, I would like to have :
<dependency>
<groupId>com.example</groupId>
<artifactId>mavenexample</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
but I cannot retrieve the library if I do not use
<dependency>
<groupId>com.example</groupId>
<artifactId>mavenexample</artifactId>
<version>0.0.1-20200511.103423-1</version>
</dependency>
What I missed? (I already set the .m2 setting.xml to target my Jfrog)
Thank you in advance
What you are seeing is the expected behavior of Maven unique snapshots (as written by JF Meier in the comments).
Maven is using a high resolution timestamp to uniquely identify the snapshot version (this is the only supported snapshot type since Maven 3).
I deploy my maven project to maven private server. After introducing dependencies in other projects, the version of okhttp3 changed from 4.7.2 to 3.14.9
[The maven dependency of the deployed project:mdm-auth-spring-boot-starter][1]
[1]: https://i.stack.imgur.com/JQJe6.png
[Another project introduces mdm-auth-spring-boot-starter][2]
[2]: https://i.stack.imgur.com/YVFnI.png
Why the version of okhttp3 has changed? My system is Win 10, JDK version 1.8.181, maven version 3.6.3
Reinstalling the system, JDK and maven, can not solve this problem.
The spring-boot-starter-parent:2.3.1-RELEASE that you extend manages the version of com.squareup.okhttp3:okhttp to 3.14.9 via spring-boot-dependencies:
<okhttp3.version>3.14.9</okhttp3.version>
...
<dependencyManagement>
<dependencies>
...
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp3.version}</version>
</dependency>
...
</dependencies>
</dependencyManagement>
This is documented under dependency management:
Each release of Spring Boot provides a curated list of dependencies that it supports. In practice, you do not need to provide a version for any of these dependencies in your build configuration, as Spring Boot manages that for you.
You'll need to either accept that, and work with that version, or set the okhttp3.version property in your project for the okhtttp version that you'd like to build with.
The problem might be in transitive dependencies (some other dependency has a dependeny to okhttp3 3.14.9 and it can overriede 4.7.2 )
You can try to execute mvn dependency:tree -Dverbose=true
https://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html
and find, which versions of okhttp3 you have, and see which other dependency brought 3.14.9 version.
I have configured a Maven build with dependencies to Eclipse plugins, which are collected through a Nexus proxy which points to Maven Central. For example, I need version 2.7.0 of the org.eclipse.emf.common jar in my build. So I added a dependency in the dependency management section of the parent pom with a version like this:
<dependency>
<groupId>org.eclipse.emf</groupId>
<artifactId>org.eclipse.emf.common</artifactId>
<version>2.7.0</version>
</dependency>
However, Eclipse plugins usually suffix their version numbers with date and build number, so the plugin is actually org.eclipse.emf.common_2.7.0-v20110520-1406.jar - and it looks as if Maven fails because it believes that a 2.7.0-something is a smaller version than 2.7.0. When put the full version number in my pom, the builds works.
Now my question is: is there a good and maybe agreed upon way to specify a version 2.7.0 or higher, no matter if there are date or build number suffixed to it?
You can check all available versions using search on maven central:
http://search.maven.org/#search%7Cga%7C1%7Corg.eclipse.emf.common
Specify dependency exists only with date and build number version, so you have to use full version... But there is another dependency (with different group id) that has exact 2.7.0 version.
Just go through all availables artifacts on search.maven.org and pick what you need.
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.