apply plugin: 'java-library'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.google.guava:guava:18.0'
}

task printGuavaMetadata {
    dependsOn configurations.compileClasspath

    doLast {
        ArtifactResolutionQuery query = dependencies.createArtifactResolutionQuery()
            .forModule('com.google.guava', 'guava', '18.0')
            .withArtifacts(MavenModule, MavenPomArtifact)
        ArtifactResolutionResult result = query.execute()

        for(component in result.resolvedComponents) {
            Set<ArtifactResult> mavenPomArtifacts = component.getArtifacts(MavenPomArtifact)
            ArtifactResult guavaPomArtifact = mavenPomArtifacts.find { it.file.name == 'guava-18.0.pom' }
            def xml = new XmlSlurper().parse(guavaPomArtifact.file)
            println guavaPomArtifact.file
            println xml.name
            println xml.description
        }
    }
}
