JSP validation fixed for external build

This commit is contained in:
nik
2012-12-25 19:25:03 +04:00
parent 92de6aff76
commit f439750a4a
3 changed files with 62 additions and 8 deletions
@@ -39,6 +39,7 @@ import com.intellij.openapi.compiler.Compiler;
import com.intellij.openapi.compiler.ex.CompileContextEx;
import com.intellij.openapi.compiler.ex.CompilerPathsEx;
import com.intellij.openapi.compiler.generic.GenericCompiler;
import com.intellij.openapi.deployment.DeploymentUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.extensions.PluginId;
@@ -76,6 +77,7 @@ import com.intellij.packaging.impl.artifacts.ArtifactImpl;
import com.intellij.packaging.impl.artifacts.ArtifactUtil;
import com.intellij.packaging.impl.compiler.ArtifactCompileScope;
import com.intellij.packaging.impl.compiler.ArtifactCompilerUtil;
import com.intellij.packaging.impl.compiler.ArtifactsCompiler;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.util.Chunk;
@@ -88,6 +90,7 @@ import com.intellij.util.containers.HashMap;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.containers.OrderedSet;
import com.intellij.util.messages.MessageBus;
import gnu.trove.THashSet;
import gnu.trove.TIntHashSet;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -498,7 +501,7 @@ public class CompileDriver {
}
final MessageBus messageBus = myProject.getMessageBus();
final MultiMap<String, Artifact> outputToArtifact = ArtifactCompilerUtil.containsArtifacts(scopes) ? ArtifactCompilerUtil.createOutputToArtifactMap(myProject) : null;
final BuildManager buildManager = BuildManager.getInstance();
buildManager.cancelAutoMakeTasks(myProject);
return buildManager.scheduleBuild(myProject, compileContext.isRebuild(), compileContext.isMake(), onlyCheckUpToDate, scopes, paths, builderParams, new DefaultMessageHandler(myProject) {
@@ -561,10 +564,23 @@ public class CompileDriver {
case FILES_GENERATED:
final List<CmdlineRemoteProto.Message.BuilderMessage.BuildEvent.GeneratedFile> generated = event.getGeneratedFilesList();
final CompilationStatusListener publisher = messageBus.syncPublisher(CompilerTopics.COMPILATION_STATUS);
Set<String> writtenArtifactOutputPaths = outputToArtifact != null ? new THashSet<String>(FileUtil.PATH_HASHING_STRATEGY) : null;
for (CmdlineRemoteProto.Message.BuilderMessage.BuildEvent.GeneratedFile generatedFile : generated) {
final String root = FileUtil.toSystemIndependentName(generatedFile.getOutputRoot());
final String relativePath = FileUtil.toSystemIndependentName(generatedFile.getRelativePath());
publisher.fileGenerated(root, relativePath);
if (outputToArtifact != null) {
Collection<Artifact> artifacts = outputToArtifact.get(root);
if (!artifacts.isEmpty()) {
for (Artifact artifact : artifacts) {
ArtifactsCompiler.addChangedArtifact(compileContext, artifact);
}
writtenArtifactOutputPaths.add(FileUtil.toSystemDependentName(DeploymentUtil.appendToPath(root, relativePath)));
}
}
}
if (writtenArtifactOutputPaths != null && !writtenArtifactOutputPaths.isEmpty()) {
ArtifactsCompiler.addWrittenPaths(compileContext, writtenArtifactOutputPaths);
}
break;
case BUILD_COMPLETED:
@@ -18,6 +18,8 @@ package com.intellij.packaging.impl.compiler;
import com.intellij.facet.Facet;
import com.intellij.facet.FacetManager;
import com.intellij.facet.FacetRootsProvider;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.compiler.CompileContext;
import com.intellij.openapi.compiler.CompilerMessageCategory;
import com.intellij.openapi.diagnostic.Logger;
@@ -25,6 +27,7 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
@@ -39,16 +42,17 @@ import com.intellij.packaging.impl.artifacts.PackagingElementProcessor;
import com.intellij.packaging.impl.elements.ArtifactPackagingElement;
import com.intellij.packaging.impl.elements.FileOrDirectoryCopyPackagingElement;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope;
import org.jetbrains.jps.incremental.artifacts.ArtifactBuildTargetType;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -139,4 +143,35 @@ public class ArtifactCompilerUtil {
}
return affectedOutputPaths;
}
public static boolean containsArtifacts(List<TargetTypeBuildScope> scopes) {
for (TargetTypeBuildScope scope : scopes) {
if (ArtifactBuildTargetType.INSTANCE.getTypeId().equals(scope.getTypeId())) {
return true;
}
}
return false;
}
public static MultiMap<String, Artifact> createOutputToArtifactMap(final Project project) {
final MultiMap<String, Artifact> result = new MultiMap<String, Artifact>() {
@Override
protected Map<String, Collection<Artifact>> createMap() {
return new THashMap<String, Collection<Artifact>>(FileUtil.PATH_HASHING_STRATEGY);
}
};
new ReadAction() {
protected void run(final Result r) {
for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
String outputPath = artifact.getOutputFilePath();
if (!StringUtil.isEmpty(outputPath)) {
result.putValue(outputPath, artifact);
}
}
}
}.execute();
return result;
}
}
@@ -15,9 +15,12 @@
*/
package com.intellij.packaging.impl.compiler;
import com.intellij.openapi.compiler.generic.*;
import com.intellij.openapi.compiler.CompileContext;
import com.intellij.openapi.compiler.CompilerManager;
import com.intellij.openapi.compiler.generic.CompileItem;
import com.intellij.openapi.compiler.generic.GenericCompiler;
import com.intellij.openapi.compiler.generic.GenericCompilerInstance;
import com.intellij.openapi.compiler.generic.VirtualFilePersistentState;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.packaging.artifacts.Artifact;
@@ -46,7 +49,7 @@ public class ArtifactsCompiler extends GenericCompiler<String, VirtualFilePersis
return compilers.length == 1 ? compilers[0] : null;
}
static void addChangedArtifact(final CompileContext context, Artifact artifact) {
public static void addChangedArtifact(final CompileContext context, Artifact artifact) {
Set<Artifact> artifacts = context.getUserData(CHANGED_ARTIFACTS);
if (artifacts == null) {
artifacts = new THashSet<Artifact>();
@@ -55,7 +58,7 @@ public class ArtifactsCompiler extends GenericCompiler<String, VirtualFilePersis
artifacts.add(artifact);
}
static void addWrittenPaths(final CompileContext context, Set<String> writtenPaths) {
public static void addWrittenPaths(final CompileContext context, Set<String> writtenPaths) {
Set<String> paths = context.getUserData(WRITTEN_PATHS_KEY);
if (paths == null) {
paths = new THashSet<String>();