2

このチュートリアルを使用して、小さなライブラリを jcenter に公開しました。

https://github.com/danielemaddaluno/gradle-jcenter-publish

ただし、他のプロジェクトの依存関係に追加すると、ライブラリから javadoc がプルされないことが判明しました。グーグルで調べたところ、その理由は .aar - パッケージングのようです。ライブラリにはリソースが含まれておらず、ソースコードのみが含まれているため、.jar としてパッケージ化できると思います。そのためには、gradle スクリプトをどのように変更すればよいですか? 前もって感謝します。

私が使用したbuild.gradleの例:

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

// This is the library version used when deploying the artifact
version = "1.0.0"

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        //applicationId "com.madx.updatechecker.lib"
        minSdkVersion 8
        targetSdkVersion 21
        versionCode 1
        versionName "1.0.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'org.jsoup:jsoup:1.8.1'
}


def siteUrl = 'https://github.com/danielemaddaluno/Android-Update-Checker'      // Homepage URL of the library
def gitUrl = 'https://github.com/danielemaddaluno/Android-Update-Checker.git'   // Git repository URL
group = "com.github.danielemaddaluno.androidupdatechecker"                      // Maven Group ID for the artifact


install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                packaging 'aar'

                // Add your description here
                name 'Android Update Checker'
                description = 'The project aims to provide a reusable instrument to check asynchronously if exists any newer released update of your Android app on the Store.'
                url siteUrl

                // Set your license
                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id 'danielemaddaluno'
                        name 'Daniele Maddaluno'
                        email 'daniele.maddaluno@gmail.com'
                    }
                }
                scm {
                    connection gitUrl
                    developerConnection gitUrl
                    url siteUrl

                }
            }
        }
    }
}

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))
}

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

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

// https://github.com/bintray/gradle-bintray-plugin
bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")

    configurations = ['archives']
    pkg {
        repo = "maven"
        // it is the name that appears in bintray when logged
        name = "androidupdatechecker"
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        licenses = ["Apache-2.0"]
        publish = true
        version {
          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 //Optional (true by default). Determines whether to sync the version to Maven Central.
//                user = properties.getProperty("bintray.oss.user") //OSS user token
//                password = properties.getProperty("bintray.oss.password") //OSS user password
//                close = '1' //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
//            }
    }        
  }
}
4

0 に答える 0