mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
delete outputs corresponding to changed files for each target before running builders on it
This commit is contained in:
@@ -774,7 +774,7 @@ public class IncProjectBuilder {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean runBuildersForChunk(CompileContext context, final BuildTargetChunk chunk) throws ProjectBuildException, IOException {
|
||||
private boolean runBuildersForChunk(final CompileContext context, final BuildTargetChunk chunk) throws ProjectBuildException, IOException {
|
||||
Set<? extends BuildTarget<?>> targets = chunk.getTargets();
|
||||
if (targets.size() > 1) {
|
||||
Set<ModuleBuildTarget> moduleTargets = new HashSet<ModuleBuildTarget>();
|
||||
@@ -798,6 +798,11 @@ public class IncProjectBuilder {
|
||||
return runModuleLevelBuilders(context, new ModuleChunk(Collections.singleton((ModuleBuildTarget)target)));
|
||||
}
|
||||
|
||||
// In general the set of files corresponding to changed source file may be different
|
||||
// Need this for example, to keep up with case changes in file names for case-insensitive OSes:
|
||||
// deleting the output before copying is the only way to ensure the case of the output file's name is exactly the same as source file's case
|
||||
cleanOldOutputs(context, target);
|
||||
|
||||
final List<TargetBuilder<?, ?>> builders = BuilderRegistry.getInstance().getTargetBuilders();
|
||||
for (TargetBuilder<?, ?> builder : builders) {
|
||||
BuildOperations.buildTarget(target, context, builder);
|
||||
@@ -806,6 +811,18 @@ public class IncProjectBuilder {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static <T extends BuildRootDescriptor>
|
||||
void cleanOldOutputs(final CompileContext context, final BuildTarget<T> target) throws ProjectBuildException, IOException {
|
||||
if (!context.getScope().isBuildForced(target)) {
|
||||
BuildOperations.cleanOutputsCorrespondingToChangedFiles(context, new DirtyFilesHolderBase<T, BuildTarget<T>>(context) {
|
||||
public void processDirtyFiles(@NotNull FileProcessor<T, BuildTarget<T>> processor) throws IOException {
|
||||
context.getProjectDescriptor().fsState.processFilesToRecompile(context, target, processor);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateDoneFraction(CompileContext context, final float delta) {
|
||||
myTargetsProcessed += delta;
|
||||
float processed = myTargetsProcessed;
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.jps.incremental.resources;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.builders.BuildOutputConsumer;
|
||||
@@ -24,7 +23,10 @@ import org.jetbrains.jps.builders.DirtyFilesHolder;
|
||||
import org.jetbrains.jps.builders.FileProcessor;
|
||||
import org.jetbrains.jps.builders.java.ResourceRootDescriptor;
|
||||
import org.jetbrains.jps.builders.java.ResourcesTargetType;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.incremental.ProjectBuildException;
|
||||
import org.jetbrains.jps.incremental.ResourcesTarget;
|
||||
import org.jetbrains.jps.incremental.TargetBuilder;
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
import org.jetbrains.jps.incremental.messages.CompilerMessage;
|
||||
import org.jetbrains.jps.incremental.messages.ProgressMessage;
|
||||
@@ -60,11 +62,6 @@ public class ResourcesBuilder extends TargetBuilder<ResourceRootDescriptor, Reso
|
||||
if (!isResourceProcessingEnabled(target.getModule())) {
|
||||
return;
|
||||
}
|
||||
if (!SystemInfo.isFileSystemCaseSensitive) {
|
||||
// keep up with case changes in file names for case-insensitive OSes:
|
||||
// deleting the output before copying is the only way to ensure the case of the output file's name is exactly the same as source file's case
|
||||
BuildOperations.cleanOutputsCorrespondingToChangedFiles(context, holder);
|
||||
}
|
||||
|
||||
try {
|
||||
holder.processDirtyFiles(new FileProcessor<ResourceRootDescriptor, ResourcesTarget>() {
|
||||
|
||||
@@ -75,6 +75,22 @@ public abstract class JpsBuildTestCase extends UsefulTestCase {
|
||||
|
||||
protected Map<String, String> myBuildParams;
|
||||
|
||||
protected static void rename(String path, String newName) {
|
||||
try {
|
||||
File file = new File(FileUtil.toSystemDependentName(path));
|
||||
assertTrue("File " + file.getAbsolutePath() + " doesn't exist", file.exists());
|
||||
final File tempFile = new File(file.getParentFile(), "__" + newName);
|
||||
FileUtil.rename(file, tempFile);
|
||||
File newFile = new File(file.getParentFile(), newName);
|
||||
FileUtil.copyContent(tempFile, newFile);
|
||||
FileUtil.delete(tempFile);
|
||||
change(newFile.getPath());
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
+10
@@ -46,6 +46,16 @@ public class ResourceCopyingTest extends JpsBuildTestCase {
|
||||
assertOutput(m, fs().file("a.xml"));
|
||||
}
|
||||
|
||||
public void testCaseChange() {
|
||||
String file = createFile("src/a.xml");
|
||||
JpsModule m = addModule("m", PathUtil.getParentPath(file));
|
||||
rebuildAll();
|
||||
assertOutput(m, fs().file("a.xml"));
|
||||
rename(file, "A.xml");
|
||||
makeAll();
|
||||
assertOutput(m, fs().file("A.xml"));
|
||||
}
|
||||
|
||||
public void testPackagePrefix() {
|
||||
String file = createFile("src/a.xml");
|
||||
JpsModule m = addModule("m", PathUtil.getParentPath(file));
|
||||
|
||||
-16
@@ -32,7 +32,6 @@ import org.jetbrains.jps.model.library.JpsOrderRootType;
|
||||
import org.jetbrains.jps.util.JpsPathUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -136,19 +135,4 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
|
||||
assertDeletedAndCopied(ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
}
|
||||
|
||||
protected static void rename(String path, String newName) {
|
||||
try {
|
||||
File file = new File(FileUtil.toSystemDependentName(path));
|
||||
assertTrue("File " + file.getAbsolutePath() + " doesn't exist", file.exists());
|
||||
final File tempFile = new File(file.getParentFile(), "__" + newName);
|
||||
FileUtil.rename(file, tempFile);
|
||||
File newFile = new File(file.getParentFile(), newName);
|
||||
FileUtil.copyContent(tempFile, newFile);
|
||||
FileUtil.delete(tempFile);
|
||||
change(newFile.getPath());
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-8
@@ -1,6 +1,5 @@
|
||||
package org.jetbrains.jps.maven.compiler;
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -8,7 +7,6 @@ import org.jetbrains.jps.builders.BuildOutputConsumer;
|
||||
import org.jetbrains.jps.builders.DirtyFilesHolder;
|
||||
import org.jetbrains.jps.builders.FileProcessor;
|
||||
import org.jetbrains.jps.builders.storage.BuildDataPaths;
|
||||
import org.jetbrains.jps.incremental.BuildOperations;
|
||||
import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.incremental.ProjectBuildException;
|
||||
import org.jetbrains.jps.incremental.TargetBuilder;
|
||||
@@ -52,12 +50,6 @@ public class MavenResourcesBuilder extends TargetBuilder<MavenResourceRootDescri
|
||||
final JpsEncodingProjectConfiguration encodingConfig =
|
||||
JpsEncodingConfigurationService.getInstance().getEncodingConfiguration(target.getModule().getProject());
|
||||
|
||||
if (!SystemInfo.isFileSystemCaseSensitive) {
|
||||
// keep up with case changes in file names for case-insensitive OSes:
|
||||
// deleting the output before copying is the only way to ensure the case of the output file's name is exactly the same as source file's case
|
||||
BuildOperations.cleanOutputsCorrespondingToChangedFiles(context, holder);
|
||||
}
|
||||
|
||||
final Date timestamp = new Date();
|
||||
|
||||
holder.processDirtyFiles(new FileProcessor<MavenResourceRootDescriptor, MavenResourcesTarget>() {
|
||||
|
||||
Reference in New Issue
Block a user