Description
Been using bintray plugin for years and it all worked wonders up until Gradle 4.10 using dcendents maven plugin with this configuration: https://github.com/gotev/android-upload-service/blob/master/uploadservice/build.gradle
Unfortunately, dcendents plugin is no longer maintained for Gradle 5.x, so when I upgraded to gradle plugin 3.4.1 and Gradle 5.4.1 I started using https://github.com/sky-uk/gradle-maven-plugin. Everything's fine as long as I deploy locally or to my internal Artifactory or Nexus, but when I want to publish on bintray I get errors like this:
$ ./gradlew clean build bintrayUpload
> Task :mylibrary:bintrayUpload FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mylibrary:bintrayUpload'.
> Could not upload to 'https://api.bintray.com/content/gotev/maven/mylibrary/2.8.2-alpha2/property(class java/lang/String, fixed(class java/lang/String, net/gotev))/property(class java.lang.String, map(provider(?)))/property(class java.lang.String, fixed(class java.lang.String, 2.8.2-alpha2))/property(class java.lang.String, map(provider(?)))-property(class java.lang.String, fixed(class java.lang.String, 2.8.2-alpha2)).pom': HTTP/1.1 400 Bad Request [message:Unable to upload files: Maven group, artifact or version defined in the pom file do not match the file path 'property(class java/lang/String, fixed(class java/lang/String, net/gotev))/property(class java.lang.String, map(provider(?)))/property(class java.lang.String, fixed(class java.lang.String, 2.8.2-alpha2))/property(class java.lang.String, map(provider(?)))-property(class java.lang.String, fixed(class java.lang.String, 2.8.2-alpha2)).pom']
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
Thinking it's an error of the new plugin, I made a configuration without it entirely, but I still get the same errors. This is my module's build.gradle
. What I'm doing wrong? Let me know if further details are needed.
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'maven-publish'
Properties properties = new Properties()
if (project.rootProject.file("local.properties").exists()) {
properties.load(project.rootProject.file('local.properties').newDataInputStream())
}
// start - do not modify this if your project is on github
project.ext{
mavDevelopers = [(properties.getProperty("bintray.user")):(maintainer)]
mavSiteUrl = "https://github.com/${github_username}/${github_repository_name}"
mavGitUrl = mavSiteUrl + '.git'
bugTrackerUrl = mavSiteUrl + '/issues/'
mavProjectName = bintray_project_name
mavLibraryLicenses = ["Apache-2.0": 'http://www.apache.org/licenses/LICENSE-2.0.txt']
mavLibraryDescription = library_description
mavVersion = library_version
}
// end - do not modify this if your project is on github
group = library_project_group
version = library_version
android {
compileSdkVersion target_sdk
defaultConfig {
minSdkVersion min_sdk
targetSdkVersion target_sdk
versionCode version_code
versionName library_version
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
warning 'InvalidPackage'
}
}
dependencies {
// Testing - https://developer.android.com/training/testing/set-up-project
testImplementation "junit:junit:$junit_version"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
// Core library
androidTestImplementation "androidx.test:core:$androidx_test_core_version"
// AndroidJUnitRunner and JUnit Rules
androidTestImplementation "androidx.test:runner:$androidx_test_runner_version"
androidTestImplementation "androidx.test:rules:$androidx_test_rules_version"
// Assertions
androidTestImplementation "androidx.test.ext:junit:$androidx_test_ext_junit_version"
androidTestImplementation "androidx.test.ext:truth:$androidx_test_ext_truth_version"
androidTestImplementation "com.google.truth:truth:$truth_version"
// Espresso dependencies
androidTestImplementation "androidx.test.espresso:espresso-core:$androidx_test_espresso_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.recyclerview:recyclerview:$androidx_recyclerview_version"
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
task androidJavadocs(type: Javadoc) {
title = "${mavProjectName} ${project.version} API"
description "Generates Javadoc"
source = android.sourceSets.main.java.srcDirs
classpath += files(android.bootClasspath)
android.libraryVariants.all { variant ->
if (variant.name == 'release') {
owner.classpath += variant.javaCompileProvider.get().classpath
}
}
exclude '**/R.html', '**/R.*.html', '**/index.html', '**/*.kt'
options {
windowTitle("${mavProjectName} ${project.version} Reference")
locale = 'en_US'
encoding = 'UTF-8'
charSet = 'UTF-8'
links("http://docs.oracle.com/javase/7/docs/api/")
linksOffline("http://d.android.com/reference", "${android.sdkDirectory}/docs/reference")
setMemberLevel(JavadocMemberLevel.PUBLIC)
}
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
artifacts {
archives androidJavadocsJar
archives androidSourcesJar
}
publishing {
publications {
bintrayPublication(MavenPublication) {
artifact androidSourcesJar
artifact androidJavadocsJar
groupId library_project_group
version library_version
pom {
name = bintray_project_name
description = library_description
url = mavGitUrl
packaging = 'aar'
licenses {
license {
name = library_licenses[0]
url = library_licenses_url
distribution = "repo"
}
}
developers {
developer {
id = properties.getProperty("bintray.user")
name = maintainer
}
}
scm {
url = mavGitUrl
}
}
}
}
}
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
publications = ['bintrayPublication']
pkg {
repo = "maven"
name = mavProjectName
desc = library_description
websiteUrl = mavSiteUrl
vcsUrl = mavGitUrl
issueTrackerUrl = bugTrackerUrl
licenses = library_licenses
labels = library_keywords
publicDownloadNumbers = true
}
}
Note:
- I had to switch from
configurations = ['archives']
topublications = ['bintrayPublication']
because without using dcendents plugin, theinstall
task does not exist