gpt4 book ai didi

scala - SBT 未解析 POM 的 部分中的传递依赖项

转载 作者:行者123 更新时间:2023-12-01 05:09:35 25 4
gpt4 key购买 nike

如果依赖项的 POM.xml 在 pom.xml 的“配置文件”部分中具有传递依赖项,那么这些依赖项不会由 SBT 解析,而是由 Maven 解析。例如:当项目中包含以下依赖项时......

   <dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>0.98.0-hadoop2</version>
</dependency>

...那么以下依赖项不是由 SBT 解析的,而是由 maven 解析的:

hadoop-annotations , hadoop-mapreduce-client-core , hadoop-auth , hadoop-common 

谁能帮我理解为什么会出现这种分辨率差异,以及如何让 SBT 包含这些瞬时依赖性。

以下是使用的测试 build.sbt:

name := "StreamMaker"

version := "1.0"

scalaVersion := "2.10.4"

resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"

libraryDependencies += "org.apache.hbase" % "hbase-client" % "0.98.0-hadoop2"

net.virtualvoid.sbt.graph.Plugin.graphSettings

以下是 hbase-client 的 pom.xml 中的条目:

    <profile>
<id>hadoop-2.0</id>
<activation>
<property>
<name>!hadoop.profile</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<exclusions>
<exclusion>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>tomcat</groupId>
<artifactId>jasper-compiler</artifactId>
</exclusion>
<exclusion>
<groupId>tomcat</groupId>
<artifactId>jasper-runtime</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-auth</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-mapreduce-client-core</artifactId>
<exclusions>
<exclusion>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly2</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-annotations</artifactId>
</dependency>
</dependencies>
</profile>

SBT 0.13.5 解决的依赖:

+-org.apache.hbase:hbase-client:0.98.0-hadoop2
+-com.github.stephenc.findbugs:findbugs-annotations:1.3.9-1
+-com.google.guava:guava:12.0.1
| +-com.google.code.findbugs:jsr305:1.3.9
|
+-com.google.protobuf:protobuf-java:2.5.0
+-commons-codec:commons-codec:1.7
+-commons-io:commons-io:2.4
+-commons-lang:commons-lang:2.6
+-commons-logging:commons-logging:1.1.1
+-io.netty:netty:3.6.6.Final
+-junit:junit:4.11
| +-org.hamcrest:hamcrest-core:1.3
|
+-log4j:log4j:1.2.17
+-org.apache.hbase:hbase-protocol:0.98.0-hadoop2
| +-com.github.stephenc.findbugs:findbugs-annotations:1.3.9-1
| +-com.google.protobuf:protobuf-java:2.5.0
| +-junit:junit:4.11
| | +-org.hamcrest:hamcrest-core:1.3
| |
| +-log4j:log4j:1.2.17
|
+-org.apache.zookeeper:zookeeper:3.4.5
| +-log4j:log4j:1.2.15 (evicted by: 1.2.17)
| +-log4j:log4j:1.2.16 (evicted by: 1.2.17)
| +-log4j:log4j:1.2.17
| +-org.slf4j:slf4j-api:1.6.1
| +-org.slf4j:slf4j-log4j12:1.6.1
| +-log4j:log4j:1.2.15 (evicted by: 1.2.17)
| +-log4j:log4j:1.2.16 (evicted by: 1.2.17)
| +-log4j:log4j:1.2.17
| +-org.slf4j:slf4j-api:1.6.1
|
+-org.cloudera.htrace:htrace-core:2.04
| +-com.google.guava:guava:12.0.1
| | +-com.google.code.findbugs:jsr305:1.3.9
| |
| +-commons-logging:commons-logging:1.1.1
| +-org.mortbay.jetty:jetty-util:6.1.26
|
+-org.codehaus.jackson:jackson-mapper-asl:1.8.8
+-org.codehaus.jackson:jackson-core-asl:1.8.8

Maven 3.0.4 解决的依赖关系:

