سؤال

I have a project that depends on another. I have been using sbt publish-local in order to update the dependency, which stinks.

So I tried to switch to subprojects, but it didn't compile. I tried putting the dependencies of the build.sbt file into the Build.scala file, and it didn't change anything.

I am using SBT 0.13 with Scala 2.10.2

Original build.sbt (renamed as build._sbt to avoid conflicts):

name := "soot-javaee"

organization := "sable"

version := "20130902"

scalaVersion := "2.10.2"

retrieveManaged := true

libraryDependencies += "sable" %% "heros" % "20130920"

//Logging
libraryDependencies ++= Seq(
  "com.typesafe" %% "scalalogging-slf4j" % "1.0.1",
  "org.slf4j" % "slf4j-api" % "1.7.5",
  "ch.qos.logback" % "logback-core" % "1.0.13",
  "ch.qos.logback" % "logback-classic" % "1.0.13",
  "org.slf4j" % "log4j-over-slf4j" % "1.7.5",
  "org.slf4j" % "jcl-over-slf4j" % "1.7.5"
)

libraryDependencies += "org.apache.ant" % "ant" % "1.9.2"

libraryDependencies += "junit" % "junit" % "4.11"

libraryDependencies += "junit" % "junit" % "3.8.2"

javacOptions ++= Seq("-source", "1.6")

compileOrder in Compile := CompileOrder.Mixed

//change unmanaged resource folder to templates
unmanagedResourceDirectories in Compile := Seq(file("generated/sablecc/"),file("src"))

excludeFilter in (Compile, unmanagedResources) ~= (_ || "*.java" || "*.scala" || "*.html" || "*.xsl" || "*.xml")


unmanagedSourceDirectories in Compile := Seq(file("src"), file("generated/jastadd/"), file("generated/sablecc"), file("generated/options"), file("generated/singletons"))

unmanagedSourceDirectories in Test := Seq (file("tests"))

//change unmanaged library folder from lib to libs
unmanagedBase <<= baseDirectory { base => base / "libs" }

//Remove some files in the libs/ folder
//dependencyClasspath in Compile ~= { libDirs => libDirs.filter(af => af.data.getName != "scala-library.jar" && af.data.getName != "log4j-1.2.17.jar" ) }

//This disables scaladoc altogether.
sources in doc in Compile := List()

The Build.scala is as follows

import sbt._
import sbt.Keys._

object DepsBuild extends Build {

  lazy val heros = /*project.in(file("../heros"))*/ RootProject(uri("git://github.com/malaverdiere/heros.git#develop"))

  lazy val root = project.in(file(".")).settings(
    name := "soot-javaee",
    organization := "sable",
    version := "20130902",
    scalaVersion := "2.10.2",
    retrieveManaged := true,
    //Logging
    libraryDependencies ++= Seq(
      "com.typesafe" %% "scalalogging-slf4j" % "1.0.1",
      "org.slf4j" % "slf4j-api" % "1.7.5",
      "ch.qos.logback" % "logback-core" % "1.0.13",
      "ch.qos.logback" % "logback-classic" % "1.0.13",
      "org.slf4j" % "log4j-over-slf4j" % "1.7.5",
      "org.slf4j" % "jcl-over-slf4j" % "1.7.5",
      "org.apache.ant" % "ant" % "1.9.2",
      "junit" % "junit" % "4.11",
      "junit" % "junit" % "3.8.2"),
    javacOptions ++= Seq("-source", "1.6"),
    compileOrder in Compile := CompileOrder.Mixed,
    //change unmanaged resource folder to templates
    unmanagedResourceDirectories in Compile := Seq(file("generated/sablecc/"), file("src")),

    excludeFilter in(Compile, unmanagedResources) ~= (_ || "*.java" || "*.scala" || "*.html" || "*.xsl" || "*.xml"),
    unmanagedSourceDirectories in Compile := Seq(file("src"), file("generated/jastadd/"), file("generated/sablecc"),
      file("generated/options"), file("generated/singletons")),
    unmanagedSourceDirectories in Test := Seq(file("tests")),
    //change unmanaged library folder from lib to libs
    unmanagedBase <<= baseDirectory {
      base => base / "libs"
    },
    //This disables scaladoc altogether.
    sources in doc in Compile := List()
  ).dependsOn(heros)

}

