What does this strange deprecation warning mean and how would I get rid of it?

I sometimes, but not always, get the following message: Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0

Usually, Gradle is linking to some part of the documentation in case of deprecation warnings like this. But not in this case.

The message is mainly showing up after removing most of the stuff in ~/.gradle

Any ideas? And most importantly: what will break with Gradle 2.0?

The culprit is likely this code:

gradle.taskGraph.whenReady { graph ->
  if (graph.hasTask(uploadArchives)) {
   task sourceJar(type: Jar) { from sourceSets.main.allSource; classifier = 'sources' }
   task javadocJar(type: Jar) { from javadoc.outputs.files; classifier = 'javadoc' }
   artifacts { archives sourceJar, javadocJar }
  }
 }

But what would be the correct way to do this? The idea is that source and javadoc should only be built if an upload is performed.

This causes the following messages while executing uploadArchives:

:foo:bar:uploadArchives
Attempted to publish an artifact 'foo#bar;2.0.0-SNAPSHOT' that does not exist '[path]-sources.jar'. This behaviour has been deprecated and is scheduled to be removed in Gradle 2.0
Attempted to publish an artifact 'foo#bar;2.0.0-SNAPSHOT' that does not exist '[path]-javadoc.jar'. This behaviour has been deprecated and is scheduled to be removed in Gradle 2.0
Uploading: [artifact] to repository remote at http://10.200.54.135/nexus/content/repositories/snapshots
Transferring 11585K from remote
Uploaded 11585K

There is no need to wrap that code in ‘gradle.taskGraph.whenReady’. Also, it’s too late to add tasks at that point. Just use:

task sourceJar(type: Jar) { from sourceSets.main.allSource; classifier = 'sources' }
task javadocJar(type: Jar) { from javadoc.outputs.files; classifier = 'javadoc' }
artifacts { archives sourceJar, javadocJar }

You are definitely right. I’m now a bit ashamed of that code… and uploading of sources and javadocs is now working again.

This doesn’t fix the deprecation warning, though.

This is GRADLE-2745.

There’s no way around the warning at the moment, but the warning is bogus.

OK, thanks. Got me a bit worried about updating Gradle in the future. I usually fix stuff like that ASAP to prevent problems.

You’re our ideal user then! :slight_smile:

Well, now this bit me. Could this bogus warning be fixed till 1.7? Seems like a pretty trivial fix?

Unless it has been fixed already, it’s too late for 1.7, which is already in the RC phase.

Was this ever fixed?

I still see this with Gradle 1.9…

Broken windows, anybody? This should be fixed.

It’s not spam when your users are trying to raise legitimate issues. Yes, it is minor, but it should have its priority raised, since it should be a easy fix.

Broken Windows, or in other words, don’t let annoying issues linger.

Byron

I’ve restored your comment. Sorry, this was a misunderstanding. You can always vote for this issue. We have this issue on our radar.