Publish android library as maven jar

Gradle / maven is new here. I created a library that is currently published in bintray / jcenter as AAR, which will be used with gradle in Android Studio projects. However, since my library does not have any hard-coded Android dependencies and can be used in any Java SE environment, I would like to publish it as well as a regular jar. Since I am not very familiar with the non-android community of java developers, I am not sure if this means I have to publish it to Maven central, or developers tend to extract my library from bintray perfectly, given that library actually hosted in maven repo on bintray? Should I just expand my artifacts to include the jar (along with the aar, javadoc and the original jar), or should I publish the jar separately, sayMaven central?

Getting a bintray / jcenter job was not a picnic, I found some tutorials on how to do this, but no one was really complete, but finally I have a job. I, however, have an amazingly difficult time to find a similar easy guide to publish maven.

My gradle file looks like this:

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        minSdkVersion 1
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
    }
}

group = <my library name>
version = <my version>

dependencies {
}

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    options.overview = 'src/main/overview.html'
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives javadocJar
    archives sourcesJar
}

bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")

    configurations = ['archives']
    pkg {
        repo = "maven"
        name = <my library name>
        websiteUrl = <my site url>
        vcsUrl = <my git url>
        licenses = ["Apache-2.0"]
        publish = true
    }
}

The plugin com.github.dcendents.android-mavenoffers a task installthat creates an AAR, Source Jar, and Javadoc Jar. I defined my own bintray task, which publishes a library for bintray. What will be the easiest way to create a task for publishing my library and as a standard jar for maven? Can I use com.github.dcendents.android-mavenfor this, or do I need a separate plugin?

+4

Source: https://habr.com/ru/post/1628275/


All Articles