Skip to content

Commit

Permalink
Add support of several resource and test resource folders in dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
essobedo committed May 13, 2021
1 parent 7d04331 commit baf154c
Show file tree
Hide file tree
Showing 26 changed files with 828 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,12 @@ public static class ModuleInfo implements Serializable {
this.appArtifactKey = builder.appArtifactKey;
this.name = builder.name;
this.projectDirectory = builder.projectDirectory;
this.main = new CompilationUnit(new LinkedHashSet<>(builder.sourcePaths), builder.classesPath, builder.resourcePath,
this.main = new CompilationUnit(new LinkedHashSet<>(builder.sourcePaths), builder.classesPath,
builder.resourcePaths,
builder.resourcesOutputPath);
if (builder.testClassesPath != null) {
this.test = new CompilationUnit(new LinkedHashSet<>(builder.testSourcePaths),
builder.testClassesPath, builder.testResourcePath, builder.testResourcesOutputPath);
builder.testClassesPath, builder.testResourcePaths, builder.testResourcesOutputPath);
} else {
this.test = null;
}
Expand Down Expand Up @@ -301,7 +302,7 @@ public static class Builder {
private String projectDirectory;
private Set<String> sourcePaths = Collections.emptySet();
private String classesPath;
private String resourcePath;
private Set<String> resourcePaths = Collections.emptySet();
private String resourcesOutputPath;

private String preBuildOutputDir;
Expand All @@ -310,7 +311,7 @@ public static class Builder {

private Set<String> testSourcePaths = Collections.emptySet();
private String testClassesPath;
private String testResourcePath;
private Set<String> testResourcePaths = Collections.emptySet();
private String testResourcesOutputPath;

public Builder setAppArtifactKey(AppArtifactKey appArtifactKey) {
Expand Down Expand Up @@ -338,8 +339,8 @@ public Builder setClassesPath(String classesPath) {
return this;
}

public Builder setResourcePath(String resourcePath) {
this.resourcePath = resourcePath;
public Builder setResourcePaths(Set<String> resourcePaths) {
this.resourcePaths = resourcePaths;
return this;
}

Expand Down Expand Up @@ -373,8 +374,8 @@ public Builder setTestClassesPath(String testClassesPath) {
return this;
}

public Builder setTestResourcePath(String testResourcePath) {
this.testResourcePath = testResourcePath;
public Builder setTestResourcePaths(Set<String> testResourcePaths) {
this.testResourcePaths = testResourcePaths;
return this;
}

Expand All @@ -392,13 +393,14 @@ public ModuleInfo build() {
public static class CompilationUnit implements Serializable {
private final Set<String> sourcePaths;
private final String classesPath;
private final String resourcePath;
private final Set<String> resourcePaths;
private final String resourcesOutputPath;

public CompilationUnit(Set<String> sourcePaths, String classesPath, String resourcePath, String resourcesOutputPath) {
public CompilationUnit(Set<String> sourcePaths, String classesPath, Set<String> resourcePaths,
String resourcesOutputPath) {
this.sourcePaths = sourcePaths;
this.classesPath = classesPath;
this.resourcePath = resourcePath;
this.resourcePaths = resourcePaths;
this.resourcesOutputPath = resourcesOutputPath;
}

Expand All @@ -410,8 +412,8 @@ public String getClassesPath() {
return classesPath;
}

public String getResourcePath() {
return resourcePath;
public Set<String> getResourcePaths() {
return resourcePaths;
}

public String getResourcesOutputPath() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;

import org.jboss.logging.Logger;

Expand Down Expand Up @@ -102,16 +103,18 @@ private DevModeContext.ModuleInfo toModule(WorkspaceModule module) throws Bootst
sourceParents.add(srcDir.getParent());
}
String resourceDirectory = null;
if (module.getSourceSet().getResourceDirectory() != null) {
resourceDirectory = module.getSourceSet().getResourceDirectory().getPath();
if (!module.getSourceSet().getResourceDirectories().isEmpty()) {
// Peek the first one as we assume that it is the primary
resourceDirectory = module.getSourceSet().getResourceDirectories().iterator().next().getPath();
}
return new DevModeContext.ModuleInfo.Builder()
.setAppArtifactKey(key)
.setName(module.getArtifactCoords().getArtifactId())
.setProjectDirectory(module.getProjectRoot().getPath())
.setSourcePaths(sourceDirectories)
.setClassesPath(QuarkusModelHelper.getClassPath(module).toAbsolutePath().toString())
.setResourcePath(module.getSourceSourceSet().getResourceDirectory().toString())
.setResourcePaths(module.getSourceSourceSet().getResourceDirectories().stream().map(Object::toString)
.collect(Collectors.toSet()))
.setResourcesOutputPath(resourceDirectory)
.setSourceParents(sourceParents)
.setPreBuildOutputDir(module.getBuildDir().toPath().resolve("generated-sources").toAbsolutePath().toString())
Expand All @@ -127,9 +130,12 @@ private DevModeContext.ModuleInfo toModule(LocalProject project) {
.setSourcePaths(Collections.singleton(project.getSourcesSourcesDir().toAbsolutePath().toString()))
.setClassesPath(project.getClassesDir().toAbsolutePath().toString())
.setResourcesOutputPath(project.getClassesDir().toAbsolutePath().toString())
.setResourcePath(project.getResourcesSourcesDir().toAbsolutePath().toString())
.setResourcePaths(
project.getResourcesSourcesDirs().stream()
.map(resourcesSourcesDir -> resourcesSourcesDir.toAbsolutePath().toString())
.collect(Collectors.toSet()))
.setSourceParents(Collections.singleton(project.getSourcesDir().toString()))
.setPreBuildOutputDir(project.getCodeGenOutputDir().toString())
.setTargetDir(project.getOutputDir().toString()).build();
}
}
}
Loading

0 comments on commit baf154c

Please sign in to comment.