mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
external artifact builder: ensure that out-src mapping stores system-independent paths
This commit is contained in:
+38
@@ -15,14 +15,18 @@
|
||||
*/
|
||||
package org.jetbrains.jps.incremental.artifacts;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.io.DataExternalizer;
|
||||
import com.intellij.util.io.IOUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.incremental.storage.AbstractStateStorage;
|
||||
import org.jetbrains.jps.incremental.storage.PathStringDescriptor;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -35,6 +39,40 @@ public class ArtifactOutputToSourceMapping extends AbstractStateStorage<String,
|
||||
super(storePath, new PathStringDescriptor(), new SourcePathListExternalizer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String path, @Nullable List<SourcePathAndRootIndex> state) throws IOException {
|
||||
super.update(FileUtil.toSystemIndependentName(path), normalize(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendData(String path, List<SourcePathAndRootIndex> data) throws IOException {
|
||||
super.appendData(FileUtil.toSystemIndependentName(path), normalize(data));
|
||||
}
|
||||
|
||||
private static List<SourcePathAndRootIndex> normalize(List<SourcePathAndRootIndex> data) {
|
||||
if (data.isEmpty()) return Collections.emptyList();
|
||||
List<SourcePathAndRootIndex> normalized = new ArrayList<SourcePathAndRootIndex>(data.size());
|
||||
for (SourcePathAndRootIndex pair : data) {
|
||||
normalized.add(new SourcePathAndRootIndex(FileUtil.toSystemIndependentName(pair.getPath()), pair.getRootIndex()));
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
public void appendData(String outputPath, int rootIndex, String sourcePath) throws IOException {
|
||||
super.appendData(outputPath, Collections.singletonList(new SourcePathAndRootIndex(FileUtil.toSystemIndependentName(sourcePath), rootIndex)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(String path) throws IOException {
|
||||
super.remove(FileUtil.toSystemIndependentName(path));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<SourcePathAndRootIndex> getState(String path) throws IOException {
|
||||
return super.getState(FileUtil.toSystemIndependentName(path));
|
||||
}
|
||||
|
||||
public static class SourcePathAndRootIndex {
|
||||
private final String myPath;
|
||||
private final int myRootIndex;
|
||||
|
||||
+1
-1
@@ -221,7 +221,7 @@ public class IncArtifactBuilder extends TargetBuilder<ArtifactRootDescriptor, Ar
|
||||
|
||||
boolean deleted = deletedPaths.contains(filePath);
|
||||
if (!deleted) {
|
||||
deleted = FileUtil.delete(new File(FileUtil.toSystemDependentName(filePath)));
|
||||
deleted = FileUtil.delete(new File(filePath));
|
||||
}
|
||||
|
||||
if (deleted) {
|
||||
|
||||
@@ -169,8 +169,7 @@ public class JarsBuilder {
|
||||
else {
|
||||
final String filePath = FileUtil.toSystemIndependentName(descriptor.getRootFile().getAbsolutePath());
|
||||
packedFilePaths.add(filePath);
|
||||
myOutSrcMapping.appendData(targetJarPath, Collections
|
||||
.singletonList(new ArtifactOutputToSourceMapping.SourcePathAndRootIndex(filePath, rootIndex)));
|
||||
myOutSrcMapping.appendData(targetJarPath, rootIndex, filePath);
|
||||
extractFileAndAddToJar(jarOutputStream, (JarBasedArtifactRootDescriptor)descriptor, relativePath, writtenPaths);
|
||||
}
|
||||
}
|
||||
@@ -350,7 +349,7 @@ public class JarsBuilder {
|
||||
|
||||
final boolean added = ZipUtil.addFileToZip(jarOutputStream, file, relativePath, writtenItemRelativePaths, null);
|
||||
if (rootIndex != -1) {
|
||||
myOutSrcMapping.appendData(targetJarPath, Collections.singletonList(new ArtifactOutputToSourceMapping.SourcePathAndRootIndex(filePath, rootIndex)));
|
||||
myOutSrcMapping.appendData(targetJarPath, rootIndex, filePath);
|
||||
if (added) {
|
||||
packedFilePaths.add(filePath);
|
||||
}
|
||||
|
||||
+1
-1
@@ -84,6 +84,6 @@ public class FileBasedArtifactRootDescriptor extends ArtifactRootDescriptor {
|
||||
else if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Target path " + targetPath + " is already registered so " + filePath + " won't be copied");
|
||||
}
|
||||
outSrcMapping.appendData(targetPath, Collections.singletonList(new ArtifactOutputToSourceMapping.SourcePathAndRootIndex(filePath, rootIndex)));
|
||||
outSrcMapping.appendData(targetPath, rootIndex, filePath);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ public class JarBasedArtifactRootDescriptor extends ArtifactRootDescriptor {
|
||||
processEntries(new EntryProcessor() {
|
||||
@Override
|
||||
public void process(@Nullable InputStream inputStream, @NotNull String relativePath, ZipEntry entry) throws IOException {
|
||||
final String fullOutputPath = FileUtil.toSystemIndependentName(JpsArtifactPathUtil.appendToPath(outputPath, relativePath));
|
||||
final String fullOutputPath = JpsArtifactPathUtil.appendToPath(outputPath, relativePath);
|
||||
final File outputFile = new File(fullOutputPath);
|
||||
|
||||
FileUtil.createParentDirs(outputFile);
|
||||
@@ -111,7 +111,7 @@ public class JarBasedArtifactRootDescriptor extends ArtifactRootDescriptor {
|
||||
}
|
||||
outputConsumer.registerOutputFile(outputFile, Collections.singletonList(filePath));
|
||||
}
|
||||
outSrcMapping.appendData(fullOutputPath, Collections.singletonList(new ArtifactOutputToSourceMapping.SourcePathAndRootIndex(filePath, rootIndex)));
|
||||
outSrcMapping.appendData(fullOutputPath, rootIndex, filePath);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user