Search in sources :

Example 16 with BuildRootDescriptor

use of org.jetbrains.jps.builders.BuildRootDescriptor 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)

Aggregations

BuildRootDescriptor (org.jetbrains.jps.builders.BuildRootDescriptor)16 File (java.io.File)15 JpsAndroidModuleExtension (org.jetbrains.jps.android.model.JpsAndroidModuleExtension)7 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 NotNull (org.jetbrains.annotations.NotNull)5 JpsModule (org.jetbrains.jps.model.module.JpsModule)5 BuildRootDescriptorImpl (org.jetbrains.jps.builders.impl.BuildRootDescriptorImpl)4 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)4 ProgressMessage (org.jetbrains.jps.incremental.messages.ProgressMessage)4 JpsFlexBuildConfiguration (com.intellij.flex.model.bc.JpsFlexBuildConfiguration)2 THashSet (gnu.trove.THashSet)2 AndroidBuildTestingManager (org.jetbrains.android.util.AndroidBuildTestingManager)2 AndroidCompilerMessageKind (org.jetbrains.android.util.AndroidCompilerMessageKind)2 AndroidDexBuildTarget (org.jetbrains.jps.android.builder.AndroidDexBuildTarget)2 BuildFSState (org.jetbrains.jps.incremental.fs.BuildFSState)2 IAndroidTarget (com.android.sdklib.IAndroidTarget)1 FlexBuildTarget (com.intellij.flex.build.FlexBuildTarget)1 FlexResourceBuildTarget (com.intellij.flex.build.FlexResourceBuildTarget)1 HashMap (com.intellij.util.containers.HashMap)1