use of com.intellij.openapi.roots.ContentEntry in project intellij-plugins by JetBrains.
the class CucumberJavaTestUtil method createCucumberJava8ProjectDescriptor.
public static DefaultLightProjectDescriptor createCucumberJava8ProjectDescriptor() {
return new DefaultLightProjectDescriptor() {
@Override
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
attachCucumberLibraries(module, model);
LanguageLevelModuleExtension extension = model.getModuleExtension(LanguageLevelModuleExtension.class);
if (extension != null) {
extension.setLanguageLevel(LanguageLevel.JDK_1_8);
}
VirtualFile sourceRoot = VirtualFileManager.getInstance().refreshAndFindFileByUrl("temp:///src");
if (sourceRoot != null) {
contentEntry.removeSourceFolder(contentEntry.getSourceFolders()[0]);
contentEntry.addSourceFolder(sourceRoot, true);
}
}
};
}
use of com.intellij.openapi.roots.ContentEntry in project intellij-plugins by JetBrains.
the class FlexModuleBuilder method setupRootModel.
public void setupRootModel(final ModifiableRootModel modifiableRootModel) throws ConfigurationException {
final ContentEntry contentEntry = doAddContentEntry(modifiableRootModel);
if (contentEntry == null)
return;
final VirtualFile sourceRoot = createSourceRoot(contentEntry);
final Module module = modifiableRootModel.getModule();
final FlexProjectConfigurationEditor currentFlexEditor = FlexBuildConfigurationsExtension.getInstance().getConfigurator().getConfigEditor();
final boolean needToCommitFlexEditor = currentFlexEditor == null;
final FlexProjectConfigurationEditor flexConfigEditor;
flexConfigEditor = currentFlexEditor != null ? currentFlexEditor : FlexProjectConfigurationEditor.createEditor(module.getProject(), Collections.singletonMap(module, modifiableRootModel), null, null);
final ModifiableFlexBuildConfiguration[] configurations = flexConfigEditor.getConfigurations(module);
assert configurations.length == 1;
final ModifiableFlexBuildConfiguration bc = configurations[0];
setupBC(modifiableRootModel, bc);
if (bc.getOutputType() == OutputType.Application) {
createRunConfiguration(module, bc);
}
if (sourceRoot != null && myCreateSampleApp && myFlexSdk != null) {
try {
final boolean flex4 = !FlexSdkUtils.isAirSdkWithoutFlex(myFlexSdk) && StringUtil.compareVersionNumbers(myFlexSdk.getVersionString(), "4") >= 0;
FlexUtils.createSampleApp(module.getProject(), sourceRoot, mySampleAppName, myTargetPlatform, flex4);
} catch (IOException ex) {
throw new ConfigurationException(ex.getMessage());
}
}
if (myCreateHtmlWrapperTemplate && myFlexSdk != null) {
final String path = VfsUtilCore.urlToPath(contentEntry.getUrl()) + "/" + CreateHtmlWrapperTemplateDialog.HTML_TEMPLATE_FOLDER_NAME;
if (CreateHtmlWrapperTemplateDialog.createHtmlWrapperTemplate(module.getProject(), myFlexSdk, path, myEnableHistory, myCheckPlayerVersion, myExpressInstall)) {
bc.setUseHtmlWrapper(true);
bc.setWrapperTemplatePath(path);
}
}
if (needToCommitFlexEditor) {
flexConfigEditor.commit();
}
}
use of com.intellij.openapi.roots.ContentEntry in project intellij-plugins by JetBrains.
the class DartWorkflowTest method testPackagesFolderExclusion.
public void testPackagesFolderExclusion() throws Exception {
try {
final String rootUrl = ModuleRootManager.getInstance(myModule).getContentEntries()[0].getUrl();
myFixture.addFileToProject("dir1/pubspec.yaml", "name: project1");
myFixture.addFileToProject("dir1/lib/foo.txt", "");
myFixture.addFileToProject("dir1/someFolder/lib/foo.dart", "");
final VirtualFile pubspec2 = myFixture.addFileToProject("dir2/pubspec.yaml", "name: project2\n" + "dependencies:\n" + " project1:\n" + " path: ../dir1").getVirtualFile();
myFixture.addFileToProject("dir2/.pub/foo.txt", "");
myFixture.addFileToProject("dir2/bin/foo.dart", "");
myFixture.addFileToProject("dir2/bin/sub/foo.dart", "");
myFixture.addFileToProject("dir2/lib/foo.dart", "");
myFixture.addFileToProject("dir2/lib/sub/foo.dart", "");
myFixture.addFileToProject("dir2/benchmark/foo.dart", "");
myFixture.addFileToProject("dir2/benchmark/sub/foo.dart", "");
myFixture.addFileToProject("dir2/test/foo.dart", "");
myFixture.addFileToProject("dir2/test/sub/foo.dart", "");
myFixture.addFileToProject("dir2/tool/foo.dart", "");
myFixture.addFileToProject("dir2/tool/sub/foo.dart", "");
myFixture.addFileToProject("dir2/web/foo.dart", "");
myFixture.addFileToProject("dir2/web/sub/foo.dart", "");
myFixture.addFileToProject("dir2/build/foo.dart", "");
myFixture.addFileToProject("dir2/build/sub/foo.dart", "");
final VirtualFile pubspec3 = myFixture.addFileToProject("dir2/example/pubspec.yaml", "name: project3\n" + "dependencies:\n" + " project2:\n" + " path: ..\n" + " outside_project:\n" + " path: ../../dir1/someFolder").getVirtualFile();
myFixture.addFileToProject("dir2/example/lib/foo.dart", "");
myFixture.addFileToProject("dir2/example/lib/sub/foo.dart", "");
myFixture.addFileToProject("dir2/example/web/foo.dart", "");
myFixture.addFileToProject("dir2/example/web/sub/foo.dart", "");
ApplicationManager.getApplication().runWriteAction(() -> {
final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
final ContentEntry contentEntry = model.getContentEntries()[0];
contentEntry.addExcludeFolder(rootUrl + "/dir1/someFolder");
contentEntry.addExcludeFolder(rootUrl + "/dir1/packages/project1");
contentEntry.addExcludeFolder(rootUrl + "/dir1/web/packages");
contentEntry.addExcludeFolder(rootUrl + "/dir2/packages/oldProject2Name");
contentEntry.addExcludeFolder(rootUrl + "/dir2/someFolder");
contentEntry.addExcludeFolder(rootUrl + "/dir2/packages");
contentEntry.addExcludeFolder(rootUrl + "/dir2/web/packages");
contentEntry.addExcludeFolder(rootUrl + "/dir2/lib/someFolder");
contentEntry.addExcludeFolder(rootUrl + "/dir2/example/nonexistent/packages");
contentEntry.addExcludeFolder(rootUrl + "/dir2/example/packages/oldProject3Name");
model.commit();
});
DartProjectComponent.excludeBuildAndPackagesFolders(myModule, pubspec2);
assertSameElements(ModuleRootManager.getInstance(myModule).getContentEntries()[0].getExcludeFolderUrls(), rootUrl + "/dir1/someFolder", rootUrl + "/dir1/packages/project1", rootUrl + "/dir1/web/packages", rootUrl + "/dir2/.pub", rootUrl + "/dir2/build", rootUrl + "/dir2/someFolder", rootUrl + "/dir2/lib/someFolder", rootUrl + "/dir2/example/packages/oldProject3Name");
DartProjectComponent.excludeBuildAndPackagesFolders(myModule, pubspec3);
assertSameElements(ModuleRootManager.getInstance(myModule).getContentEntries()[0].getExcludeFolderUrls(), rootUrl + "/dir1/someFolder", rootUrl + "/dir1/packages/project1", rootUrl + "/dir1/web/packages", rootUrl + "/dir2/.pub", rootUrl + "/dir2/build", rootUrl + "/dir2/someFolder", rootUrl + "/dir2/lib/someFolder", rootUrl + "/dir2/example/.pub", rootUrl + "/dir2/example/build");
} finally {
DartTestUtils.resetModuleRoots(myModule);
}
}
use of com.intellij.openapi.roots.ContentEntry in project intellij-plugins by JetBrains.
the class MxmlTest method testResolveResourceIfNameIsAmbiguous.
public void testResolveResourceIfNameIsAmbiguous() throws Exception {
moduleInitializer = (model, file, libs1) -> {
final VirtualFile localesDir = DesignerTests.getFile("locales");
final ContentEntry localesContentEntry = model.addContentEntry(localesDir);
//noinspection ConstantConditions
localesContentEntry.addSourceFolder(localesDir.findChild("en_US"), false);
//localesContentEntry.addSourceFolder(localesDir.findChild("ru_RU"), false);
return null;
};
testFile("ResourceDirective.mxml");
}
use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.
the class GradleSyncIntegrationTest method testJarsFolderInExplodedAarIsExcluded.
// https://code.google.com/p/android/issues/detail?id=227931
public void testJarsFolderInExplodedAarIsExcluded() throws Exception {
loadSimpleApplication();
Module appModule = myModules.getAppModule();
AndroidModuleModel androidModel = AndroidModuleModel.get(appModule);
assertNotNull(androidModel);
Collection<SyncIssue> issues = androidModel.getSyncIssues();
assertThat(issues).isEmpty();
AndroidPluginInfo pluginInfo = AndroidPluginInfo.find(getProject());
assertNotNull(pluginInfo);
assertEquals(pluginInfo.getPluginGeneration(), ORIGINAL);
GradleVersion pluginVersion = pluginInfo.getPluginVersion();
assertNotNull(pluginVersion);
if (pluginVersion.compareIgnoringQualifiers("2.3.0") >= 0) {
// it is not inside the project.
return;
}
ProjectLibraries libraries = new ProjectLibraries(getProject());
Library appCompat = libraries.findMatchingLibrary("appcompat-v7.*");
assertNotNull(appCompat);
File jarsFolderPath = null;
for (String url : appCompat.getUrls(CLASSES)) {
if (url.startsWith(JAR_PROTOCOL_PREFIX)) {
File jarPath = getJarFromJarUrl(url);
assertNotNull(jarPath);
jarsFolderPath = jarPath.getParentFile();
break;
}
}
assertNotNull(jarsFolderPath);
ContentEntry[] contentEntries = ModuleRootManager.getInstance(appModule).getContentEntries();
assertThat(contentEntries).hasLength(1);
ContentEntry contentEntry = contentEntries[0];
List<String> excludeFolderUrls = contentEntry.getExcludeFolderUrls();
assertThat(excludeFolderUrls).contains(pathToIdeaUrl(jarsFolderPath));
}
Aggregations