I need to add some external dependencies to my Maven project. For example I need this library: https://packages.atlassian.com/content/repositories/atlassian-public/com/atlassian/jira/jira-rest-java-client-core/5.1.0/ I'm struggling with adding the repository in which this library is located.
I've already tried:
- adding https://packages.atlassian.com/content/repositories/atlassian-public to Settings -> Build, Execution, Deployment -> Remote Jar Repositories -> Maven Jar Repositories
- adding repository to settings.xml following this tutorial http://maven.apache.org/settings.html#Repositories, settings file here:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>testname</id>
<repositories>
<repository>
<id>atlassianReleases</id>
<name>Atlassian Releases</name>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<url>https://packages.atlassian.com/content/repositories/atlassian-public</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>testname</activeProfile>
</activeProfiles>
</settings>
updating added repository via Settings -> Build, Execution, Deployment -> Maven -> Repositories
RMB on pom.xml -> Maven -> Reimport
rebuilding the project
Of course I have correct dependencies in my pom.xml:
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>5.1.0</version>
</dependency>
I still get error messages that used packages do not exist.
Edit:
I noticed that in my local repository I have com\atlassian\jira\jira-rest-java-client-core\5.1.0 folder but only with .pom file, _remote.repositories and .pom.sha1 file.
Edit2:
The problem was caused by my VPN settings, solved.
first you must delete com\atlassian\jira\jira-rest-java-client-core folder in .m2 directory
and again run mvn commands.
*in intellij if you changed pom.xml file ,maven plugin automatic run again
Add this to you pom.xml repositories section:
<repository>
<id>atlassian-public</id>
<url>https://packages.atlassian.com/mvn/maven-external/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
See documentation here https://developer.atlassian.com/server/framework/atlassian-sdk/atlassian-maven-repositories-2818705/
Related
My nexus repository are defined as following
maven-release - which contains my customer jars
maven-snapshots - which contains my project jars
and my settings xml file as bellows:
<repository>
<id>nexus</id>
<name>nexus-repo-snapshots</name>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>https://nx0.my.biz/repository/maven-snapshots</url>
<layout>default</layout>
</repository>
<repository>
<id>nexus</id>
<name>nexus-repo-release</name>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
<url>https://nx0.my.biz/repository/maven-releases</url>
<layout>default</layout>
</repository>
and my distributed management is as bellows:
<distributionManagement>
<repository>
<id>nexus</id>
<name>Releases</name>
<url>${nexus.url}/repository/maven-releases</url>
</repository>
<snapshotRepository>
<id>nexus</id>
<name>Snapshot</name>
<url>${nexus.url}/repository/maven-snapshots</url>
</snapshotRepository>
</distributionManagement>
I have uploaded my custom jars in maven releases
now what is happening that It is downloading jars from maven-snapshots only like
Downloading from nexus: https://nx0.my.biz/repository/maven-snapshots/com/my/custom/2.4.0/custom-2.4.0.jar
and giving error while building that
Could not find artifact com.my:custom:jar:2.4.0 in nexus (https://nx0.my.biz/repository/maven-snapshots)
Please let me know if I am doing anything wrong.
check your maven settings.xml.
if you set two mirror and both of them mirrorOf attribute been set to *,then maven will use the first mirror to download all the dependencies.
that almost killed my whole day.
The distributionManagement section of your pom is only used for uploading artifacts with either the deploy goal to the snapshot repository or the maven release plugin to the release repository.
The repositories section of your settings.xml will be used to download artifacts to your local repository (usually ~/.m2).
The repositories will be looked at in the order they are given in the settings.xml.
I´m trying to configure my maven to use a Nexus repository. What I´m trying to achieve should be very common: I want to have a Nexus repository working as a proxy for central dependencies and also two repositories for snapshots and releases. There´s plenty of documentation out there, but I am not able to get it running.
I edited my settings.xml so that it looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0
http://maven.apache.org/xsd/settings-1.1.0.xsd">
<localRepository>${M2_REPO}</localRepository>
<servers>
<server>
<id>nexus</id>
<username>myuser</username>
<password>mypass</password>
<url>https://snapshoturl</url>
</server>
<server>
<id>nexus-releases</id>
<username>myuser</username>
<password>mypass</password>
<url>https://releaseurl</url>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus</id>
<url>https://groupurl</url>
<username>myuser</username>
<password>mypass</password>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>myprofile</id>
<repositories>
<repository>
<id>nexus</id>
<url>https://snapshoturl</url>
<username>myuser</username>
<password>mypass</password>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<!--<repository>
<id>nexus-releases</id>
<url>https://releaseurl</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>-->
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://groupurl</url>
<username>myuser</username>
<password>mypass</password>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>myprofile</activeProfile>
</activeProfiles>
</settings>
But I always get the following error message:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-
plugin:2.7:deploy (default-deploy) on project share.logging: Failed to
retrieve remote metadata xxx:share.logging:1.0.0-SNAPSHOT/maven-
metadata.xml: Could not transfer metadata
xxx:share.logging:1.0.0-
SNAPSHOT/maven-metadata.xml from/to p19dai-internal (https://snapshoturl):
Not authorized , ReasonPhrase:Authorization Required. -> [Help 1]
Can anyone help me here? What am I missing?
The problem is in your pom file. The ID in the "distributionManagement" section needs to match an ID in the settings.xml file's "servers". That's how the deployment credentials are looked up by Maven.
Are you running the mvn build via eclipse or eclipse based IDE?
then go to Go to Window --> Preferences
look for maven in the list and then user settings give the path to your settings.xml in both the global settings and the user settings and click apply
also set your .m2 repo path
I am working behind a proxy and I am facing SSL issues. Therefore, I can't use HTTPS propertly, so in Eclipse in the settings.xml file of maven I set the repository to "http://repo1.maven.org/maven2", i.e. HTTP, as follows:
<settings>
<activeProfiles>
<activeProfile>securecentral</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>securecentral</id>
<repositories>
<repository>
<id>central</id>
<url>http://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
It worked for some dependencies but when I added one dependency to the pom.xml specifically this one:
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-tiff</artifactId>
<version>3.3.2</version>
</dependency>
Eclipse couldn't download it (I don't know if this issue is from the proxy, from the repository itself, or some other issue)
My question:
Does setting the repository to "http://repo1.maven.org/maven2" limit the number of plugins, libraries, or anything I can download using the normal repository "https://mvnrepository.com/", or it is exactly the same without any limitation or difference except that the first one is through HTTP not HTTPS ?
I hope you understand that both of these are repositories which include artifacts uploaded via distributionManagement by developers.
They are not same in terms of the endpoint you would reach.
The preferred would be the one for maven central - http://repo1.maven.org/maven2 which can be looked in at https://search.maven.org/
There is a useful link for consumers to start using it. - central.sonatype.org/pages/consumers and the code shared seems to be following that very likely (Consumer - Apache Maven)
I'm trying to connect to a mysql database in java and so I have to add mysql-connector-java:jar to my eclipse project. The integration with maven is not working though.
Here is what I have in my settings.xml:
<profile>
<id>default</id>
<properties>
<mvn.path>.../maven-3.0.4/bin/mvn.bat</mvn.path>
<javac.5>...bin/javac.exe</javac.5>
<javac.6>..../javac.exe</javac.6>
</properties>
<repositories>
<repository>
<id>central-repository</id>
<name>OSS central Maven Release Repository</name>
<url>https://oss.sonatype.org/content/repositories/releases</url>
</repository>
<repository>
<id>public-repository-main</id>
<name>Central Repository</name>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>public-repository</id>
<name>OSS Maven Release Repository</name>
<url>https://oss.sonatype.org/content/groups/public</url>
</repository>
</repositories>
</profile>
<interactiveMode>true</interactiveMode>
<!-- offline
| Determines whether maven should attempt to connect to the network when executing
| a build.
| This will have an effect on artifact downloads, artifact deployment, and others.
|
| Default: false <offline>false</offline> -->
<offline>false</offline>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://xxxx:8083/nexus/content/groups/public</url>
</mirror>
And here is the error I get when I try to a mvn clean install
Failure to find mysql:mysql-connector-java:jar:5.0.5 in
http://xxxx:8083/nexus/content/groups/public
How can I force nexus to download the artifact from my public repositories to nexus? Do I have to add it manually?
You need to tell maven to use your maven repository. To do this, modify $HOME/.m2/settings.xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<settings 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/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://xxxx:8083/nexus/content/groups/public</url>
</mirror>
</mirrors>
<proxies></proxies>
<servers></servers>
<pluginGroups></pluginGroups>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
The nexus profile is configured to download from the central repository with a bogus URL of http://central.
This URL is overridden by the mirror setting in the same settings.xml file to point to the URL of your single Nexus group. The nexus group is then listed as an active profile in the activeProfiles element.
Suppose you have repository Central that has repository path http://xxxx:8083/nexus/content/repositories/central and also point Remote Storage Location to http://repo1.maven.org/maven2/ you can change http://central to http://xxxx:8083/nexus/content/repositories/central or http://repo1.maven.org/maven2/.
in your pom.xml, use below dependency to getting mysql-connector.
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.33</version>
</dependency>
See also: Getting started with Nexus maven repository manager
Hope this help.
Is there a chance that you have included two different versions for mysql-connector-java?
I used to have an error like that, it turned out I had accidentally included another version, so this specific version was not accessed (it was a transitive dependency, which for peculiar reasons I could not exclude). I moved the dependency in the beginning of all other dependencies (in your case it might be in the end),and it worked. Theoretically having two versions of same dependency should not throw an error.
Here are the available versions of MySQL connector
http://mvnrepository.com/artifact/mysql/mysql-connector-java , click on any version, it will give your the dependency.
So I have a project and I do regular releases to maven without a problem. I now want to make available a SNAPSHOT version of this project. So I do 'mvn clean deploy'. Everything works as you can see below:
[INFO] Retrieving previous build number from sonatype-nexus-snapshots
Uploading: https://oss.sonatype.org/content/repositories/snapshots/me/soliveirajr/menta-regex/0.9.6-SNAPSHOT/menta-regex-0.9.6-20111010.153035-2.jar
5K uploaded (menta-regex-0.9.6-20111010.153035-2.jar)
I go to my sonatype manager and I can find the snapshot:
But now when I try to use this snapshot as a dependency on some other project in another machine I get:
<dependency>
<groupId>me.soliveirajr</groupId>
<artifactId>menta-regex</artifactId>
<version>0.9.6-SNAPSHOT</version>
</dependency>
Missing:
1) me.soliveirajr:menta-regex:jar:0.9.6-SNAPSHOT
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=me.soliveirajr -DartifactId=menta-regex -Dversion=0.9.6-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=me.soliveirajr -DartifactId=menta-regex -Dversion=0.9.6-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
So how do I force maven to download the SNAPSHOT version to my local (.m2) repository?
Just add this to your ~/.m2/settings.xml:
<profiles>
<profile>
<id>allow-snapshots</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
For the sake of completeness, I would like to add that it is also possible by modifying the pom.xml of a project, simply add
<repositories>
<repository>
<id>oss.sonatype.org-snapshot</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
to your list of repositories.
In my opinion, this is a better solution than modifying ~/.m2/settings.xml. The pom.xml file will also be available for other project participants through Git and allow them to download the snapshots as well.
Source: this answer
You can enable snapshots in repository config (~/.m2/settings.xml):
<settings>
<profiles>
<profile>
<repositories>
<repository>
<snapshots> <<<<<<<<<<<
<enabled>true</enabled> << ADD THIS
</snapshots> <<<<<<<<<<<
. . .
</settings>
See maven.apache.org/settings.html#Repositories for more properties.