6

AndroidスタジオでAndroidプロジェクトを作成します。

いくつかの apk が生成されます。

Gradleを使用してMaven Centralにapkを公開するにはどうすればよいですか?

apk のアーティファクトには何を書けばよいですか?

apply plugin: 'maven'
apply plugin: 'signing'

configurations {
    archives {
        extendsFrom configurations.default
    }
}

afterEvaluate { project ->
    uploadArchives {
        repositories {
            mavenDeployer {
                configurePOM(pom)
                beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

                repository(url: sonatypeRepositoryUrl) {
                    authentication(userName: nexusUsername, password: nexusPassword)
                }
            }
        }
    }

......

    artifacts {
       archives file: files(dir: '$buildDir/apk/*.apk', include: '*.apk')
        // archives androidReleaseApklib
        archives androidReleaseJar
        archives androidSourcesJar
        archives androidJavadocsJar
    }
}
4

1 に答える 1

1

gradle を使用して APK ファイルをローカルの Nexus リポジトリに公開します。これが私が思いついたものです。この例では、「googlePlay」ビルド フレーバーの使用を示しました。

// make sure the release builds are made before we try to upload them.    
uploadArchives.dependsOn(getTasksByName("assembleRelease", true))

// create an archive class that known how to handle apk files.
// apk files are just renamed jars.
class Apk extends Jar {
    def String getExtension() {
        return 'apk'
    }
}

// create a task that uses our apk task class.
task googlePlayApk(type: Apk) {
    classifier = 'googlePlay'
    from file("${project.buildDir}/outputs/apk/myApp-googlePlay-release.apk")
}

// add the item to the artifacts
artifacts {
    archives googlePlay
}
于 2015-02-11T03:16:02.763 に答える