Search in sources :

Example 21 with JpsJavaCompilerConfiguration

use of org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration in project intellij-community by JetBrains.

the class RmicCompilerOptionsSerializer method loadExtension.

@Override
public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) {
    JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
    RmicCompilerOptions options = XmlSerializer.deserialize(componentTag, RmicCompilerOptions.class);
    configuration.setCompilerOptions(myCompilerId, options);
}
Also used : JpsJavaCompilerConfiguration(org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration) RmicCompilerOptions(org.jetbrains.jps.model.java.compiler.RmicCompilerOptions)

Example 22 with JpsJavaCompilerConfiguration

use of org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration in project intellij-community by JetBrains.

the class JpsGroovycRunner method collectChangedFiles.

List<File> collectChangedFiles(CompileContext context, DirtyFilesHolder<R, T> dirtyFilesHolder, final boolean forStubs, final boolean forEclipse, final Ref<Boolean> hasExcludes) throws IOException {
    final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(context.getProjectDescriptor().getProject());
    assert configuration != null;
    final JpsGroovySettings settings = JpsGroovySettings.getSettings(context.getProjectDescriptor().getProject());
    final List<File> toCompile = new ArrayList<>();
    dirtyFilesHolder.processDirtyFiles(new FileProcessor<R, T>() {

        public boolean apply(T target, File file, R sourceRoot) throws IOException {
            if (shouldProcessSourceFile(file, sourceRoot, file.getPath(), configuration)) {
                if (forStubs && settings.isExcludedFromStubGeneration(file)) {
                    hasExcludes.set(true);
                    return true;
                }
                toCompile.add(file);
            }
            return true;
        }
    });
    return toCompile;
}
Also used : JpsJavaCompilerConfiguration(org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration) IOException(java.io.IOException) File(java.io.File)

Example 23 with JpsJavaCompilerConfiguration

use of org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration in project intellij-community by JetBrains.

the class JpsGroovycRunner method buildClassToSourceMap.

private Map<String, String> buildClassToSourceMap(ModuleChunk chunk, CompileContext context, Set<String> toCompilePaths, Map<T, String> finalOutputs) throws IOException {
    final Map<String, String> class2Src = new HashMap<>();
    JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(context.getProjectDescriptor().getProject());
    for (T target : getTargets(chunk)) {
        String moduleOutputPath = finalOutputs.get(target);
        final SourceToOutputMapping srcToOut = context.getProjectDescriptor().dataManager.getSourceToOutputMap(target);
        for (String src : srcToOut.getSources()) {
            if (!toCompilePaths.contains(src) && GroovyBuilder.isGroovyFile(src) && !configuration.getCompilerExcludes().isExcluded(new File(src))) {
                final Collection<String> outs = srcToOut.getOutputs(src);
                if (outs != null) {
                    for (String out : outs) {
                        if (out.endsWith(".class") && out.startsWith(moduleOutputPath)) {
                            final String className = out.substring(moduleOutputPath.length(), out.length() - ".class".length()).replace('/', '.');
                            class2Src.put(className, src);
                        }
                    }
                }
            }
        }
    }
    return class2Src;
}
Also used : JpsJavaCompilerConfiguration(org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration) SourceToOutputMapping(org.jetbrains.jps.builders.storage.SourceToOutputMapping) File(java.io.File)

Example 24 with JpsJavaCompilerConfiguration

use of org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration 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;
}
Also used : JpsJavaCompilerConfiguration(org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration) OneToManyPathsMapping(org.jetbrains.jps.incremental.storage.OneToManyPathsMapping) IOException(java.io.IOException) JpsCompilerExcludes(org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes) THashMap(gnu.trove.THashMap) JpsUiDesignerConfiguration(org.jetbrains.jps.uiDesigner.model.JpsUiDesignerConfiguration) JpsProject(org.jetbrains.jps.model.JpsProject) JavaSourceRootDescriptor(org.jetbrains.jps.builders.java.JavaSourceRootDescriptor) File(java.io.File) THashMap(gnu.trove.THashMap)

Aggregations

JpsJavaCompilerConfiguration (org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration)24 File (java.io.File)9 ProcessorConfigProfile (org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile)6 IOException (java.io.IOException)5 JpsCompilerExcludes (org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes)4 JpsModule (org.jetbrains.jps.model.module.JpsModule)4 NotNull (org.jetbrains.annotations.NotNull)3 JavaSourceRootDescriptor (org.jetbrains.jps.builders.java.JavaSourceRootDescriptor)3 JpsProject (org.jetbrains.jps.model.JpsProject)3 JpsJavaCompilerOptions (org.jetbrains.jps.model.java.compiler.JpsJavaCompilerOptions)3 JpsFlexBuildConfiguration (com.intellij.flex.model.bc.JpsFlexBuildConfiguration)2 Set (java.util.Set)2 Element (org.jdom.Element)2 ProgressMessage (org.jetbrains.jps.incremental.messages.ProgressMessage)2 JpsJavaExtensionService (org.jetbrains.jps.model.java.JpsJavaExtensionService)2 EclipseCompilerOptions (org.jetbrains.jps.model.java.compiler.EclipseCompilerOptions)2 RmicCompilerOptions (org.jetbrains.jps.model.java.compiler.RmicCompilerOptions)2 FlexResourceBuildTarget (com.intellij.flex.build.FlexResourceBuildTarget)1 SmartList (com.intellij.util.SmartList)1 THashMap (gnu.trove.THashMap)1