sbt程序集的不及物依赖性

时间:2016-06-20 07:03:19

标签: scala hadoop sbt

我下载了一个(活动的)git项目,它要求我安装scala(sbt)和hadoop。当我尝试通过sbt(sbt assembly)构建它时,会产生大量关于不及物依赖性的警告。我试图与项目供应商联系,但他们没有给我适当的答复;只是告诉我它正在他们的机器上工作。

当我尝试“sbt assembly”时,我得到:

[info] Resolving jline#jline;2.12 ...
[info] Done updating.
[warn] Found intransitive dependency (org.apache.hadoop:hadoop-common:2.6.0) while publishMavenStyle is true, but Maven repositories
[warn]   do not support intransitive dependencies. Use exclusions instead so transitive dependencies
[warn]   will be correctly excluded in dependent projects.
[warn]            
[warn] Found intransitive dependency (org.apache.hadoop:hadoop-mapreduce-client-core:2.6.0) while publishMavenStyle is true, but Maven repositories
[warn]   do not support intransitive dependencies. Use exclusions instead so transitive dependencies
[warn]   will be correctly excluded in dependent projects.
[warn]            
[warn] Found intransitive dependency (org.apache.hadoop:hadoop-mapreduce-client-common:2.6.0) while publishMavenStyle is true, but Maven repositories
[warn]   do not support intransitive dependencies. Use exclusions instead so transitive dependencies
[warn]   will be correctly excluded in dependent projects.
[warn]            
[warn] Found intransitive dependency (org.apache.hadoop:hadoop-annotations:2.6.0) while publishMavenStyle is true, but Maven repositories
[warn]   do not support intransitive dependencies. Use exclusions instead so transitive dependencies
[warn]   will be correctly excluded in dependent projects.
[warn]            
[warn] Found intransitive dependency (org.apache.hadoop:hadoop-auth:2.6.0) while publishMavenStyle is true, but Maven repositories
[warn]   do not support intransitive dependencies. Use exclusions instead so transitive dependencies
[warn]   will be correctly excluded in dependent projects.
[warn]            
[warn] Found intransitive dependency (org.apache.hadoop:hadoop-yarn-common:2.6.0) while publishMavenStyle is true, but Maven repositories
[warn]   do not support intransitive dependencies. Use exclusions instead so transitive dependencies
[warn]   will be correctly excluded in dependent projects.
[warn]            
[warn] Found intransitive dependency (org.apache.hbase:hbase-server:0.96.2-hadoop2) while publishMavenStyle is true, but Maven repositories
[warn]   do not support intransitive dependencies. Use exclusions instead so transitive dependencies
[warn]   will be correctly excluded in dependent projects ...

还有一个build.sbt文件,其中包含项目所需的所有依赖项:

libraryDependencies ++= Seq(
            "com.beust" % "jcommander" % "1.35",
            "org.apache.hadoop" % "hadoop-common" % "2.6.0" intransitive(),
            "org.apache.hadoop" % "hadoop-mapreduce-client-core" % "2.6.0"  intransitive(),
            "org.apache.hadoop" % "hadoop-mapreduce-client-common" % "2.6.0"  intransitive(),
            "org.apache.hadoop" % "hadoop-annotations" % "2.6.0" intransitive(), 
            "org.apache.hadoop" % "hadoop-auth" % "2.6.0" intransitive(),
            "org.apache.hadoop" % "hadoop-yarn-common" % "2.6.0" intransitive(),
            "org.apache.hadoop" % "hadoop-yarn-api" % "2.6.0",
            "org.apache.hbase" % "hbase-server" % "0.96.2-hadoop2" intransitive(), 
            "org.apache.hbase" % "hbase-common" % "0.96.2-hadoop2"  intransitive(), 
            "org.apache.hbase" % "hbase-client" % "0.96.2-hadoop2" intransitive(),
            "org.apache.hbase" % "hbase-protocol" % "0.96.2-hadoop2",
            "org.cloudera.htrace" % "htrace-core" % "2.04" intransitive(),
            "commons-configuration" % "commons-configuration" % "1.6" exclude("commons-beanutils", "commons-beanutils-core"),
            "commons-httpclient" % "commons-httpclient" % "3.1",
            "commons-io" % "commons-io" % "2.4",
            "com.google.guava" % "guava" % "11.0.2",
            "log4j" % "log4j" % "1.2.16",
            "org.slf4j" % "slf4j-log4j12" % "1.7.5",
            "org.codehaus.jackson" % "jackson-jaxrs" % "1.9.13",
            "org.apache.avro" % "avro" % "1.7.4",
            "junit" % "junit" % "4.11" % "it,test",
            "com.novocode" % "junit-interface" % "0.10" % "it,test",
            "com.jsuereth" % "scala-arm_2.11" % "1.4" % "it,test",
            "org.scalatest" % "scalatest_2.11" % "2.2.1" % "it,test"
            )

assemblyMergeStrategy in assembly := {
    case PathList("org", "apache", "hadoop", "yarn", xs @ _*) => MergeStrategy.first 
    case x => val oldStrategy = (assemblyMergeStrategy in assembly).value
    oldStrategy(x)
}

assemblyExcludedJars in assembly := { 
  val cp = (fullClasspath in assembly).value
  cp filter {_.data.getName == "commons-beanutils-1.7.0.jar"}
}

scalaVersion := "2.11.4"

// output jar is here: target/ruleXtract.jar
assemblyOutputPath in assembly := file("target/ruleXtract.jar") 

// we want a jar without a main class so we can run it as "hadoop jar class args"
mainClass in (Compile, packageBin) := None

为了使其有效,我该怎么办?我不知道如何在没有“sbt assembly”的情况下构建这个项目。我检查了一些关于sbt的教程,build.sbt看起来很好 - 虽然不太确定。问题是什么?你有什么建议可以解决吗?

B.R。

1 个答案:

答案 0 :(得分:2)

这可能无法解决您的问题,但它会消除警告。 SBT属性" publishMavenStyle'当您要将项目发布到Maven存储库(http://xerial.org/blog/2014/03/24/sbt/)时使用。如果您不打算发布,可以将其设置为false。

如果你正在使用多个build.sbt文件,你可以这样设置它,这将为整个项目设置它:

publishMavenStyle in ThisBuild := false