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

2

8

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:

  • A-thirdparty: project with a packaging 'bundle', built by maven-bundle-plugin, having 'Embed-Dependency' instruction, and exporting all packages which are required by a plug-in 'A'
  • A: project with a packaging 'eclipse-plugin', using tycho-maven-plugin, and Tycho's target-platform-configuration plug-in with pomDependencies set to consider.

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
Andre answered 20/4, 2012 at 10:8 Comment(3)
It would help to show us your master pom.xml as well as what commands you're invoking Maven with.Left
@Left Ok, I'll put the code sample, as I managed to minimize the code.Andre
@Left There's not that much of code, but I'm considering to move it to some sharing storage. If you can suggest one, please do so. I'm wondering now, if the issue about that Axis2 dependencies are not included, and this affects build process. However, I'm able to build these modules separately, so I'm wondering what's wrong about aggregating them via multi-module parent.Andre
R
12

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.

Regnal answered 19/7, 2012 at 16:51 Comment(1)
Thanks, this is a really valuable comment. I'll make sure to open request as soon as possible, as we're interested in getting this case working within a single build. I'm accepting your answer as it clearly explains the cause of my problem.Andre
N
1

I have just get same issue.I solve my issue this way hope this would help you

1 the reason you get the error is because you lack of plugin jars. for example in you case

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

Just look at the first one, you do not have org.apache.axis2.transaction 0.0.0. in your maven repository. To be honest, i am not sure what is jar used for and how to get it, I was just missing some plugin dependency from other version of eclipse so i just need jar in /eclipse/plugins So what you do is create a p2 repository yourself. Here is another guy who right a link how to use script to create the p2 repository http://maksim.sorokin.dk/it/2010/11/26/creating-a-p2-repository-from-features-and-plugins/

2 put this repository in ur maven pom file

    <repository>
        <id>localP2resp</id>
        <url>file:///F:/P2Repository</url>
        <layout>p2</layout>
    </repository>

3 So far you should fix the problem if you have the plugin jars that you need in you P2repository

if you have any other questions or not so satisfy with mine answer, keep asking.

Nadler answered 29/6, 2014 at 0:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.