Where to manually download the JARS from when Maven cannot find a dependency - maven

I want to create a Maven webapp sample project on a dev machine without internet, but with access a Nexus repo via the local network. The Nexus repo is years old, so it has most dependencies, but not all.
I have set up maven that it uses the local Nexus and then I typed:
$ mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DarchetypeVersion=1.4
Maven goes off and downloads what it can from the local Nexus, but then it fails with:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:generate (default-cli) on project standalone-pom: Execution default-cli of goal org.apache.maven.plugins:maven-archetype-plugin:2.4:generate failed: Plugin org.apache.maven.plugins:maven-archetype-plugin:2.4 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.codehaus.plexus:plexus-component-api:jar:1.0-alpha-16, org.codehaus.plexus:plexus-classworlds:jar:1.2-alpha-7: Failure to find org.codehaus.plexus:plexus-component-api:jar:1.0-alpha-16
Due to the fact that the machine is not connected to the internet and that I have no control over the Nexus repo (so cannot add jars to it), would need to download the depend JARs for org.codehaus.plexus:plexus-component-api and org.codehaus.plexus:plexus-classworlds manually (on another internet-connected computer).
Where on the Internet do I find them? -- I tried a search on https://jar-download.com/online-maven-download-tool.php. E.g. for org.codehaus.plexus:plexus-component-api I search with the following the XML snippet:
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-api</artifactId>
<version>1.0-alpha-16</version>
</dependency>
but this didn't yield any result.

You can use copy goal of dependency-plugin for download and copy artifacts:
mvn org.apache.maven.plugins:maven-dependency-plugin:3.3.0:copy \
-Dartifact=org.codehaus.plexus:plexus-component-api:1.0-alpha-16:jar \
-DoutputDirectory=.
You can also download manually from Maven Central repository, eg:
https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-component-api/1.0-alpha-16/

Related

Using mvn get to pull latest artifact from Nexus repository

I am trying to pull the latest artifact from my Nexus repository. I am using the get command to pull the artifact.
mvn dependency:get -Durl=http://nexus-repository:8080/nexus/content/repositories/snapshots -Dartifact=com.my.company:common:LATEST-Dtransitive=false -Ddest=. -s settings.xml
And it is the error message I am getting.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:get (default-cli) on project standalone-pom: Couldn't download artifact: Failed to resolve version for com.my.company:common:jar:LATEST: Could not find metadata com.my.company:common/maven-metadata.xml in releases (http://nexus-repository:8080/nexus/content/repositories/releases)
I do not know either why it is looking on release and not in snapshots because the version is on my snapshots repository.
When I run with the specific version everything works fine:
mvn dependency:get -Durl=http://nexus-repository:8080/nexus/content/repositories/snapshots -Dartifact=com.my.company:common:1.0.0-SNAPSHOT -Dtransitive=false -Ddest=. -s settings.xml
I will like to pull the latest version using mvn command and not curl neither wget.
Any recommendation or idea?

How to configure maven to copy dependencies from central repo to local repository mirror (not local repo)

All
Need to get maven to copy central dependencies to local filesystem repository mirror. Can't work out how to do this in maven (3.3.1).
We have:
[1] maven central, which for the UK is: "http://uk.maven.org/maven2"
[2] local remote filesystem repository mirror: "c:/mylocalRepository"
[3] local repo "c:/users/myuser/.m2/repository"
Version of maven is 3.3.1 (doing a migration from 2.0.10).
We need to run our system without connecting to central (behind firewalls) and also without using a repository manager (Nexus, Archiva or the like) - it's something we would like to change but cannot change our infrastructure immediately. Please don't reply just saying do this.
Therefore we need our dependencies in a local file system that maven will then be use as a mirror of central.
I can't find a way to configure maven to build this - I'm getting dependencies - jar + pom and then using
To install jars:
mvn org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file
-Durl="file:///{repositoryPath}"
-DrepositoryId="InternalRepo"
-Dfile="{jarFile}"
-DpomFile="{pomFile}"
-DrepositoryLayout=default
-DgroupId={groupId}
-DartifactId={artifactId}
-Dversion={version}
-Dpackaging=jar
-s "C:/apache-maven-3.3.1/conf/settings_centralRepo.xml"
To install Poms:
mvn org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file
-Durl="file:///{repositoryPath}"
-DrepositoryId="InternalRepo"
-Dfile="{pomFile}"
-DpomFile="{pomFile}"
-DrepositoryLayout=default
-DgroupId={groupId}
-DartifactId={artifactId}
-Dversion={version}
-Dpackaging=pom
-s "C:/apache-maven-3.3.1/conf/settings_centralRepo.xml"
Ideally would like a configuration that we could put in the parent pom that would trigger all dependencies to be copied over. However the documentation implies this is for build artifacts rather than dependencies. There's usually a way in maven, but it can be hard to find.
Any help much appreciated - I've currently jury-rigged a script to do this and it tedious and labour intensive.

