Search in sources :

Example 6 with JpsFlexBuildConfiguration

use of com.intellij.flex.model.bc.JpsFlexBuildConfiguration in project intellij-plugins by JetBrains.

the class FlexBuilder method build.

@Override
public void build(@NotNull final FlexBuildTarget buildTarget, @NotNull final DirtyFilesHolder<BuildRootDescriptor, FlexBuildTarget> holder, @NotNull final BuildOutputConsumer outputConsumer, @NotNull final CompileContext context) throws ProjectBuildException, IOException {
    final Collection<String> dirtyFilePaths = new ArrayList<>();
    holder.processDirtyFiles(new FileProcessor<BuildRootDescriptor, FlexBuildTarget>() {

        @Override
        public boolean apply(final FlexBuildTarget target, final File file, final BuildRootDescriptor root) throws IOException {
            assert target == buildTarget;
            dirtyFilePaths.add(file.getPath());
            return true;
        }
    });
    if (LOG.isDebugEnabled()) {
        final StringBuilder b = new StringBuilder();
        b.append(buildTarget.getId()).append(", ").append("dirty files: ").append(dirtyFilePaths.size());
        if (dirtyFilePaths.size() < 10) {
            for (String path : dirtyFilePaths) {
                b.append('\n').append(path);
            }
        }
        LOG.debug(b.toString());
    }
    final JpsFlexBuildConfiguration mainBC = buildTarget.getBC();
    final List<JpsFlexBuildConfiguration> bcsToCompile = getAllBCsToCompile(mainBC);
    if (!FlexCommonUtils.isFlexUnitBC(mainBC) && !isFlexmojosBCWithUpdatedConfigFile(mainBC)) {
        if (dirtyFilePaths.isEmpty()) {
            boolean outputFilesExist = true;
            for (JpsFlexBuildConfiguration bc : bcsToCompile) {
                if (!new File(bc.getActualOutputFilePath()).isFile()) {
                    outputFilesExist = false;
                    LOG.debug("recompile because output file doesn't exist: " + bc.getActualOutputFilePath());
                    break;
                }
            }
            if (outputFilesExist) {
                return;
            }
        } else if (mainBC.getNature().isApp() && isOnlyWrapperFilesDirty(mainBC, dirtyFilePaths)) {
            LOG.debug("only wrapper files dirty");
            FlexBuilderUtils.performPostCompileActions(context, mainBC, dirtyFilePaths, outputConsumer);
            return;
        }
    }
    for (JpsFlexBuildConfiguration bc : bcsToCompile) {
        final Status status = compileBuildConfiguration(context, bc, myBuiltInCompilerHandler);
        switch(status) {
            case Ok:
                outputConsumer.registerOutputFile(new File(mainBC.getActualOutputFilePath()), dirtyFilePaths);
                FlexBuilderUtils.performPostCompileActions(context, bc, dirtyFilePaths, outputConsumer);
                context.processMessage(new CompilerMessage(FlexBuilderUtils.getCompilerName(bc), BuildMessage.Kind.INFO, FlexCommonBundle.message("compilation.successful")));
                break;
            case Failed:
                final String message = bc.getOutputType() == OutputType.Application ? FlexCommonBundle.message("compilation.failed") : FlexCommonBundle.message("compilation.failed.dependent.will.be.skipped");
                context.processMessage(new CompilerMessage(FlexBuilderUtils.getCompilerName(bc), BuildMessage.Kind.INFO, message));
                throw new StopBuildException();
            case Cancelled:
                context.processMessage(new CompilerMessage(FlexBuilderUtils.getCompilerName(bc), BuildMessage.Kind.INFO, FlexCommonBundle.message("compilation.cancelled")));
                return;
        }
    }
}
Also used : BuildRootDescriptor(org.jetbrains.jps.builders.BuildRootDescriptor) CompilerMessage(org.jetbrains.jps.incremental.messages.CompilerMessage) ArrayList(java.util.ArrayList) IOException(java.io.IOException) FlexBuildTarget(com.intellij.flex.build.FlexBuildTarget) JpsFlexBuildConfiguration(com.intellij.flex.model.bc.JpsFlexBuildConfiguration) File(java.io.File) StopBuildException(org.jetbrains.jps.incremental.StopBuildException)

Example 7 with JpsFlexBuildConfiguration

use of com.intellij.flex.model.bc.JpsFlexBuildConfiguration in project intellij-plugins by JetBrains.

the class FlexBuilder method getAllBCsToCompile.

