summaryrefslogtreecommitdiff
path: root/java/compiler/impl/src/com/intellij/packaging/impl
diff options
context:
space:
mode:
Diffstat (limited to 'java/compiler/impl/src/com/intellij/packaging/impl')
-rw-r--r--java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompilerCompileItem.java86
-rw-r--r--java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompilerUtil.java103
-rw-r--r--java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactPackagingItemExternalizer.java52
-rw-r--r--java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactPackagingItemOutputState.java30
4 files changed, 0 insertions, 271 deletions
diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompilerCompileItem.java b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompilerCompileItem.java
deleted file mode 100644
index b4e1865f46ff..000000000000
--- a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompilerCompileItem.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2000-2010 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.packaging.impl.compiler;
-
-import com.intellij.openapi.compiler.generic.VirtualFileCompileItem;
-import com.intellij.compiler.impl.packagingCompiler.DestinationInfo;
-import com.intellij.openapi.util.Pair;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.SmartList;
-import com.intellij.util.io.DataExternalizer;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.List;
-
-/**
- * @author nik
- */
-public class ArtifactCompilerCompileItem extends VirtualFileCompileItem<ArtifactPackagingItemOutputState> {
- public static final DataExternalizer<ArtifactPackagingItemOutputState> OUTPUT_EXTERNALIZER = new ArtifactPackagingItemExternalizer();
- private final List<DestinationInfo> myDestinations = new SmartList<DestinationInfo>();
-
- public ArtifactCompilerCompileItem(VirtualFile file) {
- super(file);
- }
-
- public void addDestination(DestinationInfo info) {
- myDestinations.add(info);
- }
-
- public List<DestinationInfo> getDestinations() {
- return myDestinations;
- }
-
- @NotNull
- @Override
- public ArtifactPackagingItemOutputState computeOutputState() {
- final SmartList<Pair<String, Long>> pairs = new SmartList<Pair<String, Long>>();
- for (DestinationInfo destination : myDestinations) {
- destination.update();
- final VirtualFile outputFile = destination.getOutputFile();
- long timestamp = outputFile != null ? outputFile.getTimeStamp() : -1;
- pairs.add(Pair.create(destination.getOutputPath(), timestamp));
- }
- return new ArtifactPackagingItemOutputState(pairs);
- }
-
- @Override
- public boolean isOutputUpToDate(@NotNull ArtifactPackagingItemOutputState state) {
- final SmartList<Pair<String, Long>> cachedDestinations = state.myDestinations;
- if (cachedDestinations.size() != myDestinations.size()) {
- return false;
- }
-
- for (DestinationInfo info : myDestinations) {
- final VirtualFile outputFile = info.getOutputFile();
- long timestamp = outputFile != null ? outputFile.getTimeStamp() : -1;
- final String path = info.getOutputPath();
- boolean found = false;
- //todo[nik] use map if list contains many items
- for (Pair<String, Long> cachedDestination : cachedDestinations) {
- if (cachedDestination.first.equals(path)) {
- if (cachedDestination.second != timestamp) return false;
- found = true;
- break;
- }
- }
- if (!found) return false;
- }
-
- return true;
- }
-
-}
diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompilerUtil.java b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompilerUtil.java
index 0c2a15172c99..d4070de6b844 100644
--- a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompilerUtil.java
+++ b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactCompilerUtil.java
@@ -15,129 +15,26 @@
*/
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;
-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;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.artifacts.ArtifactManager;
-import com.intellij.packaging.elements.PackagingElement;
-import com.intellij.packaging.elements.PackagingElementResolvingContext;
-import com.intellij.packaging.impl.artifacts.ArtifactUtil;
-import com.intellij.packaging.impl.elements.FileOrDirectoryCopyPackagingElement;
-import com.intellij.util.Processor;
-import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
-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.zip.ZipEntry;
-import java.util.zip.ZipFile;
/**
* @author nik
*/
public class ArtifactCompilerUtil {
- private static final Logger LOG = Logger.getInstance("#com.intellij.packaging.impl.compiler.ArtifactCompilerUtil");
-
private ArtifactCompilerUtil() {
}
- @Nullable
- public static BufferedInputStream getJarEntryInputStream(VirtualFile sourceFile, final CompileContext context) throws IOException {
- final String fullPath = sourceFile.getPath();
- final int jarEnd = fullPath.indexOf(JarFileSystem.JAR_SEPARATOR);
- LOG.assertTrue(jarEnd != -1, fullPath);
- String pathInJar = fullPath.substring(jarEnd + JarFileSystem.JAR_SEPARATOR.length());
- String jarPath = fullPath.substring(0, jarEnd);
- final ZipFile jarFile = new ZipFile(new File(FileUtil.toSystemDependentName(jarPath)));
- final ZipEntry entry = jarFile.getEntry(pathInJar);
- if (entry == null) {
- context.addMessage(CompilerMessageCategory.ERROR, "Cannot extract '" + pathInJar + "' from '" + jarFile.getName() + "': entry not found", null, -1, -1);
- return null;
- }
-
- return new BufferedInputStream(jarFile.getInputStream(entry)) {
- @Override
- public void close() throws IOException {
- super.close();
- jarFile.close();
- }
- };
- }
-
- public static File getJarFile(VirtualFile jarEntry) {
- String fullPath = jarEntry.getPath();
- return new File(FileUtil.toSystemDependentName(fullPath.substring(fullPath.indexOf(JarFileSystem.JAR_SEPARATOR))));
- }
-
-
- @NotNull
- public static Set<VirtualFile> getArtifactOutputsContainingSourceFiles(final @NotNull Project project) {
- final List<VirtualFile> allOutputs = new ArrayList<VirtualFile>();
- for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
- ContainerUtil.addIfNotNull(artifact.getOutputFile(), allOutputs);
- }
-
- final Set<VirtualFile> roots = new HashSet<VirtualFile>();
- final PackagingElementResolvingContext context = ArtifactManager.getInstance(project).getResolvingContext();
- for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
- Processor<PackagingElement<?>> processor = new Processor<PackagingElement<?>>() {
- @Override
- public boolean process(@NotNull PackagingElement<?> element) {
- if (element instanceof FileOrDirectoryCopyPackagingElement<?>) {
- final VirtualFile file = ((FileOrDirectoryCopyPackagingElement)element).findFile();
- if (file != null) {
- roots.add(file);
- }
- }
- return true;
- }
- };
- ArtifactUtil.processRecursivelySkippingIncludedArtifacts(artifact, processor, context);
- }
-
- final Module[] modules = ModuleManager.getInstance(project).getModules();
- for (Module module : modules) {
- final Facet[] facets = FacetManager.getInstance(module).getAllFacets();
- for (Facet facet : facets) {
- if (facet instanceof FacetRootsProvider) {
- roots.addAll(((FacetRootsProvider)facet).getFacetRoots());
- }
- }
- }
-
- final Set<VirtualFile> affectedOutputPaths = new HashSet<VirtualFile>();
- for (VirtualFile output : allOutputs) {
- for (VirtualFile root : roots) {
- if (VfsUtilCore.isAncestor(output, root, false)) {
- affectedOutputPaths.add(output);
- }
- }
- }
- return affectedOutputPaths;
- }
public static boolean containsArtifacts(List<TargetTypeBuildScope> scopes) {
for (TargetTypeBuildScope scope : scopes) {
diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactPackagingItemExternalizer.java b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactPackagingItemExternalizer.java
deleted file mode 100644
index 175cdca3ea9e..000000000000
--- a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactPackagingItemExternalizer.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2000-2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.packaging.impl.compiler;
-
-import com.intellij.openapi.util.Pair;
-import com.intellij.util.SmartList;
-import com.intellij.util.io.DataExternalizer;
-import com.intellij.util.io.IOUtil;
-import org.jetbrains.annotations.NotNull;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-/**
-* @author nik
-*/
-public class ArtifactPackagingItemExternalizer implements DataExternalizer<ArtifactPackagingItemOutputState> {
- @Override
- public void save(@NotNull DataOutput out, ArtifactPackagingItemOutputState value) throws IOException {
- out.writeInt(value.myDestinations.size());
- for (Pair<String, Long> pair : value.myDestinations) {
- IOUtil.writeUTF(out, pair.getFirst());
- out.writeLong(pair.getSecond());
- }
- }
-
- @Override
- public ArtifactPackagingItemOutputState read(@NotNull DataInput in) throws IOException {
- int size = in.readInt();
- SmartList<Pair<String, Long>> destinations = new SmartList<Pair<String, Long>>();
- while (size-- > 0) {
- String path = IOUtil.readUTF(in);
- long outputTimestamp = in.readLong();
- destinations.add(Pair.create(path, outputTimestamp));
- }
- return new ArtifactPackagingItemOutputState(destinations);
- }
-}
diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactPackagingItemOutputState.java b/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactPackagingItemOutputState.java
deleted file mode 100644
index 29ac0ae91918..000000000000
--- a/java/compiler/impl/src/com/intellij/packaging/impl/compiler/ArtifactPackagingItemOutputState.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2000-2010 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.packaging.impl.compiler;
-
-import com.intellij.openapi.util.Pair;
-import com.intellij.util.SmartList;
-
-/**
-* @author nik
-*/
-public class ArtifactPackagingItemOutputState {
- public final SmartList<Pair<String, Long>> myDestinations;
-
- public ArtifactPackagingItemOutputState(SmartList<Pair<String, Long>> destinations) {
- myDestinations = destinations;
- }
-}