in flex/src/com/intellij/lang/javascript/flex/build/ValidateFlashConfigurationsPrecompileTask.java [139:375]
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 (FileUtilRt.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() && !StringUtil.toLowerCase(bc.getOutputFileName()).endsWith(".swf")) {
errorConsumer.consume(
FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(),
FlexBundle.message("output.file.wrong.extension", "swf"),
FlexBCConfigurable.Location.OutputFileName));
}
if (nature.isLib() && !StringUtil.toLowerCase(bc.getOutputFileName()).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 (!StringUtil.toLowerCase(rlm.OUTPUT_FILE).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 (!StringUtil.toLowerCase(cssPath).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);
}
}