gradle transitive dependencies download local ivy
Asked Answered
F

1

6

I have a project that i am coverting to gradle. the project has some dependencies like junit etc. The Jars for the dependencies get downloaded but the dependencies of those Jars are not downloaded. The build.gradle file is as follows

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
    }
}

Why is the Jars required by test:project:17.20.SNAPSHOT not downloaded ? this thing works with ant+ivy project

Update 1

I have added the ivy.xml file of test project

<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>
Fourthclass answered 21/3, 2017 at 19:37 Comment(13)
You've set transitive dependency resolution to "false"...Esdraelon
@MarkO'Connor not for test:project:17.20Fourthclass
In that case check the ivy file belonging to that module and see if dependencies are listed. As it stands there is no way to reproduce your issue.Esdraelon
@MarkO'Connor I have added the ivy file aboveFourthclass
@Fourthclass Would you please provide runnable file so that anyone can easily build and check?Endothelioma
And all of the spring dependencies are hosted on you local repository server as well?Panek
And what's the output of running gradlew dependencies on your project. This should give you a report on all (including transitive) project dependencies.Panek
@Panek Every deoendency is hosted on Ivy and running gradlew dependencies says build successful but I don't see anything happeningFourthclass
What version of gradle are you using?Panek
It depends on how the 'test project' specify its dependencies i think.Fluorine
I think it might be because your configuration in ivy.xml ties them up to compile default and in Gradle you use different configuration which is testCompile.Fluorine
@Fourthclass even the bounty expired and you didn't gave it to anyone :) please consider reading stackoverflow.com/help/someone-answersFluorine
@InjuredThePatient Was AFK unfortunatelyFourthclass
F
1

I think it might be because of your configuration in ivy.xml ties them up to compile default and Gradle is trying to resolve default configuration which doesnt have anything declared.

You might try to: create a new configuration configurations.add("yourConf") and extend it from compile configurations.yourConf.extendsFrom(configurations.compile) and use it for test project

or extend the 'default' configuration from compile

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

or try to delete/change the conf from ivy.xml

if you're not able to to this you might want to play with some groovy to do it.

asNode().dependencies.dependency.findAll { it.@conf }.each { it.attributes().remove("conf") }
Fluorine answered 30/3, 2017 at 15:13 Comment(2)
can you provide some details how to do that, as I am new to gradleFourthclass
Hmm, I did give you details already actually. Try to copy paste those 2 lines with configurations to your script.Fluorine

© 2022 - 2024 — McMap. All rights reserved.