Search in sources :

Example 1 with JpsFlexBuildConfiguration

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

the class FlexBuilder method createCssBC.

private static JpsFlexBuildConfiguration createCssBC(final JpsFlexBuildConfiguration mainBC, final String cssPath) {
    final JpsFlexBuildConfiguration cssBC = mainBC.getModule().getProperties().createTemporaryCopyForCompilation(mainBC);
    cssBC.setOutputType(OutputType.Application);
    cssBC.setMainClass(cssPath);
    cssBC.setOutputFileName(FileUtil.getNameWithoutExtension(PathUtilRt.getFileName(cssPath)) + ".swf");
    final String cssDirPath = PathUtilRt.getParentPath(cssPath);
    String relativeToRoot = FlexCommonUtils.getPathRelativeToSourceRoot(mainBC.getModule(), cssDirPath);
    if (relativeToRoot == null) {
        relativeToRoot = FlexCommonUtils.getPathRelativeToContentRoot(mainBC.getModule(), cssDirPath);
    }
    if (!StringUtil.isEmpty(relativeToRoot)) {
        final String outputFolder = PathUtilRt.getParentPath(mainBC.getActualOutputFilePath());
        cssBC.setOutputFolder(outputFolder + "/" + relativeToRoot);
    }
    cssBC.setUseHtmlWrapper(false);
    cssBC.setRLMs(Collections.emptyList());
    cssBC.setCssFilesToCompile(Collections.emptyList());
    final JpsFlexCompilerOptions compilerOptions = cssBC.getCompilerOptions();
    compilerOptions.setResourceFilesMode(JpsFlexCompilerOptions.ResourceFilesMode.None);
    String additionalOptions = compilerOptions.getAdditionalOptions();
    additionalOptions = FlexCommonUtils.removeOptions(additionalOptions, "link-report");
    additionalOptions = FlexCommonUtils.fixSizeReportOption(additionalOptions, FileUtil.getNameWithoutExtension(PathUtilRt.getFileName(cssPath)));
    compilerOptions.setAdditionalOptions(additionalOptions);
    return cssBC;
}
Also used : JpsFlexBuildConfiguration(com.intellij.flex.model.bc.JpsFlexBuildConfiguration) JpsFlexCompilerOptions(com.intellij.flex.model.bc.JpsFlexCompilerOptions)

Example 2 with JpsFlexBuildConfiguration

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

the class FlexBuilder method createRlmBC.

private static JpsFlexBuildConfiguration createRlmBC(final JpsFlexBuildConfiguration mainBC, final JpsFlexBuildConfiguration.RLMInfo rlm) {
    final JpsFlexBuildConfiguration rlmBC = mainBC.getModule().getProperties().createTemporaryCopyForCompilation(mainBC);
    rlmBC.setOutputType(OutputType.RuntimeLoadedModule);
    // any not empty string means that need to optimize
    rlmBC.setOptimizeFor(rlm.OPTIMIZE ? mainBC.getName() : "");
    final String subdir = PathUtilRt.getParentPath(rlm.OUTPUT_FILE);
    final String outputFileName = PathUtilRt.getFileName(rlm.OUTPUT_FILE);
    rlmBC.setMainClass(rlm.MAIN_CLASS);
    rlmBC.setOutputFileName(outputFileName);
    if (!subdir.isEmpty()) {
        final String outputFolder = PathUtilRt.getParentPath(mainBC.getActualOutputFilePath());
        rlmBC.setOutputFolder(outputFolder + "/" + subdir);
    }
    rlmBC.setUseHtmlWrapper(false);
    rlmBC.setRLMs(Collections.emptyList());
    rlmBC.setCssFilesToCompile(Collections.emptyList());
    final JpsFlexCompilerOptions compilerOptions = rlmBC.getCompilerOptions();
    compilerOptions.setResourceFilesMode(JpsFlexCompilerOptions.ResourceFilesMode.None);
    String additionalOptions = compilerOptions.getAdditionalOptions();
    additionalOptions = FlexCommonUtils.removeOptions(additionalOptions, "link-report");
    additionalOptions = FlexCommonUtils.fixSizeReportOption(additionalOptions, StringUtil.getShortName(rlmBC.getMainClass()));
    compilerOptions.setAdditionalOptions(additionalOptions);
    return rlmBC;
}
Also used : JpsFlexBuildConfiguration(com.intellij.flex.model.bc.JpsFlexBuildConfiguration) JpsFlexCompilerOptions(com.intellij.flex.model.bc.JpsFlexCompilerOptions)

