Maven Tycho: Cannot add artifact descriptor which has not been created by this repository - maven

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.

Related

Maven:Including jars from remote repository

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.

How to use the target folder of another project as target platform repository in a Tycho build?

I am creating an Eclipse plugin in an continuous integration environment. My project contains four child modules as follows
parent
---p2Repository
---eclipseplugin
---feature
---updateSite
During the continuous integration build, first the p2 repository for the dependencies is created. My Eclipse plugin project needs to point to the p2Repository's target folder to get the dependecies. But by providing the following code in the eclipse-plugin POM file is not working:
<repositories>
<repository>
<id>Dependencies</id>
<layout>p2</layout>
<url>file:/../p2Respository/target/repository/</url>
</repository>
</repositories>
Any advice?
The file URL you specified does not represent a relative path, and relative URLs are not supported in the repositories configuration.
But you can simply construct an absolute URL pointing to the sibling project's target folder by using the ${project.baseUri} Maven property:
<repositories>
<repository>
<id>Dependencies</id>
<layout>p2</layout>
<url>file:/${project.baseUri}/../p2Respository/target/repository/</url>
</repository>
</repositories>

Maven: Error resolving version for plugin

I am trying to get Batik working, having not worked with Java much in the last ten years or so and I'm running into problems with Maven being able to find the org.apache.maven.wagon:wagon-ssh-external package.
When I open or try to build the project in Netbeans, it reports the following error:
The project org.freehep:freehep-graphicsio:2.1.1 (/home/glenatron/Projects/batik/freehep-graphicsio/pom.xml) has 1 error
Unresolveable build extension:
Error resolving version for plugin 'org.apache.maven.wagon:wagon-ssh-external' from the repositories [local (/home/glenatron/.m2/repository), freehep-maven (http://java.freehep.org/maven2), central (http://www.ibiblio.org/maven2), Codehaus (http://repository.codehaus.org/), Codehaus Snapshots (http://snapshots.repository.codehaus.org/)]:
Plugin not found in any plugin repository -> [Help 2]
As far as I can tell this is correct, however, I have the following in my pom.xml file for the project:
<repositories>
<repository>
<id>freehep-maven</id>
<name>Maven FreeHEP</name>
<url>http://java.freehep.org/maven2</url>
</repository>
<repository>
<id>maven-apache</id>
<name>Maven Apache</name>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>maven1</id>
<name>Maven.org</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
From what I can judge a) that plugin should be available in one of those repositories and b) if they are in the pom.xml file, Maven should be searching them but I can't see any sign of it doing that.
The project I am trying to work with is the FreeHEP EMF driver. The bigger screen solution was to use the unsignposted but much more up to date Github repository version.
It turns out that the solution was in the message after all: Error resolving version for plugin.
So obviously it's not a repository it is a pluginRepository which goes in a different part of pom.xml:
<pluginRepositories>
<pluginRepository>
<id>maven1</id>
<name>Maven.org</name>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>
Remove the entries with repo1... cause this is maven Central and used by Maven by default so no need to define it explicit. Furthermore the given freehep.org is also available via Maven Central. So if i see it correct you don't need to define supplemental repositories at all.

Installing a maven project with a dependency on a parent

I have a collection of related projects that inherit from a common maven project.
Since they are still in alpha release, they all (including the parent) are deployed in the Sonatype snapshots repository, instead of Maven central.
The configuration for accessing the maven central is in the parent project of my application.
So its POM specifies as its parent:
...
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
...
And set the corresponding repository at Sonatype:
...
<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>
...
So the children projects do not have to repeat this configuration.
The parent also provides many other things that are common to all my projects.
Currently I keep all these projects in unrelated directories.
Now, if a user of my application checkout one of my projects and attempt to install it with mvn install, he will receive the error: Non-resolvable parent POM: Could not find artifact ...
This makes sense to me, since the project cannot access the Sonatype repository (e.g., for downloading the parent) since it is precisely the parent the one that contains how to connect to such repository.
I do not want to request the user to install first the parent project, since he should be able to install what he needs in just one single step.
Then what is the recommended way to distribute my libraries so the user can install any of them with one single command ?
It occurs to me that I could include the parent POM in each of the projects (for example, using git submodules) so the parent can be resolved locally. But I am wondering if this is the best way to organize this (?). Any better alternative is appreciated.
UPDATE
I added this to my ~/.m2/settings.xml so the parent POM could be resolved in the Sonatype snapshots repository. Apparently it is working fine and the parent POM is resolved as any other dependency.
<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>
If you want to keep it to one step install than you have to list enough information in the project pom, i.e. either:
no parent pom, put all the information into each project pom
tell maven where to find your other projects. List the sonatype shnapshot repo in each project file.
A repository manager only helps those with access to it. That is ok if the users are in one organisation. Using the sonatype repository reaches a wider circle.

Maven: adding dependency not present in the mirror

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>
...

Resources