Skip to content

Instantly share code, notes, and snippets.

@goofyahead
Forked from kellyfj/Gradle Android Jar Library
Last active August 29, 2015 14:08
Show Gist options
  • Save goofyahead/5ff6fc9625c49d1bbefa to your computer and use it in GitHub Desktop.
Save goofyahead/5ff6fc9625c49d1bbefa to your computer and use it in GitHub Desktop.

Revisions

  1. @kellyfj kellyfj renamed this gist Mar 20, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @kellyfj kellyfj renamed this gist Mar 20, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @kellyfj kellyfj revised this gist Mar 20, 2014. No changes.
  4. @kellyfj kellyfj revised this gist Mar 20, 2014. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    android.libraryVariants.all { variant ->
    def name = variant.buildType.name
    if (name.equals(com.android.builder.BuilderConstants.DEBUG)) {
  5. @kellyfj kellyfj revised this gist Mar 20, 2014. No changes.
  6. @kellyfj kellyfj revised this gist Mar 20, 2014. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,4 @@


    android.libraryVariants.all { variant ->
    def name = variant.buildType.name
    if (name.equals(com.android.builder.BuilderConstants.DEBUG)) {
  7. @kellyfj kellyfj created this gist Mar 20, 2014.
    19 changes: 19 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@


    android.libraryVariants.all { variant ->
    def name = variant.buildType.name
    if (name.equals(com.android.builder.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);
    }