Configuring Maven, jenkins with Sonar

I have installed Jenkins and Sonar, both work fine. I am able to build a maven android project using Jenkins. No i want to run Sonar on the android project. I have installed the Sonar plugin in Jenkins. Configured the sonar module in the configure system module and added a post build task for sonar to run
[ERROR] Plugin org.codehaus.mojo:sonar-maven-plugin:sonar or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:sonar-maven-plugin:jar:sonar: Could not find artifact org.codehaus.mojo:sonar-maven-plugin:pom:sonar in nbs-repo (http://10.10.2.89:8081/nexus/content/groups/public/) -> [Help 1]
org.apache.maven.plugin.PluginResolutionException: Plugin org.codehaus.mojo:sonar-maven-plugin:sonar or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:sonar-maven-plugin:jar:sonar
at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:129)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor(DefaultMavenPluginManager.java:142)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor(DefaultMavenPluginManager.java:261)
at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor(DefaultBuildPluginManager.java:185)
at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.getMojoDescriptor(MojoDescriptorCreator.java:235)
at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:106)
at
My nexus installation works fine ? What am i doing wrong. My maven pom.xml does not contain any sonar plugin. What am i doing wrong?
Kind Regards
From the error message its clear that mvn is trying to download the sonar-maven-plugin from your local Nexus repository which does not seem to have it.
Try mvn -U in the build in case you already have the plugin.This overrides the negative cache. Another thing is <updatepolicy> in your settings.xml
If you don't have the plugin and neither does your Nexus connect to the internet, you have to manually download and upload in Nexus of course. Please remember to match the version of the plugin with the SONAR installation. Also there would be a few (7-10) transitive dependencies with the plugin which you will need. I suggest using mvn -X or mvn -e to see a verbose output during your testing.

maven deploy-file to private artifactory

I've set up an artifactory and I am able to to deploy my artifacts to it with mvn deploy.
However, I am unable to to deploy-file, which I am easily able to install:
mvn install:install-file -Dfile=my.jar -DgroupId=org.group -DartifactId=art -Dversion=3.0-SNAPSHOT -Dpackaging=jar
When I try:
mvn deploy:deploy-file -Durl=http://myartifactory/artifactory/repositoryId -DrepositoryId=repositoryId -Dfile=my.jar -DgroupId=org.group -DartifactId=art -Dversion=3.0-SNAPSHOT -Dpackaging=jar
I always get:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy-file (default-cli) on project standalone-pom: Failed to retrieve remote metadata org.directwebremoting:dwr:3.0.0-rc3-SNAPSHOT/maven-metadata.xml: Could not transfer metadata org.directwebremoting:dwr:3.0.0-rc3-SNAPSHOT/maven-metadata.xml from/to repository (http://triphop:8081/artifactory/repository): Access denied to: http://triphop:8081/artifactory/repository/org/directwebremoting/dwr/3.0.0-rc3-SNAPSHOT/maven-metadata.xml -> [Help 1]
In the log of the artifactory I am getting:
20130809142431|0|REQUEST|non_authenticated_user|GET|/repository/org/group/art/3.0-SNAPSHOT/maven-metadata.xml|HTTP/1.1|401|0
Why the maven is trying to fetch the meta data? Why it does not upload them?
Maven 3 works with non unique snapshots only. Which means, it needs to know how to name your snapshot. The naming depends on what's already in repository. That's the reason it downloads the metadata.

Update interval of Maven Central Repo

Having zero experience with Maven, I am running a mvn clean install on a project and this is the error I get:
[ERROR] Failed to execute goal on project dnasequencing.CompaNY.com: Could not resolve dependencies for project com.CompaNY.dnasequencing:dnasequencing.
CompaNY.com:war:1.0-SNAPSHOT: The following artifacts could not be resolved: dsr-kepler:dsr-kepler:jar:0.0.1-SNAPSHOT, dsr-parser:dsr-parser:jar:0.0.1-
SNAPSHOT: Failure to find dsr-kepler:dsr-kepler:jar:0.0.1-SNAPSHOT in http://repo1.maven.org/maven2/ was cached in the local repository, resolution
will not be reattempted until the update interval of Maven_Central_Repo has elapsed or updates are forced -> [Help 1]
Based on these error messages, what is an startingpoint I should take a look for finding what is going wrong?
You can force Maven to update snapshots with the -U flag.
As far as what is going wrong, you can always check out the actual Maven website with your browser and see if the dependency actually exists.
http://search.maven.org/
If the dependency is not hosted in Maven central, then it seems it is a local dependency that you have to install in your local cache (run mvn clean install from that project).

Resources