Maven Repository URL - maven

I am new to maven and trying to understand how it works.
I am using maven to build my project. It download the jars that I have listed in pom.xml file. I do Maven Intall (eclipse), it downloads the jar file in my .m2/repository folder. Everything works well but I cannot figure out how it knows to pull the jar files from https://repo.maven.apache.org/maven2/. In which file, this url is defined. I do not have setting.xml file in .m2/repository and I do not have reference to https://repo.maven.apache.org/maven2/ in pom.xml. I searched everywhere in my project but no references to this URL. Just wondering which file has this URL.
thank you so much

The Maven Central Repository is defined in the Maven "Super POM".

Related

IntelliJ downloads all the jars from my local maven repo to the system/jars folder

I am new to intelliJ and trying to import maven projects. IntelliJ downloads all the jars from my local maven repo to the system/jars folder. Which is getting huge.
How can i make sure it does not copies the jar from local maven repo to system/jars folder instead should resolve dependency from the local maven repo only
Today I'v found that my system/jars folder is 6.6GB, maven dependencies which were updated are kept in jars folder even when not used.
Is there a possibility to clean this folder from old dependencies?
Also it would be better to use dependencies from local maven repo rather than making duplicates.

maven dependency repository with dots in folder's name

There I described a problem: maven can't find dependencies [dependencyResolutionException]
But when I start to analyze the url from which maven try to download object I saw
http://artifacts.com/rep/com/project/rest/common/2.0.5/common-2.0.5.pom
that it uses com/project/rest path. But in the repository in artifacts.com it has folder with com.project.rest and not subfolder structure.
How to resolve it? How to make maven download from
http://artifacts.com/rep/com.projet.rest/common/2.0.5/common-2.0.5.pom

Include java webapp lib in maven build

I was having a dynamic webapplication created on eclipse. I converted it to a maven project using M2E plugin. I added maven war plugin in the pom.xml so that it can create war for my project using maven build.
But when I do the build, it fails to compile few classes which has reference to the jars of my webapp/Web-INF/lib folder. These jars I can't include as dependency in pom.xml.
How can I tell maven to include Web-INF/lib jars also while building classes and creating a war?
Its not correct way of doing this , you should not put any jar manually in WEB-INF/lib folder.
And if that jar is not available in MAVEN CENTRAL REPO , then you can download it and install it in your NEXUS CENTRAL REPO (if you have any) otherwise put that jar in your local maven repository and add it as a dependency in your pom file. If you don't want to include that jar in your WEB-INF/lib then change the scope to provided otherwise leave it as default i.e compile.
During build time MAVEN will look for that particular jar in your local repo first , and if it don't find it there then it try to download from Centra Repo.
Once it is available in your local repo , your build won't break.

find out from which maven repository the jar is coming from

There is a plugin that works properly in my co-worker's system but doesn't in mine. I suspect it because of a repository included in his settings.xml but not in mine. Is there a tool that I can use to figure out from which repo is this plugin being downloaded from?
Maven stores that info in a file called _maven.repositories in your local maven repository (typically ~/.m2/repositories) for each artifact. The file is located right beside the corresponding artifacts in the local maven repository.
This file will typically list the repository / plugin-repository that the artifact was downloaded from. This matches to the repository from your settings.xml file.
In Maven 3, the file seems being changed to _remote.repositories

How do I add an artifact to a local maven repository so that it will properly reference its own set of dependencies?

I am developing an application that depends on a number of legacy JAR files and I want the project to build straight out of version control without other users having to install these JARs in their local repository. I cannot add them to the corporate repository so I have created a repository that is local to this project and I have added these JARs to that repository using maven-install-plugin:install-file and setup the repository entry in the POM file so it knows to search the local repository.
This works exactly the way I want...up to a point. The problem is that most of these legacy JAR files have their own set of dependencies. I would like for them to work just like other artifacts that have their own set of dependencies so that maven can resolve everything and include all the necessary files but I can't find a way to do this with any maven-install-plugin:install-file options (or any other maven commands/plugins). I am pretty new at maven so I am probably just ignorant on this point.
As a work around, I attempted to go into the local repository directory and manually edit the POM file for the artifact to include the dependencies. This didn't cause any errors but it is also not pulling in those dependencies.
Can someone out there give me a clue?
The maven-install-plugin:install-file goal has a pomFile attribute. You can use this to specify a POM file for your legacy jar. You would create a POM file that points to all of the dependencies by artifactId in the <dependencies> section. If you have a remote nexus repository you can use the admin screen for the repository to deploy a jar.
Once you edit POM files in your project specific repository, host it as maven repo using Maven Repository Managers (like sonatype nexus). Add your project nexus repo as one of the maven repo in project pom.xml as below
<repositories>
<repository>
<id>my-project-mvn-repo</id>
<name>my-project-mvn-repo</name>
<url>http://<your project maven repo URL here></url>
</repository>
<repositories>
Now all developers should be able to make build. The legacy jar files POM contains dependency. Maven should take care of automatically pulling dependent jars on developer's workspace.

Resources