Closed hastebrot closed 8 years ago
Here is a quick workaround for this issue. I've added the following code to the top of my build.gradle
build script to overwrite the root project's bintrayUpload
task.
plugins {
// use the bintray gradle plugin to upload build artifacts.
id "com.jfrog.bintray" version "1.2"
}
// only our subprojects have a bintray configuration. replace the root project's
// `bintrayUpload` task with one that restricts the calls to the subprojects.
project.afterEvaluate {
task bintrayUpload(group: "publishing", overwrite: true) {
dependsOn subprojects.bintrayUpload
}
}
Also note that I used bintray { dryRun = true; /*...*/ }
.
+1 same problem. Thanks @hastebrot for the workaround wfm.
Note, the workaround also disables version signing, publishing and maven sync from the plugin. These are defined in the original bintrayUpload
task: https://github.com/bintray/gradle-bintray-plugin/blob/master/src/main/groovy/com/jfrog/bintray/gradle/BintrayUploadTask.groovy#L396-L404
Another workaround: move the bintray
section from subprojects
to allprojects
, then for the root project:
bintray {
publications = []
configurations = []
}
This just makes sure no artifacts are published for the (empty) root project, but everything else goes as normal. Or even specify the configurations / publications conditionally to avoid confusion:
allprojects { thisproject ->
bintray {
if (thisproject == rootProject) {
configurations = []
} else {
configurations = ['archives']
}
}
}
so in this case if the configuration is empty then gradle will not run any tasks on the root project.
To clarify: the original Gradle task bintrayUpload
will run, but incidentally it won't upload any artifacts due to the empty configurations
. It will, however, sign the released version, publish the version, and/or sync to Maven Central if so configured. Why on the root project? Because the root project depends on all its subprojects, so the bintrayUpload
task in the root project will be the last to run. And there's code in the plugin (at https://github.com/bintray/gradle-bintray-plugin/blob/master/src/main/groovy/com/jfrog/bintray/gradle/BintrayUploadTask.groovy#L395) that makes sure these after-upload actions are taken when the very last bintrayUpload
task is executed.
Please fix this.
How can I publish subproject to bintray without modifying root buildscript? Why do I have to modify root buildscript at all???
This is my solution: Complete project is here
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Note:Don't use apply plugin: 'com.jfrog.bintray'
GROUP=im.quar
VERSION_NAME=1.0.0
POM_DESCRIPTION=AutoLayout for Android.
POM_URL=https://github.com/DTHeaven/AutoLayout-Android
POM_SCM_URL=https://github.com/DTHeaven/AutoLayout-Android
POM_SCM_CONNECTION=scm:git:git://github.com/DTHeaven/AutoLayout-Android.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com:DTHeaven/AutoLayout-Android.git
POM_ISSUE_URL=https://github.com/DTHeaven/AutoLayout-Android/issues
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_ALL_LICENCES=['Apache-2.0']
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=dtheaven
POM_DEVELOPER_NAME=DTHeaven
/*
* Copyright 2013 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'
version = VERSION_NAME
group = GROUP
// Bintray
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = 'maven'
name = POM_ARTIFACT_ID
desc = POM_DESCRIPTION
websiteUrl = POM_URL
issueTrackerUrl = POM_ISSUE_URL
vcsUrl = POM_SCM_URL
licenses = ["Apache-2.0"]
publish = true
publicDownloadNumbers = true
version {
desc = POM_DESCRIPTION
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password")
//Optional. The passphrase for GPG signing'
}
mavenCentralSync {
sync = true
user = properties.getProperty("bintray.oss.user")
password = properties.getProperty("bintray.oss.password")
close = '1'
}
}
}
}
if (project.getPlugins().hasPlugin('com.android.application') ||
project.getPlugins().hasPlugin('com.android.library')) {
install {
repositories.mavenInstaller {
configuration = configurations.archives
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
}
}
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.source
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.source
}
} else {
install {
repositories.mavenInstaller {
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
}
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
artifacts {
if (project.getPlugins().hasPlugin('com.android.application') ||
project.getPlugins().hasPlugin('com.android.library')) {
archives androidSourcesJar
archives androidJavadocsJar
} else {
archives sourcesJar
archives javadocJar
}
}
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
POM_NAME=AutoLayout
POM_ARTIFACT_ID=autolayout
POM_PACKAGING=aar
POM_NAME=AutoLayout Annotations
POM_ARTIFACT_ID=autolayout-annotations
POM_PACKAGING=jar
POM_NAME=AutoLayout Compiler
POM_ARTIFACT_ID=autolayout-compiler
POM_PACKAGING=jar
Note:Don't use apply plugin: 'com.jfrog.bintray'
@DTHeaven This fixed it for me. Thanks!
Nope, not working for me. I even copied the whole repository and changed IDs to get it to work, still getting the same annoying error.
OMG. Finally. The solution was to run gradle subproject:bintrayUpload
instead of gradle bintrayUpload
. This worked with Gradle 2.1 - No comment.
@hastebrot, @milosmns, @mitochondrion, @DTHeaven and @jamescway, I'd like to thank all of you for sharing all of the helpful information in this issue. Do you think there's something we can add or improve in the plugin. that is related to this issue? if you don't, we'll close it.
Well.. it would be a huge help if you could direct the command to the subproject when there is no bintray config in the root. But since I left a comment in my script, I won't be making the same mistake again :)
Thanks @milosmns, We've just implemented this (here's the commit). This will be included as part of the next release.
Thanks! Looking forward to it :+1:
@milosmns and all, Version 1.7.2 with this fix has been released.
@eyalbe4 Kewl, thanks! Here's a beer! :beer:
@eyalbe4 Thank U, Version 1.7.2 with this fix has been released! It's right!
The fix for this issue was wrong, it just fails to run the task silently now, which can cause a lot of pain when you think you've published your artifact but you didn't.
I don't understand why it is expected that a root project that has no configuration for the bintray plugin should allow the plugin to be applied on it without failing. Shouldn't everyone just configure the plugin in the sub-projects they actually use the plugin on?
If the concern is that the subProjects share some configuration, Gradle has many ways for sharing configuration, for example, from an external gradle file which the subprojects apply.
Sorry if I misunderstand this issue, but it looks to me that you just made the plugin task silently fail to fix this one particular case, without taking into consideration that it SHOULD fail in most other scenarios.
@renatoathaydes, I believe your comment refers to the original fix this issue discusses from almost two years ago. The implementation since then has been changed and improved.
Hey,
(I use gradle-bintray-plugin 1.2 and Gradle 2.4.)
I have a Gradle build configuration that contains an empty root project (no source sets) with tasks that call their counterparts in subprojects for convenience. The subprojects configure the
bintray
environent closure (i.e.user
,key
,pkg
, ...).The gradle-bintray-plugin adds the
bintrayUpload
task to the root project, but when I call it I get following error message:Calling
bintrayUpload
on the subprojects works as expected.It would be nice if the missing
bintray
environment closure could be ignored and the task in the root project could just call its counterpartbintrayUpload
in the subprojects.