Search in sources :

Example 1 with JpsCompilerExcludes

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());
}
Also used : JpsProject(org.jetbrains.jps.model.JpsProject) JpsCompilerExcludes(org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes) FileFilter(java.io.FileFilter) JpsJavaCompilerConfiguration(org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration) ResourcesTarget(org.jetbrains.jps.incremental.ResourcesTarget) Set(java.util.Set) JpsJavaExtensionService(org.jetbrains.jps.model.java.JpsJavaExtensionService) NotNull(org.jetbrains.annotations.NotNull) File(java.io.File) JpsJavaCompilerConfiguration(org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration) JpsCompilerExcludes(org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes) JpsProject(org.jetbrains.jps.model.JpsProject) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with JpsCompilerExcludes

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);
}
Also used : BuilderRegistry(org.jetbrains.jps.incremental.BuilderRegistry) JpsCompilerExcludes(org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes) FileFilter(java.io.FileFilter) Set(java.util.Set) BuildRootDescriptor(org.jetbrains.jps.builders.BuildRootDescriptor) FileUtil(com.intellij.openapi.util.io.FileUtil) JpsJavaExtensionService(org.jetbrains.jps.model.java.JpsJavaExtensionService) NotNull(org.jetbrains.annotations.NotNull) File(java.io.File) ModuleBuildTarget(org.jetbrains.jps.incremental.ModuleBuildTarget) JpsCompilerExcludes(org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes) FileFilter(java.io.FileFilter) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with JpsCompilerExcludes

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);
    }
}
Also used : JpsCompilerExcludes(org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes) THashMap(gnu.trove.THashMap) File(java.io.File) THashMap(gnu.trove.THashMap)

Example 4 with JpsCompilerExcludes

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()));
    }
}
Also used : JpsCompilerExcludes(org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes) Ref(com.intellij.openapi.util.Ref) JpsTypedModuleSourceRoot(org.jetbrains.jps.model.module.JpsTypedModuleSourceRoot) IOException(java.io.IOException) File(java.io.File)

Example 5 with JpsCompilerExcludes

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);
}
Also used : JpsJavaCompilerConfiguration(org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration) JpsCompilerExcludes(org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes) JpsJavaCompilerOptions(org.jetbrains.jps.model.java.compiler.JpsJavaCompilerOptions) ProcessorConfigProfile(org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile)

Aggregations

JpsCompilerExcludes (org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes)10 File (java.io.File)8 NotNull (org.jetbrains.annotations.NotNull)5 JpsJavaCompilerConfiguration (org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration)4 FileFilter (java.io.FileFilter)3 IOException (java.io.IOException)3 Set (java.util.Set)3 BuildRootDescriptor (org.jetbrains.jps.builders.BuildRootDescriptor)3 JpsProject (org.jetbrains.jps.model.JpsProject)3 JpsJavaExtensionService (org.jetbrains.jps.model.java.JpsJavaExtensionService)3 FileUtil (com.intellij.openapi.util.io.FileUtil)2 THashMap (gnu.trove.THashMap)2 ResourcesTarget (org.jetbrains.jps.incremental.ResourcesTarget)2 FlexResourceBuildTarget (com.intellij.flex.build.FlexResourceBuildTarget)1 JpsFlexBuildConfiguration (com.intellij.flex.model.bc.JpsFlexBuildConfiguration)1 Ref (com.intellij.openapi.util.Ref)1 Collection (java.util.Collection)1 JavaSourceRootDescriptor (org.jetbrains.jps.builders.java.JavaSourceRootDescriptor)1 BuilderRegistry (org.jetbrains.jps.incremental.BuilderRegistry)1 ModuleBuildTarget (org.jetbrains.jps.incremental.ModuleBuildTarget)1