Search in sources :

Example 1 with ExcludedJavaSourceRootProvider

use of org.jetbrains.jps.builders.java.ExcludedJavaSourceRootProvider in project intellij-community by JetBrains.

the class ModuleBuildTarget method computeRootDescriptors.

@NotNull
@Override
public List<JavaSourceRootDescriptor> computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) {
    List<JavaSourceRootDescriptor> roots = new ArrayList<>();
    JavaSourceRootType type = isTests() ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE;
    Iterable<ExcludedJavaSourceRootProvider> excludedRootProviders = JpsServiceManager.getInstance().getExtensions(ExcludedJavaSourceRootProvider.class);
    final JpsJavaCompilerConfiguration compilerConfig = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(myModule.getProject());
    roots_loop: for (JpsTypedModuleSourceRoot<JavaSourceRootProperties> sourceRoot : myModule.getSourceRoots(type)) {
        if (index.isExcludedFromModule(sourceRoot.getFile(), myModule)) {
            continue;
        }
        for (ExcludedJavaSourceRootProvider provider : excludedRootProviders) {
            if (provider.isExcludedFromCompilation(myModule, sourceRoot)) {
                continue roots_loop;
            }
        }
        final String packagePrefix = sourceRoot.getProperties().getPackagePrefix();
        // consider annotation processors output for generated sources, if contained under some source root
        Set<File> excludes = computeRootExcludes(sourceRoot.getFile(), index);
        final ProcessorConfigProfile profile = compilerConfig.getAnnotationProcessingProfile(myModule);
        if (profile.isEnabled()) {
            final File outputDir = ProjectPaths.getAnnotationProcessorGeneratedSourcesOutputDir(myModule, JavaSourceRootType.TEST_SOURCE == sourceRoot.getRootType(), profile);
            if (outputDir != null && FileUtil.isAncestor(sourceRoot.getFile(), outputDir, true)) {
                excludes = ContainerUtil.newTroveSet(FileUtil.FILE_HASHING_STRATEGY, excludes);
                excludes.add(outputDir);
            }
        }
        roots.add(new JavaSourceRootDescriptor(sourceRoot.getFile(), this, false, false, packagePrefix, excludes));
    }
    return roots;
}
Also used : JpsJavaCompilerConfiguration(org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration) THashSet(gnu.trove.THashSet) Set(java.util.Set) ExcludedJavaSourceRootProvider(org.jetbrains.jps.builders.java.ExcludedJavaSourceRootProvider) JpsTypedModuleSourceRoot(org.jetbrains.jps.model.module.JpsTypedModuleSourceRoot) ArrayList(java.util.ArrayList) ProcessorConfigProfile(org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile) JavaSourceRootDescriptor(org.jetbrains.jps.builders.java.JavaSourceRootDescriptor) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ExcludedJavaSourceRootProvider

use of org.jetbrains.jps.builders.java.ExcludedJavaSourceRootProvider in project intellij-community by JetBrains.

the class ResourcesTarget method computeRootDescriptors.

