android - Skip test tasks for specific build types -


i have 4 different build types:

  • release
  • dev
  • mock
  • test

when want make clean build task project see gradle making clean build unit tests.

it ok unit tests running every build type, takes 4 times longer clean build.

how can make clean build unit tests release build type?

there no nice task that. have write yourself.

try add next build.gradle:

project.afterevaluate {   // grab build types , product flavors   def buildtypes = android.buildtypes.collect { type -> type.name }   def productflavors = android.productflavors.collect { flavor -> flavor.name }    // when no product flavors defined, use empty   if (!productflavors) {     productflavors.add('')   }    productflavors.each { productflavorname ->     buildtypes.each { buildtypename ->       def sourcename       if (!productflavorname) {         sourcename = "${buildtypename}"       } else {         sourcename = "${productflavorname}${buildtypename.capitalize()}"       }       def testtaskname = "test${sourcename.capitalize()}unittest"       def assembletaskname = "assemble${sourcename.capitalize()}"       task "build${sourcename.capitalize()}"(dependson: ["$testtaskname", "$assembletaskname"])     }   }    task 'buildrelease'(dependson: tasks.findall { t -> t.name.startswith('build') && t.name != 'build' && t.name != 'buildneeded' }) } 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -