Search code examples
mavensbtivyplayframework-2.2

Can SBT resolve only .pom files as dependencies without jars?


So, as the title suggests, can sbtresolve .pom files dependencies that contain only configurations/properties and have no .jar file associated?

Im currently developing a new frontend app using Play! Framework and angularjs. Here's the scenario:

  1. Root Project (à la maven compilation/deploy)

    • Core business Module - pom.xml
    • Web modules - pom.xml

      • Rest API-pom.xml
        • Module - pom.xml
        • Module - pom.xml
      • Frontend (à la SBT compilation, multi-module project)

        • Mod1 - build.sbt
        • Mod2 - build.sbt (depends on mod1)
          • More modules inside - build.sbt

        build.sbt

        project/build.scala

    • Web Commons (used on the Rest API and Frontend) - pom.xml

The sbt compilation is ran via maven using a plugin, sbt-launcher if im not mistaken. Everything runs and compiles as expected, however, we ran into a problem when we added WebCommons as a dependency in the frontend's build.sbt file. The problem relys on the fact that, the root's pom.xml has a parent of his own, lets call it X, and X contains several .pom files that delegate to child modules (in this case the root project) config/properties/dependencies that are necessary to ease RPM packaging. Running maven clean install, the compilation process goes perfectly fine, we reach the frontend and the sbt compilation cycle starts as expected. When sbt tries to resolve the web-commons dependency, it also resolves every parent. In this case, web-commons->web-modules->root->X. When he reaches X, finds that there are several dependencies with him (not relevant at all for the frontend...) but these are made of .pom files not jar's. These .pom files are downloaded correctly using resolvers but then, sbt searches for the corresponding .jar files taking an enormous time to finish the build, and when it does, errors, errors everywhere (missing dependencies). I've tried several possible solutions:

1.intransitive() in web-commons dependency, not effective, still trying to find parents dep. 2.exclude(organization,filename*), again not effective.
3.excludeAll( ExclusionRule(org,dep1) ExclusionRule(org,dep2) ... ), sadly, not effective.

Im currently using sbt 0.13.2/6 (tried both). My next step was to define an ivy.xml and ivysettings.xml that configures this dependency and force the type=pom. Might this work? Any other sugestion/workaround?

Thanks in advance.


Solution

  • Hopefully good news for you!

    I've had a similar problem recently with SBT 0.13.13 where I have two projects, each publishing a POM file (no jars!) where one of the POM depends on the other.

    Adding a dependency to a POM in a *.sbt file looks like this:

    libraryDependencies += 
      "<org>"
      % "<artifact>" 
      % "<version pattern>" 
      artifacts
      Artifact("<artifact>", `type`="pom", extension="pom")
    

    If you're interested in an example, see here:

    https://github.com/TIWG/com.nomagic.magicdraw.sysml.plugin/blob/release/18.0-sp6/build.sbt#L63

    The POM is published here:

    https://bintray.com/tiwg/org.omg.tiwg.vendor.nomagic/com.nomagic.magicdraw.sysml.plugin/18.0-sp6.2

    That POM has a dependency on another POM published here:

    https://bintray.com/tiwg/org.omg.tiwg.vendor.nomagic/com.nomagic.magicdraw.package/18.0-sp6.2