Search in sources :

Example 6 with SyncMessage

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage in project android by JetBrains.

the class JdkModuleSetupStep method reportWrongJdkError.

@NotNull
private SyncMessage reportWrongJdkError(@NotNull Project project, @NotNull String text) {
    SyncMessage msg = new SyncMessage(PROJECT_CONFIGURATION_SYNC_MESSAGE_GROUP, ERROR, NonNavigatable.INSTANCE, text);
    msg.add(myJdks.getWrongJdkQuickFixes(project));
    return msg;
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with SyncMessage

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage in project android by JetBrains.

the class UniquePathModuleValidatorStrategy method fixAndReportFoundIssues.

@Override
void fixAndReportFoundIssues() {
    Set<String> modulePaths = myModulesByPath.keySet();
    for (String modulePath : modulePaths) {
        Collection<Module> modules = myModulesByPath.get(modulePath);
        int moduleCount = modules.size();
        if (moduleCount <= 1) {
            continue;
        }
        StringBuilder msg = new StringBuilder();
        msg.append("The modules [");
        int i = 0;
        Set<String> moduleNames = Sets.newHashSet();
        for (Module module : modules) {
            if (i++ != 0) {
                msg.append(", ");
            }
            String name = module.getName();
            moduleNames.add(name);
            msg.append("'").append(name).append("'");
        }
        msg.append("] point to same directory in the file system.");
        String[] lines = { msg.toString(), "Each module has to have a unique path." };
        SyncMessage message = new SyncMessage(PROJECT_STRUCTURE_ISSUES, ERROR, lines);
        List<DataNode<ModuleData>> modulesToDisplayInDialog = Lists.newArrayList();
        Project project = getProject();
        if (ProjectSubset.getInstance(project).isFeatureEnabled()) {
            DataNode<ProjectData> projectInfo = DataNodeCaches.getInstance(project).getCachedProjectData();
            if (projectInfo != null) {
                Collection<DataNode<ModuleData>> cachedModules = findAll(projectInfo, MODULE);
                for (DataNode<ModuleData> moduleNode : cachedModules) {
                    if (moduleNames.contains(moduleNode.getData().getExternalName())) {
                        modulesToDisplayInDialog.add(moduleNode);
                    }
                }
            }
        }
        if (!modulesToDisplayInDialog.isEmpty()) {
            message.add(new AddOrRemoveModulesHyperlink());
        }
        SyncMessages.getInstance(project).report(message);
    }
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) Project(com.intellij.openapi.project.Project) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) Module(com.intellij.openapi.module.Module) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 8 with SyncMessage

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage in project android by JetBrains.

the class BuildTools23Rc1ValidationStrategy method fixAndReportFoundIssues.

@Override
void fixAndReportFoundIssues() {
    if (!myModules.isEmpty()) {
        sort(myModules);
        StringBuilder msg = new StringBuilder();
        // @formatter:off
        msg.append("Build Tools 23.0.0 rc1 is <b>deprecated</b>.<br>\n").append("Please update these modules to use Build Tools 23.0.0 rc2 (or newer) instead:");
        for (String module : myModules) {
            msg.append("<br>\n * ").append(module);
        }
        msg.append("<br>\n<br>\nOtherwise the project won't build. ");
        Project project = getProject();
        SyncMessage message = new SyncMessage(DEFAULT_GROUP, ERROR, msg.toString());
        SyncMessages.getInstance(project).report(message);
        GradleSyncState.getInstance(project).getSummary().setSyncErrorsFound(true);
    }
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) AndroidProject(com.android.builder.model.AndroidProject) Project(com.intellij.openapi.project.Project)

Example 9 with SyncMessage

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage in project android by JetBrains.

the class EncodingValidationStrategy method fixAndReportFoundIssues.

@Override
void fixAndReportFoundIssues() {
    if (myMismatchingEncoding != null) {
        Project project = getProject();
        // Fix encoding mismatch.
        myEncodings.setDefaultCharsetName(myMismatchingEncoding);
        // Report encoding mismatch.
        String line = String.format("The project encoding (%1$s) has been reset to the encoding specified in the Gradle build files (%2$s).", myEncodings.getDefaultCharset().displayName(), myMismatchingEncoding);
        String[] text = { line, "Mismatching encodings can lead to serious bugs." };
        SyncMessage message = new SyncMessage(SyncMessage.DEFAULT_GROUP, INFO, text);
        message.add(new OpenUrlHyperlink("http://tools.android.com/knownissues/encoding", "More Info..."));
        SyncMessages.getInstance(project).report(message);
    }
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) AndroidProject(com.android.builder.model.AndroidProject) Project(com.intellij.openapi.project.Project) OpenUrlHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenUrlHyperlink)

Example 10 with SyncMessage

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage in project android by JetBrains.

the class ExtraGeneratedFolderValidationStrategy method fixAndReportFoundIssues.

@Override
void fixAndReportFoundIssues() {
    if (!myExtraGeneratedSourceFolderPaths.isEmpty()) {
        SyncMessages messages = SyncMessages.getInstance(getProject());
        Collections.sort(myExtraGeneratedSourceFolderPaths);
        // Warn users that there are generated source folders at the wrong location.
        for (File folder : myExtraGeneratedSourceFolderPaths) {
            // Have to add a word before the path, otherwise IDEA won't show it.
            String[] text = { "Folder " + folder.getPath() };
            messages.report(new SyncMessage(GENERATED_SOURCES, WARNING, text));
        }
        messages.report(new SyncMessage(GENERATED_SOURCES, INFO, "3rd-party Gradle plug-ins may be the cause"));
    }
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) SyncMessages(com.android.tools.idea.gradle.project.sync.messages.SyncMessages) File(java.io.File)

Aggregations

SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)55 Module (com.intellij.openapi.module.Module)18 Project (com.intellij.openapi.project.Project)14 SyncMessagesStub (com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub)12 NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)11 PositionInFile (com.android.tools.idea.gradle.util.PositionInFile)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 AndroidProject (com.android.builder.model.AndroidProject)5 MessageType (com.android.tools.idea.gradle.project.sync.messages.MessageType)5 SyncMessages (com.android.tools.idea.gradle.project.sync.messages.SyncMessages)5 Sdk (com.intellij.openapi.projectRoots.Sdk)5 GradleVersion (com.android.ide.common.repository.GradleVersion)3 ProjectSubset (com.android.tools.idea.gradle.project.subset.ProjectSubset)3 ComponentVersionReader (com.android.tools.idea.gradle.project.sync.compatibility.version.ComponentVersionReader)3 ArrayList (java.util.ArrayList)3 NotNull (org.jetbrains.annotations.NotNull)3 Message (com.android.ide.common.blame.Message)2 AndroidVersion (com.android.sdklib.AndroidVersion)2 AndroidPluginVersionUpdater (com.android.tools.idea.gradle.plugin.AndroidPluginVersionUpdater)2 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)2