MVN install, cannot find artifact in local repository - java

I did mvn install and get this error message
Failed to execute goal on project core: Could not resolve dependencies for project test:core:jar:2.0.1-SNAPSHOT: Could not find artifact lib-net:lib-net:jar:1.0.8 in central (http://repo.maven.apache.org/maven2)
this dependency is a Project of mine, which is available in the local repository ~/.m2
so I tried mvn install -o to force maven to use my local repository, and I get this
Failed to execute goal on project core: Could not resolve dependencies for project test:core:jar:2.0.1-SNAPSHOT: The repository system is offline but the artifact lib-net:lib-net:jar:1.0.8 is not available in the local repository.
I tried to delete my local repository and install everything again, but it doesn't solve my problem!
Any sugestions?

The problem is with maven version. I had the same issue on my Jenkins machine. I followed these steps and it resolved my issue:
Delete the specific older libraries in ~/.m2/
Change the version of maven to apache-maven-3.5.0
Re-run the maven goals

Think I know way how to do it properly
Download sources of your library locally
Go to ~/.m2/ and search for your lib
Delete it from here
perform "mvn clean install" for your library
search for your lib in ~/.m2/
try to "mvn clean install" on your main project
... ?
Profit
If it will no work, check that you use correct artifact id and group id.

Related

Maven on Jenkins Only Pulls from Remote Repo

Any help information would be greatly appreciated. I have a maven project that I need to build. It comes with a *.jar in the lib directory that I need to install first and add it to the local repo.
On Jenkins, subsequent build attempts ("clean install" or "clean package") fail.
I install the jar with:
mvn install:install-file -Dfile=filename.jar -DgroupId=group -DartifactId=artifact -Dversion=version# -Dpackaging=jar
This adds the dependency to /var/lib/jenkins/.m2/repository.
But during subsequent builds ("clean install" or "clean package"), this repository is never referenced in the stacktrace. Instead, I get:
Could not find artifact group:artifact:jar:#.# in AsposeJavaAPI (https://repository.aspose.com/repo/)
I wonder if anyone has an idea of what could be causing this? Jenkins obviously can identify the local repo, but it fails whenever there is read, rather than a write, attempt.
Jenkins ver. 2.222.4
Maven Integration 3.6 Plugin
Thank you for any help that can be provided.

while doing maven clean install i am getting this kind of error in eclipse smart home

while doing maven clean install i am getting this kind of error in eclipse smart home
" Failed to execute goal on project eclipsesmarthome-incubation: Could not resolve dependencies for project org.eclipse.smarthome:eclipsesmarthome-incubation:pom:0.10.0-SNAPSHOT: Could not find artifact org.eclipse.smarthome.products:org.eclipse.smarthome.repo:zip:0.10.0-SNAPSHOT -> [Help 1]"
can any one help me out
The artifact
org.eclipse.smarthome.products:org.eclipse.smarthome.repo:zip:0.10.0-SNAPSHOT
is not available. This could have several reasons:
if this artifact is supposed to come from a Maven repository on the internet, make sure that this Maven repository is added to the setttings.xml
if you are behind a proxy/firewall, make sure your Maven can go through it.
if you just downloaded the artifact, you need to add it to your local repository with the help of the Maven install plugin.

Showing jars in maven dependencies section without doing mvn install in cmd

I have added dependencies in pom.xml and immediately the corresponding jars started to show up in maven dependencies section of dynamic web project.
I just want to know that I have not done mvn install in cmd so how did they get saved in maven repository.
Another query I have, is that since jars are availble in maven dependencies folder of dynamic wep project, so my project runs successfully or not as depndencies are already satisfied without doing mvn install.
When you list a <dependency> in your project's POM, M2Eclipse (Eclipse's plugin in this case) will trigger Maven to resolve that declared dependency...meaning Maven will check your local repo first for that dependency, and if it's not found there it will pull it down from the next highest repo you have configured (possibly an agency-level repo, or Maven's default public repo on the web).
No mvn install is required, as the purpose of that would be to install your current project's packaged artifact into your local repo, rather than install any dependency.
Hope this helps to clarify why an install is not used to copy dependencies into your local repo.

Error on starting maven

I am trying to create a simple maven project and stumbled on an error upon executing this conmmand in the command line:
mvn archetype:generate -DgroupId={project-packaging} -DartifactId={project-name} -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
I am using fresh out of the box maven so I still don't have a settings.xml. Maven says that I don't have the archetype plugin and upon looking for solutions I found out that the maven central repo is not accessible in my network(maybe configured in firewall). How can I proceed now?
Thanks
If you don't have net access, try downloading the required artifacts and placing them in your local repository. The local repository path would be in the settings.xml file placed in your maven installation directory/conf. You can also try connecting to the maven central repository using a proxy setting if it is feasible.

How to provide artifacts to a maven project if those are not in public repository?

I cloned an open source library project from Github, that I'd like to use for my own Java project. This library depends on some other jars that cannot be found in any public repository. This causes mvn package to fail:
[ERROR] Failed to execute goal on project commons-gdx-core:
Could not resolve dependencies for project
com.gemserk.commons.gdx:commons-gdx-core:jar:0.0.11-SNAPSHOT:
The following artifacts could not be resolved:
com.badlogic.gdx:gdx:jar:0.9.8-SNAPSHOT,
com.gemserk.animation4j:animation4j-core:jar:0.2.2-SNAPSHOT,
com.gemserk.vecmath:vecmath:jar:1.5.3-GEMSERK:
Could not find artifact com.badlogic.gdx:gdx:jar:0.9.8-SNAPSHOT -> [Help 1]
I think I can get these jars from other sources but I don't know how to tell maven where to look for them.
as example, we have Oracle JDBC driver. You must install it into your local maven repository.
Download your lib to local folder (i.e.: Path/to/private/library.jar)
mvn install:install-file -Dfile= -DgroupId=
-DartifactId= -Dversion= -Dpackaging=jar
Or, a more advanced way, if you have a Maven Repository (like Sonatype Nexus), you can deploy it on repository and map it on your project. But, I think that you need the first option.
Use the repositories and repository tags to point to the private repositories in your pom file or update your settings.xml in the same way. Maven will download the artifacts once you tell it where to look.
Answers from apast and Chris are both correct. But if you change your computer or clean up your local repository, you project still can't be compiled. What I suggest is using system dependencies and add the jar under git version control. Here's an example.

Categories

Resources