Pergunta

I have the following fairly simple build.gradle build script:

repositories {
  mavenCentral()
}

configurations { libs }

dependencies {
  libs 'org.hibernate:hibernate-core:4.3.5.Final'
}

configurations.libs.files { println it }

When I run it with gradlew build (I'm using Gradle 1.12, latest at the moment) I get the following:

DefaultExternalModuleDependency{group='org.hibernate', name='hibernate-core', version='4.3.5.Final', configuration='default'}
DefaultExternalModuleDependency{group='org.hibernate', name='hibernate-core', version='4.3.5.Final', configuration='default'}

These seem to be the same dependencies, but I don't get it why there are 2 of them when I have added just a single one.

Does anyone know why? Did I do something wrong? Or is there something I don't understand?

Foi útil?

Solução

The Configuration#files method expects a predicate. (For API details, see Configuration in the Gradle Build Language Reference.) If you instead pass it a closure containing a println statement, (seemingly) strange things will happen. You probably want something like the following instead:

// configurations should only be resolved in 
// the execution phase, so let's declare a task
task printLibs {
    doLast {
        configurations.libs.each { println it }
    }
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top