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;
}
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;
}
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;
}
Aggregations