maven - Artifactory Publish Android Library with Resources -


problem:

i trying create android library can included in application using:

// application's build.gradle compile 'com.mycompany:mylibrary:1.0.0' 

in case, using artifactory , have gotten above work fine. problem when try run application missing resources. problem seems library has code depends on resources not getting included in jar published artifactory

// code in library, throws exception because <resource> not included in jar getstring(r.string.<resource>) 

question:

how can include resources in jar when publishing artifactory? currently, includes class files. here current gradle.build publishing:

// android library - build.gradle {     // ... other build.gradle settings go here      //==========================================================     //  artifactory settings     //==========================================================      buildscript {         repositories {             maven {                 url "${artifactory_contexturl}/plugins-release"                 credentials {                     username = "${artifactory_user}"                     password = "${artifactory_password}"                 }             }         }         dependencies {             classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.0.3"         }     }      apply plugin: "com.jfrog.artifactory"     apply plugin: 'maven-publish'      artifactory {         contexturl = "${artifactory_contexturl}"         publish {             repository {                 repokey = 'libs-release-local'                 username = "${artifactory_user}"                 password = "${artifactory_password}"                 maven = true             }             defaults {                 publications ('mavenjava')             }         }         resolve {             repository {                 repokey = 'libs-release'                 username = "${artifactory_user}"                 password = "${artifactory_password}"                 maven = true             }         }     }      task sourcejar(type: jar) {         android.sourcesets.main.java.srcdirs     }      publishing {         publications {             mavenjava(mavenpublication) {                 groupid 'com.mycompany'                 artifactid 'mylibrary'                 version '1.0.0'                 artifact(sourcejar)             }         }     } } 

i able fix issue. found solution here , here.

my original gradle.build script fine publishing jar files; however, when building android library use other projects typically want .aar file, not .jar file.


in order have artifactory publish .aar file i've copied build.gradle below.

note: must use com.android.library plugin otherwise you'll end .apk instead of .aar.

apply plugin: 'com.android.library'  android {     //... android specific parameters }  dependencies {     //... android specific dependencies }  //========================================================== //  artifactory settings //==========================================================  buildscript {     repositories {         maven {             url "${artifactory_contexturl}/plugins-release"             credentials {                 username = "${artifactory_user}"                 password = "${artifactory_password}"             }         }     }     dependencies {         classpath 'com.github.dcendents:android-maven-plugin:1.2'         classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.3'     } }  apply plugin: 'artifactory' apply plugin: 'com.github.dcendents.android-maven'  version = "1.0.0" group = "com.mycompany"  configurations {     published }  task sourcejar(type: jar) {     android.sourcesets.main.java.srcdirs }  artifactorypublish {     dependson sourcejar }  artifacts {     published sourcejar }  artifactory {     contexturl = "${artifactory_contexturl}"     publish {         repository {             repokey = 'libs-release-local'             username = "${artifactory_user}"             password = "${artifactory_password}"             maven = true         }         defaults {             publishconfigs('archives', 'published')             properties = ['build.status': 'integration']             publishpom = true             publishivy = false         }     } } 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -