Task - "UploadArchives" trying to publish artifacts from configuration other than "archives"

I am trying to introduce a new upload task to publish a specific artifact after actual uploadArchives task. And here is the sample build script.

apply plugin: 'java'
repositories {
    jcenter()
}
task generateFooFile << {
	File fooFile = file('build/foo.txt')
	fooFile << "Sample Text"
	outputs.file 'build/foo.txt'
}
configurations {
    localArchives
}
artifacts {
   localArchives file('build/foo.txt')
}
generateFooFile.dependsOn uploadArchives
uploadLocalArchives.dependsOn generateFooFile

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.12'
    testCompile 'junit:junit:4.12'
}

And when I am trying to run “uploadArchives” it fails with exception below. I am trying to understand why “uploadArchives” task trying to publish artifacts mentioned under configuration - “localArchives” which I expect to be published by “uploadLocalArchives”?

:uploadArchives FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':uploadArchives'.
> Could not publish configuration 'archives'
   > Cannot publish artifact 'foo.txt (:Gradle-Local-Publish:unspecified)' (C:\RUP\workspaces\Gradle-Local-Publish\build\foo.txt) as it does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

is this intentional or a bug?

1 Like