Scope
Simple project with sample and library structure:
--Project
----Sample
----Library
Problem
Library has robolectric tests and terminal command works well ./gradlew clean library:test
.
But in AS test
folder is not recognized but plugin, as well as dependencies starting with testCompile
.
In AS RC1 log shows the problem (but RC 2 doesn't show it anymore):
INFO - ij.compiler.impl.CompileDriver - COMPILATION STARTED (BUILD PROCESS)
2014-12-02 01:39:47,736 [1279662] INFO - dea.AndroidUnitTestDataService - Failed to set up Android modules in project 'android-validation-komensky'
java.lang.NullPointerException
at me.tatarka.androidunittest.idea.ContentRootModuleCustomizer.findOrCreateContentEntries(ContentRootModuleCustomizer.java:37)
at me.tatarka.androidunittest.idea.ContentRootModuleCustomizer.findOrCreateContentEntries(ContentRootModuleCustomizer.java:23)
at me.tatarka.androidunittest.idea.AbstractContentRootModuleCustomizer.customizeModule(AbstractContentRootModuleCustomizer.java:51)
at me.tatarka.androidunittest.idea.AndroidUnitTestDataService.customizeModule(AndroidUnitTestDataService.java:82)
at me.tatarka.androidunittest.idea.AndroidUnitTestDataService.access$100(AndroidUnitTestDataService.java:26)
at me.tatarka.androidunittest.idea.AndroidUnitTestDataService$1.execute(AndroidUnitTestDataService.java:73)
at com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange.run(DisposeAwareProjectChange.java:36)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$5$1.run(ExternalSystemApiUtil.java:364)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:984)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$5.run(ExternalSystemApiUtil.java:361)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeOnEdt(ExternalSystemApiUtil.java:374)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:359)
at me.tatarka.androidunittest.idea.AndroidUnitTestDataService.doImport(AndroidUnitTestDataService.java:66)
at me.tatarka.androidunittest.idea.AndroidUnitTestDataService.importData(AndroidUnitTestDataService.java:48)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:90)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:74)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:98)
at com.android.tools.idea.gradle.project.ProjectSetUpTask$2$1$1.run(ProjectSetUpTask.java:117)
at com.intellij.openapi.roots.impl.ProjectRootManagerImpl.mergeRootsChangesDuring(ProjectRootManagerImpl.java:329)
at com.android.tools.idea.gradle.project.ProjectSetUpTask$2$1.execute(ProjectSetUpTask.java:112)
at com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange.run(DisposeAwareProjectChange.java:36)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$5$1.run(ExternalSystemApiUtil.java:364)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:984)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil$5.run(ExternalSystemApiUtil.java:361)
at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2057)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeOnEdt(ExternalSystemApiUtil.java:381)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:359)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeProjectChangeAction(ExternalSystemApiUtil.java:355)
at com.android.tools.idea.gradle.project.ProjectSetUpTask$2.run(ProjectSetUpTask.java:109)
at com.intellij.ide.startup.impl.StartupManagerImpl$7.run(StartupManagerImpl.java:286)
at com.intellij.ide.startup.impl.StartupManagerImpl$8.run(StartupManagerImpl.java:297)
at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2057)
at com.intellij.ide.startup.impl.StartupManagerImpl.runWhenProjectIsInitialized(StartupManagerImpl.java:294)
at com.android.tools.idea.gradle.project.ProjectSetUpTask.populateProject(ProjectSetUpTask.java:106)
at com.android.tools.idea.gradle.project.ProjectSetUpTask.access$000(ProjectSetUpTask.java:46)
at com.android.tools.idea.gradle.project.ProjectSetUpTask$1.run(ProjectSetUpTask.java:68)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:715)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:676)
at java.awt.EventQueue$2.run(EventQueue.java:674)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:685)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:697)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:524)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
2014-12-02 01:39:47,768 [1279694] INFO - indexing.UnindexedFilesUpdater - Indexable files iterated in 2 ms
2014-12-02 01:39:47,768 [1279694] INFO - indexing.UnindexedFilesUpdater - Unindexed files update started: 0 files to update
2014-12-02 01:39:47,768 [1279694] INFO - indexing.UnindexedFilesUpdater - Unindexed files update done in 0 ms
2014-12-02 01:39:47,884 [1279810] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home
Details
Project's build.gradle
buildscript {
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.+'
classpath 'com.github.jcandksolutions.gradle:android-unit-test:2.0.+'
}
}
ext {
compileSdkVersion = 21
buildToolsVersion = '21.1.1'
minSdkVersion = 8
targetSdkVersion = 21
}
Lib's build.gradle
apply plugin: 'com.android.library'
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}
}
apply plugin: 'android-unit-test'
dependencies {
compile 'com.android.support:support-v4:19.+'
// Robolectric tests (change to testCompile, when android-unit-test is ready)
testCompile 'junit:junit:4.11'
testCompile 'org.mockito:mockito-core:1.9.5'
testCompile 'com.squareup:fest-android:1.0.+'
testCompile('org.robolectric:robolectric:2.4') {
exclude module: 'classworlds'
exclude module: 'commons-logging'
exclude module: 'httpclient'
exclude module: 'maven-artifact'
exclude module: 'maven-artifact-manager'
exclude module: 'maven-error-diagnostics'
exclude module: 'maven-model'
exclude module: 'maven-plugin-registry'
exclude module: 'maven-profile'
exclude module: 'maven-project'
exclude module: 'maven-settings'
exclude module: 'nekohtml'
exclude module: 'plexus-container-default'
exclude module: 'plexus-interpolation'
exclude module: 'plexus-utils'
exclude module: 'wagon-file'
exclude module: 'wagon-http-lightweight'
exclude module: 'wagon-http-shared'
exclude module: 'wagon-provider-api'
}
}
Gradle version - 2.2 or 2.2.1.
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home