androidandroid-librarybintrayandroid-maven-plugin

Publishing Android library to bintray maven produces 2 separate artifacts


I'm trying to publish my android library using bintray, but I end up with two separate artifacts in bintray maven stringx and stringx-android-sdk: https://dl.bintray.com/klimaszewski/stringx/io/stringx/ where sources and all the stuff is placed here: https://dl.bintray.com/klimaszewski/stringx/io/stringx/stringx/1.0.2/

and POM file is placed in correct artifact: https://dl.bintray.com/klimaszewski/stringx/io/stringx/stringx-android-sdk/1.0.2/

My bintray repo is: stringx and library name: stringx-android-sdk

Bacause of that library cannot be resolved in my projects. What's wrong here? build.gradle

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }

    dependencies {
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
    }
}
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

ext {
    bintrayRepo = 'stringx'
    bintrayName = 'stringx-android-sdk'

    publishedGroupId = 'io.stringx'
    libraryName = 'StringX-SDK'
    artifact = 'stringx-android-sdk'

    libraryDescription = 'Automatic app Translation for Android'

    siteUrl = 'https://www.stringx.io'
    gitUrl = 'https://github.com/SzyQ/stringx-android-sdk'

    developerId = 'klimaszewski'
    developerName = 'Szymon Klimaszewski'
    developerEmail = 'klimaszewski.szymon@gmail.com'

    licenseName = 'The Apache Software License, Version 2.0'
    licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
    allLicenses = ["Apache-2.0"]
    versionMajor = 1
    versionMinor = 0
    versionHotFix = 2

    libraryVersion = buildVersionName()
}

android {
    compileSdkVersion 27
    buildToolsVersion "26.0.2"
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 27
        versionCode buildVersionCode()
        versionName buildVersionName()
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:support-annotations:27.0.0'
}

def buildVersionName() {
    String versionName
    if (versionHotFix == null || versionHotFix == 0) {
        versionName = versionMajor + "." + versionMinor
    } else {
        versionName = versionMajor + "." + versionMinor + "." + versionHotFix
    }
    println "Version name: " + versionName
    return versionName
}

def buildVersionCode() {
    Integer versionCode
    if (versionHotFix == null || versionHotFix == 0) {
        versionCode = versionMajor * 10000 + versionMinor * 100
    } else {
        versionCode = versionMajor * 10000 + versionMinor * 100 + versionHotFix
    }
    println "Version code: " + versionCode
    return versionCode
}

apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'

Solution

  • Android module name has to match bintray package, 'stringx-android-sdk' in my case.

    So I had to change module in settings.gradle

    include ':stringx-android-sdk'
    project(":stringx-android-sdk").projectDir = file("../../stringx")