use of com.intellij.flex.model.bc.BuildConfigurationNature 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.flex.model.bc.BuildConfigurationNature in project intellij-plugins by JetBrains.
the class Flexmojos4ImporterTest method testAppWithModules.
public void testAppWithModules() throws Exception {
// hacky way to make sure that compiler.pom is downloaded.
importProject(mavenProjectDescription("fake", "pom") + " <dependencies>" + " <dependency>\n" + " <groupId>com.adobe.flex</groupId>" + " <artifactId>compiler</artifactId>" + " <version>4.5.1.21328</version>" + " <type>pom</type>" + " </dependency>\n" + " </dependencies>");
final String pomContent = mavenProjectDescription("project", "swf") + "<properties>" + " <my.suffix>zz</my.suffix>" + "</properties>" + "<build>" + " <plugins>" + " <plugin>" + flexmojosPlugin() + " <dependencies>\n" + " <dependency>\n" + " <groupId>com.adobe.flex</groupId>\n" + " <artifactId>compiler</artifactId>\n" + " <version>4.5.1.21328</version>\n" + " <type>pom</type>\n" + " </dependency>\n" + " </dependencies>\n" + " <configuration>" + " <sourceFile>\n pack\\pack2/Main.mxml\n </sourceFile>" + " <classifier>\n ${my.suffix}\n </classifier>" + " <output>\n output.swf\n </output>" + " <moduleFiles>" + " <moduleFile>Module0.mxml</moduleFile>" + " </moduleFiles>" + " <modules>" + " <qq>\n pack/ModuleBIG.mxml\n </qq>" + " <qq>" + " <sourceFile> Module2MainClass.as</sourceFile>" + " <optimize>true</optimize>" + " <finalName>Module2FinalName</finalName>" + " <destinationPath>dir1\\dir2</destinationPath>" + " </qq>" + " </modules>" + " </configuration>" + " </plugin>" + " </plugins>" + "</build>" + flexFrameworkDependency("4.5.1.21328");
importProject(pomContent);
checkBCCount("project", 3);
checkBC("project", "project", new BuildConfigurationNature(Web, false, Application), "pack.pack2.Main", "project-1.0-zz.swf", "target", "4.5.1.21328", "en_US", ".idea/flexmojos/project-com.intellij.flex.maven.test-zz.xml");
checkBC("project", "ModuleBIG", new BuildConfigurationNature(Web, false, RuntimeLoadedModule), "pack.ModuleBIG", "project-1.0-modulebig.swf", "target", "4.5.1.21328", "en_US", ".idea/flexmojos/project-com.intellij.flex.maven.test-ModuleBIG.xml");
checkBC("project", "Module2FinalName", new BuildConfigurationNature(Web, false, RuntimeLoadedModule), "Module2MainClass", "Module2FinalName.swf", "target/dir1/dir2", "4.5.1.21328", "en_US", ".idea/flexmojos/project-com.intellij.flex.maven.test-Module2FinalName.xml");
}
use of com.intellij.flex.model.bc.BuildConfigurationNature in project intellij-plugins by JetBrains.
the class FlexScopeTest method prepareTwoSdks.
public Pair<Sdk, Sdk> prepareTwoSdks() {
final Sdk sdk1 = FlexTestUtils.createSdk(FlexTestUtils.getPathToCompleteFlexSdk("4.5"), null, true);
final Sdk sdk2 = FlexTestUtils.createSdk(FlexTestUtils.getPathToCompleteFlexSdk("4.6"), null, false);
WriteAction.run(() -> FlexTestUtils.modifyConfigs(myProject, editor -> {
final ModifiableFlexBuildConfiguration bc1 = editor.getConfigurations(myModule)[0];
bc1.setName("1");
FlexTestUtils.setSdk(bc1, sdk1);
final ModifiableFlexBuildConfiguration bc2 = editor.createConfiguration(myModule);
bc2.setNature(new BuildConfigurationNature(TargetPlatform.Web, false, OutputType.Application));
bc2.setName("2");
FlexTestUtils.setSdk(bc2, sdk2);
}));
return Pair.create(sdk1, sdk2);
}
use of com.intellij.flex.model.bc.BuildConfigurationNature in project intellij-plugins by JetBrains.
the class Flexmojos3ImporterTest method testAppOnRlmDependency.
public void testAppOnRlmDependency() throws Exception {
createProjectPom(mavenProjectDescription("aggregator", "pom") + " <modules>\n" + " <module>app</module>\n" + " <module>rlm</module>\n" + " </modules>\n" + "<build>" + " <plugins>" + " <plugin>" + flexmojosPlugin() + " </plugin>" + " </plugins>" + "</build>" + flexFrameworkDependency("3.2.0.3958"));
createModulePom("app", parent() + mavenProjectDescription("app", "swf") + " <dependencies>\n" + " <dependency>\n" + " <groupId>" + TEST_GROUP_ID + "</groupId>" + " <artifactId>rlm</artifactId>" + " <version>1.0</version>" + " <scope>runtime</scope>" + " </dependency>\n" + " </dependencies>");
createModulePom("rlm", parent() + mavenProjectDescription("rlm", "swf"));
importProject();
checkBC("app", "app", new BuildConfigurationNature(Web, false, Application), "", "app-1.0.swf", "target", "3.2.0.3958", "en_US", "target/app-1.0-config-report.xml");
final FlexBuildConfiguration rlmBC = checkBC("rlm", "rlm", new BuildConfigurationNature(Web, false, Application), "", "rlm-1.0.swf", "target", "3.2.0.3958", "en_US", "target/rlm-1.0-config-report.xml");
assertModules("aggregator", "app", "rlm");
assertModuleType("aggregator", StdModuleTypes.JAVA);
assertModuleType("app", FlexModuleType.getInstance());
assertModuleType("rlm", FlexModuleType.getInstance());
checkBCOnBCDependencies("app", "rlm:Loaded");
// check that manually set RLM output type is preserved
((ModifiableFlexBuildConfiguration) rlmBC).setOutputType(RuntimeLoadedModule);
// fake change
createModulePom("rlm", parent() + mavenProjectDescription("rlm", "fake"));
createModulePom("rlm", parent() + mavenProjectDescription("rlm", "swf"));
importProject();
checkBC("rlm", "rlm", new BuildConfigurationNature(Web, false, RuntimeLoadedModule), "", "rlm-1.0.swf", "target", "3.2.0.3958", "en_US", "target/rlm-1.0-config-report.xml");
}
use of com.intellij.flex.model.bc.BuildConfigurationNature in project intellij-plugins by JetBrains.
the class Flexmojos3ImporterTest method testMainCassAndFinalName.
public void testMainCassAndFinalName() throws Exception {
final VirtualFile file = createProjectSubFile("src/main/flex/SomeClass.mxml");
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
VfsUtil.saveText(file, "<mx:Application xmlns:mx=\"http://www.adobe.com/2006/mxml\"/>");
}
}.execute().throwException();
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
importProject(mavenProjectDescription("project", "swf") + "<build>" + " <finalName>foo</finalName>" + " <sourceDirectory>src/main/flex</sourceDirectory>" + " <plugins>" + " <plugin>" + flexmojosPlugin() + " <dependencies>\n" + " <dependency>\n" + " <groupId>com.adobe.flex</groupId>\n" + " <artifactId>compiler</artifactId>\n" + " <version>3.5.0.12683</version>\n" + " <type>pom</type>\n" + " </dependency>\n" + " </dependencies>\n" + " </plugin>" + " </plugins>" + "</build>" + flexFrameworkDependency("3.5.0.12683"));
performPostImportTasks();
checkBCCount("project", 1);
checkBC("project", "project", new BuildConfigurationNature(Web, false, Application), "SomeClass", "foo.swf", "target", "3.5.0.12683", "en_US", "target/foo-config-report.xml");
}
Aggregations