加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

scala – 为什么sbt编译不会将非托管资源复制到类路径?

发布时间:2020-12-16 19:08:23 所属栏目:安全 来源:网络整理
导读:你能告诉我为什么sbt编译不会将非托管资源复制到classpath?另一方面,sbt包是.因此,我无法开始调试,除非我手动调用包调用:( 我正在使用SBT 0.12.1 下面是我的build.sbt. import AssemblyKeys._ // put this at the top of the filenet.virtualvoid.sbt.graph
你能告诉我为什么sbt编译不会将非托管资源复制到classpath?另一方面,sbt包是.因此,我无法开始调试,除非我手动调用包调用:(

我正在使用SBT 0.12.1

下面是我的build.sbt.

import AssemblyKeys._ // put this at the top of the file

net.virtualvoid.sbt.graph.Plugin.graphSettings

assemblySettings

organization  := "com.zzz"

version       := "0.1"

scalaVersion  := "2.10.2"

scalacOptions := Seq("-unchecked","-language:reflectiveCalls,postfixOps,implicitConversions","-deprecation","-feature","-encoding","utf8")

unmanagedResourceDirectories in Compile <++= baseDirectory { base =>
    Seq( base / "src/main/webapp" )
}

jarName in assembly := "zzz.jar"

mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
    {
        case "rootdoc.txt" => MergeStrategy.discard
        case x => old(x)
    }
}

mainClass in assembly := Some("com.zzz.Boot")

name := "zzz"

// disable using the Scala version in output paths and artifacts
crossPaths := false

artifactName := { (sv: ScalaVersion,module: ModuleID,artifact: Artifact) =>
  artifact.name + "." + artifact.extension
}

resolvers ++= Seq(
  "spray repo" at "http://repo.spray.io/"
)

libraryDependencies ++= {
  val sprayVersion = "1.2-M8"
  val akkaVersion  = "2.2.0-RC1"
Seq(
  "io.spray"            %   "spray-servlet" % sprayVersion withSources(),"io.spray"            %   "spray-can"     % sprayVersion withSources(),"io.spray"            %   "spray-routing" % sprayVersion withSources(),"com.typesafe.akka"   %%  "akka-actor"    % akkaVersion,"org.eclipse.jetty"       %   "jetty-webapp"  % "8.1.7.v20120910"     % "container","org.eclipse.jetty.orbit" %   "javax.servlet" % "3.0.0.v201112011016" % "container"  artifacts Artifact("javax.servlet","jar","jar"),"net.sourceforge.htmlcleaner" % "htmlcleaner" % "2.2","org.apache.httpcomponents" % "httpclient" % "4.2.3","org.apache.commons" % "commons-lang3" % "3.1","org.mongodb" %% "casbah" % "2.6.0","com.romix.scala" % "scala-kryo-serialization" % "0.2-SNAPSHOT","org.codehaus.jettison" % "jettison" % "1.3.3","com.osinka.subset" %% "subset" % "2.0.1","io.spray" %% "spray-json" % "1.2.5" intransitive()
)
}

seq(Revolver.settings: _*)

seq(webSettings: _*)

seq(Twirl.settings: _*)

解决方法

编译的工作是编译源代码,所以它通常不会与处理资源相关.但是,资源需要在类目录中用于运行,包,测试,控制台以及使用fullClasspath的任何其他内容.这是通过mergeClasspath来完成的,它们是exportsProducts,它是当前项目生成的类和资源以及dependencyClasspath,它们是依赖关系的类路径条目.

适当的解决方案取决于需要什么资源.从命令行,运行导出的产品来进行编译以及拷贝资源.通过编程方式,您通常会依赖于fullClasspath或exportedProducts.

作为附注,您通常可以找出使用the inspect command的任务.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读