如何将aar库上传到Nexus?

如何将aar库上传到Nexus?

问题描述:

我有一个与Android应用程序一起使用的Android Aar库.它可以与直接包含在Android项目中的aar库一起正常使用.我想将此库移到我的内部Nexus maven存储库中,以便其他开发人员也可以使用该库.

I have an Android aar library I am using with an Android application. It is working correctly with the aar library included directly in the Android project. I would like to move this library to my internal Nexus maven repository, so that other developers can use the library too.

如何将aar上传到Nexus(Maven存储库)? Web界面中没有明显的选择:

How do I upload the aar to Nexus (the Maven repository)? There is no apparent option to do so in the web interface:

我使用了 gradle的maven插件,可通过修改Android build.gradle文件将其上传到Nexus.

I used gradle's maven plugin to upload to Nexus by modifying the Android build.gradle file.

apply plugin: 'maven'

dependencies {
    deployerJars "org.apache.maven.wagon:wagon-http:2.2"
}

uploadArchives {
    repositories.mavenDeployer {
        configuration = configurations.deployerJars
        repository(url: "https://my.example.com/content/repositories/com.example/") {
            authentication(userName: "exampleUser", password: "examplePassword")
            pom.groupId = "com.example"
            pom.artifactId = "myexample"
            pom.version = '1.0.0'
        }
    }
}

要上传:gradlew upload,使用Android Studio项目提供的gradlew脚本.

To upload: gradlew upload, using the gradlew script that is provided by the Android Studio project.

您还可以将身份验证参数移动到不受版本控制的文件中.