mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
external compiler: extracted interface for source-to-output mapping
This commit is contained in:
@@ -9,10 +9,13 @@ import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.ProjectPaths;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Callbacks;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Mappings;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.incremental.FSOperations;
|
||||
import org.jetbrains.jps.incremental.ModuleBuildTarget;
|
||||
import org.jetbrains.jps.incremental.Utils;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.incremental.messages.ProgressMessage;
|
||||
import org.jetbrains.jps.incremental.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.jetbrains.jps.builders.storage;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface SourceToOutputMapping {
|
||||
void setOutputs(@NotNull String srcPath, @NotNull Collection<String> outputs) throws IOException;
|
||||
|
||||
void setOutput(@NotNull String srcPath, @NotNull String outputPath) throws IOException;
|
||||
|
||||
void appendOutput(@NotNull String srcPath, @NotNull String outputPath) throws IOException;
|
||||
|
||||
|
||||
void remove(@NotNull String srcPath) throws IOException;
|
||||
|
||||
void removeOutput(@NotNull String sourcePath, @NotNull String outputPath) throws IOException;
|
||||
|
||||
|
||||
@NotNull
|
||||
Collection<String> getSources() throws IOException;
|
||||
|
||||
@Nullable
|
||||
Collection<String> getOutputs(@NotNull String srcPath) throws IOException;
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.jps.builders.impl.BuildTargetChunk;
|
||||
import org.jetbrains.jps.builders.java.JavaBuilderUtil;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Callbacks;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.cmdline.BuildRunner;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
import org.jetbrains.jps.incremental.fs.BuildFSState;
|
||||
@@ -296,8 +297,8 @@ public class IncProjectBuilder {
|
||||
|
||||
public static void clearOutputFiles(CompileContext context, BuildTarget<?> target) throws IOException {
|
||||
final SourceToOutputMapping map = context.getProjectDescriptor().dataManager.getSourceToOutputMap(target);
|
||||
for (String srcPath : map.getKeys()) {
|
||||
final Collection<String> outs = map.getState(srcPath);
|
||||
for (String srcPath : map.getSources()) {
|
||||
final Collection<String> outs = map.getOutputs(srcPath);
|
||||
if (outs != null && !outs.isEmpty()) {
|
||||
for (String out : outs) {
|
||||
new File(out).delete();
|
||||
@@ -693,7 +694,7 @@ public class IncProjectBuilder {
|
||||
// actually delete outputs associated with removed paths
|
||||
for (String deletedSource : deletedPaths) {
|
||||
// deleting outputs corresponding to non-existing source
|
||||
final Collection<String> outputs = sourceToOutputStorage.getState(deletedSource);
|
||||
final Collection<String> outputs = sourceToOutputStorage.getOutputs(deletedSource);
|
||||
|
||||
if (outputs != null && !outputs.isEmpty()) {
|
||||
final JavaBuilderLogger logger = context.getLoggingManager().getJavaBuilderLogger();
|
||||
@@ -845,7 +846,7 @@ public class IncProjectBuilder {
|
||||
storageMap.put(target, srcToOut);
|
||||
}
|
||||
final String srcPath = FileUtil.toSystemIndependentName(file.getPath());
|
||||
final Collection<String> outputs = srcToOut.getState(srcPath);
|
||||
final Collection<String> outputs = srcToOut.getOutputs(srcPath);
|
||||
|
||||
if (outputs != null) {
|
||||
final JavaBuilderLogger logger = context.getLoggingManager().getJavaBuilderLogger();
|
||||
@@ -858,7 +859,7 @@ public class IncProjectBuilder {
|
||||
if (!outputs.isEmpty()) {
|
||||
context.processMessage(new FileDeletedEvent(outputs));
|
||||
}
|
||||
srcToOut.update(srcPath, Collections.<String>emptyList());
|
||||
srcToOut.setOutputs(srcPath, Collections.<String>emptyList());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -996,7 +997,7 @@ public class IncProjectBuilder {
|
||||
// handle deleted paths
|
||||
final BuildFSState fsState = pd.fsState;
|
||||
fsState.clearDeletedPaths(target);
|
||||
final SourceToOutputMapping sourceToOutputMap = pd.dataManager.getSourceToOutputMap(target);
|
||||
final SourceToOutputMappingImpl sourceToOutputMap = pd.dataManager.getSourceToOutputMap(target);
|
||||
for (final Iterator<String> it = sourceToOutputMap.getKeysIterator(); it.hasNext();) {
|
||||
final String path = it.next();
|
||||
// can check if the file exists
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ public class ArtifactSourceFilesState extends CompositeStorageOwner {
|
||||
final Set<File> currentPaths = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
|
||||
fsState.clearDeletedPaths(myTarget);
|
||||
markDirtyFiles(dataManager, currentPaths, false, context);
|
||||
final SourceToOutputMapping mapping = dataManager.getSourceToOutputMap(myTarget);
|
||||
final SourceToOutputMappingImpl mapping = dataManager.getSourceToOutputMap(myTarget);
|
||||
final Iterator<String> iterator = mapping.getKeysIterator();
|
||||
while (iterator.hasNext()) {
|
||||
String path = iterator.next();
|
||||
|
||||
+4
-4
@@ -9,6 +9,7 @@ import gnu.trove.TIntObjectHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.builders.BuildRootDescriptor;
|
||||
import org.jetbrains.jps.builders.BuildRootIndex;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.incremental.artifacts.impl.ArtifactSorter;
|
||||
@@ -18,7 +19,6 @@ import org.jetbrains.jps.incremental.fs.BuildFSState;
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
import org.jetbrains.jps.incremental.messages.CompilerMessage;
|
||||
import org.jetbrains.jps.incremental.messages.ProgressMessage;
|
||||
import org.jetbrains.jps.incremental.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifact;
|
||||
|
||||
import java.io.File;
|
||||
@@ -70,7 +70,7 @@ public class IncArtifactBuilder extends TargetBuilder<ArtifactBuildTarget> {
|
||||
final TIntObjectHashMap<Set<String>> filesToProcess = new TIntObjectHashMap<Set<String>>();
|
||||
MultiMap<String, String> filesToDelete = new MultiMap<String, String>();
|
||||
for (String sourcePath : deletedFiles) {
|
||||
final Collection<String> outputPaths = srcOutMapping.getState(sourcePath);
|
||||
final Collection<String> outputPaths = srcOutMapping.getOutputs(sourcePath);
|
||||
if (outputPaths != null) {
|
||||
for (String outputPath : outputPaths) {
|
||||
filesToDelete.putValue(outputPath, sourcePath);
|
||||
@@ -90,7 +90,7 @@ public class IncArtifactBuilder extends TargetBuilder<ArtifactBuildTarget> {
|
||||
for (File file : entry.getValue()) {
|
||||
String sourcePath = FileUtil.toSystemIndependentName(file.getPath());
|
||||
addFileToProcess(filesToProcess, rootIndex, sourcePath, deletedFiles);
|
||||
final Collection<String> outputPaths = srcOutMapping.getState(sourcePath);
|
||||
final Collection<String> outputPaths = srcOutMapping.getOutputs(sourcePath);
|
||||
if (outputPaths != null) {
|
||||
changedOutputPaths.addAll(outputPaths);
|
||||
for (String outputPath : outputPaths) {
|
||||
@@ -189,7 +189,7 @@ public class IncArtifactBuilder extends TargetBuilder<ArtifactBuildTarget> {
|
||||
outSrcMapping.remove(filePath);
|
||||
deletedPaths.add(filePath);
|
||||
for (String sourcePath : filesToDelete.get(filePath)) {
|
||||
srcOutMapping.removeValue(sourcePath, filePath);
|
||||
srcOutMapping.removeOutput(sourcePath, filePath);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -32,14 +32,16 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.JpsPathUtil;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.incremental.ProjectBuildException;
|
||||
import org.jetbrains.jps.incremental.artifacts.*;
|
||||
import org.jetbrains.jps.incremental.artifacts.ArtifactBuilderLogger;
|
||||
import org.jetbrains.jps.incremental.artifacts.ArtifactOutputToSourceMapping;
|
||||
import org.jetbrains.jps.incremental.artifacts.IncArtifactBuilder;
|
||||
import org.jetbrains.jps.incremental.artifacts.instructions.*;
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
import org.jetbrains.jps.incremental.messages.CompilerMessage;
|
||||
import org.jetbrains.jps.incremental.messages.ProgressMessage;
|
||||
import org.jetbrains.jps.incremental.storage.SourceToOutputMapping;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
@@ -168,7 +170,7 @@ public class JarsBuilder {
|
||||
else {
|
||||
final String filePath = FileUtil.toSystemIndependentName(descriptor.getRootFile().getAbsolutePath());
|
||||
logger.fileCopied(filePath);
|
||||
mySrcOutMapping.appendData(filePath, Collections.singletonList(targetJarPath));
|
||||
mySrcOutMapping.appendOutput(filePath, targetJarPath);
|
||||
myOutSrcMapping.appendData(targetJarPath, Collections
|
||||
.singletonList(new ArtifactOutputToSourceMapping.SourcePathAndRootIndex(filePath, rootIndex)));
|
||||
extractFileAndAddToJar(jarOutputStream, (JarBasedArtifactRootDescriptor)descriptor, relativePath, writtenPaths);
|
||||
@@ -214,7 +216,7 @@ public class JarsBuilder {
|
||||
if (manifestFile.exists()) {
|
||||
final String fullManifestPath = FileUtil.toSystemIndependentName(manifestFile.getAbsolutePath());
|
||||
myContext.getLoggingManager().getArtifactBuilderLogger().fileCopied(fullManifestPath);
|
||||
mySrcOutMapping.appendData(fullManifestPath, Collections.singletonList(targetJarPath));
|
||||
mySrcOutMapping.appendOutput(fullManifestPath, targetJarPath);
|
||||
//noinspection IOResourceOpenedButNotSafelyClosed
|
||||
return createManifest(new FileInputStream(manifestFile), manifestFile);
|
||||
}
|
||||
@@ -320,7 +322,7 @@ public class JarsBuilder {
|
||||
if (rootIndex != -1) {
|
||||
myOutSrcMapping.appendData(targetJarPath, Collections.singletonList(new ArtifactOutputToSourceMapping.SourcePathAndRootIndex(filePath, rootIndex)));
|
||||
if (added) {
|
||||
mySrcOutMapping.appendData(filePath, Collections.singletonList(targetJarPath));
|
||||
mySrcOutMapping.appendOutput(filePath, targetJarPath);
|
||||
myContext.getLoggingManager().getArtifactBuilderLogger().fileCopied(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,10 +2,10 @@ package org.jetbrains.jps.incremental.artifacts.instructions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.builders.BuildRootDescriptor;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.incremental.artifacts.ArtifactBuildTarget;
|
||||
import org.jetbrains.jps.incremental.artifacts.ArtifactOutputToSourceMapping;
|
||||
import org.jetbrains.jps.incremental.storage.SourceToOutputMapping;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
+2
-2
@@ -3,10 +3,10 @@ package org.jetbrains.jps.incremental.artifacts.instructions;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.JpsPathUtil;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.incremental.artifacts.ArtifactBuildTarget;
|
||||
import org.jetbrains.jps.incremental.artifacts.ArtifactOutputToSourceMapping;
|
||||
import org.jetbrains.jps.incremental.storage.SourceToOutputMapping;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -48,7 +48,7 @@ public class FileBasedArtifactRootDescriptor extends ArtifactRootDescriptor {
|
||||
context.getLoggingManager().getArtifactBuilderLogger().fileCopied(filePath);
|
||||
final File targetFile = new File(FileUtil.toSystemDependentName(targetPath));
|
||||
FileUtil.copyContent(file, targetFile);
|
||||
srcOutMapping.appendData(filePath, Collections.singletonList(targetPath));
|
||||
srcOutMapping.appendOutput(filePath, targetPath);
|
||||
}
|
||||
outSrcMapping.appendData(targetPath, Collections.singletonList(new ArtifactOutputToSourceMapping.SourcePathAndRootIndex(filePath, rootIndex)));
|
||||
}
|
||||
|
||||
+2
-2
@@ -5,11 +5,11 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.JpsPathUtil;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.incremental.artifacts.ArtifactBuildTarget;
|
||||
import org.jetbrains.jps.incremental.artifacts.ArtifactOutputToSourceMapping;
|
||||
import org.jetbrains.jps.incremental.artifacts.JarPathUtil;
|
||||
import org.jetbrains.jps.incremental.storage.SourceToOutputMapping;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Collections;
|
||||
@@ -89,7 +89,7 @@ public class JarBasedArtifactRootDescriptor extends ArtifactRootDescriptor {
|
||||
from.close();
|
||||
to.close();
|
||||
}
|
||||
srcOutMapping.appendData(filePath, Collections.singletonList(fullOutputPath));
|
||||
srcOutMapping.appendOutput(filePath, fullOutputPath);
|
||||
}
|
||||
outSrcMapping.appendData(fullOutputPath, Collections.singletonList(new ArtifactOutputToSourceMapping.SourcePathAndRootIndex(fullSourcePath, rootIndex)));
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
isTemp = rootDescriptor.isTemp;
|
||||
if (!isTemp) {
|
||||
try {
|
||||
dataManager.getSourceToOutputMap(rootDescriptor.target).appendData(sourcePath, outputPath);
|
||||
dataManager.getSourceToOutputMap(rootDescriptor.target).appendOutput(sourcePath, outputPath);
|
||||
}
|
||||
catch (Exception e) {
|
||||
context.processMessage(new CompilerMessage(BUILDER_NAME, e));
|
||||
|
||||
@@ -6,11 +6,11 @@ import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.jps.JpsPathUtil;
|
||||
import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
import org.jetbrains.jps.incremental.messages.CompilerMessage;
|
||||
import org.jetbrains.jps.incremental.messages.ProgressMessage;
|
||||
import org.jetbrains.jps.incremental.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.service.JpsServiceManager;
|
||||
@@ -113,7 +113,7 @@ public class ResourcesBuilder extends ModuleLevelBuilder {
|
||||
final String outputPath = targetPath.toString();
|
||||
FileUtil.copyContent(file, new File(outputPath));
|
||||
try {
|
||||
outputToSourceMapping.update(file.getPath(), outputPath);
|
||||
outputToSourceMapping.setOutput(file.getPath(), outputPath);
|
||||
}
|
||||
catch (Exception e) {
|
||||
context.processMessage(new CompilerMessage(BUILDER_NAME, e));
|
||||
|
||||
@@ -25,7 +25,7 @@ public class BuildDataManager implements StorageOwner {
|
||||
private static final String MAPPINGS_STORAGE = "mappings";
|
||||
|
||||
private final Object mySourceToOutputLock = new Object();
|
||||
private final Map<BuildTarget<?>, SourceToOutputMapping> mySourceToOutputs = new HashMap<BuildTarget<?>, SourceToOutputMapping>();
|
||||
private final Map<BuildTarget<?>, SourceToOutputMappingImpl> mySourceToOutputs = new HashMap<BuildTarget<?>, SourceToOutputMappingImpl>();
|
||||
|
||||
private final SourceToFormMapping mySrcToFormMap;
|
||||
private final ArtifactsBuildData myArtifactsBuildData;
|
||||
@@ -49,12 +49,12 @@ public class BuildDataManager implements StorageOwner {
|
||||
return new File(myDataStorageRoot, "output-roots");
|
||||
}
|
||||
|
||||
public SourceToOutputMapping getSourceToOutputMap(final BuildTarget<?> target) throws IOException {
|
||||
SourceToOutputMapping mapping;
|
||||
public SourceToOutputMappingImpl getSourceToOutputMap(final BuildTarget<?> target) throws IOException {
|
||||
SourceToOutputMappingImpl mapping;
|
||||
synchronized (mySourceToOutputLock) {
|
||||
mapping = mySourceToOutputs.get(target);
|
||||
if (mapping == null) {
|
||||
mapping = new SourceToOutputMapping(new File(myTargetsState.getTargetDataRoot(target), "src-out" + File.separator + "data"));
|
||||
mapping = new SourceToOutputMappingImpl(new File(myTargetsState.getTargetDataRoot(target), "src-out" + File.separator + "data"));
|
||||
mySourceToOutputs.put(target, mapping);
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class BuildDataManager implements StorageOwner {
|
||||
public void flush(boolean memoryCachesOnly) {
|
||||
myArtifactsBuildData.flush(memoryCachesOnly);
|
||||
synchronized (mySourceToOutputLock) {
|
||||
for (SourceToOutputMapping mapping : mySourceToOutputs.values()) {
|
||||
for (SourceToOutputMappingImpl mapping : mySourceToOutputs.values()) {
|
||||
mapping.flush(memoryCachesOnly);
|
||||
}
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public class BuildDataManager implements StorageOwner {
|
||||
synchronized (mySourceToOutputLock) {
|
||||
for (BuildTargetChunk chunk : chunks) {
|
||||
for (BuildTarget<?> target : chunk.getTargets()) {
|
||||
final SourceToOutputMapping mapping = mySourceToOutputs.remove(target);
|
||||
final SourceToOutputMappingImpl mapping = mySourceToOutputs.remove(target);
|
||||
if (mapping != null) {
|
||||
mapping.close();
|
||||
}
|
||||
@@ -185,7 +185,7 @@ public class BuildDataManager implements StorageOwner {
|
||||
private void closeSourceToOutputStorages() throws IOException {
|
||||
IOException ex = null;
|
||||
try {
|
||||
for (SourceToOutputMapping mapping : mySourceToOutputs.values()) {
|
||||
for (SourceToOutputMappingImpl mapping : mySourceToOutputs.values()) {
|
||||
try {
|
||||
mapping.close();
|
||||
}
|
||||
|
||||
+21
-10
@@ -5,6 +5,7 @@ import com.intellij.util.io.DataExternalizer;
|
||||
import com.intellij.util.io.IOUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
@@ -18,26 +19,29 @@ import java.util.List;
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 10/7/11
|
||||
*/
|
||||
public final class SourceToOutputMapping extends AbstractStateStorage<String, Collection<String>> {
|
||||
public final class SourceToOutputMappingImpl extends AbstractStateStorage<String, Collection<String>> implements SourceToOutputMapping {
|
||||
|
||||
public SourceToOutputMapping(File storePath) throws IOException {
|
||||
public SourceToOutputMappingImpl(File storePath) throws IOException {
|
||||
super(storePath, new PathStringDescriptor(), new StringCollectionExternalizer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull String srcPath, @NotNull Collection<String> outputs) throws IOException {
|
||||
public void setOutputs(@NotNull String srcPath, @NotNull Collection<String> outputs) throws IOException {
|
||||
super.update(FileUtil.toSystemIndependentName(srcPath), normalizePaths(outputs));
|
||||
}
|
||||
|
||||
public void update(@NotNull String srcPath, @NotNull String outputPath) throws IOException {
|
||||
@Override
|
||||
public void setOutput(@NotNull String srcPath, @NotNull String outputPath) throws IOException {
|
||||
super.update(FileUtil.toSystemIndependentName(srcPath), Collections.singleton(FileUtil.toSystemIndependentName(outputPath)));
|
||||
}
|
||||
|
||||
public void appendData(String srcPath, String outputPath) throws IOException {
|
||||
@Override
|
||||
public void appendOutput(@NotNull String srcPath, @NotNull String outputPath) throws IOException {
|
||||
super.appendData(FileUtil.toSystemIndependentName(srcPath), Collections.singleton(FileUtil.toSystemIndependentName(outputPath)));
|
||||
}
|
||||
|
||||
public void appendData(String srcPath, Collection<String> data) throws IOException {
|
||||
@Override
|
||||
public void appendData(@NotNull String srcPath, @NotNull Collection<String> data) throws IOException {
|
||||
super.appendData(FileUtil.toSystemIndependentName(srcPath), normalizePaths(data));
|
||||
}
|
||||
|
||||
@@ -48,10 +52,16 @@ public final class SourceToOutputMapping extends AbstractStateStorage<String, Co
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Collection<String> getState(@NotNull String srcPath) throws IOException {
|
||||
public Collection<String> getOutputs(@NotNull String srcPath) throws IOException {
|
||||
return super.getState(FileUtil.toSystemIndependentName(srcPath));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<String> getSources() throws IOException {
|
||||
return getKeys();
|
||||
}
|
||||
|
||||
private static Collection<String> normalizePaths(Collection<String> outputs) {
|
||||
Collection<String> normalized = new ArrayList<String>(outputs.size());
|
||||
for (String out : outputs) {
|
||||
@@ -60,15 +70,16 @@ public final class SourceToOutputMapping extends AbstractStateStorage<String, Co
|
||||
return normalized;
|
||||
}
|
||||
|
||||
public void removeValue(String sourcePath, String outputPath) throws IOException {
|
||||
final Collection<String> outputPaths = getState(FileUtil.toSystemIndependentName(sourcePath));
|
||||
@Override
|
||||
public void removeOutput(@NotNull String sourcePath, @NotNull String outputPath) throws IOException {
|
||||
final Collection<String> outputPaths = getOutputs(FileUtil.toSystemIndependentName(sourcePath));
|
||||
if (outputPaths != null) {
|
||||
outputPaths.remove(FileUtil.toSystemIndependentName(outputPath));
|
||||
if (outputPaths.isEmpty()) {
|
||||
remove(sourcePath);
|
||||
}
|
||||
else {
|
||||
update(sourcePath, outputPaths);
|
||||
setOutputs(sourcePath, outputPaths);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.android.model.JpsAndroidModuleExtension;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.incremental.java.FormsParsing;
|
||||
@@ -28,7 +29,6 @@ import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
import org.jetbrains.jps.incremental.messages.CompilerMessage;
|
||||
import org.jetbrains.jps.incremental.messages.ProgressMessage;
|
||||
import org.jetbrains.jps.incremental.storage.BuildDataManager;
|
||||
import org.jetbrains.jps.incremental.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.model.java.JpsJavaClasspathKind;
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
|
||||
import org.jetbrains.jps.model.module.JpsDependencyElement;
|
||||
@@ -422,7 +422,7 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
else {
|
||||
final SourceToOutputMapping sourceToOutputMap = context.getProjectDescriptor().dataManager.getSourceToOutputMap(buildTarget);
|
||||
sourceToOutputMap.update(filePath, outputFilePath);
|
||||
sourceToOutputMap.setOutput(filePath, outputFilePath);
|
||||
FSOperations.markDirty(context, outputFile);
|
||||
}
|
||||
}
|
||||
@@ -505,7 +505,7 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder {
|
||||
final List<String> newFilePaths = Arrays.asList(AndroidJpsUtil.toPaths(newFiles.toArray(new File[newFiles.size()])));
|
||||
|
||||
final SourceToOutputMapping sourceToOutputMap = dataManager.getSourceToOutputMap(buildTarget);
|
||||
sourceToOutputMap.update(filePath, newFilePaths);
|
||||
sourceToOutputMap.setOutputs(filePath, newFilePaths);
|
||||
|
||||
for (File newFile : newFiles) {
|
||||
FSOperations.markDirty(context, newFile);
|
||||
|
||||
+4
-4
@@ -14,6 +14,7 @@ import org.jetbrains.jps.builders.BuildRootIndex;
|
||||
import org.jetbrains.jps.builders.java.JavaBuilderUtil;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Callbacks;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Mappings;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.cmdline.ClasspathBootstrap;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
@@ -23,7 +24,6 @@ import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
import org.jetbrains.jps.incremental.messages.CompilerMessage;
|
||||
import org.jetbrains.jps.incremental.messages.FileGeneratedEvent;
|
||||
import org.jetbrains.jps.incremental.messages.ProgressMessage;
|
||||
import org.jetbrains.jps.incremental.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.javac.OutputFileObject;
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
|
||||
import org.jetbrains.jps.model.java.JpsJavaSdkType;
|
||||
@@ -267,7 +267,7 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
final RootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, new File(sourcePath));
|
||||
if (moduleAndRoot != null) {
|
||||
final ModuleBuildTarget target = moduleAndRoot.target;
|
||||
context.getProjectDescriptor().dataManager.getSourceToOutputMap(target).appendData(sourcePath, outputPath);
|
||||
context.getProjectDescriptor().dataManager.getSourceToOutputMap(target).appendOutput(sourcePath, outputPath);
|
||||
String moduleOutputPath = generationOutputs.get(target);
|
||||
generatedEvent.add(moduleOutputPath, FileUtil.getRelativePath(moduleOutputPath, outputPath, '/'));
|
||||
}
|
||||
@@ -312,10 +312,10 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
for (ModuleBuildTarget target : chunk.getTargets()) {
|
||||
String moduleOutputPath = finalOutputs.get(target);
|
||||
final SourceToOutputMapping srcToOut = context.getProjectDescriptor().dataManager.getSourceToOutputMap(target);
|
||||
for (String src : srcToOut.getKeys()) {
|
||||
for (String src : srcToOut.getSources()) {
|
||||
if (!toCompilePaths.contains(src) && isGroovyFile(src) &&
|
||||
!configuration.getCompilerExcludes().isExcluded(new File(src))) {
|
||||
final Collection<String> outs = srcToOut.getState(src);
|
||||
final Collection<String> outs = srcToOut.getOutputs(src);
|
||||
if (outs != null) {
|
||||
for (String out : outs) {
|
||||
if (out.endsWith(".class") && out.startsWith(moduleOutputPath)) {
|
||||
|
||||
Reference in New Issue
Block a user