use of org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes in project intellij-community by JetBrains.
the class FilteredResourceRootDescriptor method createFileFilter.
@NotNull
@Override
public FileFilter createFileFilter() {
final JpsProject project = getTarget().getModule().getProject();
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
final JpsCompilerExcludes excludes = configuration.getCompilerExcludes();
return file -> !excludes.isExcluded(file) && configuration.isResourceFile(file, getRootFile());
}
use of org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes in project intellij-community by JetBrains.
the class JavaSourceRootDescriptor method createFileFilter.
@NotNull
@Override
public FileFilter createFileFilter() {
final JpsCompilerExcludes excludes = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(target.getModule().getProject()).getCompilerExcludes();
final FileFilter baseFilter = BuilderRegistry.getInstance().getModuleBuilderFileFilter();
return file -> baseFilter.accept(file) && !excludes.isExcluded(file);
}
use of org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes in project intellij-plugins by JetBrains.
the class CompilerConfigGeneratorRt method addFilesIncludedInSwc.
private void addFilesIncludedInSwc(final Element rootElement) {
final JpsCompilerExcludes excludes = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(myModule.getProject()).getCompilerExcludes();
final Map<String, String> filePathToPathInSwc = new THashMap<>();
for (String path : myBC.getCompilerOptions().getFilesToIncludeInSWC()) {
final File fileOrDir = new File(path);
if (excludes.isExcluded(fileOrDir))
continue;
if (myProjectDescriptor.getIgnoredFileIndex().isIgnored(fileOrDir.getName()))
continue;
final String baseRelativePath = StringUtil.notNullize(FlexCommonUtils.getPathRelativeToSourceRoot(myModule, fileOrDir.getPath()), fileOrDir.getName());
if (fileOrDir.isDirectory()) {
processFilesRecursively(fileOrDir, file -> {
if (myProjectDescriptor.getIgnoredFileIndex().isIgnored(file.getName()))
return false;
if (!file.isDirectory() && !FlexCommonUtils.isSourceFile(file.getName()) && !excludes.isExcluded(file)) {
final String relativePath = FileUtil.getRelativePath(fileOrDir, file);
assert relativePath != null;
final String pathInSwc = baseRelativePath.isEmpty() ? relativePath : baseRelativePath + "/" + relativePath;
filePathToPathInSwc.put(file.getPath(), pathInSwc);
}
return true;
});
} else if (fileOrDir.isFile()) {
filePathToPathInSwc.put(fileOrDir.getPath(), baseRelativePath);
}
}
for (Map.Entry<String, String> entry : filePathToPathInSwc.entrySet()) {
final String value = FileUtil.toSystemIndependentName(entry.getValue()) + CompilerOptionInfo.LIST_ENTRY_PARTS_SEPARATOR + FileUtil.toSystemIndependentName(entry.getKey());
addOption(rootElement, CompilerOptionInfo.INCLUDE_FILE_INFO, value);
}
}
use of org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes in project intellij-plugins by JetBrains.
the class CompilerConfigGeneratorRt method addLibClasses.
private void addLibClasses(final Element rootElement) throws IOException {
final JpsCompilerExcludes excludes = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(myModule.getProject()).getCompilerExcludes();
final Ref<Boolean> noClasses = new Ref<>(true);
for (JpsTypedModuleSourceRoot srcRoot : myModule.getSourceRoots(JavaSourceRootType.SOURCE)) {
final File srcFolder = JpsPathUtil.urlToFile(srcRoot.getUrl());
if (srcFolder.isDirectory()) {
processFilesRecursively(srcFolder, file -> {
if (myProjectDescriptor.getIgnoredFileIndex().isIgnored(file.getName()))
return false;
if (file.isDirectory())
return true;
if (!FlexCommonUtils.isSourceFile(file.getName()))
return true;
if (excludes.isExcluded(file))
return true;
String packageRelativePath = FileUtil.getRelativePath(srcFolder, file.getParentFile());
assert packageRelativePath != null : srcFolder.getPath() + ": " + file.getPath();
if (packageRelativePath.equals("."))
packageRelativePath = "";
final String packageName = packageRelativePath.replace(File.separatorChar, '.');
final String qName = StringUtil.getQualifiedName(packageName, FileUtil.getNameWithoutExtension(file));
if (isSourceFileWithPublicDeclaration(file)) {
addOption(rootElement, CompilerOptionInfo.INCLUDE_CLASSES_INFO, qName);
noClasses.set(false);
}
return true;
});
}
}
if (noClasses.get() && myBC.getCompilerOptions().getFilesToIncludeInSWC().isEmpty() && !Utils.IS_TEST_MODE) {
throw new IOException(FlexCommonBundle.message("nothing.to.compile.in.library", myModule.getName(), myBC.getName()));
}
}
use of org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes in project intellij-community by JetBrains.
the class JpsCompilerConfigurationTest method doTest.
private void doTest(final String path) {
loadProject(path);
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(myProject);
assertNotNull(configuration);
assertFalse(configuration.isClearOutputDirectoryOnRebuild());
assertFalse(configuration.isAddNotNullAssertions());
ProcessorConfigProfile defaultProfile = configuration.getDefaultAnnotationProcessingProfile();
assertTrue(defaultProfile.isEnabled());
assertFalse(defaultProfile.isObtainProcessorsFromClasspath());
assertEquals(FileUtil.toSystemDependentName(JpsPathUtil.urlToPath(getUrl("src"))), defaultProfile.getProcessorPath());
assertEquals("b", defaultProfile.getProcessorOptions().get("a"));
assertEquals("d", defaultProfile.getProcessorOptions().get("c"));
assertEquals("gen", defaultProfile.getGeneratedSourcesDirectoryName(false));
JpsCompilerExcludes excludes = configuration.getCompilerExcludes();
assertFalse(isExcluded(excludes, "src/nonrec/x/Y.java"));
assertTrue(isExcluded(excludes, "src/nonrec/Y.java"));
assertTrue(isExcluded(excludes, "src/rec/x/Y.java"));
assertTrue(isExcluded(excludes, "src/rec/Y.java"));
assertTrue(isExcluded(excludes, "src/A.java"));
assertFalse(isExcluded(excludes, "src/B.java"));
JpsJavaCompilerOptions options = configuration.getCurrentCompilerOptions();
assertNotNull(options);
assertEquals(512, options.MAXIMUM_HEAP_SIZE);
assertFalse(options.DEBUGGING_INFO);
assertTrue(options.GENERATE_NO_WARNINGS);
assertEquals("-Xlint", options.ADDITIONAL_OPTIONS_STRING);
}
Aggregations