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 ResourceRootDescriptor method createFileFilter.
@NotNull
@Override
public FileFilter createFileFilter() {
final JpsProject project = getTarget().getModule().getProject();
final JpsCompilerExcludes excludes = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project).getCompilerExcludes();
return file -> !excludes.isExcluded(file);
}
use of org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes in project intellij-community by JetBrains.
the class JpsJavaExtensionServiceImpl method getJavaModuleIndex.
@NotNull
@Override
public JavaModuleIndex getJavaModuleIndex(@NotNull JpsProject project, @NotNull File storageRoot) {
if (myModuleIndex == null) {
JpsCompilerExcludes excludes = getOrCreateCompilerConfiguration(project).getCompilerExcludes();
myModuleIndex = JavaModuleIndexImpl.load(storageRoot, excludes);
}
return myModuleIndex;
}
use of org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes in project intellij-community by JetBrains.
the class FormsBindingManager method build.
@Override
public ExitCode build(CompileContext context, ModuleChunk chunk, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder, OutputConsumer outputConsumer) throws ProjectBuildException, IOException {
ExitCode exitCode = ExitCode.NOTHING_DONE;
final JpsProject project = context.getProjectDescriptor().getProject();
final JpsUiDesignerConfiguration config = JpsUiDesignerExtensionService.getInstance().getOrCreateUiDesignerConfiguration(project);
if (!config.isInstrumentClasses() && !config.isCopyFormsRuntimeToOutput()) {
return exitCode;
}
final Map<File, ModuleBuildTarget> filesToCompile = new THashMap<>(FileUtil.FILE_HASHING_STRATEGY);
final Map<File, ModuleBuildTarget> formsToCompile = new THashMap<>(FileUtil.FILE_HASHING_STRATEGY);
final Map<File, Collection<File>> srcToForms = new THashMap<>(FileUtil.FILE_HASHING_STRATEGY);
if (!JavaBuilderUtil.isForcedRecompilationAllJavaModules(context) && config.isInstrumentClasses() && FORCE_FORMS_REBUILD_FLAG.get(context, Boolean.FALSE)) {
// force compilation of all forms, but only once per chunk
if (!FORMS_REBUILD_FORCED.get(context, Boolean.FALSE)) {
FORMS_REBUILD_FORCED.set(context, Boolean.TRUE);
FSOperations.markDirty(context, CompilationRound.CURRENT, chunk, FORM_SOURCES_FILTER);
}
}
dirtyFilesHolder.processDirtyFiles(new FileProcessor<JavaSourceRootDescriptor, ModuleBuildTarget>() {
public boolean apply(ModuleBuildTarget target, File file, JavaSourceRootDescriptor descriptor) throws IOException {
if (JAVA_SOURCES_FILTER.accept(file)) {
filesToCompile.put(file, target);
} else if (FORM_SOURCES_FILTER.accept(file)) {
formsToCompile.put(file, target);
}
return true;
}
});
if (config.isInstrumentClasses()) {
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
final JpsCompilerExcludes excludes = configuration.getCompilerExcludes();
// force compilation of bound source file if the form is dirty
for (final Map.Entry<File, ModuleBuildTarget> entry : formsToCompile.entrySet()) {
final File form = entry.getKey();
final ModuleBuildTarget target = entry.getValue();
final Collection<File> sources = findBoundSourceCandidates(context, target, form);
for (File boundSource : sources) {
if (!excludes.isExcluded(boundSource)) {
addBinding(boundSource, form, srcToForms);
FSOperations.markDirty(context, CompilationRound.CURRENT, boundSource);
filesToCompile.put(boundSource, target);
exitCode = ExitCode.OK;
}
}
}
// form should be considered dirty if the class it is bound to is dirty
final OneToManyPathsMapping sourceToFormMap = context.getProjectDescriptor().dataManager.getSourceToFormMap();
for (Map.Entry<File, ModuleBuildTarget> entry : filesToCompile.entrySet()) {
final File srcFile = entry.getKey();
final ModuleBuildTarget target = entry.getValue();
final Collection<String> boundForms = sourceToFormMap.getState(srcFile.getPath());
if (boundForms != null) {
for (String formPath : boundForms) {
final File formFile = new File(formPath);
if (!excludes.isExcluded(formFile) && formFile.exists()) {
addBinding(srcFile, formFile, srcToForms);
FSOperations.markDirty(context, CompilationRound.CURRENT, formFile);
formsToCompile.put(formFile, target);
exitCode = ExitCode.OK;
}
}
}
}
}
FORMS_TO_COMPILE.set(context, srcToForms.isEmpty() ? null : srcToForms);
if (config.isCopyFormsRuntimeToOutput() && containsValidForm(formsToCompile.keySet())) {
for (ModuleBuildTarget target : chunk.getTargets()) {
if (!target.isTests()) {
final File outputDir = target.getOutputDir();
if (outputDir != null) {
final String outputRoot = FileUtil.toSystemIndependentName(outputDir.getPath());
final List<File> generatedFiles = CopyResourcesUtil.copyFormsRuntime(outputRoot, false);
if (!generatedFiles.isEmpty()) {
exitCode = ExitCode.OK;
// now inform others about files just copied
for (File file : generatedFiles) {
outputConsumer.registerOutputFile(target, file, Collections.<String>emptyList());
}
}
}
}
}
}
return exitCode;
}
use of org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes in project intellij-plugins by JetBrains.
the class FlexResourceBuilder method build.
public void build(@NotNull final FlexResourceBuildTarget target, @NotNull final DirtyFilesHolder<BuildRootDescriptor, FlexResourceBuildTarget> holder, @NotNull final BuildOutputConsumer outputConsumer, @NotNull final CompileContext context) throws ProjectBuildException, IOException {
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(target.getModule().getProject());
final JpsCompilerExcludes excludes = configuration.getCompilerExcludes();
try {
holder.processDirtyFiles(new FileProcessor<BuildRootDescriptor, FlexResourceBuildTarget>() {
public boolean apply(final FlexResourceBuildTarget target, final File file, final BuildRootDescriptor root) throws IOException {
if (excludes.isExcluded(file))
return true;
final String relativePath = FileUtil.toSystemIndependentName(FileUtil.getRelativePath(root.getRootFile(), file));
if (target.isTests()) {
if (!FlexCommonUtils.isSourceFile(file.getName())) {
final String outputRootUrl = JpsJavaExtensionService.getInstance().getOutputUrl(target.getModule(), target.isTests());
if (outputRootUrl == null)
return true;
final String targetPath = JpsPathUtil.urlToPath(outputRootUrl) + '/' + relativePath;
context.processMessage(new ProgressMessage("Copying " + file.getPath()));
copyResource(context, file, Collections.singleton(targetPath), outputConsumer);
}
} else {
final Collection<String> targetPaths = new ArrayList<>();
for (JpsFlexBuildConfiguration bc : target.getModule().getProperties().getBuildConfigurations()) {
if (bc.isSkipCompile() || !FlexCommonUtils.canHaveResourceFiles(bc.getNature()) || bc.getCompilerOptions().getResourceFilesMode() == JpsFlexCompilerOptions.ResourceFilesMode.None) {
continue;
}
final JpsFlexCompilerOptions.ResourceFilesMode mode = bc.getCompilerOptions().getResourceFilesMode();
if (mode == JpsFlexCompilerOptions.ResourceFilesMode.All && !FlexCommonUtils.isSourceFile(file.getName()) || mode == JpsFlexCompilerOptions.ResourceFilesMode.ResourcePatterns && configuration.isResourceFile(file, root.getRootFile())) {
final String outputFolder = PathUtilRt.getParentPath(bc.getActualOutputFilePath());
targetPaths.add(outputFolder + "/" + relativePath);
}
}
if (!targetPaths.isEmpty()) {
context.processMessage(new ProgressMessage("Copying " + file.getPath()));
copyResource(context, file, targetPaths, outputConsumer);
}
}
return true;
}
});
} catch (Exception e) {
throw new ProjectBuildException(e.getMessage(), e);
}
}
Aggregations