@NotNull
@Override
public List<ResourceRootDescriptor> computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) {
    List<ResourceRootDescriptor> roots = new ArrayList<>();
    JavaSourceRootType type = isTests() ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE;
    Iterable<ExcludedJavaSourceRootProvider> excludedRootProviders = JpsServiceManager.getInstance().getExtensions(ExcludedJavaSourceRootProvider.class);
    for (JpsTypedModuleSourceRoot<JavaSourceRootProperties> sourceRoot : myModule.getSourceRoots(type)) {
        if (!isExcludedFromCompilation(excludedRootProviders, sourceRoot)) {
            final String packagePrefix = sourceRoot.getProperties().getPackagePrefix();
            final File rootFile = sourceRoot.getFile();
            roots.add(new FilteredResourceRootDescriptor(rootFile, this, packagePrefix, computeRootExcludes(rootFile, index)));
        }
    }
    JavaResourceRootType resourceType = isTests() ? JavaResourceRootType.TEST_RESOURCE : JavaResourceRootType.RESOURCE;
    for (JpsTypedModuleSourceRoot<JavaResourceRootProperties> root : myModule.getSourceRoots(resourceType)) {
        if (!isExcludedFromCompilation(excludedRootProviders, root)) {
            File rootFile = root.getFile();
            String relativeOutputPath = root.getProperties().getRelativeOutputPath();
            roots.add(new ResourceRootDescriptor(rootFile, this, relativeOutputPath.replace('/', '.'), computeRootExcludes(rootFile, index)));
        }
    }
    return roots;
}
Also used : ArrayList(java.util.ArrayList) ExcludedJavaSourceRootProvider(org.jetbrains.jps.builders.java.ExcludedJavaSourceRootProvider) ResourceRootDescriptor(org.jetbrains.jps.builders.java.ResourceRootDescriptor) FilteredResourceRootDescriptor(org.jetbrains.jps.builders.java.FilteredResourceRootDescriptor) File(java.io.File) FilteredResourceRootDescriptor(org.jetbrains.jps.builders.java.FilteredResourceRootDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ExcludedJavaSourceRootProvider

use of org.jetbrains.jps.builders.java.ExcludedJavaSourceRootProvider in project android by JetBrains.

the class AndroidSourceGeneratingBuilder method filterExcludedByOtherProviders.

@NotNull
private static List<String> filterExcludedByOtherProviders(@NotNull JpsModule module, @NotNull Collection<String> genRoots) {
    final Set<String> genRootPaths = new THashSet<String>(FileUtil.PATH_HASHING_STRATEGY);
    for (String genRoot : genRoots) {
        genRootPaths.add(FileUtil.toSystemIndependentName(genRoot));
    }
    final List<String> result = new ArrayList<String>();
    final List<JpsModuleSourceRoot> genSourceRoots = new ArrayList<JpsModuleSourceRoot>();
    for (JpsModuleSourceRoot root : module.getSourceRoots()) {
        if (genRootPaths.contains(FileUtil.toSystemIndependentName(root.getFile().getPath()))) {
            genSourceRoots.add(root);
        }
    }
    final Iterable<ExcludedJavaSourceRootProvider> excludedRootProviders = JpsServiceManager.getInstance().getExtensions(ExcludedJavaSourceRootProvider.class);
    for (JpsModuleSourceRoot genSourceRoot : genSourceRoots) {
        boolean excluded = false;
        for (ExcludedJavaSourceRootProvider provider : excludedRootProviders) {
            if (!(provider instanceof AndroidExcludedJavaSourceRootProvider) && provider.isExcludedFromCompilation(module, genSourceRoot)) {
                excluded = true;
                break;
            }
        }
        final String genRootFilePath = genSourceRoot.getFile().getPath();
        if (!excluded) {
            result.add(genRootFilePath);
        }
    }
    return result;
}
Also used : JpsModuleSourceRoot(org.jetbrains.jps.model.module.JpsModuleSourceRoot) ExcludedJavaSourceRootProvider(org.jetbrains.jps.builders.java.ExcludedJavaSourceRootProvider) THashSet(gnu.trove.THashSet) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NotNull (org.jetbrains.annotations.NotNull)3 ExcludedJavaSourceRootProvider (org.jetbrains.jps.builders.java.ExcludedJavaSourceRootProvider)3 THashSet (gnu.trove.THashSet)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Set (java.util.Set)1 FilteredResourceRootDescriptor (org.jetbrains.jps.builders.java.FilteredResourceRootDescriptor)1 JavaSourceRootDescriptor (org.jetbrains.jps.builders.java.JavaSourceRootDescriptor)1 ResourceRootDescriptor (org.jetbrains.jps.builders.java.ResourceRootDescriptor)1 JpsJavaCompilerConfiguration (org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration)1 ProcessorConfigProfile (org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile)1 JpsModuleSourceRoot (org.jetbrains.jps.model.module.JpsModuleSourceRoot)1 JpsTypedModuleSourceRoot (org.jetbrains.jps.model.module.JpsTypedModuleSourceRoot)1