Embed external dependencies

54 views
Skip to first unread message

Paula Melgar Guerra

unread,
Mar 15, 2021, 2:31:48 PM3/15/21
to cytoscape-helpdesk
Hello everyone,

I am currently trying to build my Cytoscape app using Mavenand one of the dependencies I need is external (the other are from org.cytoscape. I was looking for information and found that I had to use <Embed-Dependency>*;scope=!provided;groupId=!org.cytoscape</Embed-Dependency>  and write  <scope>provided</scope> in the other dependencies. I had "build success" in Eclipse and after insert my app on cytoscape and it works fine until I try to run something related to the added library. I really don't know what else to try, I'm attaching my pom.xml in case someone could solve the problem for me. Thanks in advance.

pd:In my plugin jar I have the .jar of the library so I think that maybe Cytoscape doesn't endure that library.


//POM.XML
<?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/maven-v4_0_0.xsd">
    <properties>
        <bundle.symbolicName>org.cytoscape.intento</bundle.symbolicName>
        <bundle.namespace>org.cytoscape</bundle.namespace>
    </properties>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.cytoscape.intento</groupId>
    <artifactId>Intento</artifactId>
    <version>1.0</version>
    <name>Intento</name>
    <packaging>bundle</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <optimize>true</optimize>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>

            <!-- Generates the OSGi metadata based on the osgi.bnd file. -->
            <!-- https://mvnrepository.com/artifact/org.apache.felix/maven-bundle-plugin -->
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>4.0.0</version>
                <extensions>true</extensions>
                <configuration>
                    <manifestLocation>META-INF</manifestLocation>
                    <instructions>
                        <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
                        <Bundle-Version>${project.version}</Bundle-Version>
                        <Bundle-Description>A cytoscape plugin called Intento</Bundle-Description>
                        <Bundle-Activator>${bundle.namespace}.intento.Intento</Bundle-Activator>
                        <Embed-Dependency>*;scope=!provided;groupId=!org.cytoscape</Embed-Dependency>
<!--                         <Embed-Transitive>true</Embed-Transitive>  -->
                        <Import-Package>*;resolution:=optional</Import-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>



    <!-- Dependencies needed to compile this project. -->
    <dependencies>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>4.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.cytoscape</groupId>
            <artifactId>service-api</artifactId>
            <version>3.7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.cytoscape</groupId>
            <artifactId>swing-application-api</artifactId>
            <version>3.7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.cytoscape</groupId>
            <artifactId>session-api</artifactId>
            <version>3.7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.cytoscape</groupId>
            <artifactId>application-api</artifactId>
            <version>3.7.0</version>
            <scope>provided</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.cytoscape/app-api -->
        <dependency>
            <groupId>org.cytoscape</groupId>
            <artifactId>app-api</artifactId>
            <version>3.7.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>pt.uminho.ceb.biosystems</groupId>
            <artifactId>JBiclustGE</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.cytoscape</groupId>
            <artifactId>model-api</artifactId>
            <version>3.7.0</version>
            <scope>provided</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.18</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.cytoscape</groupId>
            <artifactId>work-api</artifactId>
            <version>3.7.0</version>
            <scope>provided</scope>

        </dependency>
        <dependency>
            <groupId>org.cytoscape</groupId>
            <artifactId>layout-api</artifactId>
            <version>3.7.0</version>
            <scope>provided</scope>

        </dependency>
    </dependencies>

    <!-- Links to the Cytoscape Maven repositories. -->
    <repositories>
        <repository>
            <id>cytoscape_snapshots</id>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
            </releases>
            <name>Cytoscape Snapshots</name>
            <url>http://code.cytoscape.org/nexus/content/repositories/snapshots/</url>
        </repository>
        <repository>
            <id>cytoscape_releases</id>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
            </releases>
            <name>Cytoscape Releases</name>
            <url>http://code.cytoscape.org/nexus/content/repositories/releases/</url>
        </repository>
        <repository>
            <id>git-ornrocha</id>
            <url>https://github.com/ornrocha/thirdparty/raw/master/mvn-repo</url>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
    </repositories>
</project>

Scooter Morris

unread,
Mar 18, 2021, 11:45:01 AM3/18/21
to cytoscape-helpdesk
Greetings!  So, I have an additional stanza in my POM files:

<plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>${maven-bundle-plugin.version}</version>
        <extensions>true</extensions>
        <configuration>

          <instructions>
            <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
            <Bundle-Version>${project.version}</Bundle-Version>
            <Export-Package>!${bundle.namespace}.*</Export-Package>
            <Private-Package>${bundle.namespace}.*,com.jujutsu.*</Private-Package>
            <Bundle-Activator>${bundle.namespace}.CyActivator</Bundle-Activator>
            <Embed-Dependency>*;scope=!provided</Embed-Dependency>
            <Embed-Transitive>true</Embed-Transitive>

            <Import-Package>*;resolution:=optional</Import-Package>
          </instructions>
        </configuration>
      </plugin>

And then for my external dependencies:

    <dependency>
      <groupId>org.freehep</groupId>
      <artifactId>freehep-graphicsio-svg</artifactId>
      <version>2.2.1</version>
      <optional>true</optional>
    </dependency>

I *think* this tells Maven/OSGi to import the package, but I must admit that Maven remains a bit of a black box for me.  At any rate, this works in several of my apps that use external jars.

-- scooter
Reply all
Reply to author
Forward
0 new messages