Search in sources :

Example 1 with SourceDir

use of io.quarkus.bootstrap.workspace.SourceDir in project quarkus by quarkusio.

the class LocalProject method collectTestResources.

private Collection<SourceDir> collectTestResources(PathFilter filter) {
    final List<Resource> resources = rawModel.getBuild() == null ? Collections.emptyList() : rawModel.getBuild().getTestResources();
    final Path testClassesDir = getTestClassesDir();
    if (resources.isEmpty()) {
        return Collections.singletonList(new DefaultSourceDir(new DirectoryPathTree(resolveRelativeToBaseDir(null, "src/test/resources")), new DirectoryPathTree(testClassesDir, filter), Collections.emptyMap()));
    }
    final List<SourceDir> sourceDirs = new ArrayList<>(resources.size());
    for (Resource r : resources) {
        sourceDirs.add(new DefaultSourceDir(new DirectoryPathTree(resolveRelativeToBaseDir(r.getDirectory(), "src/test/resources")), new DirectoryPathTree((r.getTargetPath() == null ? testClassesDir : testClassesDir.resolve(stripProjectBasedirPrefix(r.getTargetPath(), PROJECT_OUTPUT_DIR))), filter), Collections.emptyMap()));
    }
    return sourceDirs;
}
Also used : Path(java.nio.file.Path) DefaultSourceDir(io.quarkus.bootstrap.workspace.DefaultSourceDir) SourceDir(io.quarkus.bootstrap.workspace.SourceDir) DirectoryPathTree(io.quarkus.paths.DirectoryPathTree) Resource(org.apache.maven.model.Resource) ArrayList(java.util.ArrayList) DefaultSourceDir(io.quarkus.bootstrap.workspace.DefaultSourceDir)

Example 2 with SourceDir

use of io.quarkus.bootstrap.workspace.SourceDir in project quarkus by quarkusio.

the class LocalProject method collectMainResources.

private Collection<SourceDir> collectMainResources(PathFilter filter) {
    final List<Resource> resources = rawModel.getBuild() == null ? Collections.emptyList() : rawModel.getBuild().getResources();
    final Path classesDir = getClassesDir();
    if (resources.isEmpty()) {
        return Collections.singletonList(new DefaultSourceDir(new DirectoryPathTree(resolveRelativeToBaseDir(null, "src/main/resources")), new DirectoryPathTree(classesDir, filter), Collections.emptyMap()));
    }
    final List<SourceDir> sourceDirs = new ArrayList<>(resources.size());
    for (Resource r : resources) {
        sourceDirs.add(new DefaultSourceDir(new DirectoryPathTree(resolveRelativeToBaseDir(r.getDirectory(), "src/main/resources")), new DirectoryPathTree((r.getTargetPath() == null ? classesDir : classesDir.resolve(stripProjectBasedirPrefix(r.getTargetPath(), PROJECT_OUTPUT_DIR))), filter), Collections.emptyMap()));
    }
    return sourceDirs;
}
Also used : Path(java.nio.file.Path) DefaultSourceDir(io.quarkus.bootstrap.workspace.DefaultSourceDir) SourceDir(io.quarkus.bootstrap.workspace.SourceDir) DirectoryPathTree(io.quarkus.paths.DirectoryPathTree) Resource(org.apache.maven.model.Resource) ArrayList(java.util.ArrayList) DefaultSourceDir(io.quarkus.bootstrap.workspace.DefaultSourceDir)

Example 3 with SourceDir

use of io.quarkus.bootstrap.workspace.SourceDir in project quarkus by quarkusio.

the class QuarkusModelBuilderTest method shouldLoadMultiModuleDevModel.

