use of org.jetbrains.jps.model.module.JpsTypedModuleSourceRoot 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.model.module.JpsTypedModuleSourceRoot 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()));
}
}
Aggregations