diff --git a/java/compiler/impl/src/com/intellij/compiler/ant/artifacts/ArchiveAntCopyInstructionCreator.java b/java/compiler/impl/src/com/intellij/compiler/ant/artifacts/ArchiveAntCopyInstructionCreator.java index 1857676997c0..4ede60c941b9 100644 --- a/java/compiler/impl/src/com/intellij/compiler/ant/artifacts/ArchiveAntCopyInstructionCreator.java +++ b/java/compiler/impl/src/com/intellij/compiler/ant/artifacts/ArchiveAntCopyInstructionCreator.java @@ -53,8 +53,7 @@ public class ArchiveAntCopyInstructionCreator implements AntCopyInstructionCreat @NotNull @Override - public Generator createExtractedDirectoryInstruction(@NotNull String jarPath, @NotNull String pathInJar) { - final String pattern = pathInJar.length() == 0 ? null : pathInJar + "**"; - return ZipFileSet.createUnpackedSet(jarPath, pathInJar, true, pattern); + public Generator createExtractedDirectoryInstruction(@NotNull String jarPath) { + return ZipFileSet.createUnpackedSet(jarPath, myPrefix, true); } } diff --git a/java/compiler/impl/src/com/intellij/compiler/ant/artifacts/DirectoryAntCopyInstructionCreator.java b/java/compiler/impl/src/com/intellij/compiler/ant/artifacts/DirectoryAntCopyInstructionCreator.java index 0d8d08c4a41a..900dff463d4f 100644 --- a/java/compiler/impl/src/com/intellij/compiler/ant/artifacts/DirectoryAntCopyInstructionCreator.java +++ b/java/compiler/impl/src/com/intellij/compiler/ant/artifacts/DirectoryAntCopyInstructionCreator.java @@ -58,13 +58,7 @@ public class DirectoryAntCopyInstructionCreator implements AntCopyInstructionCre @NotNull @Override - public Generator createExtractedDirectoryInstruction(@NotNull String jarPath, @NotNull String pathInJar) { - final Unzip unzip = new Unzip(jarPath, myOutputDirectory); - if (pathInJar.length() > 0) { - final PatternSet patterns = new PatternSet(null); - patterns.add(new Include(pathInJar + "**")); - unzip.add(patterns); - } - return unzip; + public Generator createExtractedDirectoryInstruction(@NotNull String jarPath) { + return new Unzip(jarPath, myOutputDirectory); } } diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/elements/ExtractedDirectoryPackagingElement.java b/java/compiler/impl/src/com/intellij/packaging/impl/elements/ExtractedDirectoryPackagingElement.java index 32ccc9396a19..112f8c4cf95c 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/elements/ExtractedDirectoryPackagingElement.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/elements/ExtractedDirectoryPackagingElement.java @@ -15,7 +15,12 @@ */ package com.intellij.packaging.impl.elements; +import com.intellij.compiler.ant.BuildProperties; import com.intellij.compiler.ant.Generator; +import com.intellij.compiler.ant.taskdefs.Include; +import com.intellij.compiler.ant.taskdefs.Mkdir; +import com.intellij.compiler.ant.taskdefs.PatternSet; +import com.intellij.compiler.ant.taskdefs.Unzip; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.JarFileSystem; @@ -25,6 +30,7 @@ import com.intellij.packaging.elements.*; import com.intellij.packaging.impl.ui.ExtractedDirectoryPresentation; import com.intellij.packaging.ui.ArtifactEditorContext; import com.intellij.packaging.ui.PackagingElementPresentation; +import com.intellij.util.PathUtil; import com.intellij.util.xmlb.annotations.Attribute; import org.jetbrains.annotations.NotNull; @@ -73,7 +79,23 @@ public class ExtractedDirectoryPackagingElement extends FileOrDirectoryCopyPacka @NotNull ArtifactAntGenerationContext generationContext, @NotNull ArtifactType artifactType) { final String jarPath = generationContext.getSubstitutedPath(myFilePath); - return Collections.singletonList(creator.createExtractedDirectoryInstruction(jarPath, StringUtil.trimStart(myPathInJar, "/"))); + final String pathInJar = StringUtil.trimStart(myPathInJar, "/"); + if (pathInJar.length() == 0) { + return Collections.singletonList(creator.createExtractedDirectoryInstruction(jarPath)); + } + + final String archiveName = PathUtil.getFileName(myFilePath); + final String tempDirProperty = generationContext.createNewTempFileProperty("temp.unpacked.path." + archiveName, archiveName); + final String tempDirPath = BuildProperties.propertyRef(tempDirProperty); + generationContext.runBeforeCurrentArtifact(new Mkdir(tempDirPath)); + + final Unzip unzip = new Unzip(jarPath, tempDirPath); + final PatternSet patterns = new PatternSet(null); + patterns.add(new Include(pathInJar + "**")); + unzip.add(patterns); + generationContext.runBeforeCurrentArtifact(unzip); + + return Collections.singletonList(creator.createDirectoryContentCopyInstruction(tempDirPath + "/" + pathInJar)); } diff --git a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/ZipFileSet.java b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/ZipFileSet.java index 9970a9d004d5..a11b9512d4aa 100644 --- a/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/ZipFileSet.java +++ b/java/compiler/openapi/src/com/intellij/compiler/ant/taskdefs/ZipFileSet.java @@ -43,11 +43,10 @@ public class ZipFileSet extends Tag{ pair("prefix", prefix(isDir, relativePath))); } - public static ZipFileSet createUnpackedSet(@NonNls String zipFilePath, @NotNull String relativePath, final boolean isDir, String pattern) { + public static ZipFileSet createUnpackedSet(@NonNls String zipFilePath, @NotNull String relativePath, final boolean isDir) { return new ZipFileSet("zipfileset", pair("src", zipFilePath), - pair("prefix", prefix(isDir, relativePath)), - pair("includes", pattern)); + pair("prefix", prefix(isDir, relativePath))); } @Nullable diff --git a/java/compiler/openapi/src/com/intellij/packaging/elements/AntCopyInstructionCreator.java b/java/compiler/openapi/src/com/intellij/packaging/elements/AntCopyInstructionCreator.java index 0c20bb61c4b8..fc0eb0370480 100644 --- a/java/compiler/openapi/src/com/intellij/packaging/elements/AntCopyInstructionCreator.java +++ b/java/compiler/openapi/src/com/intellij/packaging/elements/AntCopyInstructionCreator.java @@ -38,5 +38,5 @@ public interface AntCopyInstructionCreator { Generator createSubFolderCommand(@NotNull String directoryName); @NotNull - Generator createExtractedDirectoryInstruction(@NotNull String jarPath, @NotNull String pathInJar); + Generator createExtractedDirectoryInstruction(@NotNull String jarPath); }