-
-
Save jiasheng-li089/0a4a7c3ef40a04d092c4d2e55ba2d51f to your computer and use it in GitHub Desktop.
Android gradle script snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| android.libraryVariants.all { variant -> | |
| def name = variant.buildType.name | |
| if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) { | |
| return; // Skip debug builds. | |
| } | |
| def task = project.tasks.create "jar${name.capitalize()}", Jar | |
| task.dependsOn variant.javaCompile | |
| //Include Java classes | |
| task.from variant.javaCompile.destinationDir | |
| //Include dependent jars with some exceptions | |
| task.from configurations.compile.findAll { | |
| it.getName() != 'android.jar' && !it.getName().startsWith('junit') && !it.getName().startsWith('hamcrest') | |
| }.collect { | |
| it.isDirectory() ? it : zipTree(it) | |
| } | |
| artifacts.add('archives', task); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| android.libraryVariants.all { variant -> | |
| def name = variant.buildType.name | |
| if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) { | |
| return; // Skip debug builds. | |
| } | |
| def task = project.tasks.create "jar${name.capitalize()}", Jar | |
| task.dependsOn variant.javaCompile | |
| //Include Java classes | |
| task.from variant.javaCompile.destinationDir | |
| artifacts.add('archives', task); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| task listrepos { | |
| doLast { | |
| println "Repositories:" | |
| project.repositories.each { println "Name: " + it.name + "; url: " + it.url } | |
| } | |
| } |
Author
Author
List all repositories url: 列出项目所配置的repositories 的url
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Android Library project 打包成jar和fat jar的配置