mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
external build: accept only compilable files by file filter for ModuleBuildTarget
This commit is contained in:
@@ -18,6 +18,7 @@ package org.jetbrains.jps.builders.java;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.builders.BuildRootDescriptor;
|
||||
import org.jetbrains.jps.incremental.BuilderRegistry;
|
||||
import org.jetbrains.jps.incremental.ModuleBuildTarget;
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
|
||||
import org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes;
|
||||
@@ -93,10 +94,11 @@ public class JavaSourceRootDescriptor extends BuildRootDescriptor {
|
||||
@Override
|
||||
public FileFilter createFileFilter() {
|
||||
final JpsCompilerExcludes excludes = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(target.getModule().getProject()).getCompilerExcludes();
|
||||
final FileFilter baseFilter = BuilderRegistry.getInstance().getModuleBuilderFileFilter();
|
||||
return new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
return !excludes.isExcluded(file);
|
||||
return baseFilter.accept(file) && !excludes.isExcluded(file);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,10 +16,16 @@
|
||||
package org.jetbrains.jps.incremental;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.builders.BuildTargetType;
|
||||
import org.jetbrains.jps.service.JpsServiceManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -34,6 +40,7 @@ public class BuilderRegistry {
|
||||
private final Map<BuilderCategory, List<ModuleLevelBuilder>> myModuleLevelBuilders = new HashMap<BuilderCategory, List<ModuleLevelBuilder>>();
|
||||
private final List<TargetBuilder<?,?>> myTargetBuilders = new ArrayList<TargetBuilder<?,?>>();
|
||||
private final Map<String, BuildTargetType<?>> myTargetTypes = new LinkedHashMap<String, BuildTargetType<?>>();
|
||||
private final FileFilter myModuleBuilderFileFilter;
|
||||
|
||||
public static BuilderRegistry getInstance() {
|
||||
return Holder.ourInstance;
|
||||
@@ -44,10 +51,19 @@ public class BuilderRegistry {
|
||||
myModuleLevelBuilders.put(category, new ArrayList<ModuleLevelBuilder>());
|
||||
}
|
||||
|
||||
Set<String> compilableFileExtensions = new THashSet<String>(FileUtil.PATH_HASHING_STRATEGY);
|
||||
for (BuilderService service : JpsServiceManager.getInstance().getExtensions(BuilderService.class)) {
|
||||
myTargetBuilders.addAll(service.createBuilders());
|
||||
final List<? extends ModuleLevelBuilder> moduleLevelBuilders = service.createModuleLevelBuilders();
|
||||
for (ModuleLevelBuilder builder : moduleLevelBuilders) {
|
||||
List<String> extensions = builder.getCompilableFileExtensions();
|
||||
if (extensions == null) {
|
||||
LOG.info(builder.getClass().getName() + " builder returns 'null' from 'getCompilableFileExtensions' method so files for module-level builders won't be filtered");
|
||||
compilableFileExtensions = null;
|
||||
}
|
||||
else if (compilableFileExtensions != null) {
|
||||
compilableFileExtensions.addAll(extensions);
|
||||
}
|
||||
myModuleLevelBuilders.get(builder.getCategory()).add(builder);
|
||||
}
|
||||
for (BuildTargetType<?> type : service.getTargetTypes()) {
|
||||
@@ -58,6 +74,18 @@ public class BuilderRegistry {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (compilableFileExtensions == null) {
|
||||
myModuleBuilderFileFilter = FileUtilRt.ALL_FILES;
|
||||
}
|
||||
else {
|
||||
final Set<String> finalCompilableFileExtensions = compilableFileExtensions;
|
||||
myModuleBuilderFileFilter = new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
return finalCompilableFileExtensions.contains(FileUtilRt.getExtension(file.getName()));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -65,6 +93,11 @@ public class BuilderRegistry {
|
||||
return myTargetTypes.get(typeId);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public FileFilter getModuleBuilderFileFilter() {
|
||||
return myModuleBuilderFileFilter;
|
||||
}
|
||||
|
||||
public Collection<BuildTargetType<?>> getTargetTypes() {
|
||||
return myTargetTypes.values();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -71,6 +72,15 @@ public abstract class ModuleLevelBuilder extends Builder {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* <strong>DO NOT RETURN {@code null}</strong> from implementation of this method. If some of builders returns {@code null} no filtering
|
||||
* will be performed for compatibility reasons.
|
||||
* @return list of extensions (without dot) of files which can be compiled by the builder
|
||||
*/
|
||||
public List<String> getCompilableFileExtensions() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final BuilderCategory getCategory() {
|
||||
return myCategory;
|
||||
}
|
||||
|
||||
+7
@@ -38,6 +38,8 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
@@ -98,6 +100,11 @@ public abstract class ClassProcessingBuilder extends ModuleLevelBuilder {
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCompilableFileExtensions() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
protected abstract ExitCode performBuild(CompileContext context, ModuleChunk chunk, InstrumentationClassFinder finder, OutputConsumer outputConsumer);
|
||||
|
||||
|
||||
|
||||
@@ -74,7 +74,8 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
public class JavaBuilder extends ModuleLevelBuilder {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.java.JavaBuilder");
|
||||
public static final String BUILDER_NAME = "java";
|
||||
private static final String JAVA_EXTENSION = ".java";
|
||||
private static final String JAVA_EXTENSION = "java";
|
||||
private static final String DOT_JAVA_EXTENSION = "." + JAVA_EXTENSION;
|
||||
public static final boolean USE_EMBEDDED_JAVAC = System.getProperty(GlobalOptions.USE_EXTERNAL_JAVAC_OPTION) == null;
|
||||
private static final Key<Integer> JAVA_COMPILER_VERSION_KEY = Key.create("_java_compiler_version_");
|
||||
private static final Key<Boolean> IS_ENABLED = Key.create("_java_compiler_enabled_");
|
||||
@@ -91,12 +92,12 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
SystemInfo.isFileSystemCaseSensitive?
|
||||
new FileFilter() {
|
||||
public boolean accept(File file) {
|
||||
return file.getPath().endsWith(JAVA_EXTENSION);
|
||||
return file.getPath().endsWith(DOT_JAVA_EXTENSION);
|
||||
}
|
||||
} :
|
||||
new FileFilter() {
|
||||
public boolean accept(File file) {
|
||||
return StringUtil.endsWithIgnoreCase(file.getPath(), JAVA_EXTENSION);
|
||||
return StringUtil.endsWithIgnoreCase(file.getPath(), DOT_JAVA_EXTENSION);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -146,6 +147,11 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
COMPILER_VERSION_INFO.set(context, new AtomicReference<String>(messageText));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCompilableFileExtensions() {
|
||||
return Collections.singletonList(JAVA_EXTENSION);
|
||||
}
|
||||
|
||||
public ExitCode build(final CompileContext context,
|
||||
final ModuleChunk chunk,
|
||||
DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder,
|
||||
|
||||
+8
-1
@@ -67,6 +67,8 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.groovy.GroovyBuilder");
|
||||
private static final Key<Boolean> CHUNK_REBUILD_ORDERED = Key.create("CHUNK_REBUILD_ORDERED");
|
||||
private static final Key<Map<String, String>> STUB_TO_SRC = Key.create("STUB_TO_SRC");
|
||||
private static final String GROOVY_EXTENSION = "groovy";
|
||||
private static final String GPP_EXTENSION = "gpp";
|
||||
private final boolean myForStubs;
|
||||
private final String myBuilderName;
|
||||
|
||||
@@ -407,7 +409,12 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
|
||||
public static boolean isGroovyFile(String path) {
|
||||
return path.endsWith(".groovy") || path.endsWith(".gpp");
|
||||
return path.endsWith("." + GROOVY_EXTENSION) || path.endsWith("." + GPP_EXTENSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCompilableFileExtensions() {
|
||||
return Arrays.asList(GROOVY_EXTENSION, GPP_EXTENSION);
|
||||
}
|
||||
|
||||
private static Map<String, String> buildClassToSourceMap(ModuleChunk chunk, CompileContext context, Set<String> toCompilePaths, Map<ModuleBuildTarget, String> finalOutputs) throws IOException {
|
||||
|
||||
+6
-4
@@ -39,10 +39,7 @@ import org.jetbrains.jps.uiDesigner.model.JpsUiDesignerExtensionService;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
@@ -87,6 +84,11 @@ public class FormsBindingManager extends FormsBuilder {
|
||||
return new File(context.getProjectDescriptor().dataManager.getDataPaths().getDataStorageRoot(), "forms_rebuild_required");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCompilableFileExtensions() {
|
||||
return Arrays.asList(FORM_EXTENSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExitCode build(CompileContext context, ModuleChunk chunk, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder, OutputConsumer outputConsumer) throws ProjectBuildException, IOException {
|
||||
ExitCode exitCode = ExitCode.NOTHING_DONE;
|
||||
|
||||
+4
-4
@@ -37,7 +37,8 @@ public abstract class FormsBuilder extends ModuleLevelBuilder {
|
||||
protected static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.uiDesigner.compiler.FormsInstrumenter");
|
||||
protected static final Key<Map<File, Collection<File>>> FORMS_TO_COMPILE = Key.create("_forms-to_compile_");
|
||||
protected static final String JAVA_EXTENSION = ".java";
|
||||
protected static final String FORM_EXTENSION = ".form";
|
||||
protected static final String FORM_EXTENSION = "form";
|
||||
protected static final String DOT_FORM_EXTENSION = "." + FORM_EXTENSION;
|
||||
protected static final FileFilter JAVA_SOURCES_FILTER =
|
||||
SystemInfo.isFileSystemCaseSensitive?
|
||||
new FileFilter() {
|
||||
@@ -55,12 +56,12 @@ public abstract class FormsBuilder extends ModuleLevelBuilder {
|
||||
SystemInfo.isFileSystemCaseSensitive?
|
||||
new FileFilter() {
|
||||
public boolean accept(File file) {
|
||||
return file.getPath().endsWith(FORM_EXTENSION);
|
||||
return file.getPath().endsWith(DOT_FORM_EXTENSION);
|
||||
}
|
||||
} :
|
||||
new FileFilter() {
|
||||
public boolean accept(File file) {
|
||||
return StringUtil.endsWithIgnoreCase(file.getPath(), FORM_EXTENSION);
|
||||
return StringUtil.endsWithIgnoreCase(file.getPath(), DOT_FORM_EXTENSION);
|
||||
}
|
||||
}
|
||||
;
|
||||
@@ -86,5 +87,4 @@ public abstract class FormsBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
forms.add(form);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
@@ -128,6 +128,11 @@ public class FormsInstrumenter extends FormsBuilder {
|
||||
return ExitCode.OK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCompilableFileExtensions() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private Map<File, Collection<File>> instrumentForms(
|
||||
CompileContext context, ModuleChunk chunk, final Map<File, String> chunkSourcePath, final InstrumentationClassFinder finder, Collection<File> forms, OutputConsumer outConsumer
|
||||
) throws ProjectBuildException {
|
||||
|
||||
Reference in New Issue
Block a user