I am building a generic parent pom file for my projects.
In that file, I would like to have a list of most common Maven repositories, in order to have most dependencies available in the sub-projects (Jboss, Spring, etc.).
Here is this current pom:
<project 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/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.courtine</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<name>Parent</name>
<version>1.0</version>
<description>Common repositories</description>
<repositories>
<repository>
<id>javanet</id>
<name>Repository for Maven2</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>google</id>
<name>Google repository for Maven2</name>
<url>https://oss.sonatype.org/content/repositories/google-releases/</url>
</repository>
<repository>
<id>jboss</id>
<name>JBoss repository for Maven2</name>
<url>http://repository.jboss.org/maven2/</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
<repository>
<id>com.springsource.repository.libraries.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Library Releases</name>
<url>http://repository.springsource.com/maven/libraries/release</url>
</repository>
<repository>
<id>com.springsource.repository.libraries.external</id>
<name>SpringSource Enterprise Bundle Repository - External Library Releases</name>
<url>http://repository.springsource.com/maven/libraries/external</url>
</repository>
</repositories>
</project>
Is such a generic file listing common repositories a good idea?
Do you know other common public Maven repositories to put in such a generic pom file?
It is not a good idea to put repositories into a pom. Better use a Repository Manager like Nexus, Artifactory or Archiva.
In such kind of pom you should put things like default plugins with their appropriate revisions (pluginManagement) or dependencies which should be used (dependencyManagement).
Take a look for explanation into this. and take a look here how to setup this.
I have another option for doing what you want to do. You could using a profile in your settings.xml which reference all your repository for you (as an nexus/archiva will do).
I've posted something about his on my site.
Simply add this in your settings.xml:
<profile>
<id>my-repository</id>
<activation>
<!-- here we did not activat this profile by default -->
<activeByDefault>false</activeByDefault>
</activation>
<repositories>
<!-- list of standard repository -->
<repository>
<id>javanet</id>
<name>Repository for Maven2</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>google</id>
<name>Google repository for Maven2</name>
<url>https://oss.sonatype.org/content/repositories/google-releases/</url>
</repository>
<repository>
<id>jboss</id>
<name>JBoss repository for Maven2</name>
<url>http://repository.jboss.org/maven2/</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
<repository>
<id>com.springsource.repository.libraries.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Library Releases</name>
<url>http://repository.springsource.com/maven/libraries/release</url>
</repository>
<repository>
<id>com.springsource.repository.libraries.external</id>
<name>SpringSource Enterprise Bundle Repository - External Library Releases</name>
<url>http://repository.springsource.com/maven/libraries/external</url>
</repository>
<repository>
<id>intelligents-ia</id>
<name>Intelligents-ia Repository</name>
<url>http://intelligents-ia.com/maven2</url>
</repository>
</repositories>
</profile>
And you could build your project by adding -Pmy-repository on the command line:
mvn -Pmy-repository clean install
Or activate this profile by default by setting true on :
<activation>
<activeByDefault>true</activeByDefault>
</activation>
Related
Failed to download 'http://central.maven.org/maven2/org/apache/struts/struts2-core/2.5.14.1/struts2-core-2.5.14.1.jar':
central.maven.org
If you have URL to Maven Central Repository in your pom.xml defined like:
<repository>
<id>Maven Central</id>
<name>Maven Central Repository</name>
<url>http://central.maven.org/maven2</url>
</repository>
then url needs to be updated, to
<repository>
<id>Maven Central</id>
<name>Maven Central Repository</name>
<url>https://repo1.maven.org/maven2</url>
</repository>
because: "Beginning January 15, 2020, The Central Repository will no longer support communication over HTTP" (https://blog.sonatype.com/central-repository-moving-to-https)
I need a .settings file, is there any common repository to access dependent jars ?
i need to access dependents for Mule projects,
Please assist.
Which .settings file are you referring to ? You mean settings.xml from maven to get access to MuleSoft repository and retrieve necessary dependencies ?
If this is the case... https://docs.mulesoft.com/mule-user-guide/v/3.8/configuring-maven-to-work-with-mule-esb
In that link you can find all the info you need to download Mule dependencies in your project.
Example:
<repositories>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Repository</name>
<url>http://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-snapshots</id>
<name>MuleSoft Snapshot Repository</name>
<url>http://repository.mulesoft.org/snapshots/</url>
<layout>default</layout>
</repository>
NOTE: for EE ( enterprise edition) dependencies you will need usename and password that must be provided by MuleSoft team, if you are not aware of your username and password, get in touch with your company or contact with Mulesoft
These are the common repositories which you need to include in your project
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<url>http://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-snapshots</id>
<name>MuleSoft Snapshots Repository</name>
<url>http://repository.mulesoft.org/snapshots/</url>
<layout>default</layout>
</repository>
How can I link an maven repository that we set up internally with my Intellij?
In the project libraries view, I am able to add a new project library that resides in the standard maven reppositories but I do not see how to point IntelliJ to a specifiy maven repository, for example the artifactory that we set up for the company.
Settings.xml is also not recognized by Intellij. I post the settings.xml afterwards, it's not recognized though (password, username and company name have been replaced) :
<settings>
<servers>
<server>
<username>USER</username>
<password>PW</password>
<id>central</id>
</server>
</servers>
<mirrors>
<mirror>
<mirrorOf>*</mirrorOf>
<url>
https://dev.mycompany.com:8443/artifactory/any
</url>
<id>central</id>
</mirror>
</mirrors>
<profiles>
<profile>
<repositories>
<repository>
<snapshots />
<id>central</id>
<url>
https://dev.mycompany.com:8443/artifactory/libs
</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots />
<id>central</id>
<url>
https://dev.mycompany.com:8443/artifactory/plugins
</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
IntelliJ uses repositories from pom.xml for your maven project and settings.xml, your maven configuration file. In order to get dependencies from repote repository and by not adding pom.xml, I believe you should define repository in settings file.
By default, this file is located in your home folder like {home}/.m2/settings.xml
Try add this configuration:
<settings>
...
<profiles>
...
<profile>
<id>myprofile</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>my-repo2</id>
<name>your custom repo</name>
<url>http://jarsm2.dyndns.dk</url>
</repository>
</repositories>
</profile>
...
</profiles>
<activeProfiles>
<activeProfile>myprofile</activeProfile>
</activeProfiles>
...
</settings>
Also remember that you should either use profile while using maven or make it active by default. See more information here
I want to build a spring mvc project by maven, I got the following error:
The following artifacts could not be resolved: org.aopalliance:com.springsource.org.aopalliance:jar:1.0.0, org.hibernate:hibernate-validator:jar:4.2.0.Beta1: Could not find artifact org.aopalliance:com.springsource.org.aopalliance:jar:1.0.0 in central (http://repo1.maven.org/maven2)
I use eclipse and m2eclipse plugin. I don't know how to add local repository. And I found for different versions of eclipse,the result is different. Some can pass, some fail. I am confused.
By the way where can I find the version of maven used in m2eclipse?
Update:Now I can handle hibernate-validator,but even I deleted all spring mvc dependencies,I found there are many other library are dependent on com.springsource.org.aopalliance,
Check your %.m2\repository\org\aopalliance\com.springsource.org.aopalliance\1.0.0\.
If there isn't a com.springsource.org.aopalliance-1.0.0.jar in there, just download it by yourself and copy it to this folder.
Since you are working with spring artifacts, you can refer to this doc. If you are working on released versions of spring, you can add the following repository in your settings.xml
<repository>
<id>com.springsource.repository.maven.release</id>
<url>http://maven.springframework.org/release/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
[Edit 1: based on the comment]
The groupId/projectId of aopalliance seems to indicate it is in spring enterprise bundle repository. The contents of this accessible from the following repository url.
<url>http://repository.springsource.com/maven/bundles/release/</url>
As for hibernate-validator, being a beta release, it is possibly not available in the normal repos. It is available from
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
The version of maven used in m2eclipse can be found in Window->Preferences->Maven->Installations
It looks like the artifact cann't be found in any repository you have defined in your settings.xml or pom file. Try adding sonatype repositories, they have artifacts you're looking for
In your pom.xml , add :
<project>
...
<repositories>
<repository>
<id>sonatype repo</id>
<url>https://repository.sonatype.org/content/repositories/central</url>
</repository>
</repositories>
...
</project>
However it's good practice to have its own repository manager (nexus, archiva, ...)
You should add the "external" repository to your pom.xml:
<repository>
<id>com.springsource.repository.bundles.external</id>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
My complete repositories tag in pom.xml is as follows:
<repositories>
<repository>
<id>com.springsource.repository.maven.release</id>
<url>http://repo.springsource.org/release/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>com.springsource.repository.bundles.release</id>
<url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
</repositories>
I just created a new Maven project using the default archetype and added the following dependency to my POM file.
<dependencies>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
<version>1.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
Realizing that the Sun's JARs are not on Maven central due to licensing issues, I added
the following Maven repo to my POM (I know this is bad practice though and that it needs to be added to a settings.xml)
<repositories>
<repository>
<id>Repo ID</id>
<layout>default</layout>
<name>Java.net Maven repo</name>
<releases>
<enabled>true</enabled>
</releases>
<url>http://download.java.net/maven/2/</url>
</repository>
</repositories>
I still see this error in my POM file.
"Missing artifact javax.jms:jms:jar:1.1:compile"
Does anyone here know what else needs to be done in addition to the config I already have?
Realizing that the Sun's JARs are not on Maven central due to licensing issues, I added
the following Maven repo to my POM
Yeah, but http://download.java.net/maven/2/javax/ doesn't have the jms artifact...
The good news is that the JBoss Nexus repository does have it:
<repository>
<id>repository.jboss.org-public</id>
<name>JBoss repository</name>
<url>https://repository.jboss.org/nexus/content/groups/public</url>
</repository>
If you just want the jms artifact and don't want to add the whole repo, you can do the following:
wget https://repository.jboss.org/nexus/content/groups/public/javax/jms/jms/1.1/jms-1.1.jar
mvn -e install:install-file -Dfile=./jms-1.1.jar -DartifactId=jms -DgroupId=javax.jms -Dversion=1.1 -Dpackaging=jar
In fact the real solution for this issue is to use the jms-api-1.1-rev-1.jar artifact available on Maven Central : http://search.maven.org/#artifactdetails%7Cjavax.jms%7Cjms-api%7C1.1-rev-1%7Cjar