obsolete code removed

This commit is contained in:
nik
2009-10-29 10:22:16 +03:00
parent aa0af0014d
commit 32640c800e
17 changed files with 6 additions and 974 deletions
@@ -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);
@@ -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<ZipFileSet> zipFileSetTags = new ArrayList<ZipFileSet>();
buildRecipe.visitInstructions(new BuildInstructionVisitor() {
public boolean visitInstruction(final BuildInstruction instruction) throws Exception {
for (final ExplodedAndJarBuildGenerator generator : generators) {
final Ref<Boolean> ref = new Ref<Boolean>(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<Boolean> 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<Tag> prepareTags = new ArrayList<Tag>();
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);
}
}
@@ -16,26 +16,12 @@
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.io.File;
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");
@@ -58,119 +44,6 @@ public class CompoundBuildInstructionImpl extends BuildInstructionBase implement
return visitor.visitCompoundBuildInstruction(this);
}
public void addFilesToJar(@NotNull final CompileContext context,
@NotNull final File jarFile,
@NotNull final JarOutputStream outputStream,
BuildRecipe dependencies,
@Nullable final Set<String> 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<String> tempWrittenRelativePaths = new THashSet<String>();
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);
}
@@ -183,24 +56,6 @@ public class CompoundBuildInstructionImpl extends BuildInstructionBase implement
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> file = new Ref<File>();
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<File> filesToDelete) {
super.collectFilesToDelete(filesToDelete);
BuildRecipe childInstructions = getChildInstructions(null);
@@ -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<String> 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) {
@@ -15,26 +15,14 @@
*/
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.compiler.make.BuildInstructionVisitor;
import com.intellij.openapi.compiler.make.JarAndCopyBuildInstruction;
import com.intellij.openapi.compiler.make.PackagingFileFilter;
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;
import java.io.File;
/**
* Created by IntelliJ IDEA.
@@ -44,9 +32,6 @@ import java.util.jar.JarFile;
* To change this template use File | Settings | File Templates.
*/
public class JarAndCopyBuildInstructionImpl extends FileCopyInstructionImpl implements JarAndCopyBuildInstruction {
private File myJarFile;
private final List<File> myTempJars = new ArrayList<File>(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);
@@ -56,63 +41,6 @@ public class JarAndCopyBuildInstructionImpl extends FileCopyInstructionImpl impl
super(directoryToJar, false, module, outputRelativePath);
}
public void addFilesToJar(@NotNull CompileContext context,
@NotNull File jarFile,
@NotNull JarOutputStream outputStream,
BuildRecipe dependencies,
@Nullable Set<String> 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<String> writtenPaths = new THashSet<String>();
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);
}
@@ -121,12 +49,4 @@ public class JarAndCopyBuildInstructionImpl extends FileCopyInstructionImpl impl
return "JAR and copy: " + getFile() + "->"+getOutputRelativePath();
}
public File getJarFile() {
return myJarFile;
}
public void deleteTemporaryJars() {
FileUtil.asyncDelete(myTempJars);
myTempJars.clear();
}
}
@@ -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<File> 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<String> classpathElements = getExternalDependenciesClasspath(buildRecipe);
final Manifest manifest = new Manifest();
setManifestAttributes(manifest.getMainAttributes(), classpathElements);
return manifest;
}
public static void setManifestAttributes(final Attributes mainAttributes, final @Nullable List<String> classpathElements) {
if (classpathElements != null && classpathElements.size() > 0) {
StringBuilder builder;
@@ -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<PackagingMethod, String> methodToDescriptionForDirs = new HashMap<PackagingMethod, String>();
private static final Map<PackagingMethod, String> methodToDescriptionForFiles = new HashMap<PackagingMethod, String>();
@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<String> getUrls() {
fixLibraryInfo();
return myLibraryInfo.getUrls();
@@ -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<PackagingMethod, String> methodToDescription = new HashMap<PackagingMethod, String>();
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;
}
@@ -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<String,String> attributes = new HashMap<String, String>();
@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<String> 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<String, String> getAttributes() {
return attributes;
}
}
@@ -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<ContainerElement> myContents = new LinkedHashSet<ContainerElement>();
@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<ContainerElement> 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<Element> 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<ModuleLink> moduleLinks = new ArrayList<ModuleLink>();
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<LibraryLink> libraryLinks = new ArrayList<LibraryLink>();
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<ContainerElement> result = new ArrayList<ContainerElement>();
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<Module> result = new ArrayList<Module>(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<ContainerElement> 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);
}
}
@@ -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
@@ -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<String> writtenRelativePaths,
@Nullable FileFilter fileFilter) throws IOException;
boolean accept(BuildInstructionVisitor visitor) throws Exception;
boolean isExternalDependencyInstruction();
File findFileByRelativePath(String relativePath);
}
@@ -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();
}
@@ -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();
}
@@ -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);
}
@@ -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<ContainerElement> {
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();
}
}
@@ -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);
}