maventycho

Tycho: 'Unable to satisfy dependency ...' when building via multi-module parent


I have to build an Eclipse-plugin with a Maven/Tycho which has dependencies to other 3rd parties. As embedding dependencies is not yet supported by Tycho, I split up projects into two as following:

When I build them separately (at first, thirdparty aggregator, then project A itself), everything works fine. However, if I aggregate both those projects (using multi-module POM), I get the following Maven ERROR:

Caused by: java.lang.RuntimeException: "No solution found because the problem is unsatisfiable.": ["Unable to satisfy dependency from A 1.0.0.qualifier to package org.apache.axis2.transaction 0.0.0.", "Unable to satisfy dependency from A 1.0.0.qualifier to package org.apache.axis2.addressing.i18n 0.0.0.", ...

Why does building projects in aggregated fashion causes this error, and what kind of workaround could be possible if that's a Tycho bug?

Though, there's no error if I leave only one module in aggregation POM (independently which one).

EDIT

Cannot reproduce with a small, similar multi-module sample. Which means there's something about my POM hierarchy.

EDIT2

Was able to reproduce with a small, similar multi-module sample, after including same set of dependencies (couple of axis2 & axiom libs).

EDIT3: Minimalistic Example

Now I'm wondering if the problem is about missing all thirdparties required by thirdparty libraries I included. If so, then why am I able to build successfully when executing both modules separately, and build fails only when done via parent, multi-module pom.xml? The example below includes only one single axis2-kernel JAR, bundled in a pom-first artifact named first-thirdparty.

Instead of A, example has keywoard first. The folder structure is as following:

./pom.xml
./first-thirdparty
    pom.xml
./first
    src/main/java/org/mydemo/Test.java // has just one method that simply returns AxisFault.class.getSimpleName(); to test import resolution
    META-INF/MANIFEST.MF
    build.properties
    pom.xml

Root pom:

<project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
        http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.mydemo</groupId>
    <artifactId>first-aggregator</artifactId>

    <packaging>pom</packaging>
    <version>1.0.0-SNAPSHOT</version>


    <modules>
        <module>first-thirdparty</module>
        <module>first</module>
    </modules>

</project>

POM of first-thirdparty. It simply embeds axis2-kernel JAR (no other libraries..):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=           "http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.mydemo</groupId>
        <artifactId>first-aggregator</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <properties>
        <manifest-location>META-INF</manifest-location>
    </properties>

    <packaging>bundle</packaging>

    <groupId>org.mydemo</groupId>
    <artifactId>first-thirdparty</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-kernel</artifactId>
            <version>1.5.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Embed-Dependency>
                            axis2-kernel
                        </Embed-Dependency>
                        <_exportcontents>
                            org.apache.axis2.*;version="1.5.1"
                        </_exportcontents>
                        <Bundle-ClassPath>{maven-dependencies}</Bundle-ClassPath>
                        <Embed-Transitive>true</Embed-Transitive>
                        <Embed-Directory>jars</Embed-Directory>
                        <_failok>true</_failok>
                        <_nouses>true</_nouses>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

POM of first, which is an eclipse-plugin, and depends on first-thirdparty:

<project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
        http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.mydemo</groupId>
        <artifactId>first-aggregator</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <groupId>org.mydemo</groupId>
    <artifactId>org.mydemo.first-bundle</artifactId>

    <packaging>eclipse-plugin</packaging>
    <version>1.0.0-SNAPSHOT</version>

    <properties>
        <tycho.ver>0.14.1</tycho.ver>
    </properties>

    <repositories>
        <repository>
            <id>helios</id>
            <layout>p2</layout>
            <url>http://download.eclipse.org/releases/indigo</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.mydemo</groupId>
            <artifactId>first-thirdparty</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
    </dependencies>

    <build> 
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-maven-plugin</artifactId>
                <version>${tycho.ver}</version>
                <extensions>true</extensions>
            </plugin>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>target-platform-configuration</artifactId>
                <version>${tycho.ver}</version>
                <configuration>
                    <pomDependencies>consider</pomDependencies>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

MANIFEST.MF of module first; it explicitly imports all packages of axis2-kernel:

Manifest-Version: 1.0
Bundle-Version: 1.0.0.qualifier
Tool: Bnd-0.0.357
Bundle-Name: first-bundle
Bnd-LastModified: 1334819004300
Created-By: 1.6.0_25 (Sun Microsystems Inc.)
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.mydemo.first-bundle
Export-Package: org.mydemo
Import-Package: org.apache.axis2.clustering.context,
 org.apache.axis2.modules,
 org.apache.axis2.deployment.util,
 org.apache.axis2.dataretrieval.client,
 org.apache.axis2.clustering,
 org.apache.axis2.wsdl.util,
 org.apache.axis2.clustering.configuration,
 org.apache.axis2.java.security,
 org.apache.axis2.deployment.resolver,
 org.apache.axis2.util,
 org.apache.axis2.wsdl,
 org.apache.axis2.addressing.metadata,
 org.apache.axis2.i18n,
 org.apache.axis2.deployment.scheduler,
 org.apache.axis2.dataretrieval,
 org.apache.axis2.dispatchers,
 org.apache.axis2.transport,org.apache.axis2.service,
 org.apache.axis2.deployment.repository.util,
 org.apache.axis2.client,
 org.apache.axis2.context,
 org.apache.axis2.classloader,
 org.apache.axis2.receivers,
 org.apache.axis2.engine,
 org.apache.axis2.addressing,
 org.apache.axis2.deployment,
 org.apache.axis2.transport.http,
 org.apache.axis2.phaseresolver,
 org.apache.axis2.context.externalize,
 org.apache.axis2.transaction,
 org.apache.axis2.description,
 org.apache.axis2.addressing.wsdl,
 org.apache.axis2.transport.http.util,
 org.apache.axis2.util.threadpool,
 org.apache.axis2,
 org.apache.axis2.handlers,
 org.apache.axis2.addressing.i18n,
 org.apache.axis2.builder,
 org.apache.axis2.description.java2wsdl,
 org.apache.axis2.builder.unknowncontent,
 org.apache.axis2.namespace,
 org.apache.axis2.description.java2wsdl.bytecode,
 org.apache.axis2.client.async,
 org.osgi.framework;version="1.3.0"
Bundle-Localization: plugin

Solution

  • It is not possible to build "POM-first" bundles (i.e. bundles built with maven-bundle-plugin) and "MANIFEST-fist" bundles (i.e. bundles built by Tycho) in the same reactor. This is a known limitation in Tycho.

    The reason is that Tycho does its dependency resolution too early in the Maven lifecycle when the maven-bundle-plugin has not yet had a chance to generate the Manifest (needed by Tycho). Addressing this problem needs quite large changes, but I still hope to get this done in mid-term.