Include folder in Gradle artifact

2019-08-30 04:23发布

问题:

Im sure this is amazingly simple but its been a long day and the Gradle docs frustrate me at the best of times (I have looked).

I want to include a folder (libs) inside a predefinined artifact (bundleRelease).

This happens to be on android (aar build) and inside a maven-publish block like

...
releaseJar(MavenPublication) {
            ...

            artifact bundleRelease
}
...

using gradle 2.3.

Thanks for any help here :)

EDIT: answered here Include /libs/ folder in aar

回答1:

Depends on what you want for the syntax but if you want the jar files in the root of the aar

android {
    ...
    sourceSets {
        main {
            resources.includes = [ '**/libs/*.jar' ]        
    }
}

If you want the entire folder included then I think this should be what you want

android {
    ...
    sourceSets {
        main {
            resources.includes = [ 'pathTo/libs' ]        
    }
}

All that said you probably don't want to package the libs with the aar because if you publish to somewhere like jcenter or mavenCentral then the maven artifact when uploaded will create a pom file that will note its dependencies and gradle will transparently import them for your lib.



标签: gradle