4
votes

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>
2
Can you elaborate on "Maybe I could build my Eclipse plugin with Maven, and the rest of projects with SBT. But don't know if this is possible."? It is indeed possible to use Maven in a project and sbt in the others. Would you like to also keep the directory structure? How should the structure look like?Jacek Laskowski
The directory structure can be changed if needed.david.perez
When is the Eclipse plugin project needed for the other projects? How are they related to each other?Jacek Laskowski
There is a main project and several satellite ones. One of the satellite ones is an Eclipse Plugin that provides custom data to Eclipse Birt. The main project, uses the same Eclipse Birt plugins that the satellite one. So, using the transitive dependencies of the custom Eclipse plugin, brings all needed Birt dependencies. The problem is that Eclipse plugins use a custom repository layout: "p2" instead of standard Maven layout.david.perez
Ah, so could that be that the real issue is the p2 repository layout? What's that?Jacek Laskowski

2 Answers

2
votes

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
1
votes

Another solution (I haven't tried yet) is to use the sbt-osgi-manager plugin, designed for this purpose. It is actively mantained.

I'll update this answer with my experiences.

UPDATE: it doesn't work for me in the first try.

The final solution is to use a standard Maven repository for the Birt plugins. This solution is good for the embedding the Birt runtime, but not for a complete RCP app.