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;
}
}
}
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;
}
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;
}
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);
}
}
Aggregations