private static List<JpsFlexBuildConfiguration> getAllBCsToCompile(final JpsFlexBuildConfiguration bc) {
    final List<JpsFlexBuildConfiguration> result = new ArrayList<>(1 + bc.getRLMs().size() + bc.getCssFilesToCompile().size());
    result.add(bc);
    if (FlexCommonUtils.canHaveRLMsAndRuntimeStylesheets(bc)) {
        for (JpsFlexBuildConfiguration.RLMInfo rlm : bc.getRLMs()) {
            result.add(createRlmBC(bc, rlm));
        }
        for (String cssPath : bc.getCssFilesToCompile()) {
            if (new File(cssPath).isFile()) {
                result.add(createCssBC(bc, cssPath));
            }
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) JpsFlexBuildConfiguration(com.intellij.flex.model.bc.JpsFlexBuildConfiguration) File(java.io.File)

Example 8 with JpsFlexBuildConfiguration

use of com.intellij.flex.model.bc.JpsFlexBuildConfiguration in project intellij-plugins by JetBrains.

the class JpsFlexUnitRunnerParameters method getBC.

@Nullable
public JpsFlexBuildConfiguration getBC(final JpsProject project) {
    final JpsFlexBuildConfiguration bc = super.getBC(project);
    if (bc == null)
        return null;
    final JpsFlexBuildConfiguration overriddenBC = bc.getModule().getProperties().createTemporaryCopyForCompilation(bc);
    overriddenBC.setOutputType(OutputType.Application);
    overriddenBC.setMainClass(FlexCommonUtils.FLEX_UNIT_LAUNCHER);
    overriddenBC.setOutputFileName("_flexunit.swf");
    final String testOutputUrl = StringUtil.notNullize(JpsJavaExtensionService.getInstance().getOutputUrl(bc.getModule(), true));
    overriddenBC.setOutputFolder(JpsPathUtil.urlToPath(testOutputUrl));
    overriddenBC.setUseHtmlWrapper(false);
    overriddenBC.setRLMs(Collections.emptyList());
    overriddenBC.setCssFilesToCompile(Collections.emptyList());
    overriddenBC.setSkipCompile(false);
    overriddenBC.getDependencies().setFrameworkLinkage(LinkageType.Merged);
    for (JpsFlexDependencyEntry entry : overriddenBC.getDependencies().getEntries()) {
        if (entry.getLinkageType() == LinkageType.External) {
            entry.setLinkageType(LinkageType.Merged);
        }
    }
    return overriddenBC;
}
Also used : JpsFlexDependencyEntry(com.intellij.flex.model.bc.JpsFlexDependencyEntry) JpsFlexBuildConfiguration(com.intellij.flex.model.bc.JpsFlexBuildConfiguration) Nullable(org.jetbrains.annotations.Nullable)

Example 9 with JpsFlexBuildConfiguration

use of com.intellij.flex.model.bc.JpsFlexBuildConfiguration 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);
    }
}
Also used : ProjectBuildException(org.jetbrains.jps.incremental.ProjectBuildException) JpsJavaCompilerConfiguration(org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration) BuildRootDescriptor(org.jetbrains.jps.builders.BuildRootDescriptor) ProgressMessage(org.jetbrains.jps.incremental.messages.ProgressMessage) IOException(java.io.IOException) FlexResourceBuildTarget(com.intellij.flex.build.FlexResourceBuildTarget) IOException(java.io.IOException) ProjectBuildException(org.jetbrains.jps.incremental.ProjectBuildException) JpsCompilerExcludes(org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes) Collection(java.util.Collection) JpsFlexBuildConfiguration(com.intellij.flex.model.bc.JpsFlexBuildConfiguration) File(java.io.File)

Aggregations

JpsFlexBuildConfiguration (com.intellij.flex.model.bc.JpsFlexBuildConfiguration)9 File (java.io.File)3 ArrayList (java.util.ArrayList)3 JpsFlexCompilerOptions (com.intellij.flex.model.bc.JpsFlexCompilerOptions)2 IOException (java.io.IOException)2 BuildRootDescriptor (org.jetbrains.jps.builders.BuildRootDescriptor)2 JpsJavaCompilerConfiguration (org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration)2 FlexBuildTarget (com.intellij.flex.build.FlexBuildTarget)1 FlexResourceBuildTarget (com.intellij.flex.build.FlexResourceBuildTarget)1 BuildConfigurationNature (com.intellij.flex.model.bc.BuildConfigurationNature)1 JpsFlexBuildConfigurationManager (com.intellij.flex.model.bc.JpsFlexBuildConfigurationManager)1 JpsFlexDependencyEntry (com.intellij.flex.model.bc.JpsFlexDependencyEntry)1 JpsFlashRunnerParameters (com.intellij.flex.model.run.JpsFlashRunnerParameters)1 JpsFlexUnitRunnerParameters (com.intellij.flex.model.run.JpsFlexUnitRunnerParameters)1 Collection (java.util.Collection)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1 ProjectBuildException (org.jetbrains.jps.incremental.ProjectBuildException)1 StopBuildException (org.jetbrains.jps.incremental.StopBuildException)1 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)1