Example 3 with JpsFlexBuildConfiguration

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

the class FlexBuildTargetType method computeAllTargets.

@NotNull
public List<FlexBuildTarget> computeAllTargets(@NotNull final JpsModel model) {
    final List<FlexBuildTarget> result = new ArrayList<>();
    final JpsProject project = model.getProject();
    for (JpsTypedRunConfiguration<JpsFlashRunnerParameters> runConfig : project.getRunConfigurations(JpsFlashRunConfigurationType.INSTANCE)) {
        ContainerUtilRt.addIfNotNull(result, FlexBuildTarget.create(project, runConfig.getType(), runConfig.getName()));
    }
    for (JpsTypedRunConfiguration<JpsFlexUnitRunnerParameters> runConfig : project.getRunConfigurations(JpsFlexUnitRunConfigurationType.INSTANCE)) {
        ContainerUtilRt.addIfNotNull(result, FlexBuildTarget.create(project, runConfig.getType(), runConfig.getName()));
    }
    for (JpsTypedModule<JpsFlexBuildConfigurationManager> module : project.getModules(JpsFlexModuleType.INSTANCE)) {
        for (JpsFlexBuildConfiguration bc : module.getProperties().getBuildConfigurations()) {
            result.add(FlexBuildTarget.create(bc, null));
            final BuildConfigurationNature nature = bc.getNature();
            if (nature.isApp() && (nature.isDesktopPlatform() || nature.isMobilePlatform())) {
                result.add(FlexBuildTarget.create(bc, Boolean.TRUE));
                result.add(FlexBuildTarget.create(bc, Boolean.FALSE));
            }
        }
    }
    return result;
}
Also used : BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) JpsFlashRunnerParameters(com.intellij.flex.model.run.JpsFlashRunnerParameters) JpsFlexUnitRunnerParameters(com.intellij.flex.model.run.JpsFlexUnitRunnerParameters) JpsProject(org.jetbrains.jps.model.JpsProject) ArrayList(java.util.ArrayList) JpsFlexBuildConfiguration(com.intellij.flex.model.bc.JpsFlexBuildConfiguration) JpsFlexBuildConfigurationManager(com.intellij.flex.model.bc.JpsFlexBuildConfigurationManager) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with JpsFlexBuildConfiguration

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

the class FlexResourceBuildTarget method writeConfiguration.

@Override
public void writeConfiguration(ProjectDescriptor pd, final PrintWriter out) {
    out.println("Module: " + getModule().getName());
    for (JpsFlexBuildConfiguration bc : getModule().getProperties().getBuildConfigurations()) {
        if (!bc.isSkipCompile() && FlexCommonUtils.canHaveResourceFiles(bc.getNature()) && bc.getCompilerOptions().getResourceFilesMode() != JpsFlexCompilerOptions.ResourceFilesMode.None) {
            out.print("BC: " + bc.getName());
            out.print(", output folder: " + PathUtilRt.getParentPath(bc.getActualOutputFilePath()));
            out.print(", mode: " + bc.getCompilerOptions().getResourceFilesMode());
            if (bc.getCompilerOptions().getResourceFilesMode() == JpsFlexCompilerOptions.ResourceFilesMode.ResourcePatterns) {
                final JpsJavaCompilerConfiguration c = JpsJavaExtensionService.getInstance().getCompilerConfiguration(getModule().getProject());
                if (c != null) {
                    out.print(", patterns: " + StringUtil.join(c.getResourcePatterns(), " "));
                }
            }
            out.println();
        }
    }
}
Also used : JpsJavaCompilerConfiguration(org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration) JpsFlexBuildConfiguration(com.intellij.flex.model.bc.JpsFlexBuildConfiguration)

Example 5 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