Search in sources :

Example 1 with DependencySetupErrors

use of com.android.tools.idea.gradle.project.sync.setup.module.common.DependencySetupErrors in project android by JetBrains.

the class DependenciesModuleSetupStep method updateModuleDependency.

private void updateModuleDependency(@NotNull Module module, @NotNull IdeModifiableModelsProvider modelsProvider, @NotNull ModuleDependency dependency, @NotNull AndroidProject androidProject) {
    Module moduleDependency = dependency.getModule(modelsProvider);
    LibraryDependency compiledArtifact = dependency.getBackupDependency();
    if (moduleDependency != null) {
        ModuleOrderEntry orderEntry = modelsProvider.getModifiableRootModel(module).addModuleOrderEntry(moduleDependency);
        orderEntry.setScope(dependency.getScope());
        orderEntry.setExported(true);
        if (compiledArtifact != null) {
            setModuleCompiledArtifact(moduleDependency, compiledArtifact);
        }
        return;
    }
    DependencySetupErrors dependencySetupErrors = DependencySetupErrors.getInstance(module.getProject());
    String backupName = compiledArtifact != null ? compiledArtifact.getName() : null;
    dependencySetupErrors.addMissingModule(dependency.getGradlePath(), module.getName(), backupName);
    // fall back to library dependency, if available.
    if (compiledArtifact != null) {
        updateLibraryDependency(module, modelsProvider, compiledArtifact, androidProject);
    }
}
Also used : DependencySetupErrors(com.android.tools.idea.gradle.project.sync.setup.module.common.DependencySetupErrors) LibraryDependency(com.android.tools.idea.gradle.project.sync.setup.module.dependency.LibraryDependency) ModuleOrderEntry(com.intellij.openapi.roots.ModuleOrderEntry) Module(com.intellij.openapi.module.Module)

Example 2 with DependencySetupErrors

use of com.android.tools.idea.gradle.project.sync.setup.module.common.DependencySetupErrors in project android by JetBrains.

the class DependenciesModuleSetupStep method updateDependency.

private static void updateDependency(@NotNull Module module, @NotNull IdeModifiableModelsProvider modelsProvider, @NotNull JavaModuleDependency dependency) {
    DependencySetupErrors setupErrors = DependencySetupErrors.getInstance(module.getProject());
    String moduleName = dependency.getModuleName();
    Module found = null;
    for (Module m : modelsProvider.getModules()) {
        if (moduleName.equals(m.getName())) {
            found = m;
        }
    }
    ModifiableRootModel moduleModel = modelsProvider.getModifiableRootModel(module);
    if (found != null) {
        AndroidFacet androidFacet = findFacet(found, modelsProvider, AndroidFacet.ID);
        if (androidFacet == null) {
            ModuleOrderEntry entry = moduleModel.addModuleOrderEntry(found);
            entry.setExported(true);
        } else {
            // If it depends on an android module, we should skip that.
            setupErrors.addInvalidModuleDependency(moduleModel.getModule(), found.getName(), "Java modules cannot depend on Android modules");
        }
        return;
    }
    setupErrors.addMissingModule(moduleName, module.getName(), null);
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) DependencySetupErrors(com.android.tools.idea.gradle.project.sync.setup.module.common.DependencySetupErrors) ModuleOrderEntry(com.intellij.openapi.roots.ModuleOrderEntry) Module(com.intellij.openapi.module.Module) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 3 with DependencySetupErrors

use of com.android.tools.idea.gradle.project.sync.setup.module.common.DependencySetupErrors in project android by JetBrains.

the class DependenciesModuleSetupStep method updateDependency.

private void updateDependency(@NotNull Module module, @NotNull IdeModifiableModelsProvider modelsProvider, @NotNull JarLibraryDependency dependency) {
    DependencyScope scope = parseScope(dependency.getScope());
    File binaryPath = dependency.getBinaryPath();
    if (binaryPath == null) {
        DependencySetupErrors setupErrors = DependencySetupErrors.getInstance(module.getProject());
        setupErrors.addMissingBinaryPath(module.getName());
        return;
    }
    // Gradle API doesn't provide library name at the moment.
    String name = binaryPath.isFile() ? getNameWithoutExtension(binaryPath) : sanitizeFileName(binaryPath.getPath());
    myDependenciesSetup.setUpLibraryDependency(module, modelsProvider, name, scope, binaryPath, dependency.getSourcePath(), dependency.getJavadocPath());
}
Also used : DependencyScope(com.intellij.openapi.roots.DependencyScope) DependencySetupErrors(com.android.tools.idea.gradle.project.sync.setup.module.common.DependencySetupErrors) File(java.io.File)

Aggregations

DependencySetupErrors (com.android.tools.idea.gradle.project.sync.setup.module.common.DependencySetupErrors)3 Module (com.intellij.openapi.module.Module)2 ModuleOrderEntry (com.intellij.openapi.roots.ModuleOrderEntry)2 LibraryDependency (com.android.tools.idea.gradle.project.sync.setup.module.dependency.LibraryDependency)1 DependencyScope (com.intellij.openapi.roots.DependencyScope)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 File (java.io.File)1 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)1