来自主项目的源会渗透到子项目中



我有一个依赖于另一个项目的项目。我一直在使用 sbt 发布本地来更新依赖项,这很臭。

所以我尝试切换到子项目,但它没有编译。我尝试将build.sbt文件的依赖项放入Build.scala文件中,但它没有改变任何东西。

我正在使用 SBT 0.13 和 Scala 2.10.2

原始build.sbt(重命名为build._sbt以避免冲突(:

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()

Build.scala如下

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)
}

当我运行 sbt 编译时,我得到以下输出

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

"项目"的输出

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

如果我运行"项目 {git://github.com/malaverdiere/heros.git#develop}heros",然后是"编译",则输出完全相同。

以下 SBT 命令的输出全部针对该项目

"编译:非托管源目录"的输出

[info] List(src)

"检查源"的输出

[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

然而,"显示源"的输出(截断(

[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,

如何修复此编译错误并在设置中包含子项目?

通过根据另一个绝对路径定义所有路径来使用绝对路径。 当将相对路径传递给 file(...) 时,这是相对于当前工作目录的,该目录由整个 jvm 共享。 处理多个项目时,这意味着子项目的路径不像您预期的那样相对于其基目录。

例如,使用:

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

而不是

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

相关内容

  • 没有找到相关文章

最新更新