use of com.intellij.openapi.application.WriteAction in project intellij-community by JetBrains.
the class MavenProjectReaderTest method testDefaults.
public void testDefaults() throws Exception {
VirtualFile file = new WriteAction<VirtualFile>() {
@Override
protected void run(@NotNull Result<VirtualFile> result) throws Throwable {
VirtualFile res = myProjectRoot.createChildData(this, "pom.xml");
result.setResult(res);
VfsUtil.saveText(res, "<project>" + " <groupId>test</groupId>" + " <artifactId>project</artifactId>" + " <version>1</version>" + "</project>");
}
}.execute().getResultObject();
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
MavenModel p = readProject(file);
assertEquals("jar", p.getPackaging());
assertNull(p.getName());
assertNull(p.getParent());
assertEquals("project-1", p.getBuild().getFinalName());
assertEquals(null, p.getBuild().getDefaultGoal());
assertSize(1, p.getBuild().getSources());
PlatformTestUtil.assertPathsEqual(pathFromBasedir("src/main/java"), p.getBuild().getSources().get(0));
assertSize(1, p.getBuild().getTestSources());
PlatformTestUtil.assertPathsEqual(pathFromBasedir("src/test/java"), p.getBuild().getTestSources().get(0));
assertEquals(1, p.getBuild().getResources().size());
assertResource(p.getBuild().getResources().get(0), pathFromBasedir("src/main/resources"), false, null, Collections.<String>emptyList(), Collections.<String>emptyList());
assertEquals(1, p.getBuild().getTestResources().size());
assertResource(p.getBuild().getTestResources().get(0), pathFromBasedir("src/test/resources"), false, null, Collections.<String>emptyList(), Collections.<String>emptyList());
PlatformTestUtil.assertPathsEqual(pathFromBasedir("target"), p.getBuild().getDirectory());
PlatformTestUtil.assertPathsEqual(pathFromBasedir("target/classes"), p.getBuild().getOutputDirectory());
PlatformTestUtil.assertPathsEqual(pathFromBasedir("target/test-classes"), p.getBuild().getTestOutputDirectory());
}
use of com.intellij.openapi.application.WriteAction in project intellij-community by JetBrains.
the class MavenProjectReaderTest method testCustomSettings.
public void testCustomSettings() throws Exception {
VirtualFile file = new WriteAction<VirtualFile>() {
@Override
protected void run(@NotNull Result<VirtualFile> result) throws Throwable {
VirtualFile res = myProjectRoot.createChildData(this, "pom.xml");
result.setResult(res);
VfsUtil.saveText(res, "<project>" + " <modelVersion>1.2.3</modelVersion>" + " <groupId>test</groupId>" + " <artifactId>project</artifactId>" + " <version>1</version>" + " <name>foo</name>" + " <packaging>pom</packaging>" + " <parent>" + " <groupId>testParent</groupId>" + " <artifactId>projectParent</artifactId>" + " <version>2</version>" + " <relativePath>../parent/pom.xml</relativePath>" + " </parent>" + " <build>" + " <finalName>xxx</finalName>" + " <defaultGoal>someGoal</defaultGoal>" + " <sourceDirectory>mySrc</sourceDirectory>" + " <testSourceDirectory>myTestSrc</testSourceDirectory>" + " <scriptSourceDirectory>myScriptSrc</scriptSourceDirectory>" + " <resources>" + " <resource>" + " <directory>myRes</directory>" + " <filtering>true</filtering>" + " <targetPath>dir</targetPath>" + " <includes><include>**.properties</include></includes>" + " <excludes><exclude>**.xml</exclude></excludes>" + " </resource>" + " </resources>" + " <testResources>" + " <testResource>" + " <directory>myTestRes</directory>" + " <includes><include>**.properties</include></includes>" + " </testResource>" + " </testResources>" + " <directory>myOutput</directory>" + " <outputDirectory>myClasses</outputDirectory>" + " <testOutputDirectory>myTestClasses</testOutputDirectory>" + " </build>" + "</project>");
}
}.execute().getResultObject();
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
MavenModel p = readProject(file);
assertEquals("pom", p.getPackaging());
assertEquals("foo", p.getName());
assertParent(p, "testParent", "projectParent", "2");
assertEquals("xxx", p.getBuild().getFinalName());
assertEquals("someGoal", p.getBuild().getDefaultGoal());
assertSize(1, p.getBuild().getSources());
PlatformTestUtil.assertPathsEqual(pathFromBasedir("mySrc"), p.getBuild().getSources().get(0));
assertSize(1, p.getBuild().getTestSources());
PlatformTestUtil.assertPathsEqual(pathFromBasedir("myTestSrc"), p.getBuild().getTestSources().get(0));
assertEquals(1, p.getBuild().getResources().size());
assertResource(p.getBuild().getResources().get(0), pathFromBasedir("myRes"), true, "dir", Collections.singletonList("**.properties"), Collections.singletonList("**.xml"));
assertEquals(1, p.getBuild().getTestResources().size());
assertResource(p.getBuild().getTestResources().get(0), pathFromBasedir("myTestRes"), false, null, Collections.singletonList("**.properties"), Collections.<String>emptyList());
PlatformTestUtil.assertPathsEqual(pathFromBasedir("myOutput"), p.getBuild().getDirectory());
PlatformTestUtil.assertPathsEqual(pathFromBasedir("myClasses"), p.getBuild().getOutputDirectory());
PlatformTestUtil.assertPathsEqual(pathFromBasedir("myTestClasses"), p.getBuild().getTestOutputDirectory());
}
use of com.intellij.openapi.application.WriteAction in project intellij-community by JetBrains.
the class InvalidProjectImportingTest method testUnknownProblemWithEmptyFile.
public void testUnknownProblemWithEmptyFile() throws Exception {
createProjectPom("");
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
myProjectPom.setBinaryContent(new byte[0]);
}
}.execute().throwException();
importProject();
assertModules("project");
MavenProject root = getRootProjects().get(0);
assertProblems(root, "'pom.xml' has syntax errors");
}
use of com.intellij.openapi.application.WriteAction in project intellij-community by JetBrains.
the class BuildoutFacetConfigurator method setupFacet.
static void setupFacet(Module module, @NotNull BuildoutFacetConfiguration config) {
//TODO: refactor, see other python facets
FacetManager facetManager = FacetManager.getInstance(module);
final ModifiableFacetModel model = facetManager.createModifiableModel();
BuildoutFacetType facetType = BuildoutFacetType.getInstance();
BuildoutFacet facet = facetManager.createFacet(facetType, facetType.getDefaultFacetName(), config, null);
model.addFacet(facet);
new WriteAction() {
protected void run(@NotNull final Result result) throws Throwable {
model.commit();
}
}.execute();
facet.updatePaths();
BuildoutFacet.attachLibrary(module);
}
use of com.intellij.openapi.application.WriteAction in project intellij-community by JetBrains.
the class ArtifactsTestCase method addModule.
protected Module addModule(final String moduleName, @Nullable final VirtualFile sourceRoot) {
return new WriteAction<Module>() {
@Override
protected void run(@NotNull final Result<Module> result) {
final Module module = createModule(moduleName);
if (sourceRoot != null) {
PsiTestUtil.addSourceContentToRoots(module, sourceRoot);
}
ModuleRootModificationUtil.setModuleSdk(module, getTestProjectJdk());
result.setResult(module);
}
}.execute().getResultObject();
}
Aggregations