- org.apache.hbase:hbase-client:jar:0.98.0-hadoop2:compile
+- org.apache.hbase:hbase-common:jar:0.98.0-hadoop2:compile
| \- commons-collections:commons-collections:jar:3.2.1:compile
+- org.apache.hbase:hbase-protocol:jar:0.98.0-hadoop2:compile
+- commons-codec:commons-codec:jar:1.7:compile
+- commons-io:commons-io:jar:2.4:compile
+- commons-lang:commons-lang:jar:2.6:compile
+- commons-logging:commons-logging:jar:1.1.1:compile
+- com.google.guava:guava:jar:12.0.1:compile
| \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
+- com.google.protobuf:protobuf-java:jar:2.5.0:compile
+- io.netty:netty:jar:3.6.6.Final:compile
+- org.apache.zookeeper:zookeeper:jar:3.4.5:compile
+- org.cloudera.htrace:htrace-core:jar:2.04:compile
| \- org.mortbay.jetty:jetty-util:jar:6.1.26:compile
+- org.codehaus.jackson:jackson-mapper-asl:jar:1.8.8:compile
| \- org.codehaus.jackson:jackson-core-asl:jar:1.8.8:compile
+- org.apache.hadoop:hadoop-common:jar:2.2.0:compile
| +- commons-cli:commons-cli:jar:1.2:compile
| +- org.apache.commons:commons-math:jar:2.1:compile
| +- xmlenc:xmlenc:jar:0.52:compile
| +- commons-httpclient:commons-httpclient:jar:3.1:compile
| +- commons-net:commons-net:jar:3.1:compile
| +- org.mortbay.jetty:jetty:jar:6.1.26:compile
| +- com.sun.jersey:jersey-core:jar:1.9:compile
| +- com.sun.jersey:jersey-json:jar:1.9:compile
| | +- org.codehaus.jettison:jettison:jar:1.1:compile
| | | \- stax:stax-api:jar:1.0.1:compile
| | +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
| | | \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
| | | \- javax.activation:activation:jar:1.1:compile
| | +- org.codehaus.jackson:jackson-jaxrs:jar:1.8.3:compile
| | \- org.codehaus.jackson:jackson-xc:jar:1.8.3:compile
| +- commons-el:commons-el:jar:1.0:runtime
| +- net.java.dev.jets3t:jets3t:jar:0.6.1:compile
| +- commons-configuration:commons-configuration:jar:1.6:compile
| | +- commons-digester:commons-digester:jar:1.8:compile
| | | \- commons-beanutils:commons-beanutils:jar:1.7.0:compile
| | \- commons-beanutils:commons-beanutils-core:jar:1.8.0:compile
| +- org.apache.avro:avro:jar:1.7.4:compile
| | +- com.thoughtworks.paranamer:paranamer:jar:2.3:compile
| | \- org.xerial.snappy:snappy-java:jar:1.0.4.1:compile
| +- com.jcraft:jsch:jar:0.1.42:compile
| \- org.apache.commons:commons-compress:jar:1.4.1:compile
| \- org.tukaani:xz:jar:1.0:compile
+- org.apache.hadoop:hadoop-auth:jar:2.2.0:compile
+- org.apache.hadoop:hadoop-mapreduce-client-core:jar:2.2.0:compile
| +- org.apache.hadoop:hadoop-yarn-common:jar:2.2.0:compile
| | +- org.apache.hadoop:hadoop-yarn-api:jar:2.2.0:compile
| | +- com.google.inject:guice:jar:3.0:compile
| | | +- javax.inject:javax.inject:jar:1:compile
| | | \- aopalliance:aopalliance:jar:1.0:compile
| | +- com.sun.jersey:jersey-server:jar:1.9:compile
| | | \- asm:asm:jar:3.1:compile
| | \- com.sun.jersey.contribs:jersey-guice:jar:1.9:compile
| \- com.google.inject.extensions:guice-servlet:jar:3.0:compile
+- org.apache.hadoop:hadoop-annotations:jar:2.2.0:compile
| \- jdk.tools:jdk.tools:jar:1.7:system
+- com.github.stephenc.findbugs:findbugs-annotations:jar:1.3.9-1:compile
\- junit:junit:jar:4.11:compile
\- org.hamcrest:hamcrest-core:jar:1.3:compile

最佳答案

sbt 不处理 maven 配置文件。您应该将依赖项(在给定的配置文件中提到)添加到您的 sbt 文件中。

name := "StreamMaker"

version := "1.0"

scalaVersion := "2.10.4"

resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"

libraryDependencies += "org.apache.hbase" % "hbase-client" % "0.98.0-hadoop2"

// Add the dependencies from the active profile.
libraryDependencies ++= Seq("org.apache.hadoop" % "hadoop-mapreduce-client-core" % "2.2.0",
"org.apache.hadoop" % "hadoop-mapreduce-client-jobclient" % "2.2.0",
"org.apache.hadoop" % "hadoop-hdfs" % "2.2.0",
"org.apache.hadoop" % "hadoop-auth" % "2.2.0",
"org.apache.hadoop" % "hadoop-common" % "2.2.0",
"org.apache.hadoop" % "hadoop-client" % "2.2.0",
"org.apache.hadoop" % "hadoop-annotations" % "2.2.0")

net.virtualvoid.sbt.graph.Plugin.graphSettings

参见 this discussion .

引用乔希的话:

Maven does allow this, but it's kind of bad form. How do you know which profile was active for deployment? Changing dependencies based on active profiles is VERY evil to your users. I'd contact that authors of the project and ask them to find an alternative method.

关于scala - SBT 未解析 POM 的 <Profile> 部分中的传递依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25961765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com