When I run sbt compile, I get the following output

Loading /usr/share/sbt/bin/sbt-launch-lib.bash
[info] Loading project definition from /home/marc-andre/soot/soot/project
[info] Compiling 1 Scala source to /home/marc-andre/soot/soot/project/target/scala-2.10/sbt-0.13/classes...
[info] Set current project to soot-javaee (in build file:/home/marc-andre/soot/soot/)
[info] Compiling 9 Scala sources and 2166 Java sources to /home/marc-andre/.sbt/0.13/staging/0e4a0b0a0c1e5185ae25/heros/target/scala-2.10/classes...
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JBossWSTestDetector.scala:8: object typesafe is not a member of package com
[error] import com.typesafe.scalalogging.slf4j.Logging
[error]            ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JBossWSTestDetector.scala:26: not found: type Logging
[error] class JBossWSTestDetector extends AbstractServletDetector with Logging{
[error]                                                                ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JBossWSTestDetector.scala:34: not found: value logger
[error]     logger.trace("Non-dandling classes ({}): {}", nonDandling.size : Integer, nonDandling.map(_.name))
[error]     ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JBossWSTestDetector.scala:40: not found: value logger
[error]     jBossWsClients.foreach(logger.info("Found JBoss WS Test Client: {}", _))
[error]                            ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JBossWSTestDetector.scala:43: not found: value logger
[error]     testMethods.foreach(logger.debug("Test method found: {}", _))
[error]                         ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JBossWSTestDetector.scala:57: not found: value logger
[error]     logger.warn("Detecting Web services from configuration files is not supported yet - switching to detection from source")
[error]     ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JaxWsServiceDetector.scala:9: object typesafe is not a member of package com
[error] import com.typesafe.scalalogging.slf4j.Logging
[error]            ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JaxWsServiceDetector.scala:33: not found: type Logging
[error] object JaxWSAttributeUtils extends Logging {
[error]                                    ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JaxWsServiceDetector.scala:180: not found: value logger
[error]       logger.info("For class {}, handler file is located at: {}", sc, url)
[error]       ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JaxWsServiceDetector.scala:202: not found: value logger
[error]         logger.info("For class {}, handler file is located at: {}", sc, handlerFile)
[error]         ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JaxWsServiceDetector.scala:208: not found: value logger
[error]         logger.warn("For class {}, handler file was wrongly located at: {}", sc, handlerFile)
[error]         ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JaxWsServiceDetector.scala:255: not found: type Logging
[error] class JaxWsServiceDetector extends AbstractServletDetector with Logging{
[error]                                                                 ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JaxWsServiceDetector.scala:279: not found: value logger
[error]     logger.warn("Detecting Web services from configuration files is not supported yet - switching to detection from source")
[error]     ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JaxWsServiceDetector.scala:371: not found: value logger
[error]         logger.error("Cannot process service {} because the specified interface is not implemented or not annotated", sc.getName)
[error]         ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JaxWsServiceDetector.scala:406: not found: value logger
[error]     serviceMethods.foreach(wm => logger.trace("Web method {} hash: {}", wm, wm.hashCode() : Integer))
[error]                                  ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JaxWsServiceDetector.scala:411: not found: value logger
[error]       logger.warn("Service {} is using an handler chain. This is not supported by the analysis.", sc.name)
[error]       ^
[error] /home/marc-andre/soot/soot/src/soot/jimple/toolkits/javaee/detectors/JaxWsServiceDetector.scala:429: not found: value logger
[error]     logger.debug("Found WS. Interface: {} Implementation: {}. Wrapper: {}. Init: {} Destroy: {} Name: {} Namespace: {} " +
[error]     ^
[error] /home/marc-andre/soot/soot/src/soot/util/ScalaWrappers.scala:10: object Options is not a member of package soot.options
[error] import soot.options.Options
[error]        ^
[error] /home/marc-andre/soot/soot/src/soot/util/ScalaWrappers.scala:158: not found: value Options
[error]       if (v.getApplicationClasses.isEmpty && Options.v.process_dir().isEmpty)
[error]                                              ^
[error] 19 errors found
[error] ({git://github.com/malaverdiere/heros.git#develop}heros/compile:compile) Compilation failed
[error] Total time: 4 s, completed Oct 4, 2013 2:57:40 PM

The output of 'projects'

[info] In file:/home/marc-andre/soot/soot/
[info]   * root
[info] In git://github.com/malaverdiere/heros.git#develop
[info]     heros

The output is exactly the same if I run ''project {git://github.com/malaverdiere/heros.git#develop}heros'' followed by 'compile'.

The output of the SBT commands below are all for that project

The output of 'compile:unmanaged-source-directories'

[info] List(src)

The output of 'inspect sources'

[info] Task: scala.collection.Seq[java.io.File]
[info] Description:
[info]  All sources, both managed and unmanaged.
[info] Provided by:
[info]  {git://github.com/malaverdiere/heros.git#develop}heros/compile:sources
[info] Defined at:
[info]  (sbt.Defaults) Defaults.scala:168
[info] Dependencies:
[info]  heros/compile:unmanagedSources
[info]  heros/compile:managedSources
[info] Delegates:
[info]  heros/compile:sources
[info]  heros/*:sources
[info]  {.}/compile:sources
[info]  {.}/*:sources
[info]  */compile:sources
[info]  */*:sources
[info] Related:
[info]  {file:/home/marc-andre/soot/soot/}root/compile:sources
[info]  {file:/home/marc-andre/soot/soot/}root/test:sources
[info]  heros/test:sources
[info]  {file:/home/marc-andre/soot/soot/}root/compile:doc::sources

Yet, the output of 'show sources' (truncated)

[info] ArrayBuffer(src/org/jcp/xmlns/javaee/PropertyType.java, src/org/jcp/xmlns/javaee/ServletLinkType.java, src/org/jcp/xmlns/javaee/EjbLocalRefType.java, src/org/jcp/xmlns/javaee/HandlerChainsType.java, src/org/jcp/xmlns/javaee/XsdStringType.java, src/org/jcp/xmlns/javaee/JavaTypeType.java, src/org/jcp/xmlns/javaee/package-info.java, src/org/jcp/xmlns/javaee/ParamValueType.java, src/org/jcp/xmlns/javaee/ServiceRefType.java, src/org/jcp/xmlns/javaee/EjbRefType.java, src/org/jcp/xmlns/javaee/TrueFalseType.java, src/org/jcp/xmlns/javaee/ListenerType.java, src/org/jcp/xmlns/javaee/LocalHomeType.java, src/org/jcp/xmlns/javaee/PersistenceContextTypeType.java, src/org/jcp/xmlns/javaee/HomeType.java, src/org/jcp/xmlns/javaee/RemoteType.java, src/org/jcp/xmlns/javaee/WebservicesType.java,

How can I fix this compilation error and have subprojects in my set-up?

هل كانت مفيدة؟

المحلول

Use absolute paths by defining all paths in terms of another absolute path. When passing a relative path to file(...), this is relative to the current working directory, which is shared by the whole jvm. When working with multiple projects, this means that a subproject's paths aren't relative to its base directory like you expect.

For example, use:

unmanagedSourceDirectories in Test := 
   Seq(baseDirectory.value / "tests")

instead of

unmanagedSourceDirectories in Test := 
   Seq(file("tests"))
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top