use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration in project intellij-plugins by JetBrains.
the class ValidateFlashConfigurationsPrecompileTask method getProblems.
static Collection<Trinity<Module, FlexBuildConfiguration, FlashProjectStructureProblem>> getProblems(final CompileScope scope, final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCsToCompile) {
final Collection<Trinity<Module, FlexBuildConfiguration, FlashProjectStructureProblem>> problems = new ArrayList<>();
for (final Pair<Module, FlexBuildConfiguration> moduleAndBC : modulesAndBCsToCompile) {
final Module module = moduleAndBC.first;
final FlexBuildConfiguration bc = moduleAndBC.second;
final Consumer<FlashProjectStructureProblem> errorConsumer = problem -> problems.add(Trinity.create(module, bc, problem));
checkConfiguration(module, bc, false, errorConsumer);
final RunConfiguration runConfig = CompileStepBeforeRun.getRunConfiguration(scope);
if (bc.getNature().isApp() && runConfig instanceof FlashRunConfiguration) {
final FlashRunnerParameters params = ((FlashRunConfiguration) runConfig).getRunnerParameters();
if (module.getName().equals(params.getModuleName()) && bc.getName().equals(params.getBCName())) {
if (bc.getNature().isDesktopPlatform()) {
FlashRunnerParameters.checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getAirDesktopPackagingOptions(), errorConsumer, false, "does not matter");
} else if (bc.getNature().isMobilePlatform()) {
switch(params.getMobileRunTarget()) {
case Emulator:
switch(params.getAppDescriptorForEmulator()) {
case Android:
FlashRunnerParameters.checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getAndroidPackagingOptions(), errorConsumer, false, "does not matter");
break;
case IOS:
FlashRunnerParameters.checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getIosPackagingOptions(), errorConsumer, false, "does not matter");
break;
}
break;
case AndroidDevice:
checkPackagingOptions(module, bc.getSdk(), bc.getAndroidPackagingOptions(), false, PathUtil.getParentPath(bc.getActualOutputFilePath()), errorConsumer);
break;
case iOSSimulator:
checkPackagingOptions(module, bc.getSdk(), bc.getIosPackagingOptions(), true, PathUtil.getParentPath(bc.getActualOutputFilePath()), errorConsumer);
break;
case iOSDevice:
checkPackagingOptions(module, bc.getSdk(), bc.getIosPackagingOptions(), false, PathUtil.getParentPath(bc.getActualOutputFilePath()), errorConsumer);
break;
}
}
}
}
}
checkSimilarOutputFiles(modulesAndBCsToCompile, trinity -> problems.add(trinity));
return problems;
}
use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration in project intellij-plugins by JetBrains.
the class ValidateFlashConfigurationsPrecompileTask method checkConfiguration.
public static void checkConfiguration(final Module module, final FlexBuildConfiguration bc, final boolean checkPackaging, final Consumer<FlashProjectStructureProblem> errorConsumer) {
final Sdk sdk = bc.getSdk();
if (sdk == null) {
errorConsumer.consume(FlashProjectStructureProblem.createDependenciesProblem(ProjectStructureProblemType.Severity.ERROR, FlexBundle.message("sdk.not.set"), DependenciesConfigurable.Location.SDK));
}
if (sdk != null) {
String version = sdk.getVersionString();
if (FlexSdkUtils.isAirSdkWithoutFlex(sdk)) {
version = version.substring(FlexCommonUtils.AIR_SDK_VERSION_PREFIX.length());
}
if (StringUtil.compareVersionNumbers(version, "0") < 0 || StringUtil.compareVersionNumbers(version, "100") > 0) {
errorConsumer.consume(FlashProjectStructureProblem.createDependenciesProblem(ProjectStructureProblemType.Severity.ERROR, FlexBundle.message("sdk.version.unknown", sdk.getName()), DependenciesConfigurable.Location.SDK));
}
if (FlexSdkUtils.isAirSdkWithoutFlex(sdk) && !bc.isPureAs()) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("air.sdk.requires.pure.as", sdk.getName()), FlexBCConfigurable.Location.Nature));
}
}
InfoFromConfigFile info = InfoFromConfigFile.DEFAULT;
final String additionalConfigFilePath = bc.getCompilerOptions().getAdditionalConfigFilePath();
if (!additionalConfigFilePath.isEmpty()) {
final VirtualFile additionalConfigFile = LocalFileSystem.getInstance().findFileByPath(additionalConfigFilePath);
if (additionalConfigFile == null || additionalConfigFile.isDirectory()) {
errorConsumer.consume(FlashProjectStructureProblem.createCompilerOptionsProblem(ProjectStructureProblemType.Severity.ERROR, FlexBundle.message("additional.config.file.not.found", FileUtil.toSystemDependentName(additionalConfigFilePath)), CompilerOptionsConfigurable.Location.AdditionalConfigFile));
}
if (!bc.isTempBCForCompilation()) {
info = FlexCompilerConfigFileUtil.getInfoFromConfigFile(additionalConfigFilePath);
}
}
final BuildConfigurationNature nature = bc.getNature();
if (!nature.isLib() && info.getMainClass(module) == null && !bc.isTempBCForCompilation()) {
if (bc.getMainClass().isEmpty()) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("main.class.not.set"), FlexBCConfigurable.Location.MainClass));
} else {
if (FlexUtils.getPathToMainClassFile(bc.getMainClass(), module).isEmpty()) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("main.class.not.found", bc.getMainClass()), FlexBCConfigurable.Location.MainClass));
}
}
}
if (info.getOutputFileName() == null && info.getOutputFolderPath() == null) {
if (FileUtil.getNameWithoutExtension(bc.getOutputFileName()).isEmpty()) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("output.file.name.not.set"), FlexBCConfigurable.Location.OutputFileName));
} else {
if (!nature.isLib() && !bc.getOutputFileName().toLowerCase().endsWith(".swf")) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("output.file.wrong.extension", "swf"), FlexBCConfigurable.Location.OutputFileName));
}
if (nature.isLib() && !bc.getOutputFileName().toLowerCase().endsWith(".swc")) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("output.file.wrong.extension", "swc"), FlexBCConfigurable.Location.OutputFileName));
}
}
if (bc.getOutputFolder().isEmpty()) {
if (BCUtils.isFlexUnitBC(bc)) {
errorConsumer.consume(FlashProjectStructureProblem.FlexUnitOutputFolderProblem.INSTANCE);
} else {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("output.folder.not.set"), FlexBCConfigurable.Location.OutputFolder));
}
} else if (!FileUtil.isAbsolute(bc.getOutputFolder())) {
if (BCUtils.isFlexUnitBC(bc)) {
errorConsumer.consume(FlashProjectStructureProblem.FlexUnitOutputFolderProblem.INSTANCE);
} else {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("output.folder.not.absolute", FileUtil.toSystemDependentName(bc.getOutputFolder())), FlexBCConfigurable.Location.OutputFolder));
}
}
}
if (nature.isWebPlatform() && nature.isApp() && bc.isUseHtmlWrapper()) {
if (bc.getWrapperTemplatePath().isEmpty()) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("html.template.folder.not.set"), FlexBCConfigurable.Location.HtmlTemplatePath));
} else {
final VirtualFile templateDir = LocalFileSystem.getInstance().findFileByPath(bc.getWrapperTemplatePath());
if (templateDir == null || !templateDir.isDirectory()) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("html.template.folder.not.found", FileUtil.toSystemDependentName(bc.getWrapperTemplatePath())), FlexBCConfigurable.Location.HtmlTemplatePath));
} else {
final VirtualFile templateFile = templateDir.findChild(FlexCommonUtils.HTML_WRAPPER_TEMPLATE_FILE_NAME);
if (templateFile == null) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexCommonBundle.message("no.index.template.html.file", templateDir.getPresentableUrl()), FlexBCConfigurable.Location.HtmlTemplatePath));
} else {
// Probably heavy calculation. Will be checked only when real html template handling is performed
/*
try {
if (!VfsUtilCore.loadText(templateFile).contains(FlexCompilationUtils.SWF_MACRO)) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(
FlexBundle.message("no.swf.macro.in.template", FileUtil.toSystemDependentName(templateFile.getPath())), "html.template"));
}
}
catch (IOException e) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(
FlexBundle.message("failed.to.load.template.file", FileUtil.toSystemDependentName(templateFile.getPath()), e.getMessage()),
"html.template"));
}
*/
final String templateFolderPath = templateDir.getPath();
boolean ok = true;
for (String url : ModuleRootManager.getInstance(module).getContentRootUrls()) {
if (ok) {
ok = checkWrapperFolderClash(bc, templateFolderPath, VfsUtilCore.urlToPath(url), "module content root", errorConsumer);
}
}
for (String url : ModuleRootManager.getInstance(module).getSourceRootUrls()) {
if (ok) {
ok = checkWrapperFolderClash(bc, templateFolderPath, VfsUtilCore.urlToPath(url), "source folder", errorConsumer);
}
}
final String outputFolderPath = StringUtil.notNullize(info.getOutputFolderPath(), bc.getOutputFolder());
if (ok && !outputFolderPath.isEmpty()) {
ok = checkWrapperFolderClash(bc, templateFolderPath, outputFolderPath, "output folder", errorConsumer);
}
}
}
}
}
if (BCUtils.canHaveRLMsAndRuntimeStylesheets(bc)) {
for (FlexBuildConfiguration.RLMInfo rlm : bc.getRLMs()) {
if (rlm.MAIN_CLASS.isEmpty()) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("rlm.main.class.not.set"), FlexBCConfigurable.Location.RLMs));
} else {
if (FlexUtils.getPathToMainClassFile(rlm.MAIN_CLASS, module).isEmpty()) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("rlm.main.class.not.found", rlm.MAIN_CLASS), FlexBCConfigurable.Location.RLMs));
}
}
if (bc.getMainClass().equals(rlm.MAIN_CLASS)) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("rlm.main.class.equal.to.bc.main.class", rlm.MAIN_CLASS), FlexBCConfigurable.Location.RLMs));
}
if (bc.getOutputFileName().equals(rlm.OUTPUT_FILE)) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("rlm.output.equal.to.bc.output", rlm.OUTPUT_FILE), FlexBCConfigurable.Location.RLMs));
}
if (rlm.OUTPUT_FILE.isEmpty()) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("rlm.output.file.name.not.specified"), FlexBCConfigurable.Location.RLMs));
} else {
if (!rlm.OUTPUT_FILE.toLowerCase().endsWith(".swf")) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("rlm.output.file.must.have.swf.extension"), FlexBCConfigurable.Location.RLMs));
}
}
}
for (String cssPath : bc.getCssFilesToCompile()) {
if (!cssPath.toLowerCase().endsWith(".css")) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("not.a.css.runtime.stylesheet", FileUtil.toSystemDependentName(cssPath)), FlexBCConfigurable.Location.RuntimeStyleSheets));
} else if (LocalFileSystem.getInstance().findFileByPath(cssPath) == null) {
errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("css.not.found", FileUtil.toSystemDependentName(cssPath)), FlexBCConfigurable.Location.RuntimeStyleSheets));
}
}
}
if (nature.isLib()) {
for (String path : bc.getCompilerOptions().getFilesToIncludeInSWC()) {
if (LocalFileSystem.getInstance().findFileByPath(path) == null) {
errorConsumer.consume(FlashProjectStructureProblem.createCompilerOptionsProblem(ProjectStructureProblemType.Severity.ERROR, FlexBundle.message("file.to.include.in.swc.not.found", FileUtil.toSystemDependentName(path)), CompilerOptionsConfigurable.Location.FilesToIncludeInSwc));
}
}
}
if (checkPackaging) {
checkPackagingOptions(module, bc, errorConsumer);
}
}
use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration in project intellij-plugins by JetBrains.
the class ValidateFlashConfigurationsPrecompileTask method reportProblems.
private static void reportProblems(final CompileContext context, final Collection<Trinity<Module, FlexBuildConfiguration, FlashProjectStructureProblem>> problems) {
for (Trinity<Module, FlexBuildConfiguration, FlashProjectStructureProblem> trinity : problems) {
final Module module = trinity.getFirst();
final FlexBuildConfiguration bc = trinity.getSecond();
final FlashProjectStructureProblem problem = trinity.getThird();
final String message = problem instanceof FlashProjectStructureProblem.FlexUnitOutputFolderProblem ? problem.errorMessage : FlexBundle.message("bc.0.module.1.problem.2", bc.getName(), module.getName(), problem.errorMessage);
final CompilerMessageCategory severity = problem.severity == ProjectStructureProblemType.Severity.ERROR ? CompilerMessageCategory.ERROR : CompilerMessageCategory.WARNING;
context.addMessage(severity, message, null, -1, -1, new BCProblemNavigatable(module, bc.getName(), problem));
}
}
use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration in project intellij-plugins by JetBrains.
the class FlashProjectStructureErrorsDialog method openProjectStructure.
private void openProjectStructure() {
final TreePath selectionPath = myTree.getSelectionPath();
DefaultMutableTreeNode node = selectionPath == null ? null : (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
Object userObject = node == null ? null : node.getUserObject();
if (userObject == null)
return;
final Ref<Module> moduleRef = new Ref<>();
final Ref<FlexBuildConfiguration> bcRef = new Ref<>();
final Ref<FlashProjectStructureProblem> problemRef = new Ref<>();
if (userObject instanceof FlashProjectStructureProblem) {
problemRef.set((FlashProjectStructureProblem) userObject);
node = (DefaultMutableTreeNode) node.getParent();
userObject = node.getUserObject();
}
if (userObject instanceof FlexBuildConfiguration) {
bcRef.set((FlexBuildConfiguration) userObject);
node = (DefaultMutableTreeNode) node.getParent();
userObject = node.getUserObject();
}
if (userObject instanceof Module) {
moduleRef.set((Module) userObject);
}
close(CANCEL_EXIT_CODE);
final ProjectStructureConfigurable configurable = ProjectStructureConfigurable.getInstance(myProject);
ShowSettingsUtil.getInstance().editConfigurable(myProject, configurable, () -> {
final Place place;
if (problemRef.get() instanceof FlashProjectStructureProblem.FlexUnitOutputFolderProblem) {
place = new Place().putPath(ProjectStructureConfigurable.CATEGORY, configurable.getProjectConfig());
} else if (moduleRef.isNull()) {
place = new Place().putPath(ProjectStructureConfigurable.CATEGORY, configurable.getModulesConfig());
} else if (bcRef.isNull()) {
place = new Place().putPath(ProjectStructureConfigurable.CATEGORY, configurable.getModulesConfig()).putPath(MasterDetailsComponent.TREE_OBJECT, moduleRef.get());
} else {
place = FlexBuildConfigurationsExtension.getInstance().getConfigurator().getPlaceFor(moduleRef.get(), bcRef.get().getName());
if (!problemRef.isNull()) {
place.putPath(CompositeConfigurable.TAB_NAME, problemRef.get().tabName);
place.putPath(FlexBCConfigurable.LOCATION_ON_TAB, problemRef.get().locationOnTab);
}
}
configurable.navigateTo(place, true);
});
}
use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration in project intellij-plugins by JetBrains.
the class FlexBuildTargetScopeProvider method getBuildTargetScopes.
@NotNull
public List<TargetTypeBuildScope> getBuildTargetScopes(@NotNull final CompileScope baseScope, @NotNull final CompilerFilter filter, @NotNull final Project project, boolean forceBuild) {
final RunConfiguration runConfiguration = CompileStepBeforeRun.getRunConfiguration(baseScope);
final Collection<Pair<Module, FlexBuildConfiguration>> bcsToCompileForPackaging = FlexResourceBuildTargetScopeProvider.getBCsToCompileForPackaging(baseScope);
List<String> targetIds = new ArrayList<>();
try {
for (Pair<Module, FlexBuildConfiguration> moduleAndBC : getModulesAndBCsToCompile(baseScope)) {
final Module module = moduleAndBC.first;
final FlexBuildConfiguration bc = moduleAndBC.second;
if (bcsToCompileForPackaging != null && contains(bcsToCompileForPackaging, module, bc)) {
final boolean forcedDebugStatus = getForcedDebugStatus(project, bc);
targetIds.add(FlexCommonUtils.getBuildTargetId(module.getName(), bc.getName(), forcedDebugStatus));
} else if (bc.isTempBCForCompilation()) {
LOG.assertTrue(runConfiguration instanceof FlashRunConfiguration || runConfiguration instanceof FlexUnitRunConfiguration, bc.getName());
final BCBasedRunnerParameters params = runConfiguration instanceof FlashRunConfiguration ? ((FlashRunConfiguration) runConfiguration).getRunnerParameters() : ((FlexUnitRunConfiguration) runConfiguration).getRunnerParameters();
LOG.assertTrue(params.getModuleName().equals(module.getName()), "Module name in run config: " + params.getModuleName() + ", expected: " + module.getName());
LOG.assertTrue(params.getBCName().equals(bc.getName()), "BC name in run config: " + params.getBCName() + ", expected: " + bc.getName());
targetIds.add(FlexCommonUtils.getBuildTargetIdForRunConfig(runConfiguration.getType().getId(), runConfiguration.getName()));
} else {
targetIds.add(FlexCommonUtils.getBuildTargetId(module.getName(), bc.getName(), null));
}
}
} catch (ConfigurationException e) {
// can't happen because checked in ValidateFlashConfigurationsPrecompileTask
LOG.error(e);
}
if (targetIds.isEmpty()) {
return Collections.emptyList();
}
return Collections.singletonList(CmdlineProtoUtil.createTargetsScope(FlexBuildTargetType.INSTANCE.getTypeId(), targetIds, forceBuild));
}
Aggregations