I wish to include jars present under \10.171.98.23 system [ex:\10.171.98.23\workspace\Project\lib] in my pom.xml by making use of remote repository concept.
How it could be achieved in Maven?Any suggestions would be more useful to proceed
The simplest example would be:
<repositories>
<repository>
<id>my-internal-site</id>
<url>http://myserver/repo</url>
</repository>
</repositories>
Check the documentation for more détails. You could also have a look at Maven the reference guide.
Related
I'm trying to build an RCP application via Tycho and I receive this error when exporting the product.
I don't really understand the issue, but could it be that the reason why it fails it's because I'm using multiple P2 repositories to retrieve my plugins dependencies?
This is the snipped of the repositories I've defined in my parent POM. The rest is pretty standard Tycho.
<repositories>
<repository>
<id>eclipse-luna</id>
<url>${eclipseLuna}</url>
<layout>p2</layout>
</repository>
<repository>
<id>systems-rc-p2</id>
<url>${systemsRcP2}</url>
<layout>p2</layout>
</repository>
<repository>
<id>systems-snapshots-p2</id>
<url>${systemsSnapshotsP2}</url>
<layout>p2</layout>
</repository>
</repositories>
I found the issue.
Basically for some reason (project needs) I had to change the "sourceDirectory" and the "outputDirectory" of the project, pointing them to the classic "src" and "bin" instead of the Maven default "src/main" and "target".
In particular, what was causing the issue was the redefinition of the <outputDirectory> property and the <directory> one. It looks like Tycho does not like it at all.
In maven settings, there is an entity which refers the local repository:
<localRepository>~/.m2/repository</localRepository>
When I add another one, like this:
<localRepository>~/another/place</localRepository>
it raises Duplicated tag error.
Can I have multiple local repository or maybe add another direcotry to the local repository?
EDIT
This idea seems a possible answer, too:
mvn -Dmaven.repo.local=/path/to/repo
Yes you can have and you can do it in your POM.xml itself. Below is an example.
<project>
...
<repositories>
<repository>
<id>firstrepo</id>
<name>repo</name>
<url>http://myrepo.my</url>
</repository>
<repository>
<id>secondrepo</id>
<name>repo2</name>
<url>http://myrepo.yours</url>
</repository>
</repositories>
...
</project>
Second Method by creating profile in your settings.xml
For multiple local repositories you can have multiple settings.xml file.
In the command line specify alternate path using
mvn -Dmaven.repo.local=/path/to/repo For more information you can check this link. Hope it helps.
I have a nexus repo on my network. In settings.xml on the build server we have
<mirror>
<id>company.com</id>
<name>nexus</name>
<url>http://build.company.com/nexus/content/groups/public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
On this build server we have a number of proxy repositories defined for public repos, and I have some commercially licensed artifacts in a hosted repo.
And a profile - Maven cannot resolve my parent pom (artifact in nexus) without this:
<profiles>
<profile>
<id>repos</id>
<repositories>
<repository>
<id>my-local-repo</id>
<name>bootstrapthingy</name>
<url>http://build.company.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>repos</activeProfile>
</activeProfiles>
My question today:
I also have removed all my
<repositories>
tags from the parent pom that all projects (should eventually!) inherit, and everything seems to work.
Is this well and good? I seem to end up a lot thinking about best practice when I work with maven - lately, around where should information be kept?
As my repositories are now defined at Nexus level, there is an element of my build that is no longer source code controlled, and this bothers me.
Yes I would argue you're on the right track!
Maven recommends to think about your infrastructure and plan it! By that it splits project concerns from infrastructure aspects. Project specific configuration goes into the pom.xml while I would vote to put infrastructure configuration into settings.xml
So the company mirror / proxy goes into settings.xml (as infrastructure may change) along with its authentication and environment settings (that are project independant!)
Usually projects do not rely on a per-project repository. If they do they could in almost any case use the nexus server for that (lets say explicit SNAPSHOT dependencies). So the practice to not have repositories in a pom.xml is ok. URL's change and builds should not request artifacts at different locations. It endangers your build reproduce-ability (as does adding all kinds of unstable remote repos into nexus).
I think within a company you need to consider (or simply acknowledge) that builds in projects are not self-maintained. Most open-source projects are since they do not have a common shared infrastructure they may benefit from (or suffer under?). You need to do the best of it but having infrastructure issues solved in settings.xml also means that the project does not need to do that anymore. Has pro's and con's - no doubt about that :)
I want to include a parent in a project pom, containing distribution management and repositories. As one would expect.
When I mvn package the child, maven is unable to resolve the parent pom, unsurprisingly.
I can make it resolve the parent by adding my internal nexus repository to the child pom. But this sounds like eggs laying chickens - I'm telling the child something it should know from the parent. I would have to add this repo to every child pom that has a parent.
How can I avoid this?
As khmarbaise wrote, you need to define your repositories in a profile in your settings.xml (this seems somewhat weird, but is actually the only feasible way):
<profiles>
<profile>
<id>repos</id>
<repositories>
<repository>
<id>my-local-repo</id>
<name>Projektserver Snapshots</name>
<url>http://my-server/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
<updatePolicy>daily</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>repos</activeProfile>
</activeProfiles>
Depending on your actual config, you would also include mirror setting and might call your local nexus central.
Sounds like the parent has been deployed to your internal nexus repository so it picks it up from there once you add in the distribution management and repository details.
To make it pick it up from your local copy. First ensure the versions match. Then navigate to the parent and run mvn clean install. This will push the parent pom to your local maven repo.
You may also get round this by ensuring you have added the releativePath element to the parent details in the child pom, you may not need to manually build the parent then but im not 100% sure and havent tested that.
The only things which should defined in your pom is distributionManagement the repositories should be defined in settings.xml instead.
We are using a local nexus mirror for all of our dependencies.
I need the following dependency in one of the projects:
<depedency>
<groupId>com.smartgwt</groupId>
<artifactId>smartgwt</artifactId>
<version>3.0</version>
</depedency>
from the repository: http://www.smartclient.com/maven2
But maven is giving me error saying that "Failure to find com.smartgwt:smartgwt:jar:3.0".
What might be the problem and how can I solve it?
(Maybe this is very trivial question but I am fairly new to Maven)
I'm assuming Nexus is working for all your standard dependencies hosted on Maven Central.
You can work out where Maven is downloading from by turning on debugging with the -X parameter when doing a build. There will be a lot of noise but if you look a few lines above where your build fails because of failing to find the dependency, it will tell you:
where it is trying to download the dependency
whether it is using a mirror
if there are any HTTP error codes when downloading
How is http://www.smartclient.com/maven2 set up in your Nexus proxy? As a separate proxy repository? Can Nexus access this repo (is it 'In Service' and not blocked)?
Is this repository in Nexus added to the 'public' group? If you don't want this then:
You have to configure a separate mirror in your settings.xml for this repository which points to the URL in Nexus.
Also check that you have added the repository in your POM, e.g.
<project>
...
<repositories>
<repository>
<id>smartclient</id>
<name>SmartClient Maven Repository</name>
<url>http://www.smartclient.com/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
...
</project>
And then configure a proxy entry in your settings.xml for this repository:
<settings>
...
<mirrors>
<mirror>
<id>smartclient-nexus-proxy</id>
<mirrorOf>smartclient</mirrorOf>
<url><url of your smartclient proxy repository in Nexus></url>
</mirror>
...