Similar to this question, I can't do a glassfish deploy because some server in Australia is down at the moment. I've had the artifacts cached locally for months.
How can I tell maven to not attempt to update the plugin (and its dependencies)? I tried adding the following to my pom, but it didn't help:
<pluginRepositories>
<pluginRepository>
<id>ocean</id>
<url>http://maven.ocean.net.au</url>
<releases>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
I also tried the command line switches. There's -npu, which didn't seem to help with Maven 2.2.1. On Maven 3 the docs say "Ineffective, only kept for backward compatibility", so I don't have a lot of hope for that one.
We will be moving to Nexus soon, but there ought to be a simple way to tell maven not to attempt a plugin update.
Use the -o or --offline switch to work offline - this should make Maven not bother to check any repositories for new updates or snapshots, as if you did not have network access.
Additionally - are you specifying the <version> for each of your plugins? There should be no need to check for updates to release versions of a plugin.
If you use maven 2 there's a file called plugin-registry.xml where you can specify the version of each plugin. The ugly thing about this file, is that it has to be copied / installed on each box that uses maven (ci server, dev boxes, etc).
The benefit is that you can specify a version, and one it's downloaded, it won't be updated again.
If you migrate to maven 3, this has been sorted out, and you can specify the version you want on the pom.
Related
In Java I am adding below maven dependency,
<dependency>
<groupId>cloudant-labs</groupId>
<artifactId>spark-cloudant</artifactId>
<version>2.0.0-s_2.11</version>
</dependency>
but it is not loading package even in pom.xml file showing below error,
Missing artifact cloudant-labs:spark-cloudant:jar:2.0.0-s_2.11
Can anyone help me please why it is causing issue?
I am able to add another maven dependencies but particularly this is not working..
It's not in the official maven repository. (http://search.maven.org/#search%7Cga%7C1%7Cspark-cloudant)
But when you check: https://mvnrepository.com/artifact/cloudant-labs/spark-cloudant/2.0.0-s_2.11 there is note:
Note: this artifact it located at Spark Packages repository
(https://dl.bintray.com/spark-packages/maven/)
So you will need to add following to your pom.xml:
<repositories>
<repository>
<id>bintray</id>
<name>bintray.com</name>
<url>https://dl.bintray.com/spark-packages/maven/</url>
</repository>
</repositories>
EDIT:
According to https://spark.apache.org/news/new-repository-service.html
Bintray, the original repository service used for https://spark-packages.org/, is in its sunset process, and will no longer be available from May 1st. To consume artifacts from the new repository service, please replace “dl.bintray.com/spark-packages/maven” with “repos.spark-packages.org” in the Maven pom files or sbt build files in your repositories.
So this should work:
<repositories>
<repository>
<id>bintray</id>
<name>bintray.com</name>
<url>https://repos.spark-packages.org</url>
</repository>
</repositories>
Check your maven repo to verify that the file name and version matches what you've specified. Most Maven repo's give you an example of what to use, copy/paste.
ex: Sonatype Nexus is a repo that I use and they let you search and get snippets so you never have to worry about typing things wrong.
I'm having some issues to configure properly my eclipse to work with maven.
I create a new project, this one is correctly build with maven in command line (mvn install), but in Eclipse I got this error:
CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 (): ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-settings:jar:2.2.1: ArtifactResolutionException: Failure to transfer org.apache.maven:maven-settings:pom:2.2.1 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-settings:pom:2.2.1 from/to central : NullPointerException pom.xml /test line 9 Maven Project Build Lifecycle Mapping Problem
Here is my settings.xml conf :
<proxy>
<active>true</active>
<protocol>http</protocol>
<username>myuser</username>
<password>$mymdp</password>
<host>myhost</host>
<port>8080</port>
<nonProxyHosts>some.host.com</nonProxyHosts>
</proxy>
....
<repository>
<id>central</id>
<name>central repo m2</name>
<url>http://central.maven.org/maven2</url>
</repository>
I choose the correct maven installation (in Preference -> Maven -> Install)
I also direct my user settings on the correct settings.xml (Preferences -> Maven -> User Settings)
But I still got this error in Eclipse and everything goes well with maven command line. Do you have and idea?
You only need to delete one folder it is throwing error for. Just go to your M2 repo and org/apache/maven/plugins/maven-compiler-plugins and delete the folder 2.3.2
Have you tried to remove the proxy username and password? A similar poster encountered that issue:
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-jar-plugin:2.3.2 or one of its dependencies could not be resolved
Failing that I found the following worked:
Delete project in Eclipse (but do not delete the contents on disk)
Delete all files in your Maven repository
Re-download all Maven dependencies:
mvn dependency:resolve
Start up Eclipse
Ensure that Eclipse is configured to use your external Maven installation (Window->Preferences->Maven->Installations)
Re-import the existing project(s) into Eclipse
Ensure that there are no Maven Eclipse plugin errors on the final screen of the project import
I was getting this problem when using IBM RSA 9.6.1 when building a brand new development machine. The problem for me ended up being because of HTTPS on the Global Maven repository. My solution was to create a Maven settings.xml that forced it to use HTTP.
The key to me was that the central repository was empty when I exploded it under Maven Repositories -- > Global Repositories
Using the following settings file worked for me:
<settings>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>insecurecentral</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>insecurecentral</id>
<!--Override the repository (and pluginRepository) "central" from the Maven Super POM -->
<repositories>
<repository>
<id>central</id>
<url>http://repo.maven.apache.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://repo.maven.apache.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
I got the idea from this stackoverflow question.
The issue has been resolved while installation of the maven settings is provided as External in Eclipse. The navigation settings are Window --> Preferences --> Installations. Select the External as installation Type, provide the Installation home and name and click on Finish. Finally select this as default installations.
I accidentally turned on offline mode.
To disable it: in the Maven tool window, click The Toggle Offline Mode button.
I also got the same issue and not able to create a jar, and I found that in Windows-->Prefernces-->Java-->installed JREs By default JRE was added to the build path of newly
created java project so just changed it to your prefered JDK.
Find your Maven local repository, navigate to maven-compiler-plugin, delete the 3.8.1 folder, so that the Maven will redownload it again.
For example:
C:\Users\mkyong.m2\repository\org\apache\maven\plugins\maven-compiler-plugin
I'm trying to import a maven project into Eclipse.
I'm using Helios. I've downloaded m2eclipse. I've imported the project.
But I'am having so much troubles to compile the project.
The full project contains 5 Eclipse projects, ie: prj1, prj2, prj3, prj4 and prj5
If I look the (Eclipse) marker at prj1/pom.xml I have this troubles:
Multiple annotations found at this line:
- Missing artifact log4j:log4j:jar:1.2.15:compile
- Missing artifact org.apache.xmlbeans:xmlbeans-xpath:jar:2.4.0:compile
- Missing artifact org.apache.ws.commons.axiom:axiom-dom:jar:1.2.5:compile
- Missing artifact org.apache.httpcomponents:httpcore:jar:4.0-alpha5:compile
.... and so many more ...
If I understood how maven works those dependecies must be downloaded my maven, am I wrong?
Why is it that those dependencies are not being downloaded? Should I download one by one, by hand?
It is not a unique issue, happens every now and then (sometimes due to a slow connection and sometimes due to proxy servers not allowing to download)
You can get rid of this by either of the following ways:
1) Force Update: Right Click on the Project in Eclipse -> Maven -> Update Project
On this screen select the check box Force Update for Snapshots/Releases
2) Clearing Maven Cache: If you are still facing a problem, go to the local repository on your system, which might be present at C:\Users\myusername\.m2\repository and delete the .cache folder and then follow step 1.
If you're still facing issues after this, manually go to the org/apache folder and delete everything and then follow step 1. (This will definitely solve the issue.)
Make sure your build path is going to /target/classes
to check:
right click on your project and go to properties
-> choose java build path
-> then go to the source tab
the default output folder is on the bottom
With Eclipse/Maven projects, I've always had more luck building from the command line (mvn clean package) first in order to download all of the dependencies. Once that completes without errors, then I import the project into Eclipse.
It can be a mistake in pom repository / dependency definition
i.e. I want include in pom groupId:org.clapper artifactId:javautil
The home page of clapper say use:
http://software.clapper.org/javautil
<repositories>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<id>clapper-org-maven-repo</id>
<name>org.clapper Maven Repo</name>
<url>http://maven.clapper.org/</url>
<layout>default</layout>
</repository>
...
</repositories>
and
<dependency>
<groupId>org.clapper</groupId>
<artifactId>javautil</artifactId>
<version>3.1.2</version>
</dependency>
It don't work! I got "Multiple annotations found at this line"!!!
If I use dependency from
https://github.com/shilad/wikibrain/blob/master/wikibrain-utils/pom.xml
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<id>clapper-org-maven-repo</id>
<name>org.clapper Maven Repo</name>
<url>http://maven.clapper.org/</url>
<layout>default</layout>
</repository>
+
<dependency>
<groupId>org.clapper</groupId>
<artifactId>javautil</artifactId>
<version>3.1.1</version>
</dependency>
It work fine!!!
I am trying to create a Eclipse project from Hibernate tutorials under path
\hibernate-distribution-3.5.3-Final\project\tutorials\eg
using command line mvn eclipse:eclipse. But i am getting this error
Reason: POM 'org.jboss.maven.plugins:maven-jdocbook-style-plugin' not found in repository: Unable to download the artifact from any repository
Can anyone faced this issue with the latest release of Hibernate?
I don't know what version of the plugin you need but JBoss has moved recently to Nexus and, while the previous repositories (mentioned here) will stay online indefinitely, ultimate versions of stuff is pushed to their Nexus repo now. So I suspect that you need the following declaration somewhere:
<repositories>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
</repository>
...
</repositories>
I'm aware I can add maven repositories for fetching dependencies in ~/.m2/settings.xml. But is it possible to add a repository using command line, something like:
mvn install -Dmaven.repository=http://example.com/maven2
The reason I want to do this is because I'm using a continuous integration tool where I have full control over the command line options it uses to call maven, but managing the settings.xml for the user that runs the integration tool is a bit of a hassle.
You can do this but you're probably better off doing it in the POM as others have said.
On the command line you can specify a property for the local repository, and another repository for the remote repositories. The remote repository will have all default settings though
The example below specifies two remote repositories and a custom local repository.
mvn package -Dmaven.repo.remote=http://www.ibiblio.org/maven/,http://myrepo
-Dmaven.repo.local="c:\test\repo"
One of the goals for Maven't Project Object Model (POM) is to capture all information needed to reliably reproduce an artifact, thus passing settings impacting the artifact creation is strongly discouraged.
To achieve your goal, you can check in your user-level settings.xml file with each project and use the -s (or --settings) option to pass it to the build.
I am not sure if you can do it using the command line. You can on the other hand add repositories in the pom.xml as in the following example. Using this approach you do not need to change the ~/.m2/settings.xml file.
<?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/xsd/maven-4.0.0.xsd">
...
<repositories>
<repository>
<id>MavenCentral</id>
<name>Maven repository</name>
<url>http://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
...
<repository>
<id>Codehaus Snapshots</id>
<url>http://snapshots.repository.codehaus.org/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
...
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<name>Apache Snapshot Repository</name>
<url>
http://people.apache.org/repo/m2-snapshot-repository
</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
<pluginRepository>
<id>Codehaus Snapshots</id>
<url>http://snapshots.repository.codehaus.org/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
...
</project>
As
#Jorge Ferreira
already said put your repository definitions in the pom.xml. Use profiles adittionally to select the repository to use via command line:
mvn deploy -P MyRepo2
mvn deploy -P MyRepo1
I'll assume here that you're asking this because you occasionally want to add a new 3rd-party repository to your builds. I may be wrong of course... :)
Your best bet in this case is to use a managed proxy such as artifactory or nexus. Then make a one-time change in settings.xml to set this up as a mirror for the world.
Any 3rd party repos that you need to add from that point on can be handled via the proxy.
I haven't really used maven 2 before, our system is still working on maven 1.x because of some issues with maven 2.
However, looking at the documentation for maven 2 it seems that there aren't any specific System properties like that. However, you could probably build one into your poms/settings using the System properties. See System properties part of this http://maven.apache.org/settings.html
So you'd have ${maven.repository} in your settings file and then use the -Dmaven.repository like you do above.
I am unsure as to if this would work, but with some tweaking I am sure you can come up with something.
Create a POM that has the repository settings that you want and then use a parent element in your project POMs to inherit the additional repositories. The use of an "organization" POM has several other benefits when a group of projects belong to one team.
I am using xmlstarlet to achieve this. Tested for Maven 3 on CentOS 7, Maven 2 was not tested yet.
XML_FULLPATH="$HOME/.m2/settings.xml"
MIRROR_ID='example'
MIRROR_MIRROROF='*'
MIRROR_NAME='Example Mirror'
MIRROR_URL='http://example.com/maven2'
## Preview settings without comment:
xmlstarlet ed -d '//comment()' "$XML_FULLPATH"
## Add Mirror settings:
xmlstarlet ed -L \
--subnode "/_:settings/_:mirrors" --type elem --name "mirrorTMP" --value "" \
--subnode "/_:settings/_:mirrors/mirrorTMP" --type elem --name "id" --value "$MIRROR_ID" \
--subnode "/_:settings/_:mirrors/mirrorTMP" --type elem --name "mirrorOf" --value "$MIRROR_MIRROROF" \
--subnode "/_:settings/_:mirrors/mirrorTMP" --type elem --name "name" --value "$MIRROR_NAME" \
--subnode "/_:settings/_:mirrors/mirrorTMP" --type elem --name "url" --value "$MIRROR_URL" \
--rename "/_:settings/_:mirrors/mirrorTMP" --value "mirror" \
"$XML_FULLPATH"
## Remove Mirror settings by id:
xmlstarlet ed -L \
--delete "/_:settings/_:mirrors/_:mirror[_:id=\"$MIRROR_ID\"]" \
"$XML_FULLPATH"
The idea is from: How to insert a new element under another with xmlstarlet?.