Search code examples
gradleartifactorypublishtar

gradle publish does not pick up artifacts: "Task has not declared any outputs despite executing actions."


I'm migrating a java project from gradle 2.x to 5.3.1.

The last problem is that no artefacts (a tar in our case) are published to artifactory.

The config in main build.gradle is

subprojects {
    apply plugin: "com.jfrog.artifactory"
    project.ext {
        artifactoryConfig = new File(project.gradle.gradleUserHomeDir, "artifactory.gradle")
    }
    if (artifactoryConfig.exists()) {
        apply plugin: 'maven'
        apply from: artifactoryConfig
    }
    sourceCompatibility = 1.8
    repositories {
        mavenCentral()
        maven { url $OUR_ARTIFACTORY }
    }
    publishing {
        publications {
            mavenJava(MavenPublication) {
                from components.java
            }
        }
    }
}
artifactory {
    publish {
        contextUrl = "${artifactoryBaseUrl}"
        repository {
            repoKey = "libs-release-local"
            username = "${artifactoryUsername}"
            password = "${artifactoryPassword}"
        }
    }
    resolve {
        repoKey = 'repos'
    }
}

And in the module

task('dist', type: Tar) {
    dependsOn('jar')
    archiveName "$MODULE-${version}.${extension}"
...
}
publishing {
    publications {
        mavenJava(MavenPublication)
                {
                    artifact dist {
                    }
                }
    }
}
configurations.archives.artifacts.clear()
artifacts {
    archives dist
}

Now when I do ./gradlew --info :$MODULE:artifactoryPublish it complains about missing outputs and does not publish the tar to artifactory.

How to fix this?

> Task :$MODULE:artifactoryPublish
Task ':$MODULE:artifactoryPublish' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
:$MODULE:artifactoryPublish (Thread[Execution worker for ':',5,main]) completed. Took 0.002 secs.
:artifactoryDeploy (Thread[Execution worker for ':',5,main]) started.

> Task :artifactoryDeploy
Task ':artifactoryDeploy' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Deploying build descriptor to: $OUR_ARTIFACTORY/artifactory/api/build
Build successfully deployed. Browse it in Artifactory under $OUR_ARTIFACTORY/artifactory/webapp/builds/$MODULE/1554465369336
:artifactoryDeploy (Thread[Execution worker for ':',5,main]) completed. Took 0.155 secs.

Solution

  • Turns out the solution was to add

    artifactoryPublish {
        publications('mavenJava')
    }