Could not resolve dependency from local repo in POM - maven

Hi I am trying to add a local jar file to maven dependency like below in POM.xml.
<repositories>
<repository>
<id>project-repo</id>
<url>file://C:/POC/Projects/Jar</url>
</repository>
</repositories>
I am always getting below error.
Could not find artifact cas:cas:jar:1.2 in project-repo (file://C:/POC/Projects/Jar)
How i can fix this issue?

The JAR needs to be installed to the local repo.
Executing the command below will install the JAR to local repo:
mvn deploy:deploy-file -DgroupId=[group] -DartifactId=[artifact] -Dversion=[vers] -DrepositoryId=project-repo -Dfile=[JAR_FILE_PATH]

Related

what is the error when integrating maven with Struts 1.3 with local project libraries?

I have some local jar files in my 'projectBaseDir/lib' location and i have added the directory with the following maven command
<repositories>
<repository>
<id>mylibid</id>
<url>file://${project.basedir}/lib</url>
</repository>
</repositories>
still, the following command shows that it doesn't find any library / showing errors.
mvn clean install
Here is a screenshot -
Create a new folder, let's say local-maven-repo at the root of your Maven project.
Just add a local repo inside your of your pom.xml:
<repositories>
<repository>
<id>local-maven-repo</id>
<url>file:///${project.basedir}/local-maven-repo</url>
</repository>
</repositories>
Then for each external jar you want to install, go at the root of your project and execute:
mvn deploy:deploy-file -DgroupId=[GROUP] -DartifactId=[ARTIFACT] -Dversion=[VERS] -Durl=file:./local-maven-repo/ -DrepositoryId=local-maven-repo -DupdateReleaseInfo=true -Dfile=[FILE_PATH]

Downloading dependency using a custom repository

My company just created a custom repository. I am trying to download a dependency I added to the repository, but the jar doesn't seem to get added to my .m2 directory.
Maven isn't throwing any errors during the install.
Here is the repository in the POM file:
<repositories>
<repository>
<id>snapshots</id>
<url>http://[domain]/artifactory/libs-snapshot</url>
</repository>
</repositories>
and the dependency:
<dependency>
<groupId>com.adobe.aem.sql</groupId>
<artifactId>mysqlAEM</artifactId>
<version>1.0.0-20170313.175547-1</version>
</dependency>
Have also replaced the timestamp with SNAPSHOT.
The path within the repository is:
http://[domain]/artifactory/libs-snapshot-local/com/adobe/aem/sql/mysqlAEM/
And i know the setup of where the JAR file is a little wonky, but I will fix that once I can get it downloaded to my local maven repository.

Maven Amdatu Bundle Remote Repository

I'm new to OSGi and Amdatu and I'm using OSGi with Maven.
Usually I import bundles like this
sudo mvn pax:import-bundle -DgroupId=org.eclipse.jetty.osgi -DartifactId=jetty-osgi-boot -Dversion=9.1.3.v20140225
In upper case importing works great because the bundle can be found in maven central repository.
But there is no amdatu bundle in maven central repository, so I tried to add amdatu repositories in pom.xml.
<repositories>
<repository>
<id>dependencies</id>
<name>Amdatu Dependencies</name>
<url>http://repository.amdatu.org/dependencies/</url>
</repository>
<repository>
<id>snapshot</id>
<name>AmdatuSnapshots</name>
<url>http://repository.amdatu.org/snapshot/</url>
</repository>
<repository>
<id>release</id>
<name>AmdatuRelease</name>
<url>http://repository.amdatu.org/release/</
</repository>
</repositories>
I can see added maven repositories in Netbeans, however when exploring any repository I get the message <No result, processing index...>
If I open the link in browser I can see the repository with index.xml file.
So I tried to install a jaxrs bundle and no luck.
sudo mvn pax:import-bundle -DgroupId=org.amdatu.web.rest.jaxrs -DartifactId=org.amdatu.web.rest.jaxrs -Dversion=1.0.4
What am I doing wrong? How can I use maven amdatu repository and import bundles?
Thank you!
What you're doing wrong is assuming that the Amdatu repositories are Maven repositories. They are not. They are in fact OSGi Bundle Repositories, and we provide an index in both the "old" (repository.xml) and "new" (index.xml) format.
Within the Amdatu project, we don't use Maven, we develop with Bndtools, so you would have to provide the proper metadata (pom.xml) yourself and then import the bundles into your own Maven repository. If someone would contribute a tool to automatically generate the proper metadata and/or upload artifacts in Maven central, we would be happy to accept that though.
Marcel, thank you for your help.
I have downloaded all bundles and install them in local maven repository with next command.
mvn org.apache.maven.plugins:maven-install-plugin:2.5.1:install-file -Dfile=path-to-your-artifact-jar \
-DgroupId=your.groupId \
-DartifactId=your-artifactId \
-Dversion=version \
-Dpackaging=jar \
-DlocalRepositoryPath=path-to-specific-local-repo
I saw that you already found a way to automatically generate pom.xml with BND Tools.
https://amdatu.atlassian.net/browse/AMDATU-712

Maven: Manually install a Jar from local folder and then go online and grab & install all its dependencies

In my project's pom file I have a dependency that I can see in Maven central repository, javax.enterprise:cdi-api:jar:1.0-SP4 but for some reason I am getting on some of my computers the following error while building the project (hence the build fails):
[INFO] Unable to find resource 'javax.enterprise:cdi-api:jar:1.0-SP4' in repository central (http://repo1.maven.org/maven2)
Any idea why I get this error only on some of my computers (I can say all the computers are using the same network)?
Why do I get this error at all? As far as I can see the jar IS in the maven central repository.
Even though maven could not locate/download the jar on some of the computers, I was able to download it manually through the browser on these computers. How could it be?
Okay, so I've downloaded the jar manually through the browser at one of the problematic computers. I want to install it manually to the local repository on this computer. So from the command line I do:
mvn install:install-file -DgroupId=javax.enterprise -DartifactId=cdi-api -Dversion=1.0-SP4 -Dpackaging=jar -Dfile=path/to/file
...but none of its dependencies has been downloaded as well. Is there some maven plugin to install the file to the local repository AND download & install all its dependencies to the local repository?
If so, please show me how to use it.
Please check in the computers where the jar are not downloaded if the settings.xml file present in .m2 folder is having the url of the jar needed. If not add them.
You are not able to download because maven searches in the urls defined in the settings.xml file only. So if the url is not present there, even if the jar is in the central repository it wont be downloaded.
In your browser you can navigate to that link and download. Maven wont be able to do it for the reason given in the second point
Ok, looks like you need to mention your repository path in your pom file, What is the url of the repository? is it local to your network or some open url? for example: http://repo2.mvn.org/???
Sample example would be like this::
<repositories>
<repository>
<id>codehausSnapshots</id>
<name>Codehaus Snapshots</name>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://snapshots.maven.codehaus.org/maven2</url>
<layout>default</layout>
</repository>
</repositories>
If you could paste the pom file, it would be easier to help you.
To answer your 3 point: Check the settings.xml file in .m2\settings.xml, make sure that same content is present. Sometimes settings.xml are modified directly in maven installation directory. so you better check in that location also.
To Answer your 4th point: mvn install:install installs (in simple terms copies) an artifact (jar/ear/zip/any artifact that meant for distribution) into maven local repository or into remote repository. So in your command, you just tried to install only cdi-api jar.
Whenever you run mvn compile, mvn package, mvn install, maven will scan your pom file and downloads all dependency mentioned into your local repository. I would suggest you to look your local repository and see how is it creating directory structure.

How can i use SVN as Maven Repository

I am working on project which has multiple dependencies. Most of the dependencies are available at our centralized maven repository. My project includes some JARs which only specific to my application and unavailable at our Maven repo. Due to some policy/restriction i cant deploy that jars to our maven repository.
When i install these jars in my local repository(i.e.UserHome/.m2/repository) and compile the code its working fine.
Now i want these dependencies in SVN so that we can build the application package using Continuum.(We cant refer local dependency from Continuum server.)
Just to achieve these i copied the locally installed dependency from .m2/repository and committed it in SVN. Then i declared repository in pom.xml like..
<repositories>
<repository>
<id>repo.pu</id>
<name>repo.pu</name>
<url>https://URL/migration2/APP1/src/main/lib/</url>
<layout>default</layout>
</repository>
</repositories>
Now to use dependency from above repo i added code like...
<dependencies>
<dependency>
<groupId>repo.pu</groupId>
<artifactId>Ptestval</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
When i type mvn verify i am getting the below error..
[ERROR] Failed to execute goal on project APP1: Could not resolve dependencies f
or project fileservices.migration2:APP1:jar:1.0: Failed to collect dependencies
for [repo.pu:Ptestval:jar:1.0 (compile)]: Failed to read artifact descriptor for
repo.pu:Ptestval:jar:1.0: Could not transfer artifact repo.pu:Ptestval:pom:1.0
from/to repo.pu (https://URL/migration2/APP1/src/main/lib/): Access denied to:
https://URL/migration2/APP1/src/main/lib/repo/pu/Ptestv
al/1.0/Ptestval-1.0.pom -> [Help 1]
Could you please someone help me to resolve these issue?
EDIT: I created a repository like ..
<repositories>
<repository>
<id>repo.pu</id>
<name>repo.pu</name>
<url>https://SVNUserName:SVNPassword#SVN_URL/BaseProj/ProjA/src/main/lib</url>
<layout>default</layout>
</repository>
</repositories>
This technique works perfectly at my Personal laptop. Maven downloads the listed dependency from repo.
But when tries to use the same in my project on company network it is not working .. It gives the same error which i was getting before using this approach.
Can anyone help me please? What would be problem? Is it a network issue?
Set up a repository manager like Nexus and don't abuse Subversion for something it was not designed for. This is unfortunately done in Google Code.
You must configure your project to use wagon-scm.
See http://maven.apache.org/wagon/wagon-providers/wagon-scm/usage.html

Resources