在Make Project

时间:2017-03-01 08:21:41

标签: android-studio intellij-idea gradle

我在Android Studio 2.2.3中有一个多项目Gradle构建,包含Java库(corecodegen)和Android库(android)模块。 Make Project显示Gradle控制台中执行的任务:

Executing tasks: [:android:generateDebugSources, :android:generateDebugAndroidTestSources, :android:mockableAndroidJar, :android:prepareDebugUnitTestDependencies, :android:compileDebugSources, :android:compileDebugAndroidTestSources, :android:compileDebugUnitTestSources, :codegen:compileJava, :core:compileJava]

但是compileJava仅编译主类路径,而不是测试,并且未列出testClassescore的{​​{1}}任务。另一方面,codegen确实运行./gradlew build

如何为Java库模块进行Android Studio编译测试?

testClasses

settings.gradle

主要include 'core' include 'codegen' include 'android'

build.gradle

buildscript { repositories { maven { url "http://10.122.85.159:9081/nexus/content/groups/public" } } dependencies { classpath 'com.android.tools.build:gradle:2.1.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { maven { url "http://10.122.85.159:9081/nexus/content/groups/public" } } } dependencies { }

core/build.gradle

apply plugin: 'java' version = '1.0.0' sourceCompatibility = '1.7' sourceSets { generated { java { srcDirs = ['src/generated/java'] } } } test { filter { } } dependencies { compile fileTree(dir: '../lib', include: '*.jar') generatedCompile project(':core') compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0' compile 'org.javatuples:javatuples:1.2' }

codegen/build.gradle

apply plugin: 'java' dependencies { compile project(':core') compile group: 'com.squareup', name: 'javapoet', version: '1.8.0' }

android/build.gradle

0 个答案:

没有答案