I have set up Nexus on and configured it so that it has a repository for my application and also the maven central repository exposed through a group called public and this groups is then added to my pom file:
<repositories>
<repository>
<id>repo1</id>
<name>my-repo</name>
<url>http://app1:8081/nexus/content/groups/public</url>
</repository>
I am able to browse the index both through eclipse maven repo browser and through a web browser but whenever I try and add a new dependency to the pom I get a missing dependency in my pom file and if I click on one of the jars in the maven repo browser in eclipse, even though it shows up in the tree I get an error message informing me that it could not resolve the artifact.
I want to be able to to disable the maven central mapping from within eclipse and ONLY go my Nexus server which has both maven central and my application specific repos supposedly exposed via the public group.
Can anyone help me with this configuration as currently I cannot resolve any new dependencies in any projects, I tried creating a new Spring MVC project and the only dependencies that resolved ok were the ones in my local maven respository.
Any help is appreciated.
The best way to enforce that only Nexus is used for artifact download is to set up a mirror in your settings.xml file. See here for information on how to do that:
http://books.sonatype.com/nexus-book/reference/maven-sect-single-group.html
Related
I am trying to setup a organization wide maven repository. I have installed archiva as a service and added a mirror in my local settings.xml of maven to disable the maven central.
I have uploaded my project1's jar into archiva internal repository. I use the groupid, artifactid and version number of the project1's jar in my project2's POM.xml. I see that that project1's jar has been added into maven dependencies. But the project1's dependencies are not downloaded.
I created the jar for project1 using maven build (using goal as "package"). What changes are needed in project1's POM.xml or any other configuration to make it work.
The issue was I was just uploading the jar. I was making a mistake of not uploading the POM.xml along with it. This resolved the issue for me.
For an Eclipse plugin project I need a p2 local repository to be automatically deployed with dependencies defined in the pom.
The best way (or the only way that really works) to do so is to use org.reficio plugin p2-maven-plugin.
Therefore I created a general project in Eclipse to prepare and hold the repository and a pom.xml that generates this repository.
When I execute the goal p2:site the repository is created successfully.
Now I am trying to make Eclipse with M2Eclipse to automatically execute that goal whenever the file pom.xml has ben changed (e.g. the user has added a new dependency or the file has been changed because an updated file has been downloaded from the SCM repository.
Is there a way to make M2Eclipse respectively it's Maven Project Builder to execute this phase automatically?
I am new to use maven to build projects, and IDE I am using is eclipse. For projects I built before, I never used attributes <repository> in POM file and they are running very well.
But when I read some projects in github, they always come with a POM file containing quite a lot of <repository>. After reading maven official website, I know that <repositories> are location to download jar files, but I am able to import all classes only specifying <dependencies> not <repositories>.
My question is why can I download libs without specify <repositories>? Is there a default value for repositories.
Yes there is the Maven Central repository, which is automatically bundled with your pom.xml / settings.xml if you don't specify one.
You usually specify a repo in your pom.xml when you need to access an artifact that your company produces internally, or when you want to reference snapshots or the third-party company you're working with hasn't given their artifacts to Central.
The dependency I'm using is for Oracle which, reading from another post, is not included in the default maven repo due to legal issues. For this reason I've added the dependency to my local repo using:
mvn install:install-file -Dfile=/home/<myname>/development/Libraries/ojdbc6.jar
-DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.3 -Dpackaging=jar
My problem is that maven is attempting to pull the file from the default remote repo and failing although it was my understanding that the local repo is checked first.
My install of maven is the default version packaged with STS (basically Eclipse).
Kind Regards,
Justin
Checking whether the jar got properly installed in your local repository might help. If you navigate to the .m2/repository/com/oracle/ojdbc6/11.2.03/ you should find the jar present there.
if this problem is present, i can suggest you to select the Offline option on maven uptade project. Whith this option enabled, the maven install search for local repository.
I would like to use my CVS as maven repository.. can anyone give suggestions?
There are 2 ways:
a) If you want to use it only in one project place a 'repo' directory at the toplevel. Than add jars in the maven convention (groupid in folders/artifactid/version/artifactif-version.jar).
To use this as a repository declare a file based repository in your pom.
<repositories>
<repository>
<id>some-repo</id>
<name>some-repo</name>
<url>file://${basedir}/repo</url>
<releases>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</repository>
</repositories>
If you use this from a module pom you have to use a url relative to your module pom.
b) if you want to use it for several projects there are socalled 'wagons'. There is one for svn. These maven plugins let you use a SCM as repository. I don't know whether there is a cvs-wagon.
I would not put the dependencies in an SCM system like CVS for many reasons.
Each time you update a dependency in the pom, you need to manually add the corresponding dependency jar - in the exact same folder structure as expected by maven.
You need to worry about transitive dependencies and it can be overwhelming.
Since these dependencies do not change (except if they are SNAPSHOTS), SCM is an overkill for them. Each time there is a new version of the dependency, it needs to be in a different folder structure.
If you want to have control over the dependencies, you could create your own maven mirror using a repository manager. These store the dependencies typically using some content management libraries and can be backed up/archived.
On a related note, Maven Wagon SCM Provider can be used to publish projects to an SCM, but has not been tested with SCM based remote repository.