Tycho - "Poor Restriction" on Import-Package

I am just starting out with Quiet, and I'm at an impasse at an early stage. Perhaps I am misunderstanding something, so just in case, this is what I expect: I determine my needs for a set in the OSGi style (i.e. In MANIFEST.MF via Import-Package ), and Tycho somehow uses instead, I need to redefine this information in Maven style instead (that is, I do not need to install dependencies in pom.xml).

So, I created a simple Maven project in Eclipse with the m2eclipse plugin, the addition of m2eclipse-tycho and the PDE plugin and added the following Tycho data to pom:

 <properties> <tycho-version>0.15.0</tycho-version> </properties> <build> <plugins> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-maven-plugin</artifactId> <version>${tycho-version}</version> <extensions>true</extensions> </plugin> </plugins> </build> 

Affected some terrible configuration errors and finally got a substantially empty project (i.e. no source code) that did not give any errors or warnings in Eclipse. Then I copied the source code from another project, and (as expected) got a bunch of compiler errors due to the lack of dependencies. The first was AbstractChannel from org.jboss.netty.channel. I am using version 3.5.1.Final Netty, so I edited my MANIFEST.MF file to include:

 Import-Package: org.jboss.netty.channel;version="[3.5.1,4)" 

Then I expected Tycho to somehow magically find out that I needed Netty, and so act as if I had entered something like the following into my Maven pom.xml:

 <dependency> <groupId>org.jboss.netty</groupId> <artifactId>netty</artifactId> <version>3.5.1.Final</version> </dependency> 

Instead, everything that happened, I got one additional error in Eclipse, saying:

 Unsatisfied constraint: 'Import-Package: org.jboss.netty.channel;version="[3.5.1,4.0.0)" 

I don’t know where to go from here. Do I have any fundamental misunderstanding of what Ticho should do? Or is there something else I need to configure so that it can perform a "magic" translation from the Import-Package entry in MANIFEST.MF to the <dependency> pom.xml entry? Or something else?

Thanks in advance.

+6
source share
3 answers

Yes, there are a few more obstacles.

In short, you will need to provide Tycho a repository from which it can get dependencies.

A bit more detailed:

  • you need to configure your target platform and pass it to Tycho. I think you have already somehow set up your target platform, otherwise Eclipse would also welcome the absence of Netty.
  • Make sure you use your target platform in your workspace, so Tycho can also access it.
  • Tell Tycho to use this target platform like this
  • Tycho-supported target platforms only support p2 layouts, so there are no simple directories. I'm not sure what the best way to do a p2 repo is like this, as I asked a back . There is no answer, but I explain what works for me (of type).

Hope this helps, Frank

+3
source

Your understanding is already good, but there is a small but necessary part. Unlike Maven, Tycho has no canonical default repository (for example, "central"). You need to configure where Tycho will look for OSGi dependency resolution.

This search area is called the β€œ target platform ” in Tycho. There are various ways, therefore, include artifacts in the target platform ; The easiest way is to configure the p2 repository containing your dependencies in the POM, with the optional attribute <layout>p2</layout> (if you know the p2 repository containing the dependencies).

+3
source

It is also possible to add the missing package through an additional dependency configuration directly to the failed package:

 <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>target-platform-configuration</artifactId> <version>${tycho.version}</version> <configuration> <dependency-resolution> <extraRequirements> <requirement> <type>eclipse-plugin</type> <id>org.eclipse.jface.text</id> <versionRange>0.0.0</versionRange> </requirement> </extraRequirements> </dependency-resolution> </configuration> </plugin> 
0
source

Source: https://habr.com/ru/post/924006/


All Articles