Configuration 'testRuntime' declares a dependency on configuration 'default' which is not declared in the module descriptor cobertura:2.0.3


(renjith4) #1

Hi,

I was using the gradle-cobertura-plugin from https://github.com/stevesaliman/gradle-cobertura-plugin to run the cobertura tests from gradle. However, recently I started hitting on the following errors

FAILURE: Build failed with an exception.
  What went wrong: Could not resolve all dependencies for configuration ':testRuntime'. > Module version misc:myproject:1.0-SNAPSHOT, configuration 'testRuntime' declares a dependency on configuration 'default' which is not declared in the module descriptor for net.sourceforge.cobertura:cobertura:2.0.3

and the configuration snippet is given below

build.gradle

buildscript {
      repositories {
        mavenCentral()
    }
    dependencies {
        classpath "net.saliman:gradle-cobertura-plugin:1.2.0"
    }
}
  apply plugin: 'java'
apply plugin: 'cobertura'
  cobertura {
    cobertura.coverageIgnoreTrivial = true
    coverageFormats = ['xml', 'html']
    cobertura.coverageExcludes = ['.*DTO.*']
}
  dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
    testCompile 'com.h2database:h2:1.3.164'
    testCompile group: 'org', name: 'mockachino', version: '0.6.1', configuration: 'runtime'
}

repository.gradle

project.ext {
    ivyArtifactPattern = '[organisation]/[module]/[module]-[revision]/[artifact]-[revision].[ext]'
    ivyPattern = '[organisation]/[module]/[module]-[revision]/ivy-[revision].xml'
}
  repositories {
    ivy {
        url 'http://ivy.dev.mycompany.com/repository'
        layout "pattern", {
            artifact project.ivyArtifactPattern
            ivy project.ivyArtifactPattern
        }
    }
      mavenCentral()
}

I am using gradle1.7. Can any one please advise on how to correct this?

Thanks in advance


(renjith4) #2

Any suggestions on what am I doing wrong in this configuration?


(renjith4) #3

It turns out that the issue could be fixed by modifying ivy.xml.

ivy.xml inside cobertura directory of ivy-cache was not having default configuration. it could be under a path like this

/home//.gradle/caches/artifacts-26/module-metadata/net.sourceforge.cobertura/cobertura/2.0.3/e9d03b7c6586155fbee8fb2de8b5b149/ivy.xml

so added the default configuration and is working. phew. ivy.xml now looks like this

<ivy-module version="2.0">
  <info organisation="net.sourceforge.cobertura" module="cobertura" revision="2.0.3"/>
  <configurations>
        <conf name="default" visibility="public" description="runtime dependencies can be used with this conf" extends="runtime"/>
        <conf name="runtime" description="Runtime dependencies (they are transitive)"/>
  </configurations>
  <publications>
    <artifact name="cobertura" type="jar"
conf="runtime" ext="jar"/>
  </publications>
  <dependencies>
    <dependency org="asm" name="asm" rev="4.1" />
    <dependency org="log4j" name="log4j" rev="1.2.16" />
  </dependencies>
</ivy-module>

(Peter Niederwieser) #4

Patching the ivy.xml in the Gradle cache is not a stable solution. I’d rather contact the author of the plugin.


(renjith4) #5

True. That would be ideal. This was only a workaround till the issue is fixed. Here is the link for it to be tracked https://github.com/cobertura/cobertura/issues/85