From 32640c800eb80a59d886bb194ef72cdebadd0488 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 29 Oct 2009 10:22:16 +0300 Subject: [PATCH] obsolete code removed --- .../compiler/ant/BuildTargetsFactoryImpl.java | 5 - .../intellij/compiler/ant/j2ee/BuildJarTarget.java | 175 ------------- .../CompoundBuildInstructionImpl.java | 283 +++++---------------- .../packagingCompiler/FileCopyInstructionImpl.java | 44 ---- .../JarAndCopyBuildInstructionImpl.java | 184 ++++---------- .../openapi/deployment/DeploymentUtilImpl.java | 26 -- .../openapi/deployment/LibraryLinkImpl.java | 36 --- .../openapi/deployment/ModuleLinkImpl.java | 23 +- .../openapi/deployment/OrderEntryInfo.java | 103 -------- .../deployment/PackagingConfigurationImpl.java | 207 --------------- .../intellij/compiler/ant/BuildTargetsFactory.java | 2 - .../openapi/compiler/make/BuildInstruction.java | 18 -- .../compiler/make/JarAndCopyBuildInstruction.java | 13 - .../openapi/deployment/ContainerElement.java | 4 - .../openapi/deployment/DeploymentUtil.java | 13 - .../ElementIgnoringAttributesEquality.java | 36 --- .../openapi/deployment/PackagingConfiguration.java | 40 --- 17 files changed, 122 insertions(+), 1090 deletions(-) delete mode 100644 java/compiler/impl/src/com/intellij/compiler/ant/j2ee/BuildJarTarget.java rewrite java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/CompoundBuildInstructionImpl.java (71%) rewrite java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/JarAndCopyBuildInstructionImpl.java (67%) delete mode 100644 java/compiler/impl/src/com/intellij/openapi/deployment/OrderEntryInfo.java delete mode 100644 java/compiler/impl/src/com/intellij/openapi/deployment/PackagingConfigurationImpl.java delete mode 100644 java/compiler/openapi/src/com/intellij/openapi/deployment/ElementIgnoringAttributesEquality.java delete mode 100644 java/compiler/openapi/src/com/intellij/openapi/deployment/PackagingConfiguration.java diff --git a/java/compiler/impl/src/com/intellij/compiler/ant/BuildTargetsFactoryImpl.java b/java/compiler/impl/src/com/intellij/compiler/ant/BuildTargetsFactoryImpl.java index aa3b7e98cf..4065ab8fcb 100644 --- a/java/compiler/impl/src/com/intellij/compiler/ant/BuildTargetsFactoryImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/ant/BuildTargetsFactoryImpl.java @@ -21,7 +21,6 @@ package com.intellij.compiler.ant; import com.intellij.compiler.ant.j2ee.BuildExplodedTarget; -import com.intellij.compiler.ant.j2ee.BuildJarTarget; import com.intellij.compiler.ant.j2ee.CompositeBuildTarget; import com.intellij.compiler.ant.taskdefs.Target; import com.intellij.openapi.compiler.make.BuildRecipe; @@ -42,10 +41,6 @@ public class BuildTargetsFactoryImpl extends BuildTargetsFactory { return new BuildExplodedTarget(parameters, buildRecipe, description); } - public Target createBuildJarTarget(final ExplodedAndJarTargetParameters parameters, final BuildRecipe buildRecipe, final String description) { - return new BuildJarTarget(parameters, buildRecipe, description); - } - public Generator createComment(final String comment) { return new Comment(comment); diff --git a/java/compiler/impl/src/com/intellij/compiler/ant/j2ee/BuildJarTarget.java b/java/compiler/impl/src/com/intellij/compiler/ant/j2ee/BuildJarTarget.java deleted file mode 100644 index b5d3bd0892..0000000000 --- a/java/compiler/impl/src/com/intellij/compiler/ant/j2ee/BuildJarTarget.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright 2000-2009 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. - */ - -/** - * @author cdr - */ -package com.intellij.compiler.ant.j2ee; - -import com.intellij.compiler.ant.BuildProperties; -import com.intellij.compiler.ant.ExplodedAndJarTargetParameters; -import com.intellij.compiler.ant.GenerationUtils; -import com.intellij.compiler.ant.Tag; -import com.intellij.compiler.ant.taskdefs.*; -import com.intellij.compiler.make.ExplodedAndJarBuildGenerator; -import com.intellij.openapi.compiler.make.*; -import com.intellij.openapi.deployment.DeploymentUtil; -import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.util.Ref; -import org.jetbrains.annotations.NonNls; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class BuildJarTarget extends Target { - - public BuildJarTarget(final ExplodedAndJarTargetParameters parameters, - final BuildRecipe buildRecipe, - final String description) { - super(parameters.getBuildJarTargetName(), null, description, null); - final File moduleBaseDir = parameters.getChunk().getBaseDir(); - - BuildConfiguration buildConfiguration = parameters.getBuildConfiguration(); - //noinspection HardCodedStringLiteral - final File jarDir = new File(buildConfiguration.isJarEnabled() ? new File(buildConfiguration.getJarPath()).getParentFile() : moduleBaseDir, "/temp"); - String tempDir = GenerationUtils.toRelativePath(jarDir.getPath(), parameters.getChunk(), parameters.getGenerationOptions()); - final String tempDirProperty = BuildProperties.getTempDirForModuleProperty(parameters.getContainingModule().getName()); - final boolean[] tempDirUsed = new boolean[] { false }; - - final ExplodedAndJarBuildGenerator[] generators = Extensions.getExtensions(DefaultExplodedAndJarBuildGenerator.EP_NAME); - final List zipFileSetTags = new ArrayList(); - buildRecipe.visitInstructions(new BuildInstructionVisitor() { - public boolean visitInstruction(final BuildInstruction instruction) throws Exception { - for (final ExplodedAndJarBuildGenerator generator : generators) { - final Ref ref = new Ref(false); - final ZipFileSet[] tags = generator.generateTagsForJarTarget(instruction, parameters, ref); - if (tags != null) { - if (ref.get() != null && ref.get()) { - tempDirUsed[0] = true; - } - zipFileSetTags.addAll(Arrays.asList(tags)); - return true; - } - } - final Ref ref = Ref.create(false); - zipFileSetTags.addAll(Arrays.asList(DefaultExplodedAndJarBuildGenerator.INSTANCE.generateTagsForJarTarget(instruction, parameters, ref))); - if (ref.get() != null && ref.get()) { - tempDirUsed[0] = true; - } - return super.visitInstruction(instruction); - } - }, false); - if (tempDirUsed[0]) { - add(new Property(tempDirProperty, tempDir)); - add(new Mkdir(BuildProperties.propertyRef(tempDirProperty))); - } - final List prepareTags = new ArrayList(); - buildRecipe.visitInstructions(new BuildInstructionVisitor() { - public boolean visitInstruction(final BuildInstruction instruction) throws Exception { - for (final ExplodedAndJarBuildGenerator generator : generators) { - final Tag[] tags = generator.generateJarBuildPrepareTags(instruction, parameters); - if (tags != null) { - prepareTags.addAll(Arrays.asList(tags)); - return true; - } - } - prepareTags.addAll(Arrays.asList(DefaultExplodedAndJarBuildGenerator.INSTANCE.generateJarBuildPrepareTags(instruction, parameters))); - return super.visitInstruction(instruction); - } - }, false); - for (Tag tag : prepareTags) { - add(tag); - } - final String destFile = BuildProperties.propertyRef(parameters.getJarPathParameter()); - final @NonNls String jarDirProperty = "jar.dir"; - add(new Dirname(jarDirProperty, destFile)); - add(new Mkdir(BuildProperties.propertyRef(jarDirProperty))); - final Jar jarTag = new Jar(destFile, "preserve"); - add(jarTag); - final java.util.jar.Manifest manifest = DeploymentUtil.getInstance().createManifest(buildRecipe); - - if (manifest != null) { - final Manifest manifestTag = new Manifest(); - jarTag.add(manifestTag); - manifestTag.applyAttributes(manifest); - } - - for (ZipFileSet zipFileSet : zipFileSetTags) { - jarTag.add(zipFileSet); - } - if (tempDirUsed[0]) { - add(new Delete(BuildProperties.propertyRef(tempDirProperty))); - } - - // emit copy commands for dependencies - buildRecipe.visitInstructions(new BuildInstructionVisitor() { - private int myJarDirCount = 2; - - public boolean visitFileCopyInstruction(FileCopyInstruction instruction) throws Exception { - if (!instruction.isExternalDependencyInstruction()) return true; - final File sourceFile = instruction.getFile(); - final String outputRelativePath = DeploymentUtil.appendToPath("/",instruction.getOutputRelativePath()); - final Module instructionModule = instruction.getModule(); - String sourceLocation = GenerationUtils.toRelativePath(sourceFile.getPath(), moduleBaseDir, instructionModule, - parameters.getGenerationOptions()); - String jarPathPropertyRef = BuildProperties.propertyRef(parameters.getJarPathParameter()); - - final Copy copy; - if (instruction.isDirectory()) { - copy = new Copy(DeploymentUtil.appendToPath(jarPathPropertyRef,outputRelativePath)); - copy.add(new FileSet(sourceLocation)); - } - else { - copy = new Copy(sourceLocation, DeploymentUtil.appendToPath(jarPathPropertyRef,outputRelativePath)); - } - - add(copy); - return true; - } - - public boolean visitJarAndCopyBuildInstruction(JarAndCopyBuildInstruction instruction) throws Exception { - if (!instruction.isExternalDependencyInstruction()) return true; - String jarPathPropertyRef = BuildProperties.propertyRef(parameters.getJarPathParameter()); - String pathToCreateJar = jarPathPropertyRef + DeploymentUtil.appendToPath("/",instruction.getOutputRelativePath()); - @NonNls final String jarDir = "jar.dir" + myJarDirCount++; - add(new Dirname(jarDir, pathToCreateJar)); - add(new Mkdir(BuildProperties.propertyRef(jarDir))); - add(DefaultExplodedAndJarBuildGenerator.generateJarTag(instruction, pathToCreateJar, moduleBaseDir, parameters.getGenerationOptions())); - return true; - } - - @Override - public boolean visitCompoundBuildInstruction(final CompoundBuildInstruction instruction) throws Exception { - if (!instruction.isExternalDependencyInstruction()) return true; - String outputPath = DeploymentUtil.appendToPath(BuildProperties.propertyRef(parameters.getJarPathParameter()), instruction.getOutputRelativePath()); - if (instruction.getBuildProperties().isJarEnabled()) { - String jarPath = BuildProperties.propertyRef(parameters.getCompoundBuildInstructionNaming().getJarPathProperty(instruction)); - add(new Copy(jarPath, outputPath)); - } - else { - AntCall call = new AntCall(parameters.getCompoundBuildInstructionNaming().getBuildJarTargetName(instruction)); - call.add(new Param(parameters.getJarPathParameter(), outputPath)); - add(call); - } - return true; - } - }, false); - } - -} \ No newline at end of file diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/CompoundBuildInstructionImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/CompoundBuildInstructionImpl.java dissimilarity index 71% index 86474fa1e5..92c99d20ff 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/CompoundBuildInstructionImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/CompoundBuildInstructionImpl.java @@ -1,214 +1,69 @@ -/* - * Copyright 2000-2009 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.compiler.impl.packagingCompiler; - -import com.intellij.openapi.compiler.CompileContext; -import com.intellij.openapi.compiler.CompilerBundle; -import com.intellij.openapi.compiler.CompilerMessageCategory; -import com.intellij.openapi.compiler.make.*; -import com.intellij.openapi.deployment.DeploymentUtil; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.Ref; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.util.PathUtil; -import com.intellij.util.io.ZipUtil; -import gnu.trove.THashSet; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.*; -import java.util.Collection; -import java.util.Set; -import java.util.jar.JarFile; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; - -public class CompoundBuildInstructionImpl extends BuildInstructionBase implements CompoundBuildInstruction { - private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.packagingCompiler.CompoundBuildInstructionImpl"); - - private final BuildConfiguration myBuildConfiguration; - private final BuildParticipant myBuildParticipant; - @NonNls private static final String TMP_FILE_SUFFIX = ".tmp"; - - public CompoundBuildInstructionImpl(BuildParticipant buildParticipant, String outputRelativePath) { - super(outputRelativePath, buildParticipant.getModule()); - myBuildConfiguration = buildParticipant.getBuildConfiguration(); - myBuildParticipant = buildParticipant; - } - - public BuildParticipant getBuildParticipant() { - return myBuildParticipant; - } - - public boolean accept(BuildInstructionVisitor visitor) throws Exception { - return visitor.visitCompoundBuildInstruction(this); - } - - public void addFilesToJar(@NotNull final CompileContext context, - @NotNull final File jarFile, - @NotNull final JarOutputStream outputStream, - BuildRecipe dependencies, - @Nullable final Set writtenRelativePaths, - @Nullable final FileFilter fileFilter) throws IOException { - // create temp jars, and add these into upper level jar - // todo optimization: cache created jars - final File tempFile; - final BuildRecipe childDependencies = new BuildRecipeImpl(); - if (myBuildConfiguration.isJarEnabled()) { - tempFile = new File(myBuildConfiguration.getJarPath()); - final BuildRecipe childModuleRecipe = getChildInstructions(context); - childModuleRecipe.visitInstructions(new BuildInstructionVisitor() { - public boolean visitInstruction(BuildInstruction instruction) throws RuntimeException { - if (instruction.isExternalDependencyInstruction()) { - childDependencies.addInstruction(instruction); - } - return true; - } - }, false); - } - else { - tempFile = File.createTempFile("jar___", TMP_FILE_SUFFIX); - tempFile.deleteOnExit(); - makeJar(context, tempFile, childDependencies, fileFilter, true); - childDependencies.visitInstructions(new BuildInstructionVisitor() { - public boolean visitFileCopyInstruction(FileCopyInstruction instruction) throws Exception { - File file = new File(PathUtil.getCanonicalPath(DeploymentUtil.appendToPath(tempFile.getPath(), instruction.getOutputRelativePath()))); - addFileToDelete(file); - return true; - } - }, false); - } - ZipUtil.addFileToZip(outputStream, tempFile, getOutputRelativePath(), writtenRelativePaths, fileFilter); - try { - childDependencies.visitInstructionsWithExceptions(new BuildInstructionVisitor() { - public boolean visitFileCopyInstruction(FileCopyInstruction instruction) throws Exception { - File file = instruction.getFile(); - String dependencyRelativePath = PathUtil.getCanonicalPath(DeploymentUtil.appendToPath(getOutputRelativePath(), instruction.getOutputRelativePath())); - - ZipUtil.addFileOrDirRecursively(outputStream, jarFile, file, dependencyRelativePath, fileFilter, writtenRelativePaths); - return true; - } - - public boolean visitJarAndCopyBuildInstruction(JarAndCopyBuildInstruction instruction) throws Exception { - if (instruction.getJarFile() == null) { - File tempJar = File.createTempFile("___",TMP_FILE_SUFFIX); - addFileToDelete(tempJar); - instruction.makeJar(context, tempJar, fileFilter); - } - File jarFile = instruction.getJarFile(); - String dependencyRelativePath = PathUtil.getCanonicalPath(DeploymentUtil.appendToPath(getOutputRelativePath(), instruction.getOutputRelativePath())); - - ZipUtil.addFileToZip(outputStream, jarFile, dependencyRelativePath, writtenRelativePaths, fileFilter); - return true; - } - }, false); - } - catch (IOException e) { - throw e; - } - catch (RuntimeException e) { - throw e; - } - catch (Exception e) { - } - } - - // return jarFile and possible jars linked via manifest - public void makeJar(final CompileContext context, - final File jarFile, - final BuildRecipe dependencies, - final FileFilter fileFilter, - final boolean processExternalDependencies) throws IOException { - final BuildRecipe buildRecipe = getChildInstructions(context); - final Manifest manifest = DeploymentUtil.getInstance().createManifest(buildRecipe); - if (manifest == null) { - File file = DeploymentUtil.getInstance().findUserSuppliedManifestFile(buildRecipe); - LOG.assertTrue(file != null); - context.addMessage(CompilerMessageCategory.WARNING, CompilerBundle.message("message.text.using.user.supplied.manifest", file.getAbsolutePath()), null, -1, -1); - } - FileUtil.createParentDirs(jarFile); - final BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(jarFile)); - final JarOutputStream jarOutputStream = manifest == null ? new JarOutputStream(out) : new JarOutputStream(out, manifest); - - final Set tempWrittenRelativePaths = new THashSet(); - if (manifest != null) { - tempWrittenRelativePaths.add(JarFile.MANIFEST_NAME); - } - try { - buildRecipe.visitInstructionsWithExceptions(new BuildInstructionVisitor() { - public boolean visitInstruction(BuildInstruction instruction) throws IOException { - if (processExternalDependencies || !instruction.isExternalDependencyInstruction()) { - instruction.addFilesToJar(context, jarFile, jarOutputStream, dependencies, tempWrittenRelativePaths, fileFilter); - } - return true; - } - }, false); - } - catch (IOException e) { - throw e; - } - catch (RuntimeException e) { - throw e; - } - catch (Exception e) { - } - finally { - jarOutputStream.close(); - } - } - - public BuildRecipe getChildInstructions(CompileContext context) { - return myBuildParticipant.getBuildInstructions(context); - } - - public BuildConfiguration getBuildProperties() { - return myBuildConfiguration; - } - - public String toString() { - return "Java EE build instruction: " + myBuildParticipant + " -> " + getOutputRelativePath(); - } - - public File findFileByRelativePath(String relativePath) { - if (!relativePath.startsWith(getOutputRelativePath())) return null; - final String pathFromFile = relativePath.substring(getOutputRelativePath().length()); - final Ref file = new Ref(); - final BuildRecipe buildRecipe = getChildInstructions(null); - buildRecipe.visitInstructions(new BuildInstructionVisitor() { - public boolean visitInstruction(BuildInstruction instruction) throws RuntimeException { - final File found = instruction.findFileByRelativePath(pathFromFile); - if (found != null) { - file.set(found); - return false; - } - return true; - } - }, false); - return file.get(); - } - - public void collectFilesToDelete(final Collection filesToDelete) { - super.collectFilesToDelete(filesToDelete); - BuildRecipe childInstructions = getChildInstructions(null); - childInstructions.visitInstructions(new BuildInstructionVisitor() { - public boolean visitInstruction(BuildInstruction instruction) throws Exception { - ((BuildInstructionBase)instruction).collectFilesToDelete(filesToDelete); - return true; - } - }, false); - } -} +/* + * Copyright 2000-2009 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.compiler.impl.packagingCompiler; + +import com.intellij.openapi.compiler.CompileContext; +import com.intellij.openapi.compiler.make.*; +import com.intellij.openapi.diagnostic.Logger; +import org.jetbrains.annotations.NonNls; + +import java.io.File; +import java.util.Collection; + +public class CompoundBuildInstructionImpl extends BuildInstructionBase implements CompoundBuildInstruction { + private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.packagingCompiler.CompoundBuildInstructionImpl"); + + private final BuildConfiguration myBuildConfiguration; + private final BuildParticipant myBuildParticipant; + @NonNls private static final String TMP_FILE_SUFFIX = ".tmp"; + + public CompoundBuildInstructionImpl(BuildParticipant buildParticipant, String outputRelativePath) { + super(outputRelativePath, buildParticipant.getModule()); + myBuildConfiguration = buildParticipant.getBuildConfiguration(); + myBuildParticipant = buildParticipant; + } + + public BuildParticipant getBuildParticipant() { + return myBuildParticipant; + } + + public boolean accept(BuildInstructionVisitor visitor) throws Exception { + return visitor.visitCompoundBuildInstruction(this); + } + + public BuildRecipe getChildInstructions(CompileContext context) { + return myBuildParticipant.getBuildInstructions(context); + } + + public BuildConfiguration getBuildProperties() { + return myBuildConfiguration; + } + + public String toString() { + return "Java EE build instruction: " + myBuildParticipant + " -> " + getOutputRelativePath(); + } + + public void collectFilesToDelete(final Collection filesToDelete) { + super.collectFilesToDelete(filesToDelete); + BuildRecipe childInstructions = getChildInstructions(null); + childInstructions.visitInstructions(new BuildInstructionVisitor() { + public boolean visitInstruction(BuildInstruction instruction) throws Exception { + ((BuildInstructionBase)instruction).collectFilesToDelete(filesToDelete); + return true; + } + }, false); + } +} diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/FileCopyInstructionImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/FileCopyInstructionImpl.java index 3f4575f9fb..4596c36c4c 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/FileCopyInstructionImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/FileCopyInstructionImpl.java @@ -15,25 +15,16 @@ */ package com.intellij.compiler.impl.packagingCompiler; -import com.intellij.openapi.compiler.CompileContext; import com.intellij.openapi.compiler.CompilerBundle; import com.intellij.openapi.compiler.make.BuildInstructionVisitor; -import com.intellij.openapi.compiler.make.BuildRecipe; import com.intellij.openapi.compiler.make.FileCopyInstruction; import com.intellij.openapi.compiler.make.PackagingFileFilter; -import com.intellij.openapi.deployment.DeploymentUtil; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtil; -import com.intellij.util.io.ZipUtil; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; -import java.io.FileFilter; -import java.io.IOException; import java.util.List; -import java.util.Set; -import java.util.jar.JarOutputStream; public class FileCopyInstructionImpl extends BuildInstructionBase implements FileCopyInstruction { private File myFile; @@ -68,41 +59,6 @@ public class FileCopyInstructionImpl extends BuildInstructionBase implements Fil return visitor.visitFileCopyInstruction(this); } - public File findFileByRelativePath(String relativePath) { - if (!relativePath.startsWith(getOutputRelativePath())) return null; - final String pathFromFile = relativePath.substring(getOutputRelativePath().length()); - if (!myIsDirectory) { - return "".equals(pathFromFile) ? myFile : null; - } - final File file = DeploymentUtil.canonicalRelativePath(myFile, pathFromFile); - - return file.exists() ? file : null; - } - - public void addFilesToJar(@NotNull CompileContext context, - @NotNull File jarFile, - @NotNull JarOutputStream outputStream, - BuildRecipe dependencies, - @Nullable Set writtenRelativePaths, - @Nullable FileFilter fileFilter) throws IOException { - final String outputRelativePath = getOutputRelativePath(); - - File file = getFile(); - if (isExternalDependencyInstruction()) { - // copy dependent file along with jar file - final File toFile = DeploymentUtil.canonicalRelativePath(jarFile, outputRelativePath); - DeploymentUtil.getInstance().copyFile(file, toFile, context, null, fileFilter); - dependencies.addInstruction(this); - } - else { - boolean ok = ZipUtil.addFileOrDirRecursively(outputStream, jarFile, file, outputRelativePath, fileFilter, writtenRelativePaths); - if (!ok) { - DeploymentUtil.reportRecursiveCopying(context, file.getPath(), jarFile.getPath(), "", - CompilerBundle.message("message.text.setup.jar.outside.directory.path", file.getPath())); - } - } - } - public String toString() { if (myChangedSet == null) { if (getModule() != null) { diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/JarAndCopyBuildInstructionImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/JarAndCopyBuildInstructionImpl.java dissimilarity index 67% index 889363da27..3cac617a4a 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/JarAndCopyBuildInstructionImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/packagingCompiler/JarAndCopyBuildInstructionImpl.java @@ -1,132 +1,52 @@ -/* - * Copyright 2000-2009 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.compiler.impl.packagingCompiler; - -import com.intellij.openapi.compiler.CompileContext; -import com.intellij.openapi.compiler.CompilerBundle; -import com.intellij.openapi.compiler.make.*; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleUtil; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.deployment.DeploymentUtil; -import com.intellij.util.io.ZipUtil; -import gnu.trove.THashSet; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.*; -import java.util.Set; -import java.util.List; -import java.util.ArrayList; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; -import java.util.jar.JarFile; - -/** - * Created by IntelliJ IDEA. - * User: cdr - * Date: Jun 21, 2004 - * Time: 4:08:34 PM - * To change this template use File | Settings | File Templates. - */ -public class JarAndCopyBuildInstructionImpl extends FileCopyInstructionImpl implements JarAndCopyBuildInstruction { - private File myJarFile; - private final List myTempJars = new ArrayList(1); - @NonNls private static final String TMP_FILE_SUFFIX = ".tmp"; - - public JarAndCopyBuildInstructionImpl(Module module, File directoryToJar, String outputRelativePath, @Nullable PackagingFileFilter fileFilter) { - super(directoryToJar, false, module, outputRelativePath, fileFilter); - } - - public JarAndCopyBuildInstructionImpl(Module module, File directoryToJar, String outputRelativePath) { - super(directoryToJar, false, module, outputRelativePath); - } - - public void addFilesToJar(@NotNull CompileContext context, - @NotNull File jarFile, - @NotNull JarOutputStream outputStream, - BuildRecipe dependencies, - @Nullable Set writtenRelativePaths, - @Nullable FileFilter fileFilter) throws IOException { - // create temp jars, and add these into upper level jar - // todo optimization: cache created jars - @NonNls final String moduleName = getModule() == null ? "jar" : ModuleUtil.getModuleNameInReadAction(getModule()); - final File tempFile = File.createTempFile(moduleName+"___",TMP_FILE_SUFFIX); - myTempJars.add(tempFile); - makeJar(context, tempFile, fileFilter); - - final String outputRelativePath = getOutputRelativePath(); - - File file = getJarFile(); - if (isExternalDependencyInstruction()) { - // copy dependent file along with jar file - final File toFile = DeploymentUtil.canonicalRelativePath(jarFile, outputRelativePath); - DeploymentUtil.getInstance().copyFile(file, toFile, context, null, fileFilter); - dependencies.addInstruction(this); - } - else { - ZipUtil.addFileToZip(outputStream, file, outputRelativePath, writtenRelativePaths, fileFilter); - } - } - - public void makeJar(@NotNull CompileContext context, @NotNull File jarFile, @Nullable FileFilter fileFilter) throws IOException { - if (jarFile.equals(myJarFile)) return; - if (myJarFile != null && myJarFile.exists()) { - // optimization: file already jarred, copy it over - DeploymentUtil.getInstance().copyFile(myJarFile, jarFile, context, null, fileFilter); - } - else { - FileUtil.createParentDirs(jarFile); - Manifest manifest = new Manifest(); - ManifestBuilder.setGlobalAttributes(manifest.getMainAttributes()); - - final JarOutputStream jarOutputStream = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(jarFile)), manifest); - - try { - final THashSet writtenPaths = new THashSet(); - writtenPaths.add(JarFile.MANIFEST_NAME); - boolean ok = ZipUtil.addDirToZipRecursively(jarOutputStream, jarFile, getFile(), "", fileFilter, writtenPaths); - if (!ok) { - String dirPath = getFile().getPath(); - DeploymentUtil.reportRecursiveCopying(context, dirPath, jarFile.getPath(), "", - CompilerBundle.message("message.text.setup.jar.outside.directory.path", dirPath)); - } - } - finally { - jarOutputStream.close(); - } - } - myJarFile = jarFile; - } - - public boolean accept(BuildInstructionVisitor visitor) throws Exception { - return visitor.visitJarAndCopyBuildInstruction(this); - } - - @NonNls public String toString() { - return "JAR and copy: " + getFile() + "->"+getOutputRelativePath(); - } - - public File getJarFile() { - return myJarFile; - } - - public void deleteTemporaryJars() { - FileUtil.asyncDelete(myTempJars); - myTempJars.clear(); - } -} +/* + * Copyright 2000-2009 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.compiler.impl.packagingCompiler; + +import com.intellij.openapi.compiler.make.BuildInstructionVisitor; +import com.intellij.openapi.compiler.make.JarAndCopyBuildInstruction; +import com.intellij.openapi.compiler.make.PackagingFileFilter; +import com.intellij.openapi.module.Module; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.Nullable; + +import java.io.File; + +/** + * Created by IntelliJ IDEA. + * User: cdr + * Date: Jun 21, 2004 + * Time: 4:08:34 PM + * To change this template use File | Settings | File Templates. + */ +public class JarAndCopyBuildInstructionImpl extends FileCopyInstructionImpl implements JarAndCopyBuildInstruction { + + public JarAndCopyBuildInstructionImpl(Module module, File directoryToJar, String outputRelativePath, @Nullable PackagingFileFilter fileFilter) { + super(directoryToJar, false, module, outputRelativePath, fileFilter); + } + + public JarAndCopyBuildInstructionImpl(Module module, File directoryToJar, String outputRelativePath) { + super(directoryToJar, false, module, outputRelativePath); + } + + public boolean accept(BuildInstructionVisitor visitor) throws Exception { + return visitor.visitJarAndCopyBuildInstruction(this); + } + + @NonNls public String toString() { + return "JAR and copy: " + getFile() + "->"+getOutputRelativePath(); + } + +} diff --git a/java/compiler/impl/src/com/intellij/openapi/deployment/DeploymentUtilImpl.java b/java/compiler/impl/src/com/intellij/openapi/deployment/DeploymentUtilImpl.java index 2f7c535956..3db6885373 100644 --- a/java/compiler/impl/src/com/intellij/openapi/deployment/DeploymentUtilImpl.java +++ b/java/compiler/impl/src/com/intellij/openapi/deployment/DeploymentUtilImpl.java @@ -29,7 +29,6 @@ import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.roots.*; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.util.Computable; -import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; @@ -48,8 +47,6 @@ import java.io.FileFilter; import java.io.IOException; import java.util.*; import java.util.jar.Attributes; -import java.util.jar.JarFile; -import java.util.jar.Manifest; /** * @author Alexey Kudravtsev @@ -285,18 +282,6 @@ public class DeploymentUtilImpl extends DeploymentUtil { return relativePath; } - public @Nullable File findUserSuppliedManifestFile(@NotNull BuildRecipe buildRecipe) { - final Ref ref = Ref.create(null); - buildRecipe.visitInstructions(new BuildInstructionVisitor() { - public boolean visitInstruction(BuildInstruction instruction) throws Exception { - final File file = instruction.findFileByRelativePath(JarFile.MANIFEST_NAME); - ref.set(file); - return file == null; - } - }, false); - return ref.get(); - } - public void checkConfigFile(final ConfigFile descriptor, final CompileContext compileContext, final Module module) { if (new File(VfsUtil.urlToPath(descriptor.getUrl())).exists()) { String message = getConfigFileErrorMessage(descriptor); @@ -312,17 +297,6 @@ public class DeploymentUtilImpl extends DeploymentUtil { } } - public @Nullable Manifest createManifest(@NotNull BuildRecipe buildRecipe) { - if (findUserSuppliedManifestFile(buildRecipe) != null) { - return null; - } - - final List classpathElements = getExternalDependenciesClasspath(buildRecipe); - final Manifest manifest = new Manifest(); - setManifestAttributes(manifest.getMainAttributes(), classpathElements); - return manifest; - } - public static void setManifestAttributes(final Attributes mainAttributes, final @Nullable List classpathElements) { if (classpathElements != null && classpathElements.size() > 0) { StringBuilder builder; diff --git a/java/compiler/impl/src/com/intellij/openapi/deployment/LibraryLinkImpl.java b/java/compiler/impl/src/com/intellij/openapi/deployment/LibraryLinkImpl.java index fc97f77fef..3bb67c3c1e 100644 --- a/java/compiler/impl/src/com/intellij/openapi/deployment/LibraryLinkImpl.java +++ b/java/compiler/impl/src/com/intellij/openapi/deployment/LibraryLinkImpl.java @@ -22,7 +22,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.impl.libraries.LibraryEx; import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.libraries.LibraryTable; import com.intellij.openapi.roots.ui.configuration.FacetsProvider; import com.intellij.openapi.roots.ui.configuration.ModulesProvider; import com.intellij.openapi.util.Comparing; @@ -40,13 +39,9 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; public class LibraryLinkImpl extends LibraryLink { - private static final Map methodToDescriptionForDirs = new HashMap(); - private static final Map methodToDescriptionForFiles = new HashMap(); @NonNls public static final String LEVEL_ATTRIBUTE_NAME = "level"; @NonNls public static final String URL_ELEMENT_NAME = "url"; @NonNls private static final String TEMP_ELEMENT_NAME = "temp"; @@ -54,17 +49,6 @@ public class LibraryLinkImpl extends LibraryLink { @NonNls private static final String JAR_SUFFIX = ".jar"; - static { - methodToDescriptionForDirs.put(PackagingMethod.DO_NOT_PACKAGE, CompilerBundle.message("packaging.method.description.do.not.package")); - methodToDescriptionForDirs.put(PackagingMethod.COPY_FILES, CompilerBundle.message("packaging.method.description.copy.directories")); - methodToDescriptionForDirs.put(PackagingMethod.JAR_AND_COPY_FILE, CompilerBundle.message("packaging.method.description.jar.and.copy.file")); - methodToDescriptionForDirs.put(PackagingMethod.JAR_AND_COPY_FILE_AND_LINK_VIA_MANIFEST, CompilerBundle.message("packaging.method.description.jar.and.copy.file.and.link.via.manifest")); - - methodToDescriptionForFiles.put(PackagingMethod.DO_NOT_PACKAGE, CompilerBundle.message("packaging.method.description.do.not.package")); - methodToDescriptionForFiles.put(PackagingMethod.COPY_FILES, CompilerBundle.message("packaging.method.description.copy.files")); - methodToDescriptionForFiles.put(PackagingMethod.COPY_FILES_AND_LINK_VIA_MANIFEST, CompilerBundle.message("packaging.method.description.copy.files.and.link.via.manifest")); - } - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.deployment.LibraryLink"); private LibraryInfo myLibraryInfo; private final Project myProject; @@ -137,26 +121,6 @@ public class LibraryLinkImpl extends LibraryLink { return FileUtil.toSystemDependentName(path); } - public String getDescription() { - String levelName = myLibraryInfo.getLevel(); - if (levelName.equals(MODULE_LEVEL)) { - return CompilerBundle.message("library.link.description.module.library"); - } - final LibraryTable table = findTable(levelName, myProject); - return table == null ? "???" : table.getPresentation().getDisplayName(false); - } - - public String getDescriptionForPackagingMethod(PackagingMethod method) { - if (hasDirectoriesOnly()) { - final String text = methodToDescriptionForDirs.get(method); - return text != null ? text : methodToDescriptionForFiles.get(method); - } - else { - final String text = methodToDescriptionForFiles.get(method); - return text != null ? text : methodToDescriptionForDirs.get(method); - } - } - public List getUrls() { fixLibraryInfo(); return myLibraryInfo.getUrls(); diff --git a/java/compiler/impl/src/com/intellij/openapi/deployment/ModuleLinkImpl.java b/java/compiler/impl/src/com/intellij/openapi/deployment/ModuleLinkImpl.java index 730a2d74ac..e3e63069c0 100644 --- a/java/compiler/impl/src/com/intellij/openapi/deployment/ModuleLinkImpl.java +++ b/java/compiler/impl/src/com/intellij/openapi/deployment/ModuleLinkImpl.java @@ -29,11 +29,8 @@ import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import org.jdom.Element; import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; - -import java.util.HashMap; -import java.util.Map; +import org.jetbrains.annotations.Nullable; public class ModuleLinkImpl extends ModuleLink { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.deployment.ModuleLink"); @@ -41,15 +38,6 @@ public class ModuleLinkImpl extends ModuleLink { @NonNls private static final String TEMP_ELEMENT_NAME = "temp"; private Module myModule; private String myModuleName; - private static final Map methodToDescription = new HashMap(); - - static { - methodToDescription.put(PackagingMethod.DO_NOT_PACKAGE, CompilerBundle.message("packaging.method.description.do.not.package")); - methodToDescription.put(PackagingMethod.COPY_FILES, CompilerBundle.message("packaging.method.description.copy.module.output")); - methodToDescription.put(PackagingMethod.JAR_AND_COPY_FILE, CompilerBundle.message("packaging.method.description.jar.module.and.copy")); - methodToDescription.put(PackagingMethod.JAR_AND_COPY_FILE_AND_LINK_VIA_MANIFEST, CompilerBundle.message("packaging.method.description.jar.module.link.via.manifest.and.copy")); - methodToDescription.put(PackagingMethod.INCLUDE_MODULE_IN_BUILD, CompilerBundle.message("packaging.method.description.include.module.in.build")); - } public ModuleLinkImpl(@NotNull Module module, @NotNull Module parentModule) { super(parentModule); @@ -99,15 +87,6 @@ public class ModuleLinkImpl extends ModuleLink { return getName(); } - public String getDescription() { - final Module module = getModule(); - return module == null ? "" : module.getModuleType().getName(); - } - - public String getDescriptionForPackagingMethod(PackagingMethod method) { - return methodToDescription.get(method); - } - public boolean resolveElement(ModulesProvider provider, final FacetsProvider facetsProvider) { return getModule(provider) != null; } diff --git a/java/compiler/impl/src/com/intellij/openapi/deployment/OrderEntryInfo.java b/java/compiler/impl/src/com/intellij/openapi/deployment/OrderEntryInfo.java deleted file mode 100644 index 09e1b2e030..0000000000 --- a/java/compiler/impl/src/com/intellij/openapi/deployment/OrderEntryInfo.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2000-2009 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.openapi.deployment; - -import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.JDOMExternalizable; -import com.intellij.openapi.util.JDOMExternalizer; -import com.intellij.openapi.util.WriteExternalException; -import com.intellij.util.containers.HashMap; -import org.jdom.Element; -import org.jetbrains.annotations.NonNls; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * @author cdr - * @deprecated - */ -class OrderEntryInfo implements JDOMExternalizable { - public boolean copy; - public String URI=""; - private final Map attributes = new HashMap(); - @NonNls protected static final String ATTRIBUTE_ELEMENT_NAME = "attribute"; - @NonNls protected static final String NAME_ATTR_NAME = "name"; - @NonNls protected static final String VALUE_ATTR_NAME = "value"; - @NonNls protected static final String ATTRIBUTES_ELEMENT_NAME = "attributes"; - - public void writeExternal(Element element) throws WriteExternalException { - JDOMExternalizer.write(element,"copy",copy); - JDOMExternalizer.write(element,"URI",URI); - writeAttributes(element); - } - - private void writeAttributes(Element element) { - if (attributes.size() == 0) return; - Element root = new Element(ATTRIBUTES_ELEMENT_NAME); - element.addContent(root); - Set names = attributes.keySet(); - for (String name : names) { - String value = attributes.get(name); - Element attr = new Element(ATTRIBUTE_ELEMENT_NAME); - attr.setAttribute(NAME_ATTR_NAME, name); - attr.setAttribute(VALUE_ATTR_NAME, value); - root.addContent(attr); - } - } - private void readAttributes(Element element) { - Element attrs = element.getChild(ATTRIBUTES_ELEMENT_NAME); - if (attrs == null) return; - List roots = attrs.getChildren(ATTRIBUTE_ELEMENT_NAME); - if (roots.size() == 0) return; - for (Object root : roots) { - Element attr = (Element)root; - String name = attr.getAttributeValue(NAME_ATTR_NAME); - String value = attr.getAttributeValue(VALUE_ATTR_NAME); - attributes.put(name, value); - } - } - - public void readExternal(Element element) throws InvalidDataException { - copy = JDOMExternalizer.readBoolean(element,"copy"); - URI = JDOMExternalizer.readString(element,"URI"); - readAttributes(element); - } - - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof OrderEntryInfo)) return false; - - final OrderEntryInfo orderEntryInfo = (OrderEntryInfo)o; - - if (copy != orderEntryInfo.copy) return false; - if (URI != null ? !URI.equals(orderEntryInfo.URI) : orderEntryInfo.URI != null) return false; - - return true; - } - - public int hashCode() { - int result; - result = copy ? 1 : 0; - result = 29 * result + (URI != null ? URI.hashCode() : 0); - return result; - } - - public Map getAttributes() { - return attributes; - } -} diff --git a/java/compiler/impl/src/com/intellij/openapi/deployment/PackagingConfigurationImpl.java b/java/compiler/impl/src/com/intellij/openapi/deployment/PackagingConfigurationImpl.java deleted file mode 100644 index 7b42d0eb45..0000000000 --- a/java/compiler/impl/src/com/intellij/openapi/deployment/PackagingConfigurationImpl.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright 2000-2009 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.openapi.deployment; - -import com.intellij.facet.impl.DefaultFacetsProvider; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.roots.ui.configuration.DefaultModulesProvider; -import com.intellij.openapi.roots.ui.configuration.FacetsProvider; -import com.intellij.openapi.roots.ui.configuration.ModulesProvider; -import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.WriteExternalException; -import gnu.trove.TObjectHashingStrategy; -import org.jdom.Element; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -import java.util.*; - -/** - * @author Alexey Kudravtsev - */ -public class PackagingConfigurationImpl implements PackagingConfiguration { - private static final Logger LOG = Logger.getInstance("#com.intellij.javaee.module.J2EEModuleContainerImpl"); - protected ModulesProvider myDefaultModulesProvider; - protected final Module myParentModule; - protected final Set myContents = new LinkedHashSet(); - - @NonNls public static final String TYPE_ATTRIBUTE_NAME = "type"; - @NonNls public static final String CONTAINER_ELEMENT_NAME = "containerElement"; - @NonNls public static final String MODULE_TYPE = "module"; - @NonNls public static final String LIBRARY_TYPE = "library"; - public static final TObjectHashingStrategy IGNORING_ATTRIBUTES_EQUALITY = new ElementIgnoringAttributesEquality(); - - public PackagingConfigurationImpl(@NotNull Module module) { - myParentModule = module; - myDefaultModulesProvider = new DefaultModulesProvider(module.getProject()); - } - - public PackagingConfigurationImpl createNewInstance() { - return new PackagingConfigurationImpl(myParentModule); - } - - public void removeLibrary(final Library library) { - for (ContainerElement content : myContents) { - if (content instanceof LibraryLink && library.equals(((LibraryLink)content).getLibrary())) { - removeContainerElement(content); - break; - } - } - } - - public void readExternal(Element element) throws InvalidDataException { - clearContainer(); - LOG.assertTrue(myParentModule != null); - - final List children = element.getChildren(CONTAINER_ELEMENT_NAME); - for (Element child : children) { - final String type = child.getAttributeValue(TYPE_ATTRIBUTE_NAME); - ContainerElement containerElement; - containerElement = createElement(child, myParentModule, type); - - containerElement.readExternal(child); - - addElement(containerElement); - } - } - - protected ContainerElement createElement(final @NotNull Element child, final @NotNull Module module, final String type) throws InvalidDataException { - if (MODULE_TYPE.equals(type)) { - return new ModuleLinkImpl((String)null, module); - } - else if (LIBRARY_TYPE.equals(type)) { - return new LibraryLinkImpl(null, module); - } - else { - throw new InvalidDataException("invalid type: " + type + " " + child); - } - } - - public void writeExternal(Element element) throws WriteExternalException { - for (final ContainerElement containerElement : myContents) { - final Element child = new Element(CONTAINER_ELEMENT_NAME); - final String type = getElementType(containerElement); - child.setAttribute(TYPE_ATTRIBUTE_NAME, type); - containerElement.writeExternal(child); - element.addContent(child); - } - } - - protected String getElementType(final ContainerElement containerElement) throws WriteExternalException { - if (containerElement instanceof ModuleLink) { - return MODULE_TYPE; - } - else if (containerElement instanceof LibraryLink) { - return LIBRARY_TYPE; - } - else { - throw new WriteExternalException("invalid type: " + containerElement); - } - } - - public ModuleLink[] getContainingModules() { - - final List moduleLinks = new ArrayList(); - - ContainerElement[] elements = getElements(); - for (ContainerElement element : elements) { - if (element instanceof ModuleLink) { - moduleLinks.add((ModuleLink)element); - } - } - - return moduleLinks.toArray(new ModuleLink[moduleLinks.size()]); - } - - public LibraryLink[] getContainingLibraries() { - final List libraryLinks = new ArrayList(); - ContainerElement[] elements = getElements(); - for (ContainerElement element : elements) { - if (element instanceof LibraryLink) { - libraryLinks.add((LibraryLink)element); - } - } - return libraryLinks.toArray(new LibraryLink[libraryLinks.size()]); - } - - public ContainerElement[] getElements() { - return getElements(myDefaultModulesProvider, DefaultFacetsProvider.INSTANCE, true, false, false); - } - - public ContainerElement[] getElements(ModulesProvider provider, final FacetsProvider facetsProvider, - final boolean includeResolved, final boolean includeUnresolved, final boolean includeNonPackaged) { - ArrayList result = new ArrayList(); - for (final ContainerElement containerElement : myContents) { - final boolean resolved = containerElement.resolveElement(provider, facetsProvider); - if ((resolved && includeResolved || !resolved && includeUnresolved) - && (includeNonPackaged || containerElement.getPackagingMethod() != PackagingMethod.DO_NOT_PACKAGE)) { - result.add(containerElement); - } - } - return result.toArray(new ContainerElement[result.size()]); - } - - public void setElements(ContainerElement[] elements) { - clearContainer(); - myContents.addAll(Arrays.asList(elements)); - } - - protected void removeModuleLinkInternal(Module module) { - for (final ContainerElement containerElement : myContents) { - if (containerElement instanceof ModuleLink && ((ModuleLink)containerElement).getModule() == module) { - removeContainerElement(containerElement); - break; - } - } - } - - public boolean removeContainerElement(final ContainerElement containerElement) { - return myContents.remove(containerElement); - } - - public Module[] getContainingIdeaModules() { - ModuleLink[] containingModules = getContainingModules(); - List result = new ArrayList(containingModules.length); - for (ModuleLink containingModule : containingModules) { - final Module module = containingModule.getModule(); - if (module != null) { - result.add(module); - } - } - return result.toArray(new Module[result.size()]); - } - - protected void clearContainer() { - myContents.clear(); - } - - public void addOrReplaceElement(final ContainerElement element) { - for (Iterator it = myContents.iterator(); it.hasNext();) { - ContainerElement content = it.next(); - if (content.equalsIgnoreAttributes(element)) { - it.remove(); - } - } - addElement(element); - } - - public void addElement(ContainerElement element) { - myContents.add(element); - } - -} diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/BuildTargetsFactory.java b/java/compiler/openapi/src/com/intellij/compiler/ant/BuildTargetsFactory.java index 1cdd1bc962..395e9e4839 100644 --- a/java/compiler/openapi/src/com/intellij/compiler/ant/BuildTargetsFactory.java +++ b/java/compiler/openapi/src/com/intellij/compiler/ant/BuildTargetsFactory.java @@ -37,8 +37,6 @@ public abstract class BuildTargetsFactory { public abstract Target createBuildExplodedTarget(ExplodedAndJarTargetParameters parameters, BuildRecipe buildRecipe, String description); - public abstract Target createBuildJarTarget(ExplodedAndJarTargetParameters parameters, BuildRecipe buildRecipe, String description); - public abstract Generator createComment(String comment); //for test diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstruction.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstruction.java index 6ed0383e06..5c796e2c10 100644 --- a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstruction.java +++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/BuildInstruction.java @@ -15,31 +15,13 @@ */ package com.intellij.openapi.compiler.make; -import com.intellij.openapi.compiler.CompileContext; import com.intellij.openapi.module.Module; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.File; -import java.io.FileFilter; -import java.io.IOException; -import java.util.Set; -import java.util.jar.JarOutputStream; public interface BuildInstruction { String getOutputRelativePath(); Module getModule(); - @Deprecated - void addFilesToJar(@NotNull CompileContext context, - @NotNull File jarFile, - @NotNull JarOutputStream outputStream, - BuildRecipe dependencies, - @Nullable Set writtenRelativePaths, - @Nullable FileFilter fileFilter) throws IOException; - boolean accept(BuildInstructionVisitor visitor) throws Exception; boolean isExternalDependencyInstruction(); - File findFileByRelativePath(String relativePath); } diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/JarAndCopyBuildInstruction.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/JarAndCopyBuildInstruction.java index 4cfccd9a60..96a9205316 100644 --- a/java/compiler/openapi/src/com/intellij/openapi/compiler/make/JarAndCopyBuildInstruction.java +++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/make/JarAndCopyBuildInstruction.java @@ -15,21 +15,8 @@ */ package com.intellij.openapi.compiler.make; -import com.intellij.openapi.compiler.CompileContext; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.io.File; -import java.io.FileFilter; -import java.io.IOException; public interface JarAndCopyBuildInstruction extends FileCopyInstruction { - @Deprecated - void makeJar(@NotNull CompileContext context, - @NotNull File jarFile, - @Nullable FileFilter fileFilter) throws IOException; - File getJarFile(); - @Deprecated - void deleteTemporaryJars(); } \ No newline at end of file diff --git a/java/compiler/openapi/src/com/intellij/openapi/deployment/ContainerElement.java b/java/compiler/openapi/src/com/intellij/openapi/deployment/ContainerElement.java index 401816c6f5..8ba21442f1 100644 --- a/java/compiler/openapi/src/com/intellij/openapi/deployment/ContainerElement.java +++ b/java/compiler/openapi/src/com/intellij/openapi/deployment/ContainerElement.java @@ -104,10 +104,6 @@ public abstract class ContainerElement implements JDOMExternalizable, Cloneable, return 0; } - public abstract String getDescription(); - - public abstract String getDescriptionForPackagingMethod(PackagingMethod method); - public ContainerElement clone() { throw new UnsupportedOperationException(); } diff --git a/java/compiler/openapi/src/com/intellij/openapi/deployment/DeploymentUtil.java b/java/compiler/openapi/src/com/intellij/openapi/deployment/DeploymentUtil.java index 05e37d52c9..2d452613d7 100644 --- a/java/compiler/openapi/src/com/intellij/openapi/deployment/DeploymentUtil.java +++ b/java/compiler/openapi/src/com/intellij/openapi/deployment/DeploymentUtil.java @@ -36,7 +36,6 @@ import java.io.File; import java.io.FileFilter; import java.io.IOException; import java.util.Set; -import java.util.jar.Manifest; public abstract class DeploymentUtil { public static DeploymentUtil getInstance() { @@ -93,8 +92,6 @@ public abstract class DeploymentUtil { public abstract void reportDeploymentDescriptorDoesNotExists(ConfigFile descriptor, CompileContext context, Module module); - @Nullable public abstract Manifest createManifest(@NotNull BuildRecipe buildRecipe); - public abstract void addJavaModuleOutputs(@NotNull Module module, @NotNull ModuleLink[] containingModules, @NotNull BuildRecipe instructions, @@ -110,14 +107,6 @@ public abstract class DeploymentUtil { @NotNull CompileContext context, String explodedPath); - public static boolean checkFileExists(final File file, CompileContext context) { - if (!file.exists()) { - context.addMessage(CompilerMessageCategory.ERROR, CompilerBundle.message("compiler.message.text.file.does.not.exist", file),null,-1,-1); - return false; - } - return true; - } - public static String concatPaths(String... paths) { final StringBuilder builder = new StringBuilder(); for (String path : paths) { @@ -194,8 +183,6 @@ public abstract class DeploymentUtil { } } - public abstract @Nullable File findUserSuppliedManifestFile(@NotNull BuildRecipe buildRecipe); - public abstract void checkConfigFile(final ConfigFile descriptor, final CompileContext compileContext, final Module module); } diff --git a/java/compiler/openapi/src/com/intellij/openapi/deployment/ElementIgnoringAttributesEquality.java b/java/compiler/openapi/src/com/intellij/openapi/deployment/ElementIgnoringAttributesEquality.java deleted file mode 100644 index 4921b1e121..0000000000 --- a/java/compiler/openapi/src/com/intellij/openapi/deployment/ElementIgnoringAttributesEquality.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2009 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.openapi.deployment; - -import gnu.trove.TObjectHashingStrategy; - -public class ElementIgnoringAttributesEquality implements TObjectHashingStrategy { - public boolean equals(ContainerElement object, ContainerElement object1) { - if (object1 == null || object == null) { - return object == object1; - } - return object.equalsIgnoreAttributes(object1); - } - - public int computeHashCode(ContainerElement object) { - String presentableName = object.getPresentableName(); - if (presentableName == null) { - return 0; - } - return presentableName.hashCode(); - } -} \ No newline at end of file diff --git a/java/compiler/openapi/src/com/intellij/openapi/deployment/PackagingConfiguration.java b/java/compiler/openapi/src/com/intellij/openapi/deployment/PackagingConfiguration.java deleted file mode 100644 index e04624ebed..0000000000 --- a/java/compiler/openapi/src/com/intellij/openapi/deployment/PackagingConfiguration.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2000-2009 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.openapi.deployment; - -import com.intellij.openapi.module.Module; -import com.intellij.openapi.util.JDOMExternalizable; -import com.intellij.openapi.roots.ui.configuration.ModulesProvider; -import com.intellij.openapi.roots.ui.configuration.FacetsProvider; - -public interface PackagingConfiguration extends JDOMExternalizable { - ModuleLink[] getContainingModules(); - - LibraryLink[] getContainingLibraries(); - - ContainerElement[] getElements(); - - void setElements(ContainerElement[] elements); - - Module[] getContainingIdeaModules(); - - ContainerElement[] getElements(ModulesProvider provider, FacetsProvider facetsProvider, - boolean includeResolved, boolean includeUnresolved, boolean includeNonPackaged); - - void addOrReplaceElement(ContainerElement element); - - boolean removeContainerElement(ContainerElement containerElement); -} \ No newline at end of file -- 2.11.4.GIT