Try to generate a p2 site with mixed osgi and non osgi bundle
Asked Answered
N

0

0

I try many thing to create a p2 repository with all transitive (OSGI and non OSGI) maven dependencies of my project, but tycho take only account of osgi.bundle ?

The maven-dependency-plugin copy all the maven files, and tycho-p2-extras-plugin generate the metadata for p2 site. tycho-p2-repository-plugin generate the p2 repository using the /target/source/plugins dependencies previously downloaded.

<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.genstar</groupId>
    <version>1.0.0</version>
    <artifactId>genstar-bundle</artifactId>
    <packaging>pom</packaging>

    <properties>
        <tycho.version>0.26.0</tycho.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.genstar</groupId>
            <artifactId>genstar-core</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <id>bintray-anrgenstar-genstar-packages</id>
            <name>bintray</name>
            <url>http://dl.bintray.com/anrgenstar/genstar-packages</url>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>copy-bundles-for-publishing</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.basedir}/target/source/plugins</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.eclipse.tycho.extras</groupId>
                <artifactId>tycho-p2-extras-plugin</artifactId>
                <version>${tycho.version}</version>
                <executions>
                    <execution>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>publish-features-and-bundles</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <includeAllDependencies>true</includeAllDependencies>
                    <compress>false</compress>
                    <append>false</append>
                    <publishArtifacts>true</publishArtifacts>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-p2-plugin</artifactId>
                <version>${tycho.version}</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>category-p2-metadata</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <target>${basedir}/target/repository</target>
                    <categoryDefinition>${project.basedir}/category.xml</categoryDefinition>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-p2-repository-plugin</artifactId>
                <configuration>
                    <includeAllDependencies>true</includeAllDependencies>
                </configuration>
                <version>${tycho.version}</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>archive-repository</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project> 

The project dependency tree by maven :

[INFO] --- maven-dependency-plugin:3.0.0:tree (default-cli) @ genstar-bundle ---
[INFO] org.genstar:genstar-bundle:pom:1.0.0
[INFO] \- org.genstar:genstar-core:jar:1.0:compile
[INFO]    +- org.apache.logging.log4j:log4j-api:jar:2.7:compile
[INFO]    +- org.apache.logging.log4j:log4j-core:jar:2.7:compile
[INFO]    +- net.sf.opencsv:opencsv:jar:2.3:compile
[INFO]    +- org.apache.poi:poi-ooxml:jar:3.9:compile
[INFO]    |  +- org.apache.poi:poi:jar:3.9:compile
[INFO]    |  |  \- commons-codec:commons-codec:jar:1.5:compile
[INFO]    |  +- org.apache.poi:poi-ooxml-schemas:jar:3.9:compile
[INFO]    |  |  \- org.apache.xmlbeans:xmlbeans:jar:2.3.0:compile
[INFO]    |  |     \- stax:stax-api:jar:1.0.1:compile
[INFO]    |  \- dom4j:dom4j:jar:1.6.1:compile
[INFO]    |     \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO]    +- javax.vecmath:vecmath:jar:1.5.2:compile
[INFO]    +- com.thoughtworks.xstream:xstream:jar:1.4.9:compile
[INFO]    |  +- xmlpull:xmlpull:jar:1.1.3.1:compile
[INFO]    |  \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO]    +- com.vividsolutions:jts-core:jar:1.14.0:compile
[INFO]    \- com.github.yannrichet:Rsession:jar:1.8.3:compile
[INFO]       +- org.slf4j:slf4j-api:jar:1.7.12:compile
[INFO]       +- commons-io:commons-io:jar:2.4:compile
[INFO]       +- com.github.yannrichet:JMathArray:jar:1.0:compile
[INFO]       |  \- gov.nist.math:jama:jar:1.0.3:compile
[INFO]       +- org.rosuda.REngine:REngine:jar:2.1.0:compile
[INFO]       \- org.rosuda.REngine:Rserve:jar:1.8.1:compile

And the final repository generated by tycho after mvn clean install only contains :

-rw-r--r-- 1 reyman reyman  50K janv. 19 23:15 genstar-core_1.0.0.jar
-rw-r--r-- 1 reyman reyman 166K janv. 19 23:15 javax.vecmath_1.5.2.jar
-rw-r--r-- 1 reyman reyman  72K janv. 19 23:15 org.apache.commons.codec_1.5.0.jar
-rw-r--r-- 1 reyman reyman 181K janv. 19 23:15 org.apache.commons.io_2.4.0.jar
-rw-r--r-- 1 reyman reyman 214K janv. 19 23:15 org.apache.logging.log4j.api_2.7.0.jar
-rw-r--r-- 1 reyman reyman 1,3M janv. 19 23:15 org.apache.logging.log4j.core_2.7.0.jar
-rw-r--r-- 1 reyman reyman  32K janv. 19 23:15 slf4j.api_1.7.12.jar
-rw-r--r-- 1 reyman reyman 537K janv. 19 23:15 xstream_1.4.9.jar

As you can see, only one part (osgi bundle) are present, why ? How can i include into this p2 repository all transitive dependencies downloaded by maven maven-dependency-plugin ?

Even an empty category.xml generate an artifact.xml which contain these lines which seems filtering osgi.bundle :s

  <mappings size='3'>
    <rule filter='(&amp; (classifier=osgi.bundle))' output='${repoUrl}/plugins/${id}_${version}.jar'/>
    <rule filter='(&amp; (classifier=binary))' output='${repoUrl}/binary/${id}_${version}'/>
    <rule filter='(&amp; (classifier=org.eclipse.update.feature))' output='${repoUrl}/features/${id}_${version}.jar'/>
  </mappings> 

How can i remove these rules in tycho ?

Nash answered 19/1, 2017 at 22:26 Comment(2)
Why do you want to put non-OSGi JARs into a p2 repository? Eclipse would not be able to install these anyway.Gabriellegabrielli
Perhaps this is a bad idea, this plugin for eclipse like project need to access all transitive dependencies, many of them are maven non osgi :/ So my first idea was to create a local p2 repository to generate my plugin + p2 site exposed into new software menu for eclipseNash

© 2022 - 2024 — McMap. All rights reserved.