当前位置: 首页 > 知识库问答 >
问题:

gradle 传递依赖项下载本地常春藤

姜献
2023-03-14

我有一个项目,我正在覆盖到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.快照不需要下载罐子?这个东西适用于蚂蚁常春藤项目

更新 1

我加了常春藤。测试项目的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>

共有1个答案

吕英豪
2023-03-14

我想这可能是因为你的配置ivy.xml将它们绑定到编译默认值,Gradle正在尝试解决没有声明任何内容的默认配置。

您可以尝试:创建新的配置配置。添加(“yourConf”)并从compile配置扩展它。yourConf.extendsFrom(configurations.compile)并将其用于测试项目

或从compile扩展“default”配置

configurations.add("default")
configurations.default.extendsFrom(configurations.compile)

或者尝试从< code>ivy.xml中删除/更改conf

如果你不能做到这一点,你可能想玩一些groovy来做到这一点。

asNode().dependencies.dependency.findAll { it.@conf }.each { it.attributes().remove("conf") }
 类似资料:
  • 我正在尝试添加以下依赖项:

  • 我使用在JAR中包含依赖项 问题是它没有添加我的dependancies的所有dependancie树,我不知道为什么。 有人知道吗?

  • 我有一个MultiProject gradle,但在我的控制器模块中gradle似乎没有下载spring引导依赖项(或任何其他的东西)。根级构建运行顺利,没有任何错误,但我不能导入任何依赖项类到我的源代码。 以下是gradle文件: 多项目的根生成.级 内部项目Build.Gradle 编辑:settings.gradle 任何帮助都将不胜感激。

  • 我刚刚将我的项目升级到gradle 7,并且遇到了缺失的可传递依赖项。我试着改变我的身材。gradle文件在依赖项中使用“api”,但这并没有修复它。 projectA依赖于projectB,projectB依赖于projectC。 projectA-build。格拉德尔 projectB-构建。格拉德尔 ProjectA编译良好,但有运行时错误-从project ectC获取类的ClassNot

  • 问题内容: 问题。 Gradle依赖管理使得: 没有简便的方法来检查依赖项更新的可用性(仅使用某些第三方插件,如ben-manes / gradle-versions-plugin)并下载更新以替换旧版本; 从远程存储库下载依赖项工件,然后将其存储在gradle缓存中,并在后续构建中重用;但是项目的成功编译必须不依赖于与Internet的连接,远程存储库的可用性以及这些存储库中特定版本的依赖项。