@Test
public void shouldLoadMultiModuleDevModel() throws URISyntaxException, IOException {
    File projectDir = getResourcesProject("builder/multi-module-project");
    final ApplicationModel quarkusModel = QuarkusGradleModelFactory.create(new File(projectDir, "application"), "DEVELOPMENT");
    assertNotNull(quarkusModel);
    assertProjectModule(quarkusModel.getApplicationModule(), new File(projectDir, quarkusModel.getApplicationModule().getId().getArtifactId()), true);
    final Collection<WorkspaceModule> projectModules = quarkusModel.getWorkspaceModules();
    assertEquals(projectModules.size(), 1);
    for (WorkspaceModule p : projectModules) {
        assertProjectModule(p, new File(projectDir, p.getId().getArtifactId()), false);
    }
    final ResolvedDependency appArtifact = quarkusModel.getAppArtifact();
    assertThat(appArtifact).isNotNull();
    assertThat(appArtifact.getWorkspaceModule()).isNotNull();
    final ArtifactSources testSources = appArtifact.getWorkspaceModule().getTestSources();
    assertThat(testSources).isNotNull();
    assertThat(testSources.getSourceDirs().size()).isEqualTo(1);
    final SourceDir testSrcDir = testSources.getSourceDirs().iterator().next();
    assertThat(testSrcDir.getDir()).isEqualTo(projectDir.toPath().resolve("application").resolve("src").resolve("test").resolve("java"));
    assertThat(testSources.getResourceDirs().size()).isEqualTo(1);
    final SourceDir testResourcesDir = testSources.getResourceDirs().iterator().next();
    assertThat(testResourcesDir.getDir()).isEqualTo(projectDir.toPath().resolve("application").resolve("src").resolve("test").resolve("resources"));
}
Also used : SourceDir(io.quarkus.bootstrap.workspace.SourceDir) ResolvedDependency(io.quarkus.maven.dependency.ResolvedDependency) ApplicationModel(io.quarkus.bootstrap.model.ApplicationModel) WorkspaceModule(io.quarkus.bootstrap.workspace.WorkspaceModule) ArtifactSources(io.quarkus.bootstrap.workspace.ArtifactSources) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 4 with SourceDir

use of io.quarkus.bootstrap.workspace.SourceDir in project quarkus by quarkusio.

the class QuarkusModelBuilderTest method assertProjectModule.

private void assertProjectModule(WorkspaceModule projectModule, File projectDir, boolean withTests) {
    assertNotNull(projectModule);
    assertEquals(projectDir, projectModule.getModuleDir());
    assertEquals(new File(projectDir, "build"), projectModule.getBuildDir());
    SourceDir src = projectModule.getMainSources().getSourceDirs().iterator().next();
    assertNotNull(src);
    assertThat(src.getOutputDir()).isEqualTo(projectDir.toPath().resolve("build/classes/java/main"));
    PathTree sourceTree = src.getSourceTree();
    assertThat(sourceTree).isNotNull();
    assertThat(sourceTree.getRoots()).hasSize(1);
    assertThat(sourceTree.getRoots().iterator().next()).isEqualTo(projectDir.toPath().resolve("src/main/java"));
    src = projectModule.getMainSources().getResourceDirs().iterator().next();
    assertNotNull(src);
    assertThat(src.getOutputDir()).isEqualTo(projectDir.toPath().resolve("build/resources/main"));
    sourceTree = src.getSourceTree();
    assertThat(sourceTree).isNotNull();
    assertThat(sourceTree.getRoots()).hasSize(1);
    assertThat(sourceTree.getRoots().iterator().next()).isEqualTo(projectDir.toPath().resolve("src/main/resources"));
    if (withTests) {
        src = projectModule.getTestSources().getSourceDirs().iterator().next();
        assertNotNull(src);
        assertThat(src.getOutputDir()).isEqualTo(projectDir.toPath().resolve("build/classes/java/test"));
        sourceTree = src.getSourceTree();
        assertThat(sourceTree).isNotNull();
        assertThat(sourceTree.getRoots()).hasSize(1);
        assertThat(sourceTree.getRoots().iterator().next()).isEqualTo(projectDir.toPath().resolve("src/test/java"));
        src = projectModule.getTestSources().getResourceDirs().iterator().next();
        assertNotNull(src);
        assertThat(src.getOutputDir()).isEqualTo(projectDir.toPath().resolve("build/resources/test"));
        sourceTree = src.getSourceTree();
        assertThat(sourceTree).isNotNull();
        assertThat(sourceTree.getRoots()).hasSize(1);
        assertThat(sourceTree.getRoots().iterator().next()).isEqualTo(projectDir.toPath().resolve("src/test/resources"));
    } else {
        assertThat(projectModule.getTestSources()).isNull();
    }
}
Also used : SourceDir(io.quarkus.bootstrap.workspace.SourceDir) File(java.io.File) PathTree(io.quarkus.paths.PathTree)

Example 5 with SourceDir

use of io.quarkus.bootstrap.workspace.SourceDir in project quarkus by quarkusio.

the class QuarkusModelBuilderTest method shouldLoadMultiModuleTestModel.

@Test
public void shouldLoadMultiModuleTestModel() throws URISyntaxException, IOException {
    File projectDir = getResourcesProject("builder/multi-module-project");
    final ApplicationModel quarkusModel = QuarkusGradleModelFactory.create(new File(projectDir, "application"), "TEST");
    assertNotNull(quarkusModel);
    assertProjectModule(quarkusModel.getApplicationModule(), new File(projectDir, quarkusModel.getApplicationModule().getId().getArtifactId()), true);
    final Collection<WorkspaceModule> projectModules = quarkusModel.getWorkspaceModules();
    assertEquals(projectModules.size(), 1);
    for (WorkspaceModule p : projectModules) {
        assertProjectModule(p, new File(projectDir, p.getId().getArtifactId()), false);
    }
    final ResolvedDependency appArtifact = quarkusModel.getAppArtifact();
    assertThat(appArtifact).isNotNull();
    assertThat(appArtifact.getWorkspaceModule()).isNotNull();
    final ArtifactSources testSources = appArtifact.getWorkspaceModule().getTestSources();
    assertThat(testSources).isNotNull();
    assertThat(testSources.getSourceDirs().size()).isEqualTo(1);
    final SourceDir testSrcDir = testSources.getSourceDirs().iterator().next();
    assertThat(testSrcDir.getDir()).isEqualTo(projectDir.toPath().resolve("application").resolve("src").resolve("test").resolve("java"));
    assertThat(testSources.getResourceDirs().size()).isEqualTo(1);
    final SourceDir testResourcesDir = testSources.getResourceDirs().iterator().next();
    assertThat(testResourcesDir.getDir()).isEqualTo(projectDir.toPath().resolve("application").resolve("src").resolve("test").resolve("resources"));
}
Also used : SourceDir(io.quarkus.bootstrap.workspace.SourceDir) ResolvedDependency(io.quarkus.maven.dependency.ResolvedDependency) ApplicationModel(io.quarkus.bootstrap.model.ApplicationModel) WorkspaceModule(io.quarkus.bootstrap.workspace.WorkspaceModule) ArtifactSources(io.quarkus.bootstrap.workspace.ArtifactSources) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

SourceDir (io.quarkus.bootstrap.workspace.SourceDir)17 Path (java.nio.file.Path)13 ArtifactSources (io.quarkus.bootstrap.workspace.ArtifactSources)8 DefaultSourceDir (io.quarkus.bootstrap.workspace.DefaultSourceDir)7 ApplicationModel (io.quarkus.bootstrap.model.ApplicationModel)6 WorkspaceModule (io.quarkus.bootstrap.workspace.WorkspaceModule)6 File (java.io.File)6 ArrayList (java.util.ArrayList)6 QuarkusBootstrap (io.quarkus.bootstrap.app.QuarkusBootstrap)4 DefaultArtifactSources (io.quarkus.bootstrap.workspace.DefaultArtifactSources)4 ResolvedDependency (io.quarkus.maven.dependency.ResolvedDependency)4 PathList (io.quarkus.paths.PathList)4 Resource (org.apache.maven.model.Resource)4 CuratedApplication (io.quarkus.bootstrap.app.CuratedApplication)3 DirectoryPathTree (io.quarkus.paths.DirectoryPathTree)3 IOException (java.io.IOException)3 BootstrapConstants (io.quarkus.bootstrap.BootstrapConstants)2 AugmentAction (io.quarkus.bootstrap.app.AugmentAction)2 DevModeContext (io.quarkus.deployment.dev.DevModeContext)2 PathTree (io.quarkus.paths.PathTree)2