bintray / gradle-bintray-plugin

Apache License 2.0
1.28k stars 194 forks source link

Multi-project publishing publishes all projects #241

Open anuraaga opened 6 years ago

anuraaga commented 6 years ago

Ever since 1.8.1, the plugin seems to have moved publishing to a root-project task that executes publishing for all uploaded artifacts. This seems to be causing a couple of problems

1) With org.gradle.configureondemand = true in gradle.properties, uploading fails with BintrayUploadTask.dependsOn cannot be called after task execution (I will get a more detailed stacktrace after exercising the bug once more).

2) After disabling configureondemand, it seems that even when running a subproject's bintrayUpload task (e.g., ./gradlew :subproject:bintrayUpload), other subprojects bintrayUpload also gets executed. When these projects have not had their version increased, this causes uploading to fail because the artifacts have already been published.

I wonder why bintrayPublish is on the top-level task and what is the purpose of aggregating tasks with the project evaluation listener? It seems like bintrayUpload tasks should be independent and all logic should be contained within a project without hackery in the root project. If the publish task was moved to the project, rather than rootproject, I think everything would be fixed.

AlexeiVainshtein commented 6 years ago

Hi @anuraaga

First of all, I wanted to update you that currently the plugin is not supporting the configure-on-demand flag. Regarding that the artifacts are being published from other projects even when you configure to run only one project, I couldn't reproduce this:

I have a multiple project and when running ./gradlew clean bintrayUpload, both api and services:webservice are being uploaded:

> Task :api:bintrayUpload
Uploading to https://api.bintray.com/content/avjfrog/maven/this_is_new2/1.32-Final-Modules/configurations-modules-example/api/3.9.4.3/api-3.9.4.3.pom...
Uploaded to 'https://api.bintray.com/content/avjfrog/maven/this_is_new2/1.32-Final-Modules/configurations-modules-example/api/3.9.4.3/api-3.9.4.3.pom'.
Uploading to https://api.bintray.com/content/avjfrog/maven/this_is_new2/1.32-Final-Modules/configurations-modules-example/api/3.9.4.3/api-3.9.4.3.jar...
Uploaded to 'https://api.bintray.com/content/avjfrog/maven/this_is_new2/1.32-Final-Modules/configurations-modules-example/api/3.9.4.3/api-3.9.4.3.jar'.

> Task :services:webservice:bintrayUpload
Uploading to https://api.bintray.com/content/avjfrog/maven2/this_is_new2/1.32-Final-Modules/configurations-modules-example/services/webservice/3.9.4.3/webservice-3.9.4.3.pom...
Uploaded to 'https://api.bintray.com/content/avjfrog/maven2/this_is_new2/1.32-Final-Modules/configurations-modules-example/services/webservice/3.9.4.3/webservice-3.9.4.3.pom'.
Uploading to https://api.bintray.com/content/avjfrog/maven2/this_is_new2/1.32-Final-Modules/configurations-modules-example/services/webservice/3.9.4.3/webservice-3.9.4.3.war...
Uploaded to 'https://api.bintray.com/content/avjfrog/maven2/this_is_new2/1.32-Final-Modules/configurations-modules-example/services/webservice/3.9.4.3/webservice-3.9.4.3.war'.

However, when I run ./gradlew :api:bintrayUpload only api is being uploaded:

> Task :api:bintrayUpload
Uploading to https://api.bintray.com/content/avjfrog/maven/this_is_new2/1.32-Final-Modules/configurations-modules-example/api/3.9.4.4/api-3.9.4.4.pom...
Uploaded to 'https://api.bintray.com/content/avjfrog/maven/this_is_new2/1.32-Final-Modules/configurations-modules-example/api/3.9.4.4/api-3.9.4.4.pom'.
Uploading to https://api.bintray.com/content/avjfrog/maven/this_is_new2/1.32-Final-Modules/configurations-modules-example/api/3.9.4.4/api-3.9.4.4.jar...
Uploaded to 'https://api.bintray.com/content/avjfrog/maven/this_is_new2/1.32-Final-Modules/configurations-modules-example/api/3.9.4.4/api-3.9.4.4.jar'.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.8/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 4s

I've tried with both 1.8.1 and 1.8.2. Can you please share with us a sample project that reproduce this issue with the latest version (1.8.2)?

Thanks,

anuraaga commented 6 years ago

I will try to set up a small reproduction if I can, but I think to reproduce you also need publish = true. I don't see the :publish task being run in those logs, and that's where it fails since it seems to try to publish everything. Admittedly, enabling publish makes it annoying to try to test this ;)

anuraaga commented 6 years ago

Here is a simple test case - https://github.com/anuraaga/gradle-bintray-test. When running with --info with dryRun enabled, we can see that bintrayPublish tries to publish both projects.

:~/git/gradle-bintray-test % ./gradlew :project1:bintrayUpload --info

> Task :project1:bintrayUpload
Caching disabled for task ':project1:bintrayUpload': Caching has not been enabled for the task
Task ':project1:bintrayUpload' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Gradle Bintray Plugin version: 1.8.2
Uploading to https://api.bintray.com/content/infostellarinc/gradle-bintray-test/gradle-bintray-example-project1/0.0.1/com/stellarstation/gradlebintraytest/gradle-bintray-example-project1/0.0.1/gradle-bintray-example-project1-0.0.1.jar...
(Dry run) Uploaded to 'https://api.bintray.com/content/infostellarinc/gradle-bintray-test/gradle-bintray-example-project1/0.0.1/com/stellarstation/gradlebintraytest/gradle-bintray-example-project1/0.0.1/gradle-bintray-example-project1-0.0.1.jar'.
Uploading to https://api.bintray.com/content/infostellarinc/gradle-bintray-test/gradle-bintray-example-project1/0.0.1/com/stellarstation/gradlebintraytest/gradle-bintray-example-project1/0.0.1/gradle-bintray-example-project1-0.0.1.pom...
(Dry run) Uploaded to 'https://api.bintray.com/content/infostellarinc/gradle-bintray-test/gradle-bintray-example-project1/0.0.1/com/stellarstation/gradlebintraytest/gradle-bintray-example-project1/0.0.1/gradle-bintray-example-project1-0.0.1.pom'.
:project1:bintrayUpload (Thread[Task worker for ':',5,main]) completed. Took 1.574 secs.
:bintrayPublish (Thread[Task worker for ':',5,main]) started.

> Task :bintrayPublish
Caching disabled for task ':bintrayPublish': Caching has not been enabled for the task
Task ':bintrayPublish' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
(Dry run) Signed version 'infostellarinc/gradle-bintray-test/gradle-bintray-example-project1/0.0.1'.
(Dry run) Published version 'infostellarinc/gradle-bintray-test/gradle-bintray-example-project1/0.0.1'.
(Dry run) Signed version 'infostellarinc/gradle-bintray-test/gradle-bintray-example-project2/0.0.1'.
(Dry run) Published version 'infostellarinc/gradle-bintray-test/gradle-bintray-example-project2/0.0.1'.
:bintrayPublish (Thread[Task worker for ':',5,main]) completed. Took 0.0 secs.

:project2:bintrayUpload was not run as expected.

AlexeiVainshtein commented 6 years ago

Thanks @anuraaga for the sample project. We have reproduced this issue and fixed it (3fe02dfdae3e807afba57e0140a0d4c2424674e1). A new version should be released in a few days.

Thanks,

AlexeiVainshtein commented 6 years ago

Hi @anuraaga

I wanted to update you that we have released a new version a few days ago (1.8.3) that should fix this issue. We would appreciate your feedback for it.

Thanks,

anuraaga commented 6 years ago

Thanks - I've confirmed that publishing works now. configureOnDemand still doesn't, and since it used to before 1.8.1, it's a bit sad, but luckily not as big a deal.

ProTip commented 6 years ago

I seem to be experiencing this same issue on 1.8.4 with a sub-subproject. It attempts to publish the 3rd level project(and gets an auth error on dry run!) even though the Bintray task has not been explicitly setup on it.

Fortunately this project is OSS and I can show you: https://github.com/rundeck/rundeck/tree/bintray-publish/rundeckapp .

Running ./gradlew rundeck:bintrayUpload will run the task rundeck:metrics-web:bintrayUpload and fail with an auth, which is odd for a dry run.

I can manually exclude the task -x rundeck:metrics-web:bintrayUpload and see the expected dry run output.

florent37 commented 5 years ago

@ProTip thanks for the -x rundeck:metrics-web:bintrayUpload