0
votes

I want to use SBT .12.2 to resolve the dependencies listed in an external ivy.xml file, such that my Play application can resolve at compile/runtime. I am using the IvyDE plugin for eclipse, and Ivy can by itself resolve the dependencies in the ivy.xml file.

I attempted to follow these docs, so this is my current Build.scala:

object ApplicationBuild extends Build {

    val appName = "App"
    val appVersion = "{VERSION}"

    val appDependencies = Seq(
        javaCore,
        javaJdbc,
        javaEbean
    )

    resolvers += Resolver.file("Local repo", file(System.getProperty("user.home") + "/.ivy2/local"))(Resolver.ivyStylePatterns)
    externalIvySettingsURL(url("file://L:/Utils/ivySettings/ivysettings.xml"))
    externalIvyFile( baseDirectory { base => base / "ivy.xml"} )

    classpathConfiguration in Compile := config("play")
    classpathConfiguration in Test := config("play")
    classpathConfiguration in Runtime := config("play")


    val main = play.Project(appName, appVersion, appDependencies).settings(

    )
}

and my ivy.xml:

<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">

    <info
        organisation="Company"
        module="App"
        status="Integration">
    </info>

    <configurations>
        <conf name="sources" description="Sources of this library" />
        <conf name="play" description="Building our play library" />  
        <conf name="test" description="Building our test library" />  
    </configurations>

    <dependencies>
        <dependency org="Apache" name="elasticsearch" rev="2.1.0" />
        <dependency org="Apache" name="json-simple" rev="1.1.1" />          
        <!-- Used for testing -->
        <dependency org="Apache" name="Selenium" rev="2.42" conf="test->default" />     
    </dependencies>
</ivy-module>

When i spin up Play, and call the dependencies command, I do not see these dependencies listed, and they are not present at runtime. The only files that Play can see are the ones defined in appDependencies. I am using a non-standard versioning pattern, but I should at least be able to see the dependencies fail to be found if my settings file wasn't getting picked up.

Thanks in advance!

1

1 Answers

0
votes

Ok, most of my initial syntax from the documentation was close, but I wasn't applying any of those settings in the context of my Play project. In addition, I wasn't pointing my resolver to the correct directory. My ivy.xml file was fine.

  val appName         = "My-Application"
  val appVersion    = ".1"

  val appDependencies = Seq(
    javaCore,
    javaJdbc,
    javaEbean
  )
    resolvers += Resolver.file("Local repo", file("C:/Utils/lib"))(Resolver.ivyStylePatterns)

    val main = play.Project(appName, appVersion, appDependencies).settings(
        externalIvySettingsURL(url("file:///C:/Utils/ivySettings/ivysettings-ian.xml")),
        externalIvyFile(),
        classpathConfiguration in Compile := config("play"),
        classpathConfiguration in Test := config("play"),
        classpathConfiguration in Runtime := config("play"),
        organization := "Company"
    )

SBT will resolve the dependencies ONLY in the ivy.xml file, so you need to add the dependencies from javaCore, javaJdbc, and javaEbean to your ivy file for resolution. Other sticking points include noting the three slashes for the file descriptor.