How to get the latest.integration version number

(Stephane Galles) #1

I’m trying create a plugin that is able to increment the version number of the projet for each uploadArchives, but I’m not able to fetch le the real latest.integration version number in the repos.

Basically, in the plugin, I create a configuration for the project itself :

configurations {
   selfConf {
    visible = true
    transitive = false
      dependencies {
   selfConf,, version:'latest.integration'
      task doesNotWork << {
   project.configurations.selfConf.resolvedConfiguration.resolvedArtifacts.each { t ->
    println t

The ‘doesNotWork’ task throws a NPE in the gradle code. Is my approach too naive ?

Thank you

(René Groeschke) #2

Hello, did you declare the repository, where your archives are uploaded to? Can you provide the stack trace of the NPE using the “-S” option when running your build.

regards, René

(Stephane Galles) #3

Yes, the repository is declared. Actually, I’ve done more tests and I’ve found out that the NPE is clearly related to the configuration targeting the group/name of the enclosing project itself. ie : - On projet A the ‘doesNotWork’ task works when I target module B on the repos, but does not work for when I target A - On projet B the ‘doesNotWork’ task works when I target module A on the repos, but does not work for when I target B

This is with Gradle m8a, with an Ivy http resolver.

The end of the stacktrace
by: java.lang.NullPointerException
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$ConfigurationNode.getArtifacts(
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$DependencyEdge.attachToParents(
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$ConfigurationNode.attachToParents(
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder.assembleResult(
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder.resolve(
        at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDependencyResolver.resolve(
        at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver$1.create(
        at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver$1.create(
        at org.gradle.cache.internal.DefaultCacheAccess.useCache(
        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(
        at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.useCache(
        at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver.resolve(
        at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyResolver.resolve(
        at org.gradle.api.internal.artifacts.ivyservice.ShortcircuitEmptyConfigsArtifactDependencyResolver.resolve(
        at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.resolve(
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getResolvedConfiguration(
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getResolvedConfiguration(Unknown Source)

(Stephane Galles) #4

Should I create a bug for this NPE ?


(Stephane Galles) #5

I don’t know if something was wrong with my first code, but I’ve found a hack to make it work. It seems that somehow I’m not supposed to create a configuration with the artifact of the project itself, never mind, let’s create an other project to hide this new conf.

Fasten your seatbelt, this is not pretty :

task displayLatestPublication << {
    Project sandBox = org.gradle.testfixtures.ProjectBuilder.builder().withName('dummyName').build()
    sandBox.configurations {
        selfConf {
            transitive = false
    sandBox.dependencies {
        selfConf,, version:'latest.integration'
    sandBox.configurations.selfConf.resolvedConfiguration.resolvedArtifacts.each { t ->
        println t

Well, at least I think that I can create my plugin now…that will break as soon as ProjectBuilder is removed from the runtime classpath of Gradle, to prevent this type of hack !