While building my app I came across the following error:
Unable to resolve artifact: Missing:
org.robolectric:android-all:jar:10-robolectric-5803371
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.robolectric -DartifactId=android-all -Dversion=10-robolectric-5803371 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=org.robolectric -DartifactId=android-all -Dversion=10-robolectric-5803371 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.apache.maven:super-pom:pom:2.0
2) org.robolectric:android-all:jar:10-robolectric-5803371
So I did exactly what I was told.
I manually downloaded the file from Maven respository.
Located the file in OS(C:)
Tried to install it using the Command Promt
And that's where I run into trouble. I have no idea what's wrong but I won't work.
Here's what it looks like in the cmd
I have a scenario, where in my maven repository, the required JAR is available, but it is not inside the version folder, instead, it is directly under the group.
For Example I need test-1.0.0.jar
In my Maven Repo, the jar is placed in the path like below,
com.java.test
----test-1.0.0.jar
But it is supposed to be like the below,
com.java.test
---1.0.0
------test-1.0.0.jar
Because of this, the jar is not downloading when I do maven install. Are there any workarounds to get the jar downloaded without changing the maven repository structure?
I think there is a problem with pom.xml of test.jar or jar uploaded to the remote repo incorrectly.
In that case, if you have control over test.jar codebase or remote repo, you can figure out what is wrong and fix it. If you don't have control over them, you can treat like it is 3rd party jar. Using below command you can populate the jar into your local maven repository.
mvn install:install-file
Basically, this command reads this dependency and installs into your local maven repository within the constraints you provided as a parameter.
Below example have been taken from Apache Maven Documentation.
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
But keep in mind, it is just a workaround for your local development. In the long run, the actual problem needs to be resolved. As mentioned earlier, either pom.xml of test.jar should be fixed or structure of remote repository should be corrected by re-uploading the jar.
You would need to re-upload your jar to the right path in Nexus, using mvn deploy:deploy-file :
In Windows:
cmd /v /c "set g=com.java&& set a=test&& set v=1.0.0&& mvn deploy:deploy-file -Dfile=!a!-!v!.jar -Dpackaging=jar -DgroupId=!g! -DartifactId=!a! -Dversion=!v! -DrepositoryId=your-nexus-id -Durl=https://nexus.your.comany.com repository/public"
You can execute that in the folder where the jar is, even without any pom.xml.
Is there any way to install an arbitrary Maven artifact into your local repository without first creating and switching to a project and specifying that package as one of its dependencies?
Yes, if you have the jar file of the artifact that you want to install to your local repository, you can the run the below command from your command prompt or terminal. Replace the value inside the angle brackets to your desired ones. And then you can use this as a dependency in your Maven projects.
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
HTH
I am trying to deploy jar to remote repository. I wrote a maven deploy command for that
mvn deploy:deploy-file -q -Dfile=$jarf -DgroupId=lsls -DartifactId=$JAR_NAME -Dversion=1.0.0 -Dpackaging=jar -DgeneratePom=true -DrepositoryId=internal -Durl= http://XXXXX.com
I dont have any project or pom file . I only have a settings.xml file in .m2 folder . I am getting this error
No plugin found for prefix 'http' in the current project and in the plugin groups.
I have looked up for other solutions but they never worked.
I added a jar with:
mvn install:install-file
-Dfile=<path-to-file>
-DgroupId=<group-id>
-DartifactId=<artifact-id>
-Dversion=<version>
-Dpackaging=<packaging>
-DgeneratePom=true
And added it as a dependency. M2eclipse went through the external repository URLs attempting to download the jar and failed. When and how will it check the local repository for the jar?
Resolved: don't mix up underscores and hyphens.
Go to your user directory i.e. C:\Profiles\youruser there should be a folder called .m2 may be hidden. Inside you can see whether that jar has been installed or not(although if the console says BUILD success you should be good).