From 07809d5bebaecaa8182b9dfbc20cbcc1bf3463a7 Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Wed, 12 Dec 2012 17:43:02 +0400 Subject: [PATCH 1/9] Make refresh async. --- .../org/jetbrains/idea/maven/project/MavenProjectsManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java index 333795cd09ff..622ff9bbe4ec 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java @@ -968,7 +968,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent if (myProject.isDisposed()) return; MavenFoldersImporter.updateProjectFolders(myProject, targetFoldersOnly); - VirtualFileManager.getInstance().syncRefresh(); + VirtualFileManager.getInstance().asyncRefresh(null); } }); } From 6584fd8c2bc8524476730e0ded2c1c2624c5ce49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Wed, 12 Dec 2012 14:33:49 +0100 Subject: [PATCH 2/9] pre-calc hashCode --- .../src/com/intellij/util/xml/XmlName.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/xml/dom-openapi/src/com/intellij/util/xml/XmlName.java b/xml/dom-openapi/src/com/intellij/util/xml/XmlName.java index 3dcf355729c7..f1a43a0c423e 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/XmlName.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/XmlName.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,11 +22,13 @@ import org.jetbrains.annotations.Nullable; /** * @author peter -*/ + */ public class XmlName implements Comparable { private final String myLocalName; private final String myNamespaceKey; + private final int myHashCode; + public XmlName(@NotNull @NonNls final String localName) { this(localName, null); } @@ -34,6 +36,8 @@ public class XmlName implements Comparable { public XmlName(@NotNull @NonNls final String localName, @Nullable final String namespaceKey) { myLocalName = localName; myNamespaceKey = namespaceKey; + + myHashCode = 31 * myLocalName.hashCode() + (myNamespaceKey != null ? myNamespaceKey.hashCode() : 0); } @NotNull @@ -61,10 +65,7 @@ public class XmlName implements Comparable { } public int hashCode() { - int result; - result = myLocalName.hashCode(); - result = 31 * result + (myNamespaceKey != null ? myNamespaceKey.hashCode() : 0); - return result; + return myHashCode; } From a930c3827368e19e4739529cbee96191d29c9b82 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Tue, 11 Dec 2012 17:43:42 +0400 Subject: [PATCH 3/9] remove unused class --- .../AndroidArtifactSigningCompiler.java | 122 ------------------ 1 file changed, 122 deletions(-) delete mode 100644 plugins/android/src/org/jetbrains/android/compiler/artifact/AndroidArtifactSigningCompiler.java diff --git a/plugins/android/src/org/jetbrains/android/compiler/artifact/AndroidArtifactSigningCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/artifact/AndroidArtifactSigningCompiler.java deleted file mode 100644 index bacf8b670933..000000000000 --- a/plugins/android/src/org/jetbrains/android/compiler/artifact/AndroidArtifactSigningCompiler.java +++ /dev/null @@ -1,122 +0,0 @@ -package org.jetbrains.android.compiler.artifact; - -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.compiler.CompileContext; -import com.intellij.openapi.compiler.CompileScope; -import com.intellij.openapi.compiler.PackagingCompiler; -import com.intellij.openapi.compiler.ValidityState; -import com.intellij.openapi.util.Computable; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -/** - * @author Eugene.Kudelevsky - */ -public class AndroidArtifactSigningCompiler implements PackagingCompiler { - @Override - public void processOutdatedItem(CompileContext context, String url, @Nullable ValidityState state) { - } - - @NotNull - @Override - public ProcessingItem[] getProcessingItems(CompileContext context) { - return ApplicationManager.getApplication().runReadAction(new Computable() { - @Override - public ProcessingItem[] compute() { - return null; - } - }); - } - - @Override - public ProcessingItem[] process(CompileContext context, ProcessingItem[] items) { - return new ProcessingItem[0]; //To change body of implemented methods use File | Settings | File Templates. - } - - @NotNull - @Override - public String getDescription() { - return "Android Artifact Signing Compiler"; - } - - @Override - public boolean validateConfiguration(CompileScope scope) { - return true; - } - - @Override - public ValidityState createValidityState(DataInput in) throws IOException { - return new MyValidityState(in); - } - - private static class MyProcessingItem implements ProcessingItem { - private final VirtualFile myApkFile; - private final AndroidArtifactSigningMode mySigningMode; - private final String myDebugKeyStorePath; - private final MyValidityState myValidityState; - - private MyProcessingItem(@NotNull VirtualFile apkFile, - @NotNull AndroidArtifactSigningMode signingMode, - @Nullable String debugKeyStorePath) { - myApkFile = apkFile; - mySigningMode = signingMode; - myDebugKeyStorePath = debugKeyStorePath; - - myValidityState = new MyValidityState(myApkFile.getModificationStamp(), - mySigningMode.name(), - myDebugKeyStorePath); - } - - @NotNull - @Override - public VirtualFile getFile() { - return myApkFile; - } - - @Override - public ValidityState getValidityState() { - return myValidityState; - } - } - - private static class MyValidityState implements ValidityState { - private final long myApkFileTimestamp; - private final String mySigningMode; - private final String myDebugKeyStorePath; - - private MyValidityState(long apkFileTimestamp, @NotNull String signingMode, @NotNull String debugKeyStorePath) { - myApkFileTimestamp = apkFileTimestamp; - mySigningMode = signingMode; - myDebugKeyStorePath = debugKeyStorePath; - } - - private MyValidityState(@NotNull DataInput in) throws IOException { - myApkFileTimestamp = in.readLong(); - mySigningMode = in.readUTF(); - myDebugKeyStorePath = in.readUTF(); - } - - @Override - public boolean equalsTo(ValidityState otherState) { - if (!(otherState instanceof MyValidityState)) { - return false; - } - final MyValidityState state = (MyValidityState)otherState; - return state.myApkFileTimestamp == myApkFileTimestamp && - state.mySigningMode.equals(mySigningMode) && - state.myDebugKeyStorePath.equals(myDebugKeyStorePath); - } - - @Override - public void save(DataOutput out) throws IOException { - out.writeLong(myApkFileTimestamp); - out.writeUTF(mySigningMode); - out.writeUTF(myDebugKeyStorePath); - } - } -} From ebe8336cd4e52215fde2b5459e9bd0e909c72d19 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Wed, 12 Dec 2012 17:29:54 +0400 Subject: [PATCH 4/9] IDEA-95839 IDEA-96107 force read jps model for android projects --- .../android/compiler/AndroidPrecompileTask.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidPrecompileTask.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidPrecompileTask.java index 066b34bed60a..72bf24cf8349 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidPrecompileTask.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidPrecompileTask.java @@ -19,6 +19,7 @@ import com.intellij.compiler.CompilerConfiguration; import com.intellij.compiler.CompilerConfigurationImpl; import com.intellij.compiler.CompilerWorkspaceConfiguration; import com.intellij.compiler.options.CompileStepBeforeRun; +import com.intellij.compiler.server.BuildManager; import com.intellij.facet.ProjectFacetManager; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; @@ -72,6 +73,11 @@ public class AndroidPrecompileTask implements CompileTask { public boolean execute(CompileContext context) { final Project project = context.getProject(); + if (!ProjectFacetManager.getInstance(project).hasFacets(AndroidFacet.ID)) { + return true; + } + BuildManager.forceModelLoading(context); + // in out-of-process mode gen roots will be excluded by AndroidExcludedJavaSourceRootProvider // we do it here for internal mode and also to make there roots 'visibly excluded' in IDE settings createGenModulesAndSourceRoots(project); @@ -149,9 +155,6 @@ public class AndroidPrecompileTask implements CompileTask { private static boolean checkArtifacts(@NotNull CompileContext context) { final Project project = context.getProject(); - if (!ProjectFacetManager.getInstance(project).hasFacets(AndroidFacet.ID)) { - return true; - } final CompileScope scope = context.getCompileScope(); final Set artifacts = ApplicationManager.getApplication().runReadAction(new Computable>() { From aa7dd9f375310790cf47c226306853d69945ed13 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Wed, 12 Dec 2012 17:43:43 +0400 Subject: [PATCH 5/9] do not launch dex target build at all for library modules and during light build --- .../jps/android/AndroidDexBuilder.java | 9 +-- .../android/builder/AndroidBuildTarget.java | 34 +++++++++--- .../builder/AndroidPackagingBuildTarget.java | 25 ++++++++- plugins/android/src/META-INF/plugin.xml | 1 + .../AndroidBuildTargetScopeProvider.java | 55 +++++++++++++++++++ 5 files changed, 108 insertions(+), 16 deletions(-) create mode 100644 plugins/android/src/org/jetbrains/android/compiler/AndroidBuildTargetScopeProvider.java diff --git a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidDexBuilder.java b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidDexBuilder.java index 15e620bec038..a3f1429da95c 100644 --- a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidDexBuilder.java +++ b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidDexBuilder.java @@ -73,9 +73,7 @@ public class AndroidDexBuilder extends TargetBuilder holder, @NotNull BuildOutputConsumer outputConsumer, @NotNull CompileContext context) throws ProjectBuildException, IOException { - if (AndroidJpsUtil.isLightBuild(context)) { - return; - } + assert !AndroidJpsUtil.isLightBuild(context); try { if (!doDexBuild(buildTarget, context, holder.hasDirtyFiles())) { @@ -97,10 +95,7 @@ public class AndroidDexBuilder extends TargetBuilder { +public abstract class AndroidBuildTarget extends BuildTarget { private final AndroidBuildTargetType myTargetType; + protected final JpsModule myModule; public AndroidBuildTarget(@NotNull AndroidBuildTargetType targetType, @NotNull JpsModule module) { - super(targetType, module); + super(targetType); myTargetType = targetType; + myModule = module; + } + + @NotNull + public JpsModule getModule() { + return myModule; } @Override @@ -67,11 +74,6 @@ public abstract class AndroidBuildTarget extends ModuleBasedTarget getOutputRoots(CompileContext context) { - return Collections.emptyList(); + final File moduleOutputDir = context.getProjectPaths().getModuleOutputDir(myModule, false); + final JpsAndroidModuleExtension extension = AndroidJpsUtil.getExtension(myModule); + + if (moduleOutputDir == null || extension == null) { + return Collections.emptyList(); + } + final String outputPath = AndroidJpsUtil.getApkPath(extension, moduleOutputDir); + + if (outputPath == null) { + return Collections.emptyList(); + } + final String afpFile = AndroidCommonUtils.addSuffixToFileName( + outputPath, AndroidCommonUtils.ANDROID_FINAL_PACKAGE_FOR_ARTIFACT_SUFFIX); + return Collections.singletonList(new File(FileUtil.toSystemDependentName(afpFile))); } @Override protected void fillDependencies(List> result) { - result.add(new AndroidDexBuildTarget(myModule)); + final JpsAndroidModuleExtension extension = AndroidJpsUtil.getExtension(myModule); + + if (extension != null && !extension.isLibrary()) { + // todo: remove this when AndroidPackagingBuilder will be fully target-based + result.add(new AndroidDexBuildTarget(myModule)); + } } public static class MyTargetType extends AndroidBuildTargetType { diff --git a/plugins/android/src/META-INF/plugin.xml b/plugins/android/src/META-INF/plugin.xml index 157fdcf04763..7c3554fe831b 100644 --- a/plugins/android/src/META-INF/plugin.xml +++ b/plugins/android/src/META-INF/plugin.xml @@ -337,6 +337,7 @@ + diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidBuildTargetScopeProvider.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidBuildTargetScopeProvider.java new file mode 100644 index 000000000000..3a037938ce8b --- /dev/null +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidBuildTargetScopeProvider.java @@ -0,0 +1,55 @@ +package org.jetbrains.android.compiler; + +import com.intellij.compiler.impl.BuildTargetScopeProvider; +import com.intellij.facet.ProjectFacetManager; +import com.intellij.openapi.compiler.CompileScope; +import com.intellij.openapi.compiler.CompilerFilter; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; +import org.jetbrains.android.facet.AndroidFacet; +import org.jetbrains.android.util.AndroidCommonUtils; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope; + +/** + * @author Eugene.Kudelevsky + */ +public class AndroidBuildTargetScopeProvider extends BuildTargetScopeProvider { + @NotNull + @Override + public List getBuildTargetScopes( + @NotNull CompileScope baseScope, @NotNull CompilerFilter filter, @NotNull Project project) { + + if (!ProjectFacetManager.getInstance(project).hasFacets(AndroidFacet.ID)) { + return Collections.emptyList(); + } + final List dexTargetIds = new ArrayList(); + final List packagingTargetIds = new ArrayList(); + final boolean fullBuild = AndroidCompileUtil.isFullBuild(baseScope); + + for (Module module : baseScope.getAffectedModules()) { + final AndroidFacet facet = AndroidFacet.getInstance(module); + + if (facet == null) { + continue; + } + // todo: make AndroidPackagingBuilder fully target-based and change this + packagingTargetIds.add(module.getName()); + + if (fullBuild && !facet.getConfiguration().LIBRARY_PROJECT) { + dexTargetIds.add(module.getName()); + } + } + return Arrays.asList( + TargetTypeBuildScope.newBuilder().setTypeId(AndroidCommonUtils.DEX_BUILD_TARGET_TYPE_ID). + addAllTargetId(dexTargetIds).build(), + TargetTypeBuildScope.newBuilder().setTypeId(AndroidCommonUtils.PACKAGING_BUILD_TARGET_TYPE_ID). + addAllTargetId(packagingTargetIds).build()); + } +} From bfc9f8ffa0eb816e2db3e443ceb03f13ff4d13de Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Wed, 12 Dec 2012 18:13:37 +0400 Subject: [PATCH 6/9] IDEA-97096 register apk.afp (file that packed into artifact) in OutputConsumer --- .../jps/android/AndroidPackagingBuilder.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidPackagingBuilder.java b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidPackagingBuilder.java index e13186b8b1b4..45118d7e21d3 100644 --- a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidPackagingBuilder.java +++ b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidPackagingBuilder.java @@ -87,7 +87,7 @@ public class AndroidPackagingBuilder extends TargetBuilder modules) throws IOException { + private static boolean doPackaging(@NotNull CompileContext context, + @NotNull Collection modules, + @NotNull BuildOutputConsumer outputConsumer) throws IOException { final boolean release = AndroidJpsUtil.isReleaseBuild(context); final File dataStorageRoot = context.getProjectDescriptor().dataManager.getDataPaths().getDataStorageRoot(); @@ -332,7 +334,8 @@ public class AndroidPackagingBuilder extends TargetBuilderemptyList()); } AndroidJpsUtil.addMessages(context, messages, BUILDER_NAME, module.getName()); final boolean success = messages.get(AndroidCompilerMessageKind.ERROR).isEmpty(); From 4e892bf8abc1f3bd6a159fa25ffa8f3f9bb86a26 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 12 Dec 2012 18:17:24 +0400 Subject: [PATCH 7/9] diagnostics --- .../com/intellij/codeInspection/InspectionProfileTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java index 2f0a53676e4d..35071ac99f04 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java @@ -263,7 +263,8 @@ public class InspectionProfileTest extends LightIdeaTestCase { profile.enableTool(id); } profile.writeExternal(new Element("profile")); - assertEquals(1, countInitializedTools(profile)); + List initializedTools = getInitializedTools(profile); + assertEquals(initializedTools.toString(), 1, initializedTools.size()); } public void testInspectionInitializationForSerialization() throws Exception { From b015a0afad6a5d909d9a7e89edea17b5bab91bf6 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 12 Dec 2012 18:24:37 +0400 Subject: [PATCH 8/9] external artifact builder: extract content of jar even if jar is excluded, simplified --- .../ArtifactCompilerInstructionCreatorBase.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/instructions/ArtifactCompilerInstructionCreatorBase.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/instructions/ArtifactCompilerInstructionCreatorBase.java index e4d6db4f3a70..89c64aefa236 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/instructions/ArtifactCompilerInstructionCreatorBase.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/artifacts/instructions/ArtifactCompilerInstructionCreatorBase.java @@ -56,9 +56,12 @@ public abstract class ArtifactCompilerInstructionCreatorBase implements Artifact @Override public void addExtractDirectoryInstruction(@NotNull File jarFile, @NotNull String pathInJar) { - final boolean copyExcluded = myInstructionsBuilder.getRootsIndex().isExcluded(jarFile); + //an entry of a jar file is excluded if and only if the jar file itself is excluded. In that case we should unpack entries to the artifact + // because the jar itself is explicitly added to the artifact layout. + boolean includeExcluded = true; + final SourceFileFilterImpl filter = new SourceFileFilterImpl(null, myInstructionsBuilder.getRootsIndex(), - myInstructionsBuilder.getIgnoredFileIndex(), copyExcluded); + myInstructionsBuilder.getIgnoredFileIndex(), includeExcluded); DestinationInfo destination = createDirectoryDestination(); if (destination != null) { ArtifactRootDescriptor descriptor = myInstructionsBuilder.createJarBasedRoot(jarFile, pathInJar, filter, destination); From 3f07b12b99942f0470fdea79235560602ed0807c Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Wed, 12 Dec 2012 18:25:03 +0400 Subject: [PATCH 9/9] [git] Fix cherry-pick tests (according to slightly modified commit message style) --- plugins/git4idea/testFramework/git4idea/test/MockGit.groovy | 2 +- .../git4idea/tests/git4idea/cherrypick/GitCherryPickTest.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/git4idea/testFramework/git4idea/test/MockGit.groovy b/plugins/git4idea/testFramework/git4idea/test/MockGit.groovy index 79cd15b5f862..cc819a7a5083 100644 --- a/plugins/git4idea/testFramework/git4idea/test/MockGit.groovy +++ b/plugins/git4idea/testFramework/git4idea/test/MockGit.groovy @@ -309,7 +309,7 @@ class MockGit implements Git { } static String commitMessageForCherryPick(GitCommit commit) { - "$commit.subject\n(cherry-picked from ${commit.shortHash.getString()})" + "$commit.subject\n\n(cherry-picked from ${commit.shortHash.getString()})" } } diff --git a/plugins/git4idea/tests/git4idea/cherrypick/GitCherryPickTest.groovy b/plugins/git4idea/tests/git4idea/cherrypick/GitCherryPickTest.groovy index 5779b0321194..a1dbce3ebcc4 100644 --- a/plugins/git4idea/tests/git4idea/cherrypick/GitCherryPickTest.groovy +++ b/plugins/git4idea/tests/git4idea/cherrypick/GitCherryPickTest.groovy @@ -160,7 +160,7 @@ hint: and commit the result with 'git commit' } String newCommitMessage(GitCommit commit) { - "${commit.description}\n(cherry-picked from ${commit.hash.value})" + "${commit.description}\n\n(cherry-picked from ${commit.hash.value})" } protected static class OKCommitDialogHandler implements MockVcsHelper.CommitHandler {