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;
}
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;
}
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"));
}
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();
}
}
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"));
}
Aggregations