Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for project modules that produce multiple JARs (with classifiers) #22336

Merged
merged 2 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public PathCollection getResolvedPaths() {
}

@Override
@Deprecated
/**
* @deprecated in favor of {@link #getKey()}
* @return archive key
*/
public AppArtifactKey getArtifactKey() {
return artifactKey == null ? null
: new AppArtifactKey(artifactKey.getGroupId(), artifactKey.getArtifactId(), artifactKey.getClassifier(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import java.util.function.Consumer;

import io.quarkus.bootstrap.model.ApplicationModel;
import io.quarkus.bootstrap.model.PathsCollection;
import io.quarkus.bootstrap.prebuild.CodeGenException;
import io.quarkus.deployment.codegen.CodeGenData;
import io.quarkus.paths.PathCollection;
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.configuration.ConfigUtils;
import io.smallrye.config.PropertiesConfigSource;
Expand All @@ -25,7 +25,7 @@ public class CodeGenerator {

// used by Gradle and Maven
public static void initAndRun(ClassLoader classLoader,
PathsCollection sourceParentDirs, Path generatedSourcesDir, Path buildDir,
PathCollection sourceParentDirs, Path generatedSourcesDir, Path buildDir,
Consumer<Path> sourceRegistrar, ApplicationModel appModel, Properties properties,
String launchMode) throws CodeGenException {
List<CodeGenData> generators = init(classLoader, sourceParentDirs, generatedSourcesDir, buildDir, sourceRegistrar);
Expand All @@ -36,7 +36,7 @@ public static void initAndRun(ClassLoader classLoader,
}

public static List<CodeGenData> init(ClassLoader deploymentClassLoader,
PathsCollection sourceParentDirs,
PathCollection sourceParentDirs,
Path generatedSourcesDir,
Path buildDir,
Consumer<Path> sourceRegistrar) throws CodeGenException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
import io.quarkus.bootstrap.model.ApplicationModel;
import io.quarkus.bootstrap.model.PathsCollection;
import io.quarkus.builder.BuildChain;
import io.quarkus.builder.BuildChainBuilder;
import io.quarkus.builder.BuildExecutionBuilder;
Expand Down Expand Up @@ -46,7 +45,7 @@ public class QuarkusAugmentor {

private final ClassLoader classLoader;
private final ClassLoader deploymentClassLoader;
private final PathsCollection root;
private final PathCollection root;
private final Set<Class<? extends BuildItem>> finalResults;
private final List<Consumer<BuildChainBuilder>> buildChainCustomizers;
private final LaunchMode launchMode;
Expand Down Expand Up @@ -193,7 +192,7 @@ public static final class Builder {
List<PathCollection> additionalApplicationArchives = new ArrayList<>();
Collection<Path> excludedFromIndexing = Collections.emptySet();
ClassLoader classLoader;
PathsCollection root;
PathCollection root;
Path targetDir;
Set<Class<? extends BuildItem>> finalResults = new HashSet<>();
private final List<Consumer<BuildChainBuilder>> buildChainCustomizers = new ArrayList<>();
Expand Down Expand Up @@ -274,7 +273,7 @@ public Builder setClassLoader(ClassLoader classLoader) {
return this;
}

public PathsCollection getRoot() {
public PathCollection getRoot() {
return root;
}

Expand All @@ -283,7 +282,7 @@ public <T extends BuildItem> Builder addFinal(Class<T> clazz) {
return this;
}

public Builder setRoot(PathsCollection root) {
public Builder setRoot(PathCollection root) {
this.root = root;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.quarkus.bootstrap.model.PathsCollection;
import io.quarkus.builder.item.SimpleBuildItem;
import io.quarkus.fs.util.ZipUtils;
import io.quarkus.paths.PathCollection;

public final class ArchiveRootBuildItem extends SimpleBuildItem {

Expand All @@ -29,7 +30,7 @@ public Builder addArchiveRoot(Path root) {
return this;
}

public Builder addArchiveRoots(PathsCollection paths) {
public Builder addArchiveRoots(PathCollection paths) {
paths.forEach(archiveRoots::add);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import io.quarkus.builder.item.MultiBuildItem;
import io.quarkus.deployment.pkg.NativeConfig;
import io.quarkus.deployment.util.GlobUtil;
import io.quarkus.util.GlobUtil;

/**
* A build item that indicates that a set of resource paths defined by regular expression patterns or globs should be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.List;
import java.util.Set;

import io.quarkus.bootstrap.model.PathsCollection;
import io.quarkus.paths.PathCollection;

public interface CompilationProvider extends Closeable {

Expand All @@ -23,7 +23,7 @@ default Set<String> handledSourcePaths() {

void compile(Set<File> files, Context context);

Path getSourcePath(Path classFilePath, PathsCollection sourcePaths, String classesPath);
Path getSourcePath(Path classFilePath, PathCollection sourcePaths, String classesPath);

@Override
default void close() throws IOException {
Expand Down Expand Up @@ -58,7 +58,6 @@ public Context(
String targetJvmVersion,
List<String> compilePluginArtifacts,
List<String> compilerPluginOptions) {

this.name = name;
this.classpath = classpath;
this.projectDirectory = projectDirectory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import java.util.Set;

import io.quarkus.bootstrap.app.QuarkusBootstrap;
import io.quarkus.bootstrap.model.AppArtifactKey;
import io.quarkus.bootstrap.model.PathsCollection;
import io.quarkus.maven.dependency.ArtifactKey;
import io.quarkus.paths.PathCollection;
import io.quarkus.paths.PathList;

/**
* Object that is used to pass context data from the plugin doing the invocation
Expand All @@ -27,7 +27,7 @@
*/
public class DevModeContext implements Serializable {

public static final CompilationUnit EMPTY_COMPILATION_UNIT = new CompilationUnit(PathsCollection.of(), null, null, null);
public static final CompilationUnit EMPTY_COMPILATION_UNIT = new CompilationUnit(PathList.of(), null, null, null);

public static final String ENABLE_PREVIEW_FLAG = "--enable-preview";

Expand Down Expand Up @@ -59,7 +59,7 @@ public class DevModeContext implements Serializable {
private String alternateEntryPoint;
private QuarkusBootstrap.Mode mode = QuarkusBootstrap.Mode.DEV;
private String baseName;
private final Set<AppArtifactKey> localArtifacts = new HashSet<>();
private final Set<ArtifactKey> localArtifacts = new HashSet<>();

public boolean isLocalProjectDiscovery() {
return localProjectDiscovery;
Expand Down Expand Up @@ -232,7 +232,7 @@ public void setBaseName(String baseName) {
this.baseName = baseName;
}

public Set<AppArtifactKey> getLocalArtifacts() {
public Set<ArtifactKey> getLocalArtifacts() {
return localArtifacts;
}

Expand All @@ -245,16 +245,17 @@ public static class ModuleInfo implements Serializable {
private final CompilationUnit test;

private final String preBuildOutputDir;
private final PathsCollection sourceParents;
private final PathCollection sourceParents;
private final String targetDir;

ModuleInfo(Builder builder) {
this.appArtifactKey = builder.appArtifactKey;
this.name = builder.name;
this.name = builder.name == null ? builder.appArtifactKey.toGacString() : builder.name;
this.projectDirectory = builder.projectDirectory;
this.main = new CompilationUnit(builder.sourcePaths, builder.classesPath,
builder.resourcePaths,
builder.resourcesOutputPath);

if (builder.testClassesPath != null) {
this.test = new CompilationUnit(builder.testSourcePaths,
builder.testClassesPath, builder.testResourcePaths, builder.testResourcesOutputPath);
Expand All @@ -274,7 +275,7 @@ public String getProjectDirectory() {
return projectDirectory;
}

public PathsCollection getSourceParents() {
public PathCollection getSourceParents() {
return sourceParents;
}

Expand Down Expand Up @@ -312,18 +313,18 @@ public static class Builder {
private ArtifactKey appArtifactKey;
private String name;
private String projectDirectory;
private PathsCollection sourcePaths = PathsCollection.of();
private PathCollection sourcePaths = PathList.of();
private String classesPath;
private PathsCollection resourcePaths = PathsCollection.of();
private PathCollection resourcePaths = PathList.of();
private String resourcesOutputPath;

private String preBuildOutputDir;
private PathsCollection sourceParents = PathsCollection.of();
private PathCollection sourceParents = PathList.of();
private String targetDir;

private PathsCollection testSourcePaths = PathsCollection.of();
private PathCollection testSourcePaths = PathList.of();
private String testClassesPath;
private PathsCollection testResourcePaths = PathsCollection.of();
private PathCollection testResourcePaths = PathList.of();
private String testResourcesOutputPath;

public Builder setArtifactKey(ArtifactKey appArtifactKey) {
Expand All @@ -341,7 +342,7 @@ public Builder setProjectDirectory(String projectDirectory) {
return this;
}

public Builder setSourcePaths(PathsCollection sourcePaths) {
public Builder setSourcePaths(PathCollection sourcePaths) {
this.sourcePaths = sourcePaths;
return this;
}
Expand All @@ -351,7 +352,7 @@ public Builder setClassesPath(String classesPath) {
return this;
}

public Builder setResourcePaths(PathsCollection resourcePaths) {
public Builder setResourcePaths(PathCollection resourcePaths) {
this.resourcePaths = resourcePaths;
return this;
}
Expand All @@ -366,7 +367,7 @@ public Builder setPreBuildOutputDir(String preBuildOutputDir) {
return this;
}

public Builder setSourceParents(PathsCollection sourceParents) {
public Builder setSourceParents(PathCollection sourceParents) {
this.sourceParents = sourceParents;
return this;
}
Expand All @@ -376,7 +377,7 @@ public Builder setTargetDir(String targetDir) {
return this;
}

public Builder setTestSourcePaths(PathsCollection testSourcePaths) {
public Builder setTestSourcePaths(PathCollection testSourcePaths) {
this.testSourcePaths = testSourcePaths;
return this;
}
Expand All @@ -386,7 +387,7 @@ public Builder setTestClassesPath(String testClassesPath) {
return this;
}

public Builder setTestResourcePaths(PathsCollection testResourcePaths) {
public Builder setTestResourcePaths(PathCollection testResourcePaths) {
this.testResourcePaths = testResourcePaths;
return this;
}
Expand All @@ -403,28 +404,28 @@ public ModuleInfo build() {
}

public static class CompilationUnit implements Serializable {
private PathsCollection sourcePaths;
private PathCollection sourcePaths;
private final String classesPath;
private final PathsCollection resourcePaths;
private final PathCollection resourcePaths;
private final String resourcesOutputPath;

public CompilationUnit(PathsCollection sourcePaths, String classesPath, PathsCollection resourcePaths,
public CompilationUnit(PathCollection sourcePaths, String classesPath, PathCollection resourcePaths,
String resourcesOutputPath) {
this.sourcePaths = sourcePaths;
this.classesPath = classesPath;
this.resourcePaths = resourcePaths;
this.resourcesOutputPath = resourcesOutputPath;
}

public PathsCollection getSourcePaths() {
public PathCollection getSourcePaths() {
return sourcePaths;
}

public String getClassesPath() {
return classesPath;
}

public PathsCollection getResourcePaths() {
public PathCollection getResourcePaths() {
return resourcePaths;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
import org.apache.commons.lang3.SystemUtils;
import org.jboss.logging.Logger;

import io.quarkus.bootstrap.app.AdditionalDependency;
import io.quarkus.bootstrap.app.CuratedApplication;
import io.quarkus.bootstrap.app.QuarkusBootstrap;
import io.quarkus.bootstrap.model.AppArtifactKey;
import io.quarkus.bootstrap.model.PathsCollection;
import io.quarkus.deployment.util.ProcessUtil;
import io.quarkus.dev.appstate.ApplicationStateNotification;
import io.quarkus.dev.spi.DevModeType;
import io.quarkus.maven.dependency.ArtifactKey;
import io.quarkus.paths.PathList;

/**
* The main entry point for the dev mojo execution
Expand Down Expand Up @@ -87,8 +86,8 @@ public void start() throws Exception {
}
}
}
final PathsCollection.Builder appRoots = PathsCollection.builder();
Path p = Paths.get(context.getApplicationRoot().getMain().getClassesPath());
final PathList.Builder appRoots = PathList.builder();
Path p = Path.of(context.getApplicationRoot().getMain().getClassesPath());
if (Files.exists(p)) {
appRoots.add(p);
}
Expand Down Expand Up @@ -116,22 +115,10 @@ public void start() throws Exception {
} else {
bootstrapBuilder.setProjectRoot(new File(".").toPath());
}
for (AppArtifactKey i : context.getLocalArtifacts()) {
for (ArtifactKey i : context.getLocalArtifacts()) {
bootstrapBuilder.addLocalArtifact(i);
}

for (DevModeContext.ModuleInfo i : context.getAdditionalModules()) {
if (i.getMain().getClassesPath() != null) {
Path classesPath = Paths.get(i.getMain().getClassesPath());
bootstrapBuilder.addAdditionalApplicationArchive(new AdditionalDependency(classesPath, true, false));
}
if (i.getMain().getResourcesOutputPath() != null
&& !i.getMain().getResourcesOutputPath().equals(i.getMain().getClassesPath())) {
Path resourceOutputPath = Paths.get(i.getMain().getResourcesOutputPath());
bootstrapBuilder.addAdditionalApplicationArchive(new AdditionalDependency(resourceOutputPath, true, false));
}
}

linkDotEnvFile();

Properties buildSystemProperties = new Properties();
Expand Down
Loading