use of com.intellij.openapi.externalSystem.model.project.ProjectData in project android by JetBrains.
the class FastGradleSync method requestProjectSync.
@NotNull
public Callback requestProjectSync(@NotNull Project project) {
Callback callback = new Callback();
GradleExecutionSettings settings = getGradleExecutionSettings(project);
ExternalSystemTaskId id = ExternalSystemTaskId.create(GRADLE_SYSTEM_ID, RESOLVE_PROJECT, project);
String projectPath = project.getBasePath();
assert projectPath != null;
ApplicationManager.getApplication().executeOnPooledThread(() -> {
try {
DataNode<ProjectData> projectDataNode = myProjectResolver.resolveProjectInfo(id, projectPath, false, settings, NULL_OBJECT);
assert projectDataNode != null;
invokeAndWaitIfNeeded((ThrowableRunnable) () -> populate(project, projectDataNode, null, false));
callback.setDone();
} catch (Throwable e) {
callback.setRejected(e);
}
});
return callback;
}
use of com.intellij.openapi.externalSystem.model.project.ProjectData in project android by JetBrains.
the class AndroidGradleProjectResolverIdeaTest method testPopulateModuleContentRootsWithJavaProject.
public void testPopulateModuleContentRootsWithJavaProject() {
ProjectData project = myProjectResolver.createProject();
DataNode<ProjectData> projectNode = new DataNode<>(PROJECT, project, null);
DataNode<ModuleData> moduleDataNode = myProjectResolver.createModule(myJavaModuleModel, projectNode);
myProjectResolver.populateModuleContentRoots(myJavaModuleModel, moduleDataNode);
// Verify module does not have AndroidGradleModel.
Collection<DataNode<AndroidModuleModel>> androidModelNodes = getChildren(moduleDataNode, ANDROID_MODEL);
assertThat(androidModelNodes).isEmpty();
// Verify module has IdeaGradleProject.
Collection<DataNode<GradleModuleModel>> gradleModelNodes = getChildren(moduleDataNode, GRADLE_MODULE_MODEL);
assertThat(gradleModelNodes).hasSize(1);
DataNode<GradleModuleModel> gradleModelNode = getFirstItem(gradleModelNodes);
assertNotNull(gradleModelNode);
assertEquals(myJavaModuleModel.getGradleProject().getPath(), gradleModelNode.getData().getGradlePath());
}
use of com.intellij.openapi.externalSystem.model.project.ProjectData in project android by JetBrains.
the class AndroidGradleProjectResolverIdeaTest method testPopulateModuleContentRootsWithNativeAndroidProject.
public void testPopulateModuleContentRootsWithNativeAndroidProject() {
ProjectData project = myProjectResolver.createProject();
DataNode<ProjectData> projectNode = new DataNode<>(PROJECT, project, null);
DataNode<ModuleData> moduleDataNode = myProjectResolver.createModule(myNativeAndroidModuleModel, projectNode);
myProjectResolver.populateModuleContentRoots(myNativeAndroidModuleModel, moduleDataNode);
// Verify module does not have AndroidGradleModel.
Collection<DataNode<AndroidModuleModel>> androidModelNodes = getChildren(moduleDataNode, ANDROID_MODEL);
assertThat(androidModelNodes).isEmpty();
// Verify module has NativeAndroidGradleModel.
Collection<DataNode<NdkModuleModel>> ndkModuleModelNodes = getChildren(moduleDataNode, NDK_MODEL);
assertThat(ndkModuleModelNodes).hasSize(1);
DataNode<NdkModuleModel> nativeAndroidModelNode = getFirstItem(ndkModuleModelNodes);
assertNotNull(nativeAndroidModelNode);
assertSame(myNativeAndroidProject, nativeAndroidModelNode.getData().getAndroidProject());
// Verify module has IdeaGradleProject.
Collection<DataNode<GradleModuleModel>> gradleModelNodes = getChildren(moduleDataNode, GRADLE_MODULE_MODEL);
assertThat(gradleModelNodes).hasSize(1);
DataNode<GradleModuleModel> gradleModelNode = getFirstItem(gradleModelNodes);
assertNotNull(gradleModelNode);
assertEquals(myNativeAndroidModuleModel.getGradleProject().getPath(), gradleModelNode.getData().getGradlePath());
}
use of com.intellij.openapi.externalSystem.model.project.ProjectData in project android by JetBrains.
the class AndroidGradleProjectResolverIdeaTest method testPopulateModuleContentRootsWithAndroidProject.
public void testPopulateModuleContentRootsWithAndroidProject() {
when(myVariantSelector.findVariantToSelect(myAndroidProject)).thenReturn(myAndroidProject.getFirstVariant());
ProjectData project = myProjectResolver.createProject();
DataNode<ProjectData> projectNode = new DataNode<>(PROJECT, project, null);
DataNode<ModuleData> moduleDataNode = myProjectResolver.createModule(myAndroidModuleModel, projectNode);
myProjectResolver.populateModuleContentRoots(myAndroidModuleModel, moduleDataNode);
// Verify module has AndroidGradleModel.
Collection<DataNode<AndroidModuleModel>> androidModelNodes = getChildren(moduleDataNode, ANDROID_MODEL);
assertThat(androidModelNodes).hasSize(1);
DataNode<AndroidModuleModel> androidModelNode = getFirstItem(androidModelNodes);
assertNotNull(androidModelNode);
assertSame(myAndroidProject, androidModelNode.getData().getAndroidProject());
// Verify module has IdeaGradleProject.
Collection<DataNode<GradleModuleModel>> gradleModelNodes = getChildren(moduleDataNode, GRADLE_MODULE_MODEL);
assertThat(gradleModelNodes).hasSize(1);
DataNode<GradleModuleModel> gradleModelNode = getFirstItem(gradleModelNodes);
assertNotNull(gradleModelNode);
assertEquals(myAndroidModuleModel.getGradleProject().getPath(), gradleModelNode.getData().getGradlePath());
}
use of com.intellij.openapi.externalSystem.model.project.ProjectData in project android by JetBrains.
the class AndroidGradleProjectResolverIdeaTest method testCreateModuleWithOldModelVersion.
public void testCreateModuleWithOldModelVersion() {
AndroidProject androidProject = mock(AndroidProject.class);
ProjectImportAction.AllModels allModels = new ProjectImportAction.AllModels(myProjectModel);
allModels.addExtraProject(androidProject, AndroidProject.class, myAndroidModuleModel);
myResolverCtx.setModels(allModels);
when(androidProject.getModelVersion()).thenReturn("0.0.1");
ProjectData project = myProjectResolver.createProject();
DataNode<ProjectData> projectDataNode = new DataNode<>(PROJECT, project, null);
try {
myProjectResolver.createModule(myAndroidModuleModel, projectDataNode);
fail("Expecting IllegalStateException to be thrown");
} catch (IllegalStateException e) {
assertThat(e.getMessage()).startsWith("The project is using an unsupported version of the Android Gradle plug-in (0.0.1)");
}
}
Aggregations