我有一个项目,我正在转向gradle。该项目有一些依赖,如junit等。 可以下载依赖项的Jars,但不会下载这些Jars的依赖项。 build.gradle文件如下
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
repositories {
ivy {
url 'http://localserver/repo'
layout 'pattern', {
artifact 'snapshot/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]'
artifact '3rd-party/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]'
artifact 'b2bdev/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]'
file 'snapshot/[organisation]/[module]/ivys/ivy-[revision].xml'
file '3rd-party/[organisation]/[module]/ivys/ivy-[revision].xml'
}
}
}
targetCompatibility = sourceCompatibility = JavaVersion.VERSION_1_6
dependencies {
testCompile('test:project:17.20.SNAPSHOT') {
transitive = true
}
testCompile('org.hibernate.common:hibernate-commons-annotations:4.0.1.Final') {
transitive = false
}
testCompile('org.hibernate:hibernate-ehcache:4.1.2.Final') {
transitive = false
}
testCompile('org.javassist:javassist:3.16.1-GA') {
transitive = false
}
compileOnly('javax.servlet:javax.servlet-api:3.0.1') {
transitive = false
}
compileOnly('dom4j:dom4j:1.6.1') {
transitive = false
}
}
为什么测试所需的罐子:项目:17.20.SNAPSHOT没有下载? 这件事适用于ant + ivy项目
更新1
我添加了测试项目的ivy.xml文件
<ivy-module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="test" module="project" revision="17.20.SNAPSHOT" status="integration" publication="434334345"></info>
<configurations>
<conf name="test" visibility="public" description="Dependencies needed only for testing"/>
<conf name="compile" visibility="public" description="Dependencies required for compile time that are not provided by a container"/>
<conf name="runtime" extends="compile" visibility="public" description="Dependencies not needed for compile time but are needed for runtime"/>
<conf name="provided" visibility="public" description="Dependencies provided by a container"/>
<conf name="ear" visibility="public" description="Dependencies managed by ear level classloader"/>
<conf name="war" visibility="public" description="Dependencies managed by war level classloader"/>
<conf name="default" visibility="public"/>
<conf name="optional" visibility="public"/>
<conf name="sources" visibility="public"/>
</configurations>
<publications>
<artifact name="project"/>
<artifact name="project-sources" type="src" ext="jar" conf="sources"/>
</publications>
<dependencies>
<!-- Spring and related dependencies -->
<dependency org="org.springframework" name="spring-core" rev="4.1.6.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework" name="spring-context" rev="4.1.6.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework" name="spring-web" rev="4.1.6.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework" name="spring-beans" rev="4.1.6.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework" name="spring-expression" rev="4.1.6.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework" name="spring-aop" rev="4.1.6.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework" name="spring-orm" rev="4.1.6.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework" name="spring-tx" rev="4.1.6.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework" name="spring-jdbc" rev="4.1.6.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework" name="spring-test" rev="4.1.6.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework" name="spring-context-support" rev="4.1.6.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework" name="spring-oxm" rev="4.1.6.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework.data" name="spring-data-neo4j" rev="2.1.0.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework.data" name="spring-data-neo4j-tx" rev="2.1.0.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework.batch" name="spring-batch-core" rev="2.1.8.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework.batch" name="spring-batch-infrastructure" rev="2.1.8.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework.security" name="spring-security-core" rev="3.2.4.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework.security" name="spring-security-web" rev="3.2.4.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework.security" name="spring-security-config" rev="3.2.4.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework.security" name="spring-security-ldap" rev="3.2.4.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
<dependency org="org.springframework.ldap" name="spring-ldap" rev="1.3.0.RELEASE" transitive="false" conf="compile->default; war->default; ear->default"/>
</ivy-module>
答案 0 :(得分:1)
我认为这可能是因为你在ivy.xml中的配置将它们绑定到编译默认值而Gradle正在尝试解决没有声明任何内容的默认配置。
您可以尝试:
创建新配置configurations.add("yourConf")
并从编译configurations.yourConf.extendsFrom(configurations.compile)
扩展它
并将其用于测试项目
或从编译
扩展'default'配置configurations.add("default")
configurations.default.extendsFrom(configurations.compile)
或尝试从ivy.xml
如果你不能这样做,你可能想要玩一些groovy来做它。
asNode().dependencies.dependency.findAll { it.@conf }.each { it.attributes().remove("conf") }