Search in sources :

Example 11 with GradleModuleModel

use of com.android.tools.idea.gradle.project.model.GradleModuleModel in project android by JetBrains.

the class GradleModuleSetup method setUpModule.

public void setUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull SyncAction.ModuleModels models) {
    GradleModuleModel gradleModuleModel = createGradleModel(module, models);
    setUpModule(module, ideModelsProvider, gradleModuleModel);
}
Also used : GradleModuleModel(com.android.tools.idea.gradle.project.model.GradleModuleModel)

Example 12 with GradleModuleModel

use of com.android.tools.idea.gradle.project.model.GradleModuleModel in project android by JetBrains.

the class ModulesToImportDialogTest method createModule.

@NotNull
private static DataNode<ModuleData> createModule(@NotNull String name, boolean isGradleProject) {
    String path = "~/project/" + name;
    ModuleData data = new ModuleData(name, GradleConstants.SYSTEM_ID, StdModuleTypes.JAVA.getId(), name, path, path);
    DataNode<ModuleData> module = new DataNode<>(MODULE, data, null);
    if (isGradleProject) {
        List<String> taskNames = Collections.emptyList();
        module.createChild(GRADLE_MODULE_MODEL, new GradleModuleModel("app", taskNames, ":" + name, null, null));
    }
    return module;
}
Also used : GradleModuleModel(com.android.tools.idea.gradle.project.model.GradleModuleModel) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with GradleModuleModel

use of com.android.tools.idea.gradle.project.model.GradleModuleModel 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());
}
Also used : GradleModuleModel(com.android.tools.idea.gradle.project.model.GradleModuleModel) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 14 with GradleModuleModel

use of com.android.tools.idea.gradle.project.model.GradleModuleModel 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());
}
Also used : GradleModuleModel(com.android.tools.idea.gradle.project.model.GradleModuleModel) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) NdkModuleModel(com.android.tools.idea.gradle.project.model.NdkModuleModel) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 15 with GradleModuleModel

use of com.android.tools.idea.gradle.project.model.GradleModuleModel 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());
}
Also used : GradleModuleModel(com.android.tools.idea.gradle.project.model.GradleModuleModel) DataNode(com.intellij.openapi.externalSystem.model.DataNode) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Aggregations

GradleModuleModel (com.android.tools.idea.gradle.project.model.GradleModuleModel)16 GradleFacet (com.android.tools.idea.gradle.project.facet.gradle.GradleFacet)7 DataNode (com.intellij.openapi.externalSystem.model.DataNode)6 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)5 Module (com.intellij.openapi.module.Module)5 NdkModuleModel (com.android.tools.idea.gradle.project.model.NdkModuleModel)4 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)3 File (java.io.File)3 GradleProject (org.gradle.tooling.model.GradleProject)3 Nullable (org.jetbrains.annotations.Nullable)3 GradleScript (org.gradle.tooling.model.gradle.GradleScript)2 NotNull (org.jetbrains.annotations.NotNull)2 BuildScriptClasspathModel (org.jetbrains.plugins.gradle.model.BuildScriptClasspathModel)2 VisibleForTesting (com.android.annotations.VisibleForTesting)1 AndroidProject (com.android.builder.model.AndroidProject)1 NativeAndroidProject (com.android.builder.model.NativeAndroidProject)1 Variant (com.android.builder.model.Variant)1 GradleVersion (com.android.ide.common.repository.GradleVersion)1