Last active
January 5, 2017 15:44
-
-
Save tmiyamon/18ff74afe336d7b7915b491bb87e5206 to your computer and use it in GitHub Desktop.
Enable groovy for unit test of android project with other jvm language in gradle
This file contains 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
dependencies { | |
testCompile "org.spockframework:spock-core:1.0-groovy-2.4" | |
testCompile "cglib:cglib-nodep:3.1" | |
testCompile "org.objenesis:objenesis:2.1" | |
} | |
android.applicationVariants.all { | |
def variantName = it.name | |
def capitalizedName = "${variantName[0].toUpperCase()}${variantName[1..-1]}" | |
def compileUnitTestJavaWithJavac = tasks.findByName("compile${capitalizedName}UnitTestJavaWithJavac") | |
def compileUnitTestGroovy = tasks.create(name: "compile${capitalizedName}UnitTestGroovy", type: GroovyCompile) { | |
source("src/test/java", "src/test/groovy") | |
include('**/*.groovy') | |
destinationDir = compileUnitTestJavaWithJavac.destinationDir | |
classpath = compileUnitTestJavaWithJavac.classpath | |
groovyClasspath = compileUnitTestJavaWithJavac.classpath | |
} | |
compileUnitTestJavaWithJavac.dependsOn(compileUnitTestGroovy) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment