Gradle Download android android app in maven repo (nexus)

I am trying to create a CI assembly that builds a version for an Android application and uploads the resulting apk to the neaven repository of the maven sonata.

When I run assembleRelease, apk is generated, signed, runs proguard and is in the build / output / apk / app-release.apk file

to load into nexus, I used this gradle plugin: https://github.com/chrisbanes/gradle-mvn-push with one difference that I used POM_PACKAGING = apk

I run: gradle uploadArchives and it works fine, it downloads apk to nexus, but its not the same file as in build / output / apk / app-release.apk (different creation dates).

means that he either does everything assembleRelease does, or simply archives the source, but skips some of the required actions required for the Android application.

The gradle plugin defines these artifacts:

artifacts { archives androidSourcesJar archives androidJavadocsJar } 

Perhaps I should add a file artifact to build / exits / apk / app-release.apk?

+6
source share
2 answers

I tried the solution mentioned, but I always had the "apk file not exist" problem when Jenkins tried to upload the apk file to our nexus repository. In the gradle plugin documentation, the path starts with the "build" folder. ( https://docs.gradle.org/current/userguide/artifact_management.html )
I tried to insert some env variables into the path, but jenkins always complained "file not found". I came up with this solution and it just works.

 uploadArchives { repositories { mavenDeployer { repository(url: "https://repo.domain.com/content/repositories/snapshots") { authentication(userName: nexususername, password: nexuspassword) } pom.project { version "0.0.1-SNAPSHOT" artifactId "android-artifact" name "android-name" groupId "com.domain.foo.bar" } } } } // /data/jenkins_work/NAME_OF_THE_BUILD_JOB/artifact/app/build/outputs/apk/app-debug.apk def apk = file('app/build/outputs/apk/yourapp.apk') artifacts { archives apk } 
+5
source

We publish our APK files in our local Nexus repository using gradle. This is what I came up with. This example demonstrated the use of the googlePlay build attribute.

 // 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 } 
0
source

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


All Articles