Search in sources :

Example 1 with JavaModuleDependency

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

the class DependenciesModuleSetupStep method doSetUpModule.

@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull JavaModuleModel javaModuleModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
    List<String> unresolved = new ArrayList<>();
    for (JavaModuleDependency dependency : javaModuleModel.getJavaModuleDependencies()) {
        updateDependency(module, ideModelsProvider, dependency);
    }
    for (JarLibraryDependency dependency : javaModuleModel.getJarLibraryDependencies()) {
        if (dependency.isResolved()) {
            updateDependency(module, ideModelsProvider, dependency);
        } else {
            unresolved.add(dependency.getName());
        }
    }
    UnresolvedDependenciesReporter.getInstance().report(unresolved, module);
}
Also used : JarLibraryDependency(com.android.tools.idea.gradle.model.java.JarLibraryDependency) ArrayList(java.util.ArrayList) JavaModuleDependency(com.android.tools.idea.gradle.model.java.JavaModuleDependency)

Example 2 with JavaModuleDependency

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

the class DependenciesModuleSetupStepTest method testSetUpModuleDependency.

public void testSetUpModuleDependency() {
    String moduleName = "lib";
    // This is the module to add as dependency.
    Module libModule = createModule(moduleName);
    JavaModuleDependency moduleDependency = new JavaModuleDependency(moduleName, "compile", true);
    Collection<JavaModuleDependency> moduleDependencies = new ArrayList<>();
    moduleDependencies.add(moduleDependency);
    // We only want module dependencies
    when(myJavaModuleModel.getJavaModuleDependencies()).thenReturn(moduleDependencies);
    when(myJavaModuleModel.getJarLibraryDependencies()).thenReturn(Collections.emptyList());
    Module mainModule = getModule();
    mySetupStep.setUpModule(mainModule, myModelsProvider, myJavaModuleModel, null, null);
    // needed to check if the module dependency was added.
    ApplicationManager.getApplication().runWriteAction(() -> myModelsProvider.commit());
    // See https://code.google.com/p/android/issues/detail?id=225923
    ExpectedModuleDependency expected = new ExpectedModuleDependency(libModule, COMPILE, true);
    assertAbout(moduleDependencies()).that(mainModule).contains(expected);
}
Also used : ExpectedModuleDependency(com.android.tools.idea.gradle.project.sync.ExpectedModuleDependency) ArrayList(java.util.ArrayList) Module(com.intellij.openapi.module.Module) JavaModuleDependency(com.android.tools.idea.gradle.model.java.JavaModuleDependency)

Aggregations

JavaModuleDependency (com.android.tools.idea.gradle.model.java.JavaModuleDependency)2 ArrayList (java.util.ArrayList)2 JarLibraryDependency (com.android.tools.idea.gradle.model.java.JarLibraryDependency)1 ExpectedModuleDependency (com.android.tools.idea.gradle.project.sync.ExpectedModuleDependency)1 Module (com.intellij.openapi.module.Module)1