Search in sources :

Example 1 with SyncIssue

use of com.android.builder.model.SyncIssue in project android by JetBrains.

the class PsAndroidModuleAnalyzerTest method createIssueFrom.

@Test
public void createIssueFrom() {
    SyncIssue syncIssue = mock(SyncIssue.class);
    when(syncIssue.getMessage()).thenReturn("Conflict with dependency 'com.google.guava:guava'. Resolved versions for app (16.0) " + "and test app (16.0.1) differ. See http://g.co/androidstudio/app-test-app-conflict for " + "details.");
    when(syncIssue.getSeverity()).thenReturn(SEVERITY_ERROR);
    PsPath path = mock(PsPath.class);
    PsIssue issue = PsAndroidModuleAnalyzer.createIssueFrom(syncIssue, path, null);
    assertThat(issue.getText()).isEqualTo("Conflict with dependency 'com.google.guava:guava'. Resolved versions for app (16.0) " + "and test app (16.0.1) differ. See " + "<a href='http://g.co/androidstudio/app-test-app-conflict'>http://g.co/androidstudio/app-test-app-conflict</a> " + "for details.");
    assertThat(issue.getSeverity()).isEqualTo(ERROR);
}
Also used : PsPath(com.android.tools.idea.gradle.structure.model.PsPath) SyncIssue(com.android.builder.model.SyncIssue) PsIssue(com.android.tools.idea.gradle.structure.model.PsIssue) Test(org.junit.Test)

Example 2 with SyncIssue

use of com.android.builder.model.SyncIssue in project android by JetBrains.

the class SyncIssuesReporter method report.

public void report(@NotNull Collection<SyncIssue> syncIssues, @NotNull Module module) {
    if (syncIssues.isEmpty()) {
        return;
    }
    boolean hasSyncErrors = false;
    VirtualFile buildFile = getGradleBuildFile(module);
    for (SyncIssue syncIssue : syncIssues) {
        if (syncIssue.getSeverity() == SEVERITY_ERROR) {
            hasSyncErrors = true;
        }
        report(syncIssue, module, buildFile);
    }
    if (hasSyncErrors) {
        Project project = module.getProject();
        GradleSyncState.getInstance(project).getSummary().setSyncErrorsFound(true);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) SyncIssue(com.android.builder.model.SyncIssue)

Example 3 with SyncIssue

use of com.android.builder.model.SyncIssue in project atlas by alibaba.

the class AtlasDependencyManager2 method resolveDependencies.

public Set<AndroidDependency> resolveDependencies(@NonNull VariantScope variantScope) {
    // this.apDependencies = resolveApDependencies(variantDeps);
    AtlasDependencyGraph artifactDependencyGraph = new AtlasDependencyGraph();
    DependencyGraphs dependencyGraphs = artifactDependencyGraph.createLevel4DependencyGraph(variantScope, false, true, new Consumer<SyncIssue>() {

        @Override
        public void accept(SyncIssue syncIssue) {
            sLogger.error(syncIssue.getMessage());
        }
    });
    return null;
}
Also used : DependencyGraphs(com.android.builder.model.level2.DependencyGraphs) SyncIssue(com.android.builder.model.SyncIssue) AtlasDependencyGraph(com.android.build.gradle.internal.ide.AtlasDependencyGraph)

Example 4 with SyncIssue

use of com.android.builder.model.SyncIssue in project android by JetBrains.

the class DependenciesModuleSetupStep method doSetUpModule.

@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull AndroidModuleModel androidModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
    AndroidProject androidProject = androidModel.getAndroidProject();
    DependencySet dependencies = myDependenciesExtractor.extractFrom(androidModel);
    for (LibraryDependency dependency : dependencies.onLibraries()) {
        updateLibraryDependency(module, ideModelsProvider, dependency, androidProject);
    }
    for (ModuleDependency dependency : dependencies.onModules()) {
        updateModuleDependency(module, ideModelsProvider, dependency, androidProject);
    }
    addExtraSdkLibrariesAsDependencies(module, ideModelsProvider, androidProject);
    Collection<SyncIssue> syncIssues = androidModel.getSyncIssues();
    if (syncIssues != null) {
        SyncIssuesReporter.getInstance().report(syncIssues, module);
    } else {
        //noinspection deprecation
        Collection<String> unresolvedDependencies = androidProject.getUnresolvedDependencies();
        UnresolvedDependenciesReporter.getInstance().report(unresolvedDependencies, module);
    }
}
Also used : ModuleDependency(com.android.tools.idea.gradle.project.sync.setup.module.dependency.ModuleDependency) LibraryDependency(com.android.tools.idea.gradle.project.sync.setup.module.dependency.LibraryDependency) SyncIssue(com.android.builder.model.SyncIssue) DependencySet(com.android.tools.idea.gradle.project.sync.setup.module.dependency.DependencySet) AndroidProject(com.android.builder.model.AndroidProject)

Example 5 with SyncIssue

use of com.android.builder.model.SyncIssue in project android by JetBrains.

the class PsAndroidModuleAnalyzer method doAnalyze.

@Override
protected void doAnalyze(@NotNull PsAndroidModule module, @NotNull PsIssueCollection issueCollection) {
    Multimap<String, SyncIssue> issuesByData = ArrayListMultimap.create();
    AndroidModuleModel gradleModel = module.getGradleModel();
    Collection<SyncIssue> syncIssues = gradleModel.getAndroidProject().getSyncIssues();
    for (SyncIssue syncIssue : syncIssues) {
        String data = nullToEmpty(syncIssue.getData());
        issuesByData.put(data, syncIssue);
    }
    PsModulePath modulePath = new PsModulePath(module);
    module.forEachDependency(dependency -> {
        if (dependency instanceof PsLibraryDependency && dependency.isDeclared()) {
            PsLibraryDependency libraryDependency = (PsLibraryDependency) dependency;
            PsPath path = new PsLibraryDependencyNavigationPath(getContext(), libraryDependency);
            PsArtifactDependencySpec resolvedSpec = libraryDependency.getResolvedSpec();
            String issueKey = resolvedSpec.group + GRADLE_PATH_SEPARATOR + resolvedSpec.name;
            Collection<SyncIssue> librarySyncIssues = issuesByData.get(issueKey);
            for (SyncIssue syncIssue : librarySyncIssues) {
                PsIssue issue = createIssueFrom(syncIssue, path, modulePath);
                issueCollection.add(issue);
            }
            analyzeDeclaredDependency(libraryDependency, modulePath, issueCollection);
        }
    });
}
Also used : SyncIssue(com.android.builder.model.SyncIssue) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) XmlStringUtil.escapeString(com.intellij.xml.util.XmlStringUtil.escapeString) PsLibraryDependencyNavigationPath(com.android.tools.idea.gradle.structure.navigation.PsLibraryDependencyNavigationPath)

Aggregations

SyncIssue (com.android.builder.model.SyncIssue)6 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)2 AtlasDependencyGraph (com.android.build.gradle.internal.ide.AtlasDependencyGraph)1 AndroidProject (com.android.builder.model.AndroidProject)1 DependencyGraphs (com.android.builder.model.level2.DependencyGraphs)1 GradleVersion (com.android.ide.common.repository.GradleVersion)1 ProjectLibraries (com.android.tools.idea.gradle.ProjectLibraries)1 AndroidPluginInfo (com.android.tools.idea.gradle.plugin.AndroidPluginInfo)1 DependencySet (com.android.tools.idea.gradle.project.sync.setup.module.dependency.DependencySet)1 LibraryDependency (com.android.tools.idea.gradle.project.sync.setup.module.dependency.LibraryDependency)1 ModuleDependency (com.android.tools.idea.gradle.project.sync.setup.module.dependency.ModuleDependency)1 PsIssue (com.android.tools.idea.gradle.structure.model.PsIssue)1 PsPath (com.android.tools.idea.gradle.structure.model.PsPath)1 PsLibraryDependencyNavigationPath (com.android.tools.idea.gradle.structure.navigation.PsLibraryDependencyNavigationPath)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 ContentEntry (com.intellij.openapi.roots.ContentEntry)1 Library (com.intellij.openapi.roots.libraries.Library)1 FileUtil.writeToFile (com.intellij.openapi.util.io.FileUtil.writeToFile)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1