How can I compile jar with test classes in android? I am using android gradle plugin 1.3.1:
classpath 'com.android.tools.build:gradle:1.3.1'
I've tried:
task testSourcesJar(type: Jar) {
from android.sourceSets.test.java.srcDirs
}
And it creates exactly what is defined: a jar with test sources, not with compiled classes. Where are the compiled classess and on which task I should depend on to create jar with test classes?
I need it to prepare test artifact for another project, which must extend some test classes.
Below is whole build.gradle with my modifications. This is google's volley library.
// NOTE: The only changes that belong in this file are the definitions
// of tool versions (gradle plugin, compile SDK, build tools), so that
// Volley can be built via gradle as a standalone project.
//
// Any other changes to the build config belong in rules.gradle, which
// is used by projects that depend on Volley but define their own
// tools versions across all dependencies to ensure a consistent build.
//
// Most users should just add this line to settings.gradle:
// include(":volley")
//
// If you have a more complicated Gradle setup you can choose to use
// this instead:
// include(":volley")
// project(':volley').buildFileName = 'rules.gradle'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
apply plugin: 'com.android.library'
repositories {
jcenter()
}
android {
compileSdkVersion 22
buildToolsVersion = '22.0.1'
}
task testSourcesJar(type: Jar, dependsOn: 'testClasses') {
from android.sourceSets.test.java.srcDirs
}
configurations {
testArtifacts
}
artifacts {
testArtifacts testSourcesJar
}
apply from: 'rules.gradle'