Search code examples
eclipse-pluginsbttycho

How to build Eclipse plugin project with dependency on Eclipse Birt?


I have a set of Maven projects that I would like to migrate to SBT.

Tne only thing stopping me to do so, it's a project that is an Eclipse plugin, that has dependencies with Eclipse Birt.

The Tycho plugin for Maven, handles all the dependencies. This tool isn't available in SBT. I've found sbt-tycho plugin for SBT, but it looks like unmaintained (3 years with no activity).

Maybe I could build my Eclipse plugin with Maven, and the rest of projects with SBT. But don't know if this is possible.

Other alternative is to use Gradle, by means of the wuff plugin.

Related questions in StackOverflow:

But I prefer SBT before Maven or Gradle, in order not to introduce yet another language besides Scala.

Is it possible to have all projects in SBT except the one that uses Tycho (Eclipse plugin)?. The Eclipse plugin project is a dependency of the main project, and it rarely changes.

Any ideas?

Update 1: additional information. Eclipse plugins use the p2 repository format for handling dependencies, instead of the standard Maven repository used for Gradle, Maven, Ivy and SBT. That's why special tools are needed. My custom Eclipse plugin has over 100 indirect p2 dependencies.

Update 2

pom.xml of my Eclipse plugin:

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
    <groupId>myCompany</groupId>
  <artifactId>myPlugin</artifactId>
    <version>1.0.0-SNAPSHOT</version>
  <packaging>eclipse-plugin</packaging>
  <properties>
    <tycho.version>0.19.0</tycho.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <repositories>
    <repository>
      <id>eclipse</id>
      <url>http://download.eclipse.org/releases/kepler</url>
      <layout>p2</layout>
    </repository>
    <repository>
      <id>babel</id>
      <url>http://download.eclipse.org/technology/babel/update-site/R0.11.1/kepler</url>
      <layout>p2</layout>
    </repository>
    <repository>
      <id>logback</id>
      <url>http://logback.qos.ch/p2/</url>
      <layout>p2</layout>
    </repository>
  </repositories>

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

      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>target-platform-configuration</artifactId>
        <version>${tycho.version}</version>
        <configuration>
      <resolver>p2</resolver>
      <environments>
              <environment>
                <os>linux</os>
                <ws>gtk</ws>
                <arch>x86_64</arch>
              </environment>
              <environment>
                <os>win32</os>
                <ws>win32</ws>
                <arch>x86</arch>
              </environment>
      </environments>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

Solution

  • It appears that the support for Eclipse updatesite with OSGi bundles is already available in Ivy. It doesn't however mean that the resolver can be used directly in sbt (I have never read about it and seen it in use before so I might be mistaken).

    There's a way to include any resolver of Ivy in sbt using externalIvySettings():

    create the configuration files as you would for Maven (pom.xml) or Ivy (ivy.xml and optionally ivysettings.xml). External configuration is selected by using one of the following expressions.

    There's Ivy settings (resolver configuration) with externalIvySettings and Ivy file (dependency configuration) with externalIvyFile.

    My guess is that you might be quite successful leveraging the support. Just add externalIvySettings and/or externalIvyFile to build.sbt, and create ivy.xml in the top-level directory of the Eclipse plugin's project with a declaration of Ivy's Eclipse updatesite resolver.

    You may want to explore the support with the following build.sbt:

    externalIvySettings()
    
    libraryDependencies += "bundle" % "org.eclipse.swt.cocoa.macosx.x86_64" % "3.100.1.v4234e"
    

    Place ivysettings.xml in the project's top-level directory (alongside build.sbt):

    <ivysettings>
      <settings defaultResolver="chain"/>
      <resolvers>
        <chain name="chain">
          <ibiblio name="central" m2compatible="true"/>
          <updatesite name="eclipse-juno" url="http://download.eclipse.org/releases/juno" />
        </chain>
      </resolvers>
    </ivysettings>
    

    With the two files above I could update up to failing on some packages:

    > update
    [info] Updating {file:/Users/jacek/sandbox/eclipse-p2/}eclipse-p2...
    :: loading settings :: file = /Users/jacek/sandbox/eclipse-p2/ivysettings.xml
    [warn]  module not found: package#org.eclipse.swt.accessibility2;[0.0.0,)
    [warn] ==== central: tried
    [warn]   http://repo1.maven.org/maven2/package/org.eclipse.swt.accessibility2/[revision]/org.eclipse.swt.accessibility2-[revision].pom
    [warn]   -- artifact package#org.eclipse.swt.accessibility2;[0.0.0,)!org.eclipse.swt.accessibility2.jar:
    [warn]   http://repo1.maven.org/maven2/package/org.eclipse.swt.accessibility2/[revision]/org.eclipse.swt.accessibility2-[revision].jar
    [warn] ==== eclipse-juno: tried
    [warn]  module not found: package#org.mozilla.xpcom;[0.0.0,)
    [warn] ==== central: tried
    [warn]   http://repo1.maven.org/maven2/package/org.mozilla.xpcom/[revision]/org.mozilla.xpcom-[revision].pom
    [warn]   -- artifact package#org.mozilla.xpcom;[0.0.0,)!org.mozilla.xpcom.jar:
    [warn]   http://repo1.maven.org/maven2/package/org.mozilla.xpcom/[revision]/org.mozilla.xpcom-[revision].jar
    [warn] ==== eclipse-juno: tried
    [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
    [warn]  ::          UNRESOLVED DEPENDENCIES         ::
    [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
    [warn]  :: package#org.eclipse.swt.accessibility2;[0.0.0,): not found
    [warn]  :: package#org.mozilla.xpcom;[0.0.0,): not found
    [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
    [warn]
    [warn]  Note: Unresolved dependencies path:
    [warn]      package:org.eclipse.swt.accessibility2:[0.0.0,)
    [warn]        +- bundle:org.eclipse.swt:[3.0.0,4.0.0)
    [warn]        +- bundle:org.eclipse.swt.cocoa.macosx.x86_64:3.100.1.v4234e (/Users/jacek/sandbox/eclipse-p2/build.sbt#L3-4)
    [warn]        +- default:eclipse-p2_2.10:0.1-SNAPSHOT
    [warn]      package:org.mozilla.xpcom:[0.0.0,)
    [warn]        +- bundle:org.eclipse.swt:[3.0.0,4.0.0)
    [warn]        +- bundle:org.eclipse.swt.cocoa.macosx.x86_64:3.100.1.v4234e (/Users/jacek/sandbox/eclipse-p2/build.sbt#L3-4)
    [warn]        +- default:eclipse-p2_2.10:0.1-SNAPSHOT