Search in sources :

Example 1 with MavenRootModelAdapter

use of org.jetbrains.idea.maven.importing.MavenRootModelAdapter in project intellij-community by JetBrains.

the class MavenFoldersImporterTest method testDoNotUpdateOutputFoldersWhenUpdatingExcludedFolders.

public void testDoNotUpdateOutputFoldersWhenUpdatingExcludedFolders() throws Exception {
    importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>");
    ApplicationManager.getApplication().runWriteAction(() -> {
        MavenRootModelAdapter adapter = new MavenRootModelAdapter(myProjectsTree.findProject(myProjectPom), getModule("project"), new IdeModifiableModelsProviderImpl(myProject));
        adapter.useModuleOutput(new File(myProjectRoot.getPath(), "target/my-classes").getPath(), new File(myProjectRoot.getPath(), "target/my-test-classes").getPath());
        adapter.getRootModel().commit();
    });
    MavenFoldersImporter.updateProjectFolders(myProject, true);
    ModuleRootManager rootManager = ModuleRootManager.getInstance(getModule("project"));
    CompilerModuleExtension compiler = rootManager.getModuleExtension(CompilerModuleExtension.class);
    assertTrue(compiler.getCompilerOutputUrl(), compiler.getCompilerOutputUrl().endsWith("my-classes"));
    assertTrue(compiler.getCompilerOutputUrlForTests(), compiler.getCompilerOutputUrlForTests().endsWith("my-test-classes"));
}
Also used : IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) MavenRootModelAdapter(org.jetbrains.idea.maven.importing.MavenRootModelAdapter) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 2 with MavenRootModelAdapter

use of org.jetbrains.idea.maven.importing.MavenRootModelAdapter in project intellij-community by JetBrains.

the class MavenFoldersImporterTest method testDoesNotExcludeRegisteredSources.

public void testDoesNotExcludeRegisteredSources() throws Exception {
    importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>");
    new File(myProjectRoot.getPath(), "target/foo").mkdirs();
    final File sourceDir = new File(myProjectRoot.getPath(), "target/src");
    sourceDir.mkdirs();
    ApplicationManager.getApplication().runWriteAction(() -> {
        MavenRootModelAdapter adapter = new MavenRootModelAdapter(myProjectsTree.findProject(myProjectPom), getModule("project"), new IdeModifiableModelsProviderImpl(myProject));
        adapter.addSourceFolder(sourceDir.getPath(), JavaSourceRootType.SOURCE);
        adapter.getRootModel().commit();
    });
    updateProjectFolders();
    assertSources("project", "target/src");
    assertExcludes("project", "target");
}
Also used : IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) MavenRootModelAdapter(org.jetbrains.idea.maven.importing.MavenRootModelAdapter) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Aggregations

IdeModifiableModelsProviderImpl (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2 MavenRootModelAdapter (org.jetbrains.idea.maven.importing.MavenRootModelAdapter)2