provider) {
}
protected void addProvidedType(Class> providedType) {
- if(providedTypes.isEmpty()) {
+ if (providedTypes.isEmpty()) {
providedTypes = new ArrayList<>(1);
}
providedTypes.add(providedType);
@@ -52,7 +52,7 @@ boolean isFlagOn(int flag) {
}
boolean setFlag(int flag) {
- if((flags & flag) > 0) {
+ if ((flags & flag) > 0) {
return false;
}
flags ^= flag;
@@ -60,7 +60,7 @@ boolean setFlag(int flag) {
}
void clearFlag(int flag) {
- if((flags & flag) > 0) {
+ if ((flags & flag) > 0) {
flags ^= flag;
}
}
diff --git a/core/creator/src/main/java/io/quarkus/creator/phase/augment/AugmentOutcome.java b/core/creator/src/main/java/io/quarkus/creator/phase/augment/AugmentOutcome.java
index 5140355568990..a917350be6f11 100644
--- a/core/creator/src/main/java/io/quarkus/creator/phase/augment/AugmentOutcome.java
+++ b/core/creator/src/main/java/io/quarkus/creator/phase/augment/AugmentOutcome.java
@@ -19,8 +19,6 @@
import java.nio.file.Path;
-import io.quarkus.creator.AppDependency;
-
/**
* Represents an outcome of {@link AugmentPhase}
*
@@ -51,13 +49,9 @@ public interface AugmentOutcome {
Path getWiringClassesDir();
/**
- * Phases that consume this outcome may check whether an application
- * dependency was "whitelisted" for processing during augmentation.
- *
- * The need for this method has to be further reviewed.
+ * Directory containing config files used by the application
*
- * @param dep application dependency
- * @return true if the dependency was whitelisted, otherwise - false
+ * @return directory containing config files
*/
- boolean isWhitelisted(AppDependency dep);
+ Path getConfigDir();
}
diff --git a/core/creator/src/main/java/io/quarkus/creator/phase/augment/AugmentPhase.java b/core/creator/src/main/java/io/quarkus/creator/phase/augment/AugmentPhase.java
index 898b78b5a274b..57dab7b440655 100644
--- a/core/creator/src/main/java/io/quarkus/creator/phase/augment/AugmentPhase.java
+++ b/core/creator/src/main/java/io/quarkus/creator/phase/augment/AugmentPhase.java
@@ -17,24 +17,23 @@
package io.quarkus.creator.phase.augment;
-import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLClassLoader;
-import java.nio.charset.StandardCharsets;
+import java.nio.file.CopyOption;
+import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.StandardCopyOption;
+import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.ExecutorService;
@@ -42,28 +41,27 @@
import java.util.concurrent.Future;
import java.util.function.BiFunction;
import java.util.function.Consumer;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
import org.eclipse.microprofile.config.Config;
-import org.jboss.builder.BuildResult;
import org.jboss.logging.Logger;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
-import io.quarkus.creator.AppArtifact;
-import io.quarkus.creator.AppArtifactResolver;
+import io.quarkus.bootstrap.BootstrapDependencyProcessingException;
+import io.quarkus.bootstrap.model.AppDependency;
+import io.quarkus.bootstrap.resolver.AppModelResolver;
+import io.quarkus.bootstrap.util.IoUtils;
+import io.quarkus.bootstrap.util.ZipUtils;
+import io.quarkus.builder.BuildResult;
import io.quarkus.creator.AppCreationPhase;
import io.quarkus.creator.AppCreator;
import io.quarkus.creator.AppCreatorException;
-import io.quarkus.creator.AppDependency;
import io.quarkus.creator.config.reader.MappedPropertiesHandler;
import io.quarkus.creator.config.reader.PropertiesHandler;
import io.quarkus.creator.outcome.OutcomeProviderRegistration;
import io.quarkus.creator.phase.curate.CurateOutcome;
-import io.quarkus.creator.util.IoUtils;
-import io.quarkus.creator.util.ZipUtils;
+import io.quarkus.deployment.ApplicationInfoUtil;
import io.quarkus.deployment.ClassOutput;
import io.quarkus.deployment.QuarkusAugmentor;
import io.quarkus.deployment.QuarkusClassWriter;
@@ -81,17 +79,15 @@
*/
public class AugmentPhase implements AppCreationPhase, AugmentOutcome {
- private static final String DEPENDENCIES_RUNTIME = "dependencies.runtime";
- private static final String FILENAME_STEP_CLASSES = "META-INF/quarkus-build-steps.list";
- private static final String PROVIDED = "provided";
-
private static final Logger log = Logger.getLogger(AugmentPhase.class);
+ private static final String APPLICATION_INFO_PROPERTIES = "application-info.properties";
+ private static final String META_INF = "META-INF";
private Path outputDir;
private Path appClassesDir;
private Path transformedClassesDir;
private Path wiringClassesDir;
- private Set whitelist = new HashSet<>();
+ private Path configDir;
/**
* Output directory for the outcome of this phase.
@@ -144,6 +140,17 @@ public AugmentPhase setWiringClassesDir(Path wiringClassesDir) {
return this;
}
+ /**
+ * Directory containing the configuration files.
+ *
+ * @param configDir directory the configuration files (application.properties)
+ * @return this phase instance
+ */
+ public AugmentPhase setConfigDir(Path configDir) {
+ this.configDir = configDir;
+ return this;
+ }
+
@Override
public Path getAppClassesDir() {
return appClassesDir;
@@ -160,8 +167,8 @@ public Path getWiringClassesDir() {
}
@Override
- public boolean isWhitelisted(AppDependency dep) {
- return whitelist.contains(getDependencyConflictId(dep.getArtifact()));
+ public Path getConfigDir() {
+ return configDir;
}
@Override
@@ -177,16 +184,34 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
if (appClassesDir == null) {
appClassesDir = outputDir.resolve("classes");
- final Path appJar = appState.getArtifactResolver().resolve(appState.getAppArtifact());
+ Path appJar = appState.getAppArtifact().getPath();
try {
ZipUtils.unzip(appJar, appClassesDir);
} catch (IOException e) {
throw new AppCreatorException("Failed to unzip " + appJar, e);
}
- final Path metaInf = appClassesDir.resolve("META-INF");
+ final Path metaInf = appClassesDir.resolve(META_INF);
IoUtils.recursiveDelete(metaInf.resolve("maven"));
IoUtils.recursiveDelete(metaInf.resolve("INDEX.LIST"));
IoUtils.recursiveDelete(metaInf.resolve("MANIFEST.MF"));
+ IoUtils.recursiveDelete(metaInf.resolve(APPLICATION_INFO_PROPERTIES));
+ }
+
+ ApplicationInfoUtil.writeApplicationInfoProperties(appState.getAppArtifact(), appClassesDir);
+
+ //lets default to appClassesDir for now
+ if (configDir == null)
+ configDir = appClassesDir;
+ else {
+ //if we use gradle we copy the configDir contents to appClassesDir
+ try {
+ if (!Files.isSameFile(configDir, appClassesDir)) {
+ Files.walkFileTree(configDir,
+ new CopyDirVisitor(configDir, appClassesDir, StandardCopyOption.REPLACE_EXISTING));
+ }
+ } catch (IOException e) {
+ throw new AppCreatorException("Failed while copying files from " + configDir + " to " + appClassesDir, e);
+ }
}
transformedClassesDir = IoUtils
@@ -201,7 +226,7 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
private void doProcess(CurateOutcome appState) throws AppCreatorException {
//first lets look for some config, as it is not on the current class path
//and we need to load it to run the build process
- Path config = appClassesDir.resolve("application.properties");
+ Path config = configDir.resolve("application.properties");
if (Files.exists(config)) {
try {
Config built = SmallRyeConfigProviderResolver.instance().getBuilder()
@@ -215,71 +240,27 @@ private void doProcess(CurateOutcome appState) throws AppCreatorException {
}
}
- final AppArtifactResolver depResolver = appState.getArtifactResolver();
- final List appDeps = appState.getEffectiveDeps();
+ final AppModelResolver depResolver = appState.getArtifactResolver();
+ List appDeps;
+ try {
+ appDeps = appState.getEffectiveModel().getAllDependencies();
+ } catch (BootstrapDependencyProcessingException e) {
+ throw new AppCreatorException("Failed to resolve application build classpath", e);
+ }
URLClassLoader runnerClassLoader = null;
try {
// we need to make sure all the deployment artifacts are on the class path
- final List cpUrls = new ArrayList<>();
+ final List cpUrls = new ArrayList<>(appDeps.size() + 1);
cpUrls.add(appClassesDir.toUri().toURL());
- List problems = null;
for (AppDependency appDep : appDeps) {
- final AppArtifact depArtifact = appDep.getArtifact();
- final Path resolvedDep = depResolver.resolve(depArtifact);
+ final Path resolvedDep = depResolver.resolve(appDep.getArtifact());
cpUrls.add(resolvedDep.toUri().toURL());
-
- if (!"jar".equals(depArtifact.getType())) {
- continue;
- }
- try (ZipFile zip = openZipFile(resolvedDep)) {
- boolean deploymentArtifact = zip.getEntry("META-INF/quarkus-build-steps.list") != null;
- if (!appDep.getScope().equals(PROVIDED) && deploymentArtifact) {
- if (problems == null) {
- problems = new ArrayList<>();
- }
- problems.add("Artifact " + appDep
- + " is a deployment artifact, however it does not have scope required. This will result in unnecessary jars being included in the final image");
- }
- if (!deploymentArtifact) {
- ZipEntry entry = zip.getEntry(DEPENDENCIES_RUNTIME);
- if (entry != null) {
- whitelist.add(getDependencyConflictId(appDep.getArtifact()));
- try (InputStream in = zip.getInputStream(entry)) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
- String line;
- while ((line = reader.readLine()) != null) {
- String[] parts = line.trim().split(":");
- if (parts.length < 5) {
- continue;
- }
- String scope = parts[4];
- if (scope.equals("test")) {
- continue;
- }
- StringBuilder sb = new StringBuilder();
- //the last two bits are version and scope
- //which we don't want
- for (int i = 0; i < parts.length - 2; ++i) {
- if (i > 0) {
- sb.append(':');
- }
- sb.append(parts[i]);
- }
- whitelist.add(sb.toString());
- }
- }
- }
- }
- }
- }
- if (problems != null) {
- //TODO: add a config option to just log an error instead
- throw new AppCreatorException(problems.toString());
}
runnerClassLoader = new URLClassLoader(cpUrls.toArray(new URL[cpUrls.size()]), getClass().getClassLoader());
+
final Path wiringClassesDirectory = wiringClassesDir;
ClassOutput classOutput = new ClassOutput() {
@Override
@@ -323,11 +304,9 @@ public void writeResource(String name, byte[] data) throws IOException {
if (!bytecodeTransformerBuildItems.isEmpty()) {
final Map>> bytecodeTransformers = new HashMap<>(
bytecodeTransformerBuildItems.size());
- if (!bytecodeTransformerBuildItems.isEmpty()) {
- for (BytecodeTransformerBuildItem i : bytecodeTransformerBuildItems) {
- bytecodeTransformers.computeIfAbsent(i.getClassToTransform(), (h) -> new ArrayList<>())
- .add(i.getVisitorFunction());
- }
+ for (BytecodeTransformerBuildItem i : bytecodeTransformerBuildItems) {
+ bytecodeTransformers.computeIfAbsent(i.getClassToTransform(), (h) -> new ArrayList<>())
+ .add(i.getVisitorFunction());
}
// now copy all the contents to the runner jar
@@ -345,7 +324,7 @@ public void accept(Path path) {
return;
}
final String pathName = appClassesDir.relativize(path).toString();
- if (!pathName.endsWith(".class") || bytecodeTransformers.isEmpty()) {
+ if (!pathName.endsWith(".class")) {
return;
}
final String className = pathName.substring(0, pathName.length() - 6).replace('/', '.');
@@ -407,31 +386,6 @@ public FutureEntry call() throws Exception {
}
}
- private static String getDependencyConflictId(AppArtifact coords) {
- StringBuilder sb = new StringBuilder(128);
- sb.append(coords.getGroupId());
- sb.append(':');
- sb.append(coords.getArtifactId());
- sb.append(':');
- sb.append(coords.getType());
- if (!coords.getClassifier().isEmpty()) {
- sb.append(':');
- sb.append(coords.getClassifier());
- }
- return sb.toString();
- }
-
- private ZipFile openZipFile(Path p) {
- if (!Files.isReadable(p)) {
- throw new RuntimeException("File not existing or not allowed for reading: " + p);
- }
- try {
- return new ZipFile(p.toFile());
- } catch (IOException e) {
- throw new RuntimeException("Error opening zip stream from artifact: " + p, e);
- }
- }
-
private static final class FutureEntry {
final byte[] data;
final String location;
@@ -458,6 +412,34 @@ public AugmentPhase getTarget() {
.map("output", (AugmentPhase t, String value) -> t.setOutputDir(Paths.get(value)))
.map("classes", (AugmentPhase t, String value) -> t.setAppClassesDir(Paths.get(value)))
.map("transformed-classes", (AugmentPhase t, String value) -> t.setTransformedClassesDir(Paths.get(value)))
- .map("wiring-classes", (AugmentPhase t, String value) -> t.setWiringClassesDir(Paths.get(value)));
+ .map("wiring-classes", (AugmentPhase t, String value) -> t.setWiringClassesDir(Paths.get(value)))
+ .map("config", (AugmentPhase t, String value) -> t.setConfigDir(Paths.get(value)));
+ }
+
+ public static class CopyDirVisitor extends SimpleFileVisitor {
+ private final Path fromPath;
+ private final Path toPath;
+ private final CopyOption copyOption;
+
+ public CopyDirVisitor(Path fromPath, Path toPath, CopyOption copyOption) {
+ this.fromPath = fromPath;
+ this.toPath = toPath;
+ this.copyOption = copyOption;
+ }
+
+ @Override
+ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
+ Path targetPath = toPath.resolve(fromPath.relativize(dir));
+ if (!Files.exists(targetPath)) {
+ Files.createDirectory(targetPath);
+ }
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+ Files.copy(file, toPath.resolve(fromPath.relativize(file)), copyOption);
+ return FileVisitResult.CONTINUE;
+ }
}
}
diff --git a/core/creator/src/main/java/io/quarkus/creator/phase/curate/CurateOutcome.java b/core/creator/src/main/java/io/quarkus/creator/phase/curate/CurateOutcome.java
index 0577805a90d89..1c70577d4d528 100644
--- a/core/creator/src/main/java/io/quarkus/creator/phase/curate/CurateOutcome.java
+++ b/core/creator/src/main/java/io/quarkus/creator/phase/curate/CurateOutcome.java
@@ -27,13 +27,15 @@
import org.apache.maven.model.Repository;
import org.jboss.logging.Logger;
-import io.quarkus.creator.AppArtifact;
-import io.quarkus.creator.AppArtifactResolver;
+import io.quarkus.bootstrap.model.AppArtifact;
+import io.quarkus.bootstrap.model.AppDependency;
+import io.quarkus.bootstrap.model.AppModel;
+import io.quarkus.bootstrap.resolver.AppModelResolver;
+import io.quarkus.bootstrap.resolver.AppModelResolverException;
+import io.quarkus.bootstrap.resolver.BootstrapAppModelResolver;
+import io.quarkus.bootstrap.resolver.maven.workspace.ModelUtils;
import io.quarkus.creator.AppCreator;
import io.quarkus.creator.AppCreatorException;
-import io.quarkus.creator.AppDependency;
-import io.quarkus.creator.NoOpArtifactResolver;
-import io.quarkus.creator.resolver.aether.AetherArtifactResolver;
/**
*
@@ -51,34 +53,28 @@ public class CurateOutcome {
public static class Builder {
- private AppArtifact appArtifact;
private AppArtifact stateArtifact;
- private List initialDeps = Collections.emptyList();
+ private AppModel appModel;
private List updatedDeps = Collections.emptyList();
- private AppArtifactResolver resolver;
+ private AppModelResolver resolver;
private List artifactRepos = Collections.emptyList();
private boolean loadedFromState;
private Builder() {
}
- public Builder setAppArtifact(AppArtifact appArtifact) {
- this.appArtifact = appArtifact;
- return this;
- }
-
public Builder setStateArtifact(AppArtifact stateArtifact) {
this.stateArtifact = stateArtifact;
return this;
}
- public Builder setArtifactResolver(AppArtifactResolver resolver) {
+ public Builder setAppModelResolver(AppModelResolver resolver) {
this.resolver = resolver;
return this;
}
- public Builder setInitialDeps(List deps) {
- this.initialDeps = deps;
+ public Builder setAppModel(AppModel appModel) {
+ this.appModel = appModel;
return this;
}
@@ -104,38 +100,35 @@ public static Builder builder() {
return new Builder();
}
- protected final AppArtifact appArtifact;
protected final AppArtifact stateArtifact;
- protected final List initialDeps;
+ protected final AppModel initialModel;
protected final List updatedDeps;
- protected final AppArtifactResolver resolver;
+ protected final AppModelResolver resolver;
protected final List artifactRepos;
protected final boolean loadedFromState;
- protected List effectiveDeps;
+ protected AppModel effectiveModel;
protected boolean persisted;
public CurateOutcome(Builder builder) {
- this.appArtifact = builder.appArtifact;
this.stateArtifact = builder.stateArtifact;
- this.initialDeps = builder.initialDeps.isEmpty() ? builder.initialDeps
- : Collections.unmodifiableList(builder.initialDeps);
+ this.initialModel = builder.appModel;
this.updatedDeps = builder.updatedDeps.isEmpty() ? builder.updatedDeps
: Collections.unmodifiableList(builder.updatedDeps);
- this.resolver = builder.resolver == null ? new NoOpArtifactResolver() : builder.resolver;
+ this.resolver = builder.resolver;
this.artifactRepos = builder.artifactRepos;
this.loadedFromState = builder.loadedFromState;
}
- public AppArtifactResolver getArtifactResolver() {
+ public AppModelResolver getArtifactResolver() {
return resolver;
}
public AppArtifact getAppArtifact() {
- return appArtifact;
+ return initialModel.getAppArtifact();
}
- public List getInitialDeps() {
- return initialDeps;
+ public AppModel getInitialModel() {
+ return initialModel;
}
public boolean hasUpdatedDeps() {
@@ -146,33 +139,38 @@ public List getUpdatedDeps() {
return updatedDeps;
}
- public List getEffectiveDeps() throws AppCreatorException {
- if (effectiveDeps != null) {
- return effectiveDeps;
+ public AppModel getEffectiveModel() throws AppCreatorException {
+ if (effectiveModel != null) {
+ return effectiveModel;
}
if (updatedDeps.isEmpty()) {
- return effectiveDeps = initialDeps;
+ return effectiveModel = initialModel;
+ }
+ try {
+ return effectiveModel = resolver.resolveModel(initialModel.getAppArtifact(), updatedDeps);
+ } catch (AppModelResolverException e) {
+ throw new AppCreatorException("Failed to resolve effective application dependencies", e);
}
- return effectiveDeps = resolver.collectDependencies(appArtifact, updatedDeps);
}
public boolean isPersisted() {
return persisted;
}
- public void persist(AppCreator ctx) throws AppCreatorException {
+ public void persist(AppCreator creator) throws AppCreatorException {
if (persisted || loadedFromState && !hasUpdatedDeps()) {
log.info("Skipping provisioning state persistence");
return;
}
log.info("Persisting provisioning state");
- final Path stateDir = ctx.createWorkDir("state");
+ final Path stateDir = creator.createWorkDir("state");
final Path statePom = stateDir.resolve("pom.xml");
+ final AppArtifact appArtifact = initialModel.getAppArtifact();
AppArtifact stateArtifact;
if (this.stateArtifact == null) {
- stateArtifact = Utils.getStateArtifact(appArtifact);
+ stateArtifact = ModelUtils.getStateArtifact(appArtifact);
} else {
stateArtifact = new AppArtifact(this.stateArtifact.getGroupId(),
this.stateArtifact.getArtifactId(),
@@ -240,9 +238,13 @@ public void persist(AppCreator ctx) throws AppCreatorException {
* }
* }
*/
- Utils.persistModel(statePom, model);
- ((AetherArtifactResolver) resolver).install(stateArtifact, statePom);
+ try {
+ ModelUtils.persistModel(statePom, model);
+ ((BootstrapAppModelResolver) resolver).install(stateArtifact, statePom);
+ } catch (Exception e) {
+ throw new AppCreatorException("Failed to persist application state artifact", e);
+ }
log.info("Persisted provisioning state as " + stateArtifact);
//ctx.getArtifactResolver().relink(stateArtifact, statePom);
diff --git a/core/creator/src/main/java/io/quarkus/creator/phase/curate/CuratePhase.java b/core/creator/src/main/java/io/quarkus/creator/phase/curate/CuratePhase.java
index 8815ca6335cfa..5565faf980a11 100644
--- a/core/creator/src/main/java/io/quarkus/creator/phase/curate/CuratePhase.java
+++ b/core/creator/src/main/java/io/quarkus/creator/phase/curate/CuratePhase.java
@@ -18,15 +18,13 @@
package io.quarkus.creator.phase.curate;
import java.io.IOException;
+import java.nio.file.FileSystem;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
-import java.util.Set;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
@@ -35,17 +33,24 @@
import org.eclipse.aether.repository.RepositoryPolicy;
import org.jboss.logging.Logger;
-import io.quarkus.creator.AppArtifact;
-import io.quarkus.creator.AppArtifactResolver;
+import io.quarkus.bootstrap.BootstrapConstants;
+import io.quarkus.bootstrap.BootstrapDependencyProcessingException;
+import io.quarkus.bootstrap.model.AppArtifact;
+import io.quarkus.bootstrap.model.AppDependency;
+import io.quarkus.bootstrap.model.AppModel;
+import io.quarkus.bootstrap.resolver.AppModelResolver;
+import io.quarkus.bootstrap.resolver.AppModelResolverException;
+import io.quarkus.bootstrap.resolver.BootstrapAppModelResolver;
+import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
+import io.quarkus.bootstrap.resolver.maven.workspace.ModelUtils;
+import io.quarkus.bootstrap.util.ZipUtils;
import io.quarkus.creator.AppCreationPhase;
import io.quarkus.creator.AppCreator;
import io.quarkus.creator.AppCreatorException;
-import io.quarkus.creator.AppDependency;
import io.quarkus.creator.config.reader.MappedPropertiesHandler;
import io.quarkus.creator.config.reader.PropertiesConfigReaderException;
import io.quarkus.creator.config.reader.PropertiesHandler;
import io.quarkus.creator.outcome.OutcomeProviderRegistration;
-import io.quarkus.creator.resolver.aether.AetherArtifactResolver;
/**
*
@@ -58,9 +63,6 @@ public class CuratePhase implements AppCreationPhase {
public static final String CONFIG_PROP_LOCAL_REPO = "local-repo";
public static final String CONFIG_PROP_VERSION_UPDATE = "version-update";
public static final String CONFIG_PROP_VERSION_UPDATE_NUMBER = "version-update-number";
- public static final String CONFIG_PROP_UPDATE_GROUP_ID = "update-groupId";
-
- private static final String GROUP_ID_SPLIT_EXPR = "\\s*(,|\\s)\\s*";
public static String completePropertyName(String name) {
return CONFIG_PROP + '.' + name;
@@ -72,7 +74,6 @@ public static String completePropertyName(String name) {
private VersionUpdate update = VersionUpdate.NONE;
private VersionUpdateNumber updateNumber = VersionUpdateNumber.MICRO;
private Path localRepo;
- private Set updateGroupIds = Collections.singleton("io.quarkus");
public void setInitialDeps(DependenciesOrigin initialDeps) {
this.depsOrigin = initialDeps;
@@ -126,9 +127,6 @@ public CuratePhase getTarget() throws PropertiesConfigReaderException {
+ VersionUpdateNumber.MAJOR + ", " + VersionUpdateNumber.MINOR + " or "
+ VersionUpdateNumber.MICRO + " but was " + value);
}
- })
- .map(CONFIG_PROP_UPDATE_GROUP_ID, (target, value) -> {
- updateGroupIds = new HashSet<>(Arrays.asList(value.split(GROUP_ID_SPLIT_EXPR)));
});
}
@@ -153,75 +151,82 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
final CurateOutcome.Builder outcome = CurateOutcome.builder();
- final AppArtifact appArtifact = Utils.resolveAppArtifact(appJar);
- outcome.setAppArtifact(appArtifact);
+ AppArtifact appArtifact;
+ try {
+ appArtifact = ModelUtils.resolveAppArtifact(appJar);
+ } catch (IOException e) {
+ throw new AppCreatorException("Failed to resolve application artifact coordindates from " + appJar, e);
+ }
- AppArtifactResolver resolver = ctx.getArtifactResolver();
- if (resolver == null) {
- final AetherArtifactResolver aetherResolver = AetherArtifactResolver
- .getInstance(this.localRepo == null ? ctx.getWorkPath("repo") : this.localRepo);
- aetherResolver.relink(appArtifact, appJar);
- final List artifactRepos = aetherResolver.resolveArtifactRepos(appArtifact);
- if (!artifactRepos.isEmpty()) {
- aetherResolver.addRemoteRepositories(artifactRepos);
- final List modelRepos = new ArrayList<>(artifactRepos.size());
- for (RemoteRepository repo : artifactRepos) {
- final Repository modelRepo = new Repository();
- modelRepo.setId(repo.getId());
- modelRepo.setUrl(repo.getUrl());
- modelRepo.setLayout(repo.getContentType());
- RepositoryPolicy policy = repo.getPolicy(true);
- if (policy != null) {
- modelRepo.setSnapshots(toMavenRepoPolicy(policy));
- }
- policy = repo.getPolicy(false);
- if (policy != null) {
- modelRepo.setReleases(toMavenRepoPolicy(policy));
+ AppModelResolver modelResolver = ctx.getArtifactResolver();
+ final AppModel initialDepsList;
+ try {
+ if (modelResolver == null) {
+ final BootstrapAppModelResolver bsResolver = new BootstrapAppModelResolver(
+ MavenArtifactResolver.builder()
+ .setRepoHome(this.localRepo == null ? ctx.getWorkPath("repo") : this.localRepo)
+ .build());
+ bsResolver.relink(appArtifact, appJar);
+ final List artifactRepos = bsResolver.resolveArtifactRepos(appArtifact);
+ if (!artifactRepos.isEmpty()) {
+ bsResolver.addRemoteRepositories(artifactRepos);
+ final List modelRepos = new ArrayList<>(artifactRepos.size());
+ for (RemoteRepository repo : artifactRepos) {
+ final Repository modelRepo = new Repository();
+ modelRepo.setId(repo.getId());
+ modelRepo.setUrl(repo.getUrl());
+ modelRepo.setLayout(repo.getContentType());
+ RepositoryPolicy policy = repo.getPolicy(true);
+ if (policy != null) {
+ modelRepo.setSnapshots(toMavenRepoPolicy(policy));
+ }
+ policy = repo.getPolicy(false);
+ if (policy != null) {
+ modelRepo.setReleases(toMavenRepoPolicy(policy));
+ }
+ modelRepos.add(modelRepo);
}
- modelRepos.add(modelRepo);
+ outcome.setArtifactRepos(modelRepos);
}
- outcome.setArtifactRepos(modelRepos);
+ modelResolver = bsResolver;
+ } else {
+ modelResolver.relink(appArtifact, appJar);
}
- resolver = aetherResolver;
- } else {
- resolver.relink(appArtifact, appJar);
- }
- outcome.setArtifactResolver(resolver);
+ outcome.setAppModelResolver(modelResolver);
- final List initialDepsList;
- if (depsOrigin == DependenciesOrigin.LAST_UPDATE) {
- log.info("Looking for the state of the last update");
- Path statePath = null;
- try {
- AppArtifact stateArtifact = Utils.getStateArtifact(appArtifact);
- final String latest = resolver.getLatestVersion(stateArtifact, null, false);
- if (!stateArtifact.getVersion().equals(latest)) {
- stateArtifact = new AppArtifact(stateArtifact.getGroupId(),
- stateArtifact.getArtifactId(),
- stateArtifact.getClassifier(),
- stateArtifact.getType(),
- latest);
+ if (depsOrigin == DependenciesOrigin.LAST_UPDATE) {
+ log.info("Looking for the state of the last update");
+ Path statePath = null;
+ try {
+ AppArtifact stateArtifact = ModelUtils.getStateArtifact(appArtifact);
+ final String latest = modelResolver.getLatestVersion(stateArtifact, null, false);
+ if (!stateArtifact.getVersion().equals(latest)) {
+ stateArtifact = new AppArtifact(stateArtifact.getGroupId(), stateArtifact.getArtifactId(),
+ stateArtifact.getClassifier(), stateArtifact.getType(), latest);
+ }
+ statePath = modelResolver.resolve(stateArtifact);
+ outcome.setStateArtifact(stateArtifact);
+ log.info("- located the state at " + statePath);
+ } catch (AppModelResolverException e) {
+ // for now let's assume this means artifact does not exist
+ // System.out.println(" no state found");
}
- statePath = resolver.resolve(stateArtifact);
- outcome.setStateArtifact(stateArtifact);
- log.info("- located the state at " + statePath);
- } catch (AppCreatorException e) {
- // for now let's assume this means artifact does not exist
- //System.out.println(" no state found");
- }
- if (statePath != null) {
- try {
- final Model model = Utils.readModel(statePath);
+ if (statePath != null) {
+ Model model;
+ try {
+ model = ModelUtils.readModel(statePath);
+ } catch (IOException e) {
+ throw new AppCreatorException("Failed to read application state " + statePath, e);
+ }
/*
- * final Properties props = model.getProperties();
- * final String appGroupId = props.getProperty(CurateOutcome.CREATOR_APP_GROUP_ID);
- * final String appArtifactId = props.getProperty(CurateOutcome.CREATOR_APP_ARTIFACT_ID);
- * final String appClassifier = props.getProperty(CurateOutcome.CREATOR_APP_CLASSIFIER);
- * final String appType = props.getProperty(CurateOutcome.CREATOR_APP_TYPE);
- * final String appVersion = props.getProperty(CurateOutcome.CREATOR_APP_VERSION);
- * final AppArtifact modelAppArtifact = new AppArtifact(appGroupId, appArtifactId, appClassifier, appType,
- * appVersion);
+ * final Properties props = model.getProperties(); final String appGroupId =
+ * props.getProperty(CurateOutcome.CREATOR_APP_GROUP_ID); final String appArtifactId =
+ * props.getProperty(CurateOutcome.CREATOR_APP_ARTIFACT_ID); final String appClassifier =
+ * props.getProperty(CurateOutcome.CREATOR_APP_CLASSIFIER); final String appType =
+ * props.getProperty(CurateOutcome.CREATOR_APP_TYPE); final String appVersion =
+ * props.getProperty(CurateOutcome.CREATOR_APP_VERSION); final AppArtifact modelAppArtifact = new
+ * AppArtifact(appGroupId, appArtifactId, appClassifier, appType, appVersion);
*/
final List modelStateDeps = model.getDependencies();
final List updatedDeps = new ArrayList<>(modelStateDeps.size());
@@ -231,32 +236,58 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
continue;
}
updatedDeps.add(new AppDependency(new AppArtifact(modelDep.getGroupId(), modelDep.getArtifactId(),
- modelDep.getClassifier(), modelDep.getType(), modelDep.getVersion()), modelDep.getScope()));
+ modelDep.getClassifier(), modelDep.getType(), modelDep.getVersion()), modelDep.getScope(),
+ modelDep.isOptional()));
}
- initialDepsList = resolver.collectDependencies(appArtifact, updatedDeps);
+ initialDepsList = modelResolver.resolveModel(appArtifact, updatedDeps);
outcome.setLoadedFromState();
- } catch (IOException e) {
- throw new AppCreatorException("Failed to load application state POM " + statePath, e);
+ } else {
+ initialDepsList = modelResolver.resolveModel(appArtifact);
}
} else {
- initialDepsList = resolver.collectDependencies(appArtifact);
+ initialDepsList = modelResolver.resolveModel(appArtifact);
}
- } else {
- initialDepsList = resolver.collectDependencies(appArtifact);
+ } catch (AppModelResolverException e) {
+ throw new AppCreatorException("Failed to resolve initial application dependencies", e);
}
- //logDeps("INITIAL:", initialDepsList);
-
- outcome.setInitialDeps(initialDepsList);
+ outcome.setAppModel(initialDepsList);
if (update == VersionUpdate.NONE) {
ctx.pushOutcome(outcome.build());
return;
}
log.info("Checking for available updates");
- final List appDeps = Utils.getUpdateCandidates(Utils.readAppModel(appJar, appArtifact).getDependencies(),
- initialDepsList, updateGroupIds);
- final UpdateDiscovery ud = new DefaultUpdateDiscovery(resolver, updateNumber);
+ List appDeps;
+ try {
+ appDeps = modelResolver.resolveUserDependencies(appArtifact, initialDepsList.getUserDependencies());
+ } catch (AppModelResolverException | BootstrapDependencyProcessingException e) {
+ throw new AppCreatorException("Failed to determine the list of dependencies to update", e);
+ }
+ final Iterator depsI = appDeps.iterator();
+ while (depsI.hasNext()) {
+ final AppArtifact appDep = depsI.next().getArtifact();
+ if (!appDep.getType().equals(AppArtifact.TYPE_JAR)) {
+ depsI.remove();
+ continue;
+ }
+ final Path path = appDep.getPath();
+ if (Files.isDirectory(path)) {
+ if (!Files.exists(path.resolve(BootstrapConstants.DESCRIPTOR_PATH))) {
+ depsI.remove();
+ }
+ } else {
+ try (FileSystem artifactFs = ZipUtils.newFileSystem(path)) {
+ if (!Files.exists(artifactFs.getPath(BootstrapConstants.DESCRIPTOR_PATH))) {
+ depsI.remove();
+ }
+ } catch (IOException e) {
+ throw new AppCreatorException("Failed to open " + path, e);
+ }
+ }
+ }
+
+ final UpdateDiscovery ud = new DefaultUpdateDiscovery(modelResolver, updateNumber);
List availableUpdates = null;
int i = 0;
while (i < appDeps.size()) {
@@ -264,7 +295,7 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
final AppArtifact depArtifact = dep.getArtifact();
final String updatedVersion = update == VersionUpdate.NEXT ? ud.getNextVersion(depArtifact)
: ud.getLatestVersion(depArtifact);
- if (depArtifact.getVersion().equals(updatedVersion)) {
+ if (updatedVersion == null || depArtifact.getVersion().equals(updatedVersion)) {
continue;
}
log.info(dep.getArtifact() + " -> " + updatedVersion);
@@ -291,16 +322,4 @@ private static org.apache.maven.model.RepositoryPolicy toMavenRepoPolicy(Reposit
mvnPolicy.setUpdatePolicy(policy.getUpdatePolicy());
return mvnPolicy;
}
-
- private static void logDeps(String header, List deps) {
- final List list = new ArrayList<>(deps.size());
- for (AppDependency dep : deps) {
- list.add(dep.toString());
- }
- Collections.sort(list);
- System.out.println(header);
- for (String str : list) {
- System.out.println("- " + str);
- }
- }
}
diff --git a/core/creator/src/main/java/io/quarkus/creator/phase/curate/DefaultUpdateDiscovery.java b/core/creator/src/main/java/io/quarkus/creator/phase/curate/DefaultUpdateDiscovery.java
index df684a70fa9d5..d9e2f3d640863 100644
--- a/core/creator/src/main/java/io/quarkus/creator/phase/curate/DefaultUpdateDiscovery.java
+++ b/core/creator/src/main/java/io/quarkus/creator/phase/curate/DefaultUpdateDiscovery.java
@@ -19,8 +19,9 @@
import java.util.List;
-import io.quarkus.creator.AppArtifact;
-import io.quarkus.creator.AppArtifactResolver;
+import io.quarkus.bootstrap.model.AppArtifact;
+import io.quarkus.bootstrap.resolver.AppModelResolver;
+import io.quarkus.bootstrap.resolver.AppModelResolverException;
import io.quarkus.creator.AppCreatorException;
/**
@@ -29,22 +30,30 @@
*/
public class DefaultUpdateDiscovery implements UpdateDiscovery {
- private final AppArtifactResolver resolver;
+ private final AppModelResolver resolver;
private final VersionUpdateNumber updateNumber;
- public DefaultUpdateDiscovery(AppArtifactResolver resolver, VersionUpdateNumber updateNumber) {
+ public DefaultUpdateDiscovery(AppModelResolver resolver, VersionUpdateNumber updateNumber) {
this.resolver = resolver;
this.updateNumber = updateNumber;
}
@Override
public List listUpdates(AppArtifact artifact) throws AppCreatorException {
- return resolver.listLaterVersions(artifact, resolveUpToVersion(artifact), false);
+ try {
+ return resolver.listLaterVersions(artifact, resolveUpToVersion(artifact), false);
+ } catch (AppModelResolverException e) {
+ throw new AppCreatorException("Failed to collect later versions", e);
+ }
}
@Override
public String getNextVersion(AppArtifact artifact) throws AppCreatorException {
- return resolver.getNextVersion(artifact, resolveUpToVersion(artifact), false);
+ try {
+ return resolver.getNextVersion(artifact, getFromVersion(artifact), true, resolveUpToVersion(artifact), false);
+ } catch (AppModelResolverException e) {
+ throw new AppCreatorException("Failed to determine the next available version", e);
+ }
}
@Override
@@ -62,7 +71,11 @@ public String getLatestVersion(AppArtifact artifact) throws AppCreatorException
* }
* return latestStr;
*/
- return resolver.getLatestVersion(artifact, resolveUpToVersion(artifact), false);
+ try {
+ return resolver.getLatestVersion(artifact, resolveUpToVersion(artifact), false);
+ } catch (AppModelResolverException e) {
+ throw new AppCreatorException("Failed to determine the latest available version", e);
+ }
}
private String resolveUpToVersion(AppArtifact artifact) throws AppCreatorException {
@@ -103,4 +116,55 @@ private String resolveUpToVersion(AppArtifact artifact) throws AppCreatorExcepti
}
return majorStr + "." + String.valueOf(minor + 1) + ".alpha";
}
+
+ private String getFromVersion(AppArtifact artifact) throws AppCreatorException {
+ // here we are looking for the major version which is going to be used
+ // as the base for the version range to look for the updates
+ final String version = artifact.getVersion();
+ final int majorMinorSep = version.indexOf('.');
+ if (majorMinorSep <= 0) {
+ throw new AppCreatorException("Failed to determine the major version in " + version);
+ }
+ final String majorStr = version.substring(0, majorMinorSep);
+ if (updateNumber == VersionUpdateNumber.MAJOR) {
+ final long major;
+ try {
+ major = Long.parseLong(majorStr);
+ } catch (NumberFormatException e) {
+ throw new AppCreatorException(
+ "The version is expected to start with a number indicating the major version: " + version);
+ }
+ return String.valueOf(major + 1) + ".alpha";
+ }
+
+ final int minorMicroSep = version.indexOf('.', majorMinorSep + 1);
+ if (minorMicroSep <= 0) {
+ throw new AppCreatorException("Failed to determine the minor version in " + version);
+ }
+ final String minorStr = version.substring(majorMinorSep + 1, minorMicroSep);
+ if (updateNumber == VersionUpdateNumber.MINOR) {
+ final long minor;
+ try {
+ minor = Long.parseLong(minorStr);
+ } catch (NumberFormatException e) {
+ throw new AppCreatorException(
+ "Failed to parse the minor number in version: " + version);
+ }
+ return majorStr + "." + String.valueOf(minor + 1) + ".alpha";
+ }
+
+ if (minorMicroSep == version.length() - 1) {
+ throw new AppCreatorException("Failed to determine the micro version in " + version);
+ }
+ final String microStr = version.substring(minorMicroSep + 1);
+
+ final long micro;
+ try {
+ micro = Long.parseLong(microStr);
+ } catch (NumberFormatException e) {
+ throw new AppCreatorException(
+ "Failed to parse the micro number in version: " + version);
+ }
+ return majorStr + "." + minorStr + "." + String.valueOf(micro + 1) + ".alpha";
+ }
}
diff --git a/core/creator/src/main/java/io/quarkus/creator/phase/curate/DependenciesOrigin.java b/core/creator/src/main/java/io/quarkus/creator/phase/curate/DependenciesOrigin.java
index dd06657edfbca..9c1b4f1bf136f 100644
--- a/core/creator/src/main/java/io/quarkus/creator/phase/curate/DependenciesOrigin.java
+++ b/core/creator/src/main/java/io/quarkus/creator/phase/curate/DependenciesOrigin.java
@@ -23,7 +23,9 @@
*/
public enum DependenciesOrigin {
- APPLICATION("application"), LAST_UPDATE("last-update"), UNKNOWN(null);
+ APPLICATION("application"),
+ LAST_UPDATE("last-update"),
+ UNKNOWN(null);
private final String name;
diff --git a/core/creator/src/main/java/io/quarkus/creator/phase/curate/UpdateDiscovery.java b/core/creator/src/main/java/io/quarkus/creator/phase/curate/UpdateDiscovery.java
index 84942e042e815..68c8cee776433 100644
--- a/core/creator/src/main/java/io/quarkus/creator/phase/curate/UpdateDiscovery.java
+++ b/core/creator/src/main/java/io/quarkus/creator/phase/curate/UpdateDiscovery.java
@@ -19,7 +19,7 @@
import java.util.List;
-import io.quarkus.creator.AppArtifact;
+import io.quarkus.bootstrap.model.AppArtifact;
import io.quarkus.creator.AppCreatorException;
/**
diff --git a/core/creator/src/main/java/io/quarkus/creator/phase/curate/Utils.java b/core/creator/src/main/java/io/quarkus/creator/phase/curate/Utils.java
deleted file mode 100644
index 826e4f37a22df..0000000000000
--- a/core/creator/src/main/java/io/quarkus/creator/phase/curate/Utils.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright 2018 Red Hat, Inc. and/or its affiliates
- * and other contributors as indicated by the @author tags.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.quarkus.creator.phase.curate;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.nio.file.DirectoryStream;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
-import io.quarkus.creator.AppArtifact;
-import io.quarkus.creator.AppCreatorException;
-import io.quarkus.creator.AppDependency;
-
-/**
- *
- * @author Alexey Loubyansky
- */
-public class Utils {
-
- private static final String STATE_ARTIFACT_INITIAL_VERSION = "1";
-
- /**
- * Returns the provisioning state artifact for the given application artifact
- *
- * @param appArtifact application artifact
- * @return provisioning state artifact
- */
- static AppArtifact getStateArtifact(AppArtifact appArtifact) {
- return new AppArtifact(appArtifact.getGroupId() + ".quarkus.curate",
- appArtifact.getArtifactId(),
- "",
- "pom",
- STATE_ARTIFACT_INITIAL_VERSION);
- }
-
- /**
- * Filters out non-platform from application POM dependencies.
- *
- * @param deps POM model application dependencies
- * @param appDeps resolved application dependencies
- * @return dependencies that can be checked for updates
- * @throws AppCreatorException in case of a failure
- */
- static List getUpdateCandidates(List deps, List appDeps, Set groupIds)
- throws AppCreatorException {
- final Map appDepMap = new LinkedHashMap<>(appDeps.size());
- for (AppDependency appDep : appDeps) {
- appDepMap.put(new ArtifactKey(appDep.getArtifact()), appDep);
- }
- final List updateCandidates = new ArrayList<>(deps.size());
- // it's critical to preserve the order of the dependencies from the pom
- for (Dependency dep : deps) {
- if (!groupIds.contains(dep.getGroupId()) || "test".equals(dep.getScope())) {
- continue;
- }
- final AppDependency appDep = appDepMap.remove(new ArtifactKey(dep));
- if (appDep == null) {
- // This normally would be a dependency that's missing test in the artifact's pom
- // but is marked as such in one of artifact's parent poms
- //throw new AppCreatorException("Failed to locate dependency " + new AppArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getClassifier(), dep.getType(), dep.getVersion()) + " present in pom.xml among resolved application dependencies");
- continue;
- }
- updateCandidates.add(appDep);
- }
- for (AppDependency appDep : appDepMap.values()) {
- if (groupIds.contains(appDep.getArtifact().getGroupId())) {
- updateCandidates.add(appDep);
- }
- }
- return updateCandidates;
- }
-
- static AppArtifact resolveAppArtifact(Path appJar) throws AppCreatorException {
- try (FileSystem fs = FileSystems.newFileSystem(appJar, null)) {
- final Path metaInfMaven = fs.getPath("META-INF", "maven");
- if (Files.exists(metaInfMaven)) {
- try (DirectoryStream groupIds = Files.newDirectoryStream(metaInfMaven)) {
- for (Path groupIdPath : groupIds) {
- if (!Files.isDirectory(groupIdPath)) {
- continue;
- }
- try (DirectoryStream artifactIds = Files.newDirectoryStream(groupIdPath)) {
- for (Path artifactIdPath : artifactIds) {
- if (!Files.isDirectory(artifactIdPath)) {
- continue;
- }
- final Path propsPath = artifactIdPath.resolve("pom.properties");
- if (Files.exists(propsPath)) {
- final Properties props = loadPomProps(appJar, artifactIdPath);
- return new AppArtifact(props.getProperty("groupId"), props.getProperty("artifactId"),
- props.getProperty("version"));
- }
- }
- }
- }
- }
- }
- throw new AppCreatorException(
- "Failed to located META-INF/maven///pom.properties in " + appJar);
- } catch (IOException e) {
- throw new AppCreatorException("Failed to load pom.properties from " + appJar, e);
- }
- }
-
- static Model readAppModel(Path appJar, AppArtifact appArtifact) throws AppCreatorException {
- try (FileSystem fs = FileSystems.newFileSystem(appJar, null)) {
- final Path pomXml = fs.getPath("META-INF", "maven", appArtifact.getGroupId(), appArtifact.getArtifactId(),
- "pom.xml");
- if (!Files.exists(pomXml)) {
- throw new AppCreatorException("Failed to located META-INF/maven///pom.xml in " + appJar);
- }
- try {
- return readModel(pomXml);
- } catch (IOException e) {
- throw new AppCreatorException("Failed to read " + pomXml, e);
- }
- } catch (IOException e) {
- throw new AppCreatorException("Failed to load pom.xml from " + appJar, e);
- }
- }
-
- static Model readAppModel(Path appJar) throws AppCreatorException {
- try (FileSystem fs = FileSystems.newFileSystem(appJar, null)) {
- final Path metaInfMaven = fs.getPath("META-INF", "maven");
- if (Files.exists(metaInfMaven)) {
- try (DirectoryStream groupIds = Files.newDirectoryStream(metaInfMaven)) {
- for (Path groupIdPath : groupIds) {
- if (!Files.isDirectory(groupIdPath)) {
- continue;
- }
- try (DirectoryStream artifactIds = Files.newDirectoryStream(groupIdPath)) {
- for (Path artifactIdPath : artifactIds) {
- if (!Files.isDirectory(artifactIdPath)) {
- continue;
- }
- final Path pomXml = artifactIdPath.resolve("pom.xml");
- if (Files.exists(pomXml)) {
- final Model model;
- try {
- model = readModel(pomXml);
- } catch (IOException e) {
- throw new AppCreatorException("Failed to read " + pomXml, e);
- }
- Properties props = null;
- if (model.getGroupId() == null) {
- props = loadPomProps(appJar, artifactIdPath);
- final String groupId = props.getProperty("groupId");
- if (groupId == null) {
- throw new AppCreatorException("Failed to determine groupId for " + appJar);
- }
- model.setGroupId(groupId);
- }
- if (model.getVersion() == null) {
- if (props == null) {
- props = loadPomProps(appJar, artifactIdPath);
- }
- final String version = props.getProperty("version");
- if (version == null) {
- throw new AppCreatorException(
- "Failed to determine the artifact version for " + appJar);
- }
- model.setVersion(version);
- }
- return model;
- }
- }
- }
- }
- }
- }
- throw new AppCreatorException("Failed to located META-INF/maven///pom.xml in " + appJar);
- } catch (IOException e) {
- throw new AppCreatorException("Failed to load pom.xml from " + appJar, e);
- }
- }
-
- private static Properties loadPomProps(Path appJar, Path artifactIdPath) throws AppCreatorException {
- final Path propsPath = artifactIdPath.resolve("pom.properties");
- if (!Files.exists(propsPath)) {
- throw new AppCreatorException(
- "Failed to located META-INF/maven///pom.properties in " + appJar);
- }
- final Properties props = new Properties();
- try (BufferedReader reader = Files.newBufferedReader(propsPath)) {
- props.load(reader);
- } catch (IOException e) {
- throw new AppCreatorException("Failed to read " + propsPath, e);
- }
- return props;
- }
-
- static Model readModel(final Path pomXml) throws IOException, AppCreatorException {
- try (BufferedReader reader = Files.newBufferedReader(pomXml)) {
- final MavenXpp3Reader xpp3Reader = new MavenXpp3Reader();
- return xpp3Reader.read(reader);
- } catch (XmlPullParserException e) {
- throw new AppCreatorException("Failed to parse application POM model", e);
- }
- }
-
- public static void persistModel(Path pomFile, Model model) throws AppCreatorException {
- final MavenXpp3Writer xpp3Writer = new MavenXpp3Writer();
- try (BufferedWriter pomFileWriter = Files.newBufferedWriter(pomFile)) {
- xpp3Writer.write(pomFileWriter, model);
- } catch (IOException e) {
- throw new AppCreatorException("Faile to write the pom.xml file", e);
- }
- }
-
- private static class ArtifactKey {
- final String groupId;
- final String artifactId;
- final String classifier;
-
- ArtifactKey(AppArtifact artifact) {
- this.groupId = artifact.getGroupId();
- this.artifactId = artifact.getArtifactId();
- this.classifier = artifact.getClassifier();
- }
-
- ArtifactKey(Dependency artifact) {
- this.groupId = artifact.getGroupId();
- this.artifactId = artifact.getArtifactId();
- final String classifier = artifact.getClassifier();
- this.classifier = classifier == null ? "" : classifier;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((artifactId == null) ? 0 : artifactId.hashCode());
- result = prime * result + ((classifier == null) ? 0 : classifier.hashCode());
- result = prime * result + ((groupId == null) ? 0 : groupId.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ArtifactKey other = (ArtifactKey) obj;
- if (artifactId == null) {
- if (other.artifactId != null)
- return false;
- } else if (!artifactId.equals(other.artifactId))
- return false;
- if (classifier == null) {
- if (other.classifier != null)
- return false;
- } else if (!classifier.equals(other.classifier))
- return false;
- if (groupId == null) {
- if (other.groupId != null)
- return false;
- } else if (!groupId.equals(other.groupId))
- return false;
- return true;
- }
- }
-
-}
diff --git a/core/creator/src/main/java/io/quarkus/creator/phase/curate/VersionUpdate.java b/core/creator/src/main/java/io/quarkus/creator/phase/curate/VersionUpdate.java
index 3e58265ed75e9..71666be83d097 100644
--- a/core/creator/src/main/java/io/quarkus/creator/phase/curate/VersionUpdate.java
+++ b/core/creator/src/main/java/io/quarkus/creator/phase/curate/VersionUpdate.java
@@ -23,7 +23,10 @@
*/
public enum VersionUpdate {
- LATEST("latest"), NEXT("next"), NONE("none"), UNKNOWN(null);
+ LATEST("latest"),
+ NEXT("next"),
+ NONE("none"),
+ UNKNOWN(null);
private final String name;
diff --git a/core/creator/src/main/java/io/quarkus/creator/phase/curate/VersionUpdateNumber.java b/core/creator/src/main/java/io/quarkus/creator/phase/curate/VersionUpdateNumber.java
index 183ae1ccba459..a873776917599 100644
--- a/core/creator/src/main/java/io/quarkus/creator/phase/curate/VersionUpdateNumber.java
+++ b/core/creator/src/main/java/io/quarkus/creator/phase/curate/VersionUpdateNumber.java
@@ -23,7 +23,10 @@
*/
public enum VersionUpdateNumber {
- MAJOR("major"), MINOR("minor"), MICRO("micro"), UNKNOWN(null);
+ MAJOR("major"),
+ MINOR("minor"),
+ MICRO("micro"),
+ UNKNOWN(null);
private final String name;
diff --git a/core/creator/src/main/java/io/quarkus/creator/phase/nativeimage/NativeImagePhase.java b/core/creator/src/main/java/io/quarkus/creator/phase/nativeimage/NativeImagePhase.java
index 3554376ed8509..b350a46b7c019 100644
--- a/core/creator/src/main/java/io/quarkus/creator/phase/nativeimage/NativeImagePhase.java
+++ b/core/creator/src/main/java/io/quarkus/creator/phase/nativeimage/NativeImagePhase.java
@@ -20,7 +20,8 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
-import java.io.PrintStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -38,6 +39,7 @@
import org.eclipse.microprofile.config.Config;
import org.jboss.logging.Logger;
+import io.quarkus.bootstrap.util.IoUtils;
import io.quarkus.creator.AppCreationPhase;
import io.quarkus.creator.AppCreator;
import io.quarkus.creator.AppCreatorException;
@@ -46,7 +48,6 @@
import io.quarkus.creator.outcome.OutcomeProviderRegistration;
import io.quarkus.creator.phase.augment.AugmentOutcome;
import io.quarkus.creator.phase.runnerjar.RunnerJarOutcome;
-import io.quarkus.creator.util.IoUtils;
import io.smallrye.config.SmallRyeConfigProviderResolver;
/**
@@ -63,6 +64,7 @@ public class NativeImagePhase implements AppCreationPhase, Nat
private static final String QUARKUS_PREFIX = "quarkus.";
private static final boolean IS_LINUX = System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("linux");
+ private static final boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("windows");
private Path outputDir;
@@ -86,6 +88,8 @@ public class NativeImagePhase implements AppCreationPhase, Nat
private boolean enableIsolates;
+ private boolean enableFallbackImages;
+
private String graalvmHome;
private boolean enableServer;
@@ -98,7 +102,11 @@ public class NativeImagePhase implements AppCreationPhase, Nat
private String nativeImageXmx;
- private String dockerBuild;
+ private String builderImage = "quay.io/quarkus/centos-quarkus-native-image:graalvm-1.0.0-rc16";
+
+ private String containerRuntime = "";
+
+ private List containerRuntimeOptions = new ArrayList<>();
private boolean enableVMInspection;
@@ -170,6 +178,11 @@ public NativeImagePhase setEnableIsolates(boolean enableIsolates) {
return this;
}
+ public NativeImagePhase setEnableFallbackImages(boolean enableFallbackImages) {
+ this.enableFallbackImages = enableFallbackImages;
+ return this;
+ }
+
public NativeImagePhase setGraalvmHome(String graalvmHome) {
this.graalvmHome = graalvmHome;
return this;
@@ -201,7 +214,41 @@ public NativeImagePhase setNativeImageXmx(String nativeImageXmx) {
}
public NativeImagePhase setDockerBuild(String dockerBuild) {
- this.dockerBuild = dockerBuild;
+ if (dockerBuild == null) {
+ return this;
+ }
+
+ if ("false".equals(dockerBuild.toLowerCase())) {
+ this.containerRuntime = "";
+ } else {
+ this.containerRuntime = "docker";
+
+ // TODO: use an 'official' image
+ if (!"true".equals(dockerBuild.toLowerCase())) {
+ this.builderImage = dockerBuild;
+ }
+ }
+
+ return this;
+ }
+
+ public NativeImagePhase setContainerRuntime(String containerRuntime) {
+ if (containerRuntime == null) {
+ return this;
+ }
+ if ("podman".equals(containerRuntime) || "docker".equals(containerRuntime)) {
+ this.containerRuntime = containerRuntime;
+ } else {
+ log.warn("container runtime is not docker or podman. fallback to docker");
+ this.containerRuntime = "docker";
+ }
+ return this;
+ }
+
+ public NativeImagePhase setContainerRuntimeOptions(String containerRuntimeOptions) {
+ if (containerRuntimeOptions != null) {
+ this.containerRuntimeOptions = Arrays.asList(containerRuntimeOptions.split(","));
+ }
return this;
}
@@ -271,19 +318,20 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
String noPIE = "";
- if (dockerBuild != null && !dockerBuild.toLowerCase().equals("false")) {
-
+ if (!"".equals(containerRuntime)) {
// E.g. "/usr/bin/docker run -v {{PROJECT_DIR}}:/project --rm quarkus/graalvm-native-image"
nativeImage = new ArrayList<>();
- //TODO: use an 'official' image
- String image;
- if (dockerBuild.toLowerCase().equals("true")) {
- image = "swd847/centos-graal-native-image-rc13";
- } else {
- //allow the use of a custom image
- image = dockerBuild;
+ Collections.addAll(nativeImage, containerRuntime, "run", "-v", outputDir.toAbsolutePath() + ":/project:z", "--rm");
+
+ if (IS_LINUX & "docker".equals(containerRuntime)) {
+ String uid = getLinuxID("-ur");
+ String gid = getLinuxID("-gr");
+ if (uid != null & gid != null & !"".equals(uid) & !"".equals(gid)) {
+ Collections.addAll(nativeImage, "--user", uid.concat(":").concat(gid));
+ }
}
- Collections.addAll(nativeImage, "docker", "run", "-v", outputDir.toAbsolutePath() + ":/project:z", "--rm", image);
+ nativeImage.addAll(containerRuntimeOptions);
+ nativeImage.add(this.builderImage);
} else {
if (IS_LINUX) {
noPIE = detectNoPIE();
@@ -298,12 +346,13 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
throw new AppCreatorException("GRAALVM_HOME was not set");
}
}
- nativeImage = Collections.singletonList(graalvmHome + File.separator + "bin" + File.separator + "native-image");
+ String imageName = IS_WINDOWS ? "native-image.cmd" : "native-image";
+ nativeImage = Collections.singletonList(graalvmHome + File.separator + "bin" + File.separator + imageName);
+
}
try {
- List command = new ArrayList<>();
- command.addAll(nativeImage);
+ List command = new ArrayList<>(nativeImage);
if (cleanupServer) {
List cleanup = new ArrayList<>(nativeImage);
cleanup.add("--server-shutdown");
@@ -349,13 +398,21 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
enableAllSecurityServices = true;
}
if (additionalBuildArgs != null) {
- additionalBuildArgs.forEach(command::add);
+ command.addAll(additionalBuildArgs);
}
command.add("-H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime"); //the default collection policy results in full GC's 50% of the time
command.add("-jar");
command.add(runnerJarName);
//https://github.com/oracle/graal/issues/660
command.add("-J-Djava.util.concurrent.ForkJoinPool.common.parallelism=1");
+ if (enableFallbackImages) {
+ command.add("-H:FallbackThreshold=5");
+ } else {
+ //Default: be strict as those fallback images aren't very useful
+ //and tend to cover up real problems.
+ command.add("-H:FallbackThreshold=0");
+ }
+
if (reportErrorsAtRuntime) {
command.add("-H:+ReportUnsupportedElementsAtRuntime");
}
@@ -413,7 +470,7 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
} else {
command.add("-H:-JNI");
}
- if (!enableServer) {
+ if (!enableServer && !IS_WINDOWS) {
command.add("--no-server");
}
if (enableVMInspection) {
@@ -466,13 +523,62 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
private boolean isThisGraalVMRCObsolete() {
final String vmName = System.getProperty("java.vm.name");
log.info("Running Quarkus native-image plugin on " + vmName);
- if (vmName.contains("-rc9") || vmName.contains("-rc10") || vmName.contains("-rc11") || vmName.contains("-rc12")) {
- log.error("Out of date RC build of GraalVM detected! Please upgrade to RC13");
+ final List obsoleteGraalVmVersions = Arrays.asList("-rc9", "-rc10", "-rc11", "-rc12", "-rc13", "-rc14",
+ "-rc15");
+ final boolean vmVersionIsObsolete = obsoleteGraalVmVersions.stream().anyMatch(vmName::contains);
+ if (vmVersionIsObsolete) {
+ log.error("Out of date RC build of GraalVM detected! Please upgrade to GraalVM RC16");
return true;
}
return false;
}
+ private static String getLinuxID(String option) {
+ Process process;
+
+ try {
+ StringBuilder responseBuilder = new StringBuilder();
+ String line;
+
+ ProcessBuilder idPB = new ProcessBuilder().command("id", option);
+ idPB.redirectError(new File("/dev/null"));
+ idPB.redirectInput(new File("/dev/null"));
+
+ process = idPB.start();
+ try (InputStream inputStream = process.getInputStream()) {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
+ while ((line = reader.readLine()) != null) {
+ responseBuilder.append(line);
+ }
+ safeWaitFor(process);
+ return responseBuilder.toString();
+ }
+ } catch (Throwable t) {
+ safeWaitFor(process);
+ throw t;
+ }
+ } catch (IOException e) { //from process.start()
+ //swallow and return null id
+ return null;
+ }
+ }
+
+ static void safeWaitFor(Process process) {
+ boolean intr = false;
+ try {
+ for (;;)
+ try {
+ process.waitFor();
+ return;
+ } catch (InterruptedException ex) {
+ intr = true;
+ }
+ } finally {
+ if (intr)
+ Thread.currentThread().interrupt();
+ }
+ }
+
private static String detectNoPIE() {
String argument = testGCCArgument("-no-pie");
@@ -545,6 +651,9 @@ public boolean set(NativeImagePhase t, PropertyContext ctx) {
case "enable-isolates":
t.setEnableIsolates(Boolean.parseBoolean(value));
break;
+ case "enable-fallback-images":
+ t.setEnableFallbackImages(Boolean.parseBoolean(value));
+ break;
case "graalvm-home":
t.setGraalvmHome(value);
break;
diff --git a/core/creator/src/main/java/io/quarkus/creator/phase/runnerjar/RunnerJarOutcome.java b/core/creator/src/main/java/io/quarkus/creator/phase/runnerjar/RunnerJarOutcome.java
index 7274d409f68f3..879f4ed4bdcd0 100644
--- a/core/creator/src/main/java/io/quarkus/creator/phase/runnerjar/RunnerJarOutcome.java
+++ b/core/creator/src/main/java/io/quarkus/creator/phase/runnerjar/RunnerJarOutcome.java
@@ -28,4 +28,6 @@ public interface RunnerJarOutcome {
Path getRunnerJar();
Path getLibDir();
+
+ Path getOriginalJar();
}
diff --git a/core/creator/src/main/java/io/quarkus/creator/phase/runnerjar/RunnerJarPhase.java b/core/creator/src/main/java/io/quarkus/creator/phase/runnerjar/RunnerJarPhase.java
index dbdf1834e74d3..b7a7b8342b1f9 100644
--- a/core/creator/src/main/java/io/quarkus/creator/phase/runnerjar/RunnerJarPhase.java
+++ b/core/creator/src/main/java/io/quarkus/creator/phase/runnerjar/RunnerJarPhase.java
@@ -31,9 +31,9 @@
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
-import java.nio.file.attribute.PosixFilePermissions;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
@@ -47,19 +47,19 @@
import org.jboss.logging.Logger;
-import io.quarkus.creator.AppArtifact;
-import io.quarkus.creator.AppArtifactResolver;
+import io.quarkus.bootstrap.model.AppArtifact;
+import io.quarkus.bootstrap.model.AppDependency;
+import io.quarkus.bootstrap.resolver.AppModelResolver;
+import io.quarkus.bootstrap.util.IoUtils;
+import io.quarkus.bootstrap.util.ZipUtils;
import io.quarkus.creator.AppCreationPhase;
import io.quarkus.creator.AppCreator;
import io.quarkus.creator.AppCreatorException;
-import io.quarkus.creator.AppDependency;
import io.quarkus.creator.config.reader.MappedPropertiesHandler;
import io.quarkus.creator.config.reader.PropertiesHandler;
import io.quarkus.creator.outcome.OutcomeProviderRegistration;
import io.quarkus.creator.phase.augment.AugmentOutcome;
import io.quarkus.creator.phase.curate.CurateOutcome;
-import io.quarkus.creator.util.IoUtils;
-import io.quarkus.creator.util.ZipUtils;
/**
* Based on the provided {@link io.quarkus.creator.phase.augment.AugmentOutcome},
@@ -70,7 +70,6 @@
public class RunnerJarPhase implements AppCreationPhase, RunnerJarOutcome {
private static final String DEFAULT_MAIN_CLASS = "io.quarkus.runner.GeneratedMain";
- private static final String PROVIDED = "provided";
private static final Logger log = Logger.getLogger(RunnerJarPhase.class);
@@ -79,20 +78,28 @@ public class RunnerJarPhase implements AppCreationPhase, RunnerJ
"META-INF/MANIFEST.MF",
"module-info.class",
"META-INF/LICENSE",
- "META-INF/NOTICE",
"META-INF/LICENSE.txt",
+ "META-INF/LICENSE.md",
+ "META-INF/NOTICE",
"META-INF/NOTICE.txt",
- "dependencies.runtime",
+ "META-INF/NOTICE.md",
"META-INF/README",
- "META-INF/quarkus-config-roots.list",
+ "META-INF/README.txt",
+ "META-INF/README.md",
"META-INF/DEPENDENCIES",
"META-INF/beans.xml",
+ "META-INF/quarkus-config-roots.list",
"META-INF/quarkus-javadoc.properties",
+ "META-INF/quarkus-extension.properties",
+ "META-INF/quarkus-deployment-dependency.graph",
"LICENSE")));
+ private final Set userConfiguredIgnoredEntries = new HashSet<>();
+
private Path outputDir;
private Path libDir;
private Path runnerJar;
+ private Path originalJar;
private String finalName;
@@ -160,6 +167,19 @@ public RunnerJarPhase setUberJar(boolean uberJar) {
return this;
}
+ /**
+ * Entries that should be ignored when creating the runner JAR. The entries
+ * are relatives to the root of the JAR. I.e. "META-INF/README.MD".
+ *
+ * @param ignoredEntries the entries that should be ignored when creating
+ * the runner JAR
+ * @return this phase instance
+ */
+ public RunnerJarPhase setUserConfiguredIgnoredEntries(Collection ignoredEntries) {
+ this.userConfiguredIgnoredEntries.addAll(ignoredEntries);
+ return this;
+ }
+
@Override
public Path getRunnerJar() {
return runnerJar;
@@ -170,6 +190,11 @@ public Path getLibDir() {
return libDir;
}
+ @Override
+ public Path getOriginalJar() {
+ return originalJar;
+ }
+
@Override
public void register(OutcomeProviderRegistration registration) throws AppCreatorException {
registration.provides(RunnerJarOutcome.class);
@@ -184,7 +209,7 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
libDir = IoUtils.mkdirs(libDir == null ? outputDir.resolve("lib") : libDir);
if (finalName == null) {
- final String name = appState.getArtifactResolver().resolve(appState.getAppArtifact()).getFileName().toString();
+ final String name = toUri(appState.getAppArtifact().getPath().getFileName());
int i = name.lastIndexOf('.');
if (i > 0) {
finalName = name.substring(0, i);
@@ -206,39 +231,42 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
}
// when using uberJar, we rename the standard jar to include the .original suffix
- // this greatly aids tools (such as s2i) that look for a single jar in the output directory to work OOTB
+ // this greatly aids tools (such as s2i) that look for a single jar in the output directory to work OOTB.
+ // we only do this if the standard jar was present in the output dir in the first place.
if (uberJar) {
try {
- Path originalFile = outputDir.resolve(finalName + ".jar.original");
- Files.deleteIfExists(originalFile);
- Files.move(outputDir.resolve(finalName + ".jar"), originalFile);
+ Path standardJar = outputDir.resolve(finalName + ".jar");
+ if (standardJar.toFile().exists()) {
+ originalJar = outputDir.resolve(finalName + ".jar.original");
+ Files.deleteIfExists(originalJar);
+ Files.move(standardJar, originalJar);
+ }
} catch (IOException e) {
throw new AppCreatorException("Unable to build uberjar", e);
}
+ } else {
+ originalJar = outputDir.resolve(finalName + ".jar");
}
ctx.pushOutcome(RunnerJarOutcome.class, this);
}
- private void buildRunner(FileSystem runnerZipFs, CurateOutcome appState, AugmentOutcome augmentOutcome) throws Exception {
+ private void buildRunner(FileSystem runnerZipFs, CurateOutcome curateOutcome, AugmentOutcome augmentOutcome)
+ throws Exception {
log.info("Building jar: " + runnerJar);
- final AppArtifactResolver depResolver = appState.getArtifactResolver();
- final List appDeps = appState.getEffectiveDeps();
+ final AppModelResolver depResolver = curateOutcome.getArtifactResolver();
final Map seen = new HashMap<>();
final Map> duplicateCatcher = new HashMap<>();
final StringBuilder classPath = new StringBuilder();
final Map> services = new HashMap<>();
+ Set finalIgnoredEntries = new HashSet<>(IGNORED_ENTRIES);
+ finalIgnoredEntries.addAll(this.userConfiguredIgnoredEntries);
+ final List appDeps = curateOutcome.getEffectiveModel().getUserDependencies();
for (AppDependency appDep : appDeps) {
- if (appDep.getScope().equals(PROVIDED) && !augmentOutcome.isWhitelisted(appDep)) {
- continue;
- }
final AppArtifact depArtifact = appDep.getArtifact();
- if (depArtifact.getArtifactId().equals("svm") && depArtifact.getGroupId().equals("com.oracle.substratevm")) {
- continue;
- }
final Path resolvedDep = depResolver.resolve(depArtifact);
if (uberJar) {
try (FileSystem artifactFs = ZipUtils.newFileSystem(resolvedDep)) {
@@ -248,9 +276,9 @@ private void buildRunner(FileSystem runnerZipFs, CurateOutcome appState, Augment
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
throws IOException {
- final String relativePath = root.relativize(dir).toString();
+ final String relativePath = toUri(root.relativize(dir));
if (!relativePath.isEmpty()) {
- addDir(runnerZipFs, dir, relativePath);
+ addDir(runnerZipFs, relativePath);
}
return FileVisitResult.CONTINUE;
}
@@ -258,10 +286,11 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
throws IOException {
- final String relativePath = root.relativize(file).toString();
+ final String relativePath = toUri(root.relativize(file));
if (relativePath.startsWith("META-INF/services/") && relativePath.length() > 18) {
services.computeIfAbsent(relativePath, (u) -> new ArrayList<>()).add(read(file));
- } else if (!IGNORED_ENTRIES.contains(relativePath)) {
+ return FileVisitResult.CONTINUE;
+ } else if (!finalIgnoredEntries.contains(relativePath)) {
duplicateCatcher.computeIfAbsent(relativePath, (a) -> new HashSet<>()).add(appDep);
if (!seen.containsKey(relativePath)) {
seen.put(relativePath, appDep.toString());
@@ -302,11 +331,11 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
@Override
public void accept(Path path) {
try {
- final String relativePath = wiringClassesDir.relativize(path).toString();
+ final String relativePath = toUri(wiringClassesDir.relativize(path));
if (Files.isDirectory(path)) {
if (!seen.containsKey(relativePath + "/") && !relativePath.isEmpty()) {
seen.put(relativePath + "/", "Current Application");
- addDir(runnerZipFs, path, relativePath);
+ addDir(runnerZipFs, relativePath);
}
return;
}
@@ -325,16 +354,13 @@ public void accept(Path path) {
}
});
- final Manifest manifest = new Manifest();
- manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
- manifest.getMainAttributes().put(Attributes.Name.CLASS_PATH, classPath.toString());
- manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, mainClass);
- try (OutputStream os = Files.newOutputStream(runnerZipFs.getPath("META-INF", "MANIFEST.MF"))) {
- manifest.write(os);
+ copyFiles(augmentOutcome.getAppClassesDir(), runnerZipFs, services);
+ if (Files.exists(augmentOutcome.getConfigDir())) {
+ copyFiles(augmentOutcome.getConfigDir(), runnerZipFs, services);
}
+ copyFiles(augmentOutcome.getTransformedClassesDir(), runnerZipFs, services);
- copyFiles(augmentOutcome.getAppClassesDir(), runnerZipFs);
- copyFiles(augmentOutcome.getTransformedClassesDir(), runnerZipFs);
+ generateManifest(runnerZipFs, classPath.toString());
for (Map.Entry> entry : services.entrySet()) {
try (OutputStream os = Files.newOutputStream(runnerZipFs.getPath(entry.getKey()))) {
@@ -346,32 +372,95 @@ public void accept(Path path) {
}
}
- private void copyFiles(Path dir, FileSystem fs) throws IOException {
- Files.walk(dir).forEach(new Consumer() {
- @Override
- public void accept(Path path) {
- final String relativePath = dir.relativize(path).toString();
- if (relativePath.isEmpty()) {
- return;
- }
- try {
- if (Files.isDirectory(path)) {
- addDir(fs, path, relativePath);
- } else {
- Files.copy(path, fs.getPath(relativePath), StandardCopyOption.REPLACE_EXISTING);
+ /**
+ * Manifest generation is quite simple : we just have to push some attributes in manifest.
+ * However, it gets a little more complex if the manifest preexists.
+ * So we first try to see if a manifest exists, and otherwise create a new one.
+ *
+ * BEWARE this method should be invoked after file copy from target/classes and so on.
+ * Otherwise this manifest manipulation will be useless.
+ */
+ private void generateManifest(FileSystem runnerZipFs, final String classPath) throws IOException {
+ final Path manifestPath = runnerZipFs.getPath("META-INF", "MANIFEST.MF");
+ final Manifest manifest = new Manifest();
+ if (Files.exists(manifestPath)) {
+ try (InputStream is = Files.newInputStream(manifestPath)) {
+ manifest.read(is);
+ }
+ Files.delete(manifestPath);
+ }
+ Attributes attributes = manifest.getMainAttributes();
+ attributes.put(Attributes.Name.MANIFEST_VERSION, "1.0");
+ if (attributes.containsKey(Attributes.Name.CLASS_PATH)) {
+ log.warn(
+ "Your MANIFEST.MF already defined a CLASS_PATH entry. Quarkus has overwritten this existing entry.");
+ }
+ attributes.put(Attributes.Name.CLASS_PATH, classPath);
+ if (attributes.containsKey(Attributes.Name.MAIN_CLASS)) {
+ String existingMainClass = attributes.getValue(Attributes.Name.MAIN_CLASS);
+ if (!mainClass.equals(existingMainClass)) {
+ log.warn("Your MANIFEST.MF already defined a MAIN_CLASS entry. Quarkus has overwritten your existing entry.");
+ }
+ }
+ attributes.put(Attributes.Name.MAIN_CLASS, mainClass);
+ try (OutputStream os = Files.newOutputStream(manifestPath)) {
+ manifest.write(os);
+ }
+ }
+
+ /**
+ * Copy files from {@code dir} to {@code fs}, filtering out service providers into the given map.
+ *
+ * @param dir the source directory
+ * @param fs the destination filesystem
+ * @param services the services map
+ * @throws IOException if an error occurs
+ */
+ private void copyFiles(Path dir, FileSystem fs, Map> services) throws IOException {
+ try {
+ Files.walk(dir).forEach(new Consumer() {
+ @Override
+ public void accept(Path path) {
+ final Path file = dir.relativize(path);
+ final String relativePath = toUri(file);
+ if (relativePath.isEmpty()) {
+ return;
+ }
+ try {
+ if (Files.isDirectory(path)) {
+ addDir(fs, relativePath);
+ } else {
+ if (relativePath.startsWith("META-INF/services/") && relativePath.length() > 18) {
+ final byte[] content;
+ try {
+ content = Files.readAllBytes(path);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ services.computeIfAbsent(relativePath, (u) -> new ArrayList<>()).add(content);
+ } else {
+ Files.copy(path, fs.getPath(relativePath), StandardCopyOption.REPLACE_EXISTING);
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
}
- } catch (Exception e) {
- throw new RuntimeException(e);
}
+ });
+ } catch (RuntimeException re) {
+ final Throwable cause = re.getCause();
+ if (cause instanceof IOException) {
+ throw (IOException) cause;
}
- });
+ throw re;
+ }
}
- private void addDir(FileSystem fs, Path dir, final String relativePath)
+ private void addDir(FileSystem fs, final String relativePath)
throws IOException, FileAlreadyExistsException {
final Path targetDir = fs.getPath(relativePath);
try {
- Files.copy(dir, targetDir);
+ Files.createDirectory(targetDir);
} catch (FileAlreadyExistsException e) {
if (!Files.isDirectory(targetDir)) {
throw e;
@@ -410,4 +499,23 @@ public RunnerJarPhase getTarget() {
.map("main-class", RunnerJarPhase::setMainClass)
.map("uber-jar", (RunnerJarPhase t, String value) -> t.setUberJar(Boolean.parseBoolean(value)));
}
+
+ private static String toUri(Path path) {
+ if (path.isAbsolute()) {
+ return path.toUri().getPath();
+ } else if (path.getNameCount() == 0) {
+ return "";
+ } else {
+ return toUri(new StringBuilder(), path, 0).toString();
+ }
+ }
+
+ private static StringBuilder toUri(StringBuilder b, Path path, int seg) {
+ b.append(path.getName(seg));
+ if (seg < path.getNameCount() - 1) {
+ b.append('/');
+ toUri(b, path, seg + 1);
+ }
+ return b;
+ }
}
diff --git a/core/creator/src/main/java/io/quarkus/creator/resolver/aether/AetherArtifactResolver.java b/core/creator/src/main/java/io/quarkus/creator/resolver/aether/AetherArtifactResolver.java
deleted file mode 100644
index dccd262f6fbc7..0000000000000
--- a/core/creator/src/main/java/io/quarkus/creator/resolver/aether/AetherArtifactResolver.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * Copyright 2018 Red Hat, Inc. and/or its affiliates
- * and other contributors as indicated by the @author tags.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.quarkus.creator.resolver.aether;
-
-import java.io.File;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.maven.settings.Settings;
-import org.eclipse.aether.DefaultRepositorySystemSession;
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.aether.collection.CollectRequest;
-import org.eclipse.aether.graph.Dependency;
-import org.eclipse.aether.graph.DependencyNode;
-import org.eclipse.aether.installation.InstallRequest;
-import org.eclipse.aether.installation.InstallationException;
-import org.eclipse.aether.repository.LocalRepository;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.resolution.ArtifactDescriptorException;
-import org.eclipse.aether.resolution.ArtifactDescriptorRequest;
-import org.eclipse.aether.resolution.ArtifactDescriptorResult;
-import org.eclipse.aether.resolution.ArtifactRequest;
-import org.eclipse.aether.resolution.ArtifactResolutionException;
-import org.eclipse.aether.resolution.ArtifactResult;
-import org.eclipse.aether.resolution.DependencyRequest;
-import org.eclipse.aether.resolution.DependencyResolutionException;
-import org.eclipse.aether.resolution.DependencyResult;
-import org.eclipse.aether.resolution.VersionRangeRequest;
-import org.eclipse.aether.resolution.VersionRangeResolutionException;
-import org.eclipse.aether.resolution.VersionRangeResult;
-import org.eclipse.aether.version.Version;
-
-import io.quarkus.creator.AppArtifact;
-import io.quarkus.creator.AppArtifactResolverBase;
-import io.quarkus.creator.AppCreatorException;
-import io.quarkus.creator.AppDependency;
-
-/**
- *
- * @author Alexey Loubyansky
- */
-public class AetherArtifactResolver extends AppArtifactResolverBase {
-
- public static AetherArtifactResolver getInstance(Path repoHome) throws AppCreatorException {
- final RepositorySystem repoSystem = MavenRepoInitializer.getRepositorySystem();
- final Settings settings = MavenRepoInitializer.getSettings();
- final DefaultRepositorySystemSession repoSession = MavenRepoInitializer.newSession(repoSystem, settings);
- final AppCreatorLocalRepositoryManager appCreatorLocalRepoManager = new AppCreatorLocalRepositoryManager(
- repoSystem.newLocalRepositoryManager(repoSession,
- new LocalRepository(repoHome.toString())),
- Paths.get(MavenRepoInitializer.getLocalRepo(settings)));
- repoSession.setLocalRepositoryManager(appCreatorLocalRepoManager);
- repoSession.setDependencySelector(new AppCreatorDependencySelector(true));
- final AetherArtifactResolver resolver = new AetherArtifactResolver(repoSystem, repoSession,
- MavenRepoInitializer.getRemoteRepos(settings));
- resolver.setLocalRepositoryManager(appCreatorLocalRepoManager);
- return resolver;
- }
-
- public static AetherArtifactResolver getInstance(Path repoHome, List remoteRepos)
- throws AppCreatorException {
- final RepositorySystem repoSystem = MavenRepoInitializer.getRepositorySystem();
- final Settings settings = MavenRepoInitializer.getSettings();
- final DefaultRepositorySystemSession repoSession = MavenRepoInitializer.newSession(repoSystem, settings);
- final AppCreatorLocalRepositoryManager appCreatorLocalRepoManager = new AppCreatorLocalRepositoryManager(
- repoSystem.newLocalRepositoryManager(repoSession,
- new LocalRepository(repoHome.toString())),
- Paths.get(MavenRepoInitializer.getLocalRepo(settings)));
- repoSession.setLocalRepositoryManager(appCreatorLocalRepoManager);
- repoSession.setDependencySelector(new AppCreatorDependencySelector(true));
- final AetherArtifactResolver resolver = new AetherArtifactResolver(repoSystem, repoSession, remoteRepos);
- resolver.setLocalRepositoryManager(appCreatorLocalRepoManager);
- return resolver;
- }
-
- protected final RepositorySystem repoSystem;
- protected final RepositorySystemSession repoSession;
- protected final List remoteRepos;
- protected AppCreatorLocalRepositoryManager localRepoManager;
-
- public AetherArtifactResolver() throws AppCreatorException {
- this(MavenRepoInitializer.getRepositorySystem(),
- MavenRepoInitializer.newSession(MavenRepoInitializer.getRepositorySystem()),
- MavenRepoInitializer.getRemoteRepos());
- }
-
- public AetherArtifactResolver(RepositorySystem repoSystem, RepositorySystemSession repoSession,
- List remoteRepos) {
- super();
- this.repoSystem = repoSystem;
- this.repoSession = repoSession;
- this.remoteRepos = remoteRepos;
- }
-
- public void setLocalRepositoryManager(AppCreatorLocalRepositoryManager localRepoManager) {
- this.localRepoManager = localRepoManager;
- }
-
- public void addRemoteRepositories(List repos) {
- remoteRepos.addAll(repos);
- }
-
- @Override
- public void relink(AppArtifact artifact, Path path) throws AppCreatorException {
- if (localRepoManager == null) {
- throw new AppCreatorException("Failed to (re-)link " + artifact + " to " + path
- + ": AppCreatorLocalRepositoryManager has not been initialized");
- }
- localRepoManager.relink(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getType(),
- artifact.getVersion(), path);
- setPath(artifact, path);
- }
-
- @Override
- protected void doResolve(AppArtifact artifact) throws AppCreatorException {
- final ArtifactRequest artifactRequest = new ArtifactRequest();
- artifactRequest.setArtifact(toAetherArtifact(artifact));
- artifactRequest.setRepositories(remoteRepos);
- ArtifactResult artifactResult;
- try {
- artifactResult = repoSystem.resolveArtifact(repoSession, artifactRequest);
- } catch (ArtifactResolutionException e) {
- throw new AppCreatorException("Failed to resolve artifact " + artifact, e);
- }
- setPath(artifact, artifactResult.getArtifact().getFile().toPath());
- }
-
- @Override
- public List collectDependencies(AppArtifact coords) throws AppCreatorException {
- final CollectRequest collectRequest = new CollectRequest();
- collectRequest.setRoot(new Dependency(toAetherArtifact(coords), "runtime"));
- //collectRequest.setRootArtifact(toAetherArtifact(coords));
- collectRequest.setRepositories(remoteRepos);
-
- final DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null);
-
- final DependencyResult depResult;
- try {
- depResult = repoSystem.resolveDependencies(repoSession, dependencyRequest);
- } catch (DependencyResolutionException e) {
- throw new AppCreatorException("Failed to collect dependencies for " + coords, e);
- }
-
- final List depNodes = depResult.getRoot().getChildren();
- if (depNodes.isEmpty()) {
- return Collections.emptyList();
- }
-
- final List appDeps = new ArrayList<>();
- collect(depNodes, appDeps);
- return appDeps;
- }
-
- @Override
- public List collectDependencies(AppArtifact root, List coords) throws AppCreatorException {
- final CollectRequest collectRequest = new CollectRequest();
- collectRequest.setRoot(new Dependency(toAetherArtifact(root), "runtime"));
- for (AppDependency dep : coords) {
- collectRequest.addDependency(new Dependency(toAetherArtifact(dep.getArtifact()), dep.getScope()));
- }
- collectRequest.setRepositories(remoteRepos);
-
- final DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null);
-
- final DependencyResult depResult;
- try {
- depResult = repoSystem.resolveDependencies(repoSession, dependencyRequest);
- } catch (DependencyResolutionException e) {
- throw new AppCreatorException("Failed to collect dependencies for " + coords, e);
- }
-
- final List depNodes = depResult.getRoot().getChildren();
- if (depNodes.isEmpty()) {
- return Collections.emptyList();
- }
-
- final List appDeps = new ArrayList<>();
- collect(depNodes, appDeps);
- return appDeps;
- }
-
- /*
- * @Override
- * public List collectDependencies(AppArtifact coords) throws AppCreatorException {
- * final CollectRequest collectRequest = new CollectRequest();
- * collectRequest.setRoot(new Dependency(toAetherArtifact(coords), "runtime"));
- * //collectRequest.setRootArtifact(toAetherArtifact(coords));
- * collectRequest.setRepositories(remoteRepos);
- *
- * final CollectResult depResult;
- * try {
- * depResult = repoSystem.collectDependencies(repoSession, collectRequest);
- * } catch (DependencyCollectionException e) {
- * throw new AppCreatorException("Failed to collect dependencies for " + coords, e);
- * }
- *
- * final List depNodes = depResult.getRoot().getChildren();
- * if(depNodes.isEmpty()) {
- * return Collections.emptyList();
- * }
- *
- * final List appDeps = new ArrayList<>();
- * collect(depNodes, appDeps);
- * return appDeps;
- * }
- */
- @Override
- public List listLaterVersions(AppArtifact appArtifact, String upToVersion, boolean inclusive)
- throws AppCreatorException {
- final VersionRangeResult rangeResult = resolveVersionRangeResult(appArtifact, upToVersion, inclusive);
- final List resolvedVersions = rangeResult.getVersions();
- final List versions = new ArrayList<>(resolvedVersions.size());
- for (Version v : resolvedVersions) {
- versions.add(v.toString());
- }
- return versions;
- }
-
- @Override
- public String getNextVersion(AppArtifact appArtifact, String upToVersion, boolean inclusive) throws AppCreatorException {
- final VersionRangeResult rangeResult = resolveVersionRangeResult(appArtifact, upToVersion, inclusive);
- final List versions = rangeResult.getVersions();
- if (versions.isEmpty()) {
- return appArtifact.getVersion();
- }
- Version next = versions.get(0);
- for (int i = 1; i < versions.size(); ++i) {
- final Version candidate = versions.get(i);
- if (next.compareTo(candidate) > 0) {
- next = candidate;
- }
- }
- return next.toString();
- }
-
- @Override
- public String getLatestVersion(AppArtifact appArtifact, String upToVersion, boolean inclusive) throws AppCreatorException {
- final VersionRangeResult rangeResult = resolveVersionRangeResult(appArtifact, upToVersion, inclusive);
- final List versions = rangeResult.getVersions();
- if (versions.isEmpty()) {
- return appArtifact.getVersion();
- }
- Version latest = versions.get(0);
- for (int i = 1; i < versions.size(); ++i) {
- final Version candidate = versions.get(i);
- if (latest.compareTo(candidate) < 0) {
- latest = candidate;
- }
- }
- return latest.toString();
- }
-
- public List resolveArtifactRepos(AppArtifact appArtifact) throws AppCreatorException {
- final ArtifactDescriptorRequest request = new ArtifactDescriptorRequest();
- request.setArtifact(new DefaultArtifact(appArtifact.getGroupId(), appArtifact.getArtifactId(),
- appArtifact.getClassifier(), appArtifact.getType(), appArtifact.getVersion()));
- //request.setRepositories(remoteRepos);
- final ArtifactDescriptorResult result;
- try {
- result = repoSystem.readArtifactDescriptor(repoSession, request);
- } catch (ArtifactDescriptorException e) {
- throw new AppCreatorException("Failed to resolve descriptor for " + appArtifact, e);
- }
- return result.getRepositories();
- }
-
- private VersionRangeResult resolveVersionRangeResult(AppArtifact appArtifact, String upToVersion, boolean inclusive)
- throws AppCreatorException {
- final Artifact artifact = new DefaultArtifact(appArtifact.getGroupId(),
- appArtifact.getArtifactId(), appArtifact.getType(),
- '(' + appArtifact.getVersion() + ',' + (upToVersion == null ? ')' : upToVersion + (inclusive ? ']' : ')')));
- //System.out.println("AetherArtifactResolver.listLaterVersions for range " + artifact.getVersion());
- final VersionRangeResult rangeResult = getVersionRange(artifact);
- return rangeResult;
- }
-
- public void install(AppArtifact appArtifact, Path localPath) throws AppCreatorException {
- final InstallRequest request = new InstallRequest();
- request.addArtifact(
- new DefaultArtifact(appArtifact.getGroupId(), appArtifact.getArtifactId(), appArtifact.getClassifier(),
- appArtifact.getType(), appArtifact.getVersion(), Collections.emptyMap(), localPath.toFile()));
- try {
- repoSystem.install(repoSession, request);
- } catch (InstallationException ex) {
- throw new AppCreatorException("Failed to install " + appArtifact, ex);
- }
- }
-
- private VersionRangeResult getVersionRange(Artifact artifact) throws AppCreatorException {
- final VersionRangeRequest rangeRequest = new VersionRangeRequest();
- rangeRequest.setArtifact(artifact);
- rangeRequest.setRepositories(remoteRepos);
- VersionRangeResult rangeResult;
- try {
- rangeResult = repoSystem.resolveVersionRange(repoSession, rangeRequest);
- } catch (VersionRangeResolutionException ex) {
- throw new AppCreatorException("Failed to resolve version range for " + artifact, ex);
- }
- return rangeResult;
- }
-
- private static void collect(List nodes, List appDeps) {
- for (DependencyNode node : nodes) {
- collect(node.getChildren(), appDeps);
- appDeps.add(new AppDependency(toAppArtifact(node.getArtifact()), node.getDependency().getScope()));
- }
- }
-
- private static Artifact toAetherArtifact(AppArtifact artifact) {
- return new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(),
- artifact.getType(), artifact.getVersion());
- }
-
- private static AppArtifact toAppArtifact(Artifact artifact) {
- final AppArtifact mvn = new AppArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(),
- artifact.getExtension(), artifact.getVersion());
- final File file = artifact.getFile();
- if (file != null) {
- setPath(mvn, file.toPath());
- }
- return mvn;
- }
-}
diff --git a/core/creator/src/main/java/io/quarkus/creator/resolver/aether/AppCreatorDependencySelector.java b/core/creator/src/main/java/io/quarkus/creator/resolver/aether/AppCreatorDependencySelector.java
deleted file mode 100644
index b4c5ef84ac202..0000000000000
--- a/core/creator/src/main/java/io/quarkus/creator/resolver/aether/AppCreatorDependencySelector.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- *
- */
-package io.quarkus.creator.resolver.aether;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.aether.collection.DependencyCollectionContext;
-import org.eclipse.aether.collection.DependencySelector;
-import org.eclipse.aether.graph.Dependency;
-
-/**
- *
- * @author Alexey Loubyansky
- */
-public class AppCreatorDependencySelector implements DependencySelector {
-
- static final String COMPILE = "compile";
- static final String PROVIDED = "provided";
- static final String RUNTIME = "runtime";
- static final String SYSTEM = "system";
- static final String WILDCARD = "*";
-
- static final Set APP_SCOPES = new HashSet<>(Arrays.asList(new String[] { COMPILE, SYSTEM, PROVIDED, RUNTIME }));
- static final Set TRANSITIVE_SCOPES = new HashSet<>(Arrays.asList(new String[] { COMPILE, SYSTEM, RUNTIME }));
-
- protected final boolean debug;
-
- public AppCreatorDependencySelector(boolean debug) {
- this.debug = debug;
- }
-
- @Override
- public boolean selectDependency(Dependency dependency) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public DependencySelector deriveChildSelector(DependencyCollectionContext context) {
- final Dependency dependency = context.getDependency();
- if (dependency != null && (dependency.isOptional() || !APP_SCOPES.contains(dependency.getScope()))) {
- return DisabledDependencySelector.INSTANCE;
- }
- return new DerivedDependencySelector(debug, dependency);
- }
-}
diff --git a/core/creator/src/main/java/io/quarkus/creator/resolver/aether/DerivedDependencySelector.java b/core/creator/src/main/java/io/quarkus/creator/resolver/aether/DerivedDependencySelector.java
deleted file mode 100644
index 8fc48217e9419..0000000000000
--- a/core/creator/src/main/java/io/quarkus/creator/resolver/aether/DerivedDependencySelector.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright 2018 Red Hat, Inc. and/or its affiliates
- * and other contributors as indicated by the @author tags.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.quarkus.creator.resolver.aether;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.collection.DependencyCollectionContext;
-import org.eclipse.aether.collection.DependencySelector;
-import org.eclipse.aether.graph.Dependency;
-import org.eclipse.aether.graph.Exclusion;
-import org.jboss.logging.Logger;
-
-/**
- *
- * @author Alexey Loubyansky
- */
-public class DerivedDependencySelector implements DependencySelector {
-
- private static final Logger log = Logger.getLogger(DerivedDependencySelector.class);
-
- private static class DepExclusions {
-
- private final Collection exclusions;
- private final DepExclusions parent;
-
- DepExclusions(DepExclusions parent, Collection exclusions) {
- this.parent = parent;
- this.exclusions = exclusions;
- }
-
- boolean isExcluded(Dependency dep) {
- for (Exclusion excl : exclusions) {
- final String exclGroupId = excl.getGroupId();
- final String exclArtifactId = excl.getArtifactId();
- final String exclClassifier = excl.getClassifier();
- final String exclExt = excl.getExtension();
- final Artifact artifact = dep.getArtifact();
- if ((exclGroupId.equals(AppCreatorDependencySelector.WILDCARD) || exclGroupId.equals(artifact.getGroupId())) &&
- (exclArtifactId.equals(AppCreatorDependencySelector.WILDCARD)
- || exclArtifactId.equals(artifact.getArtifactId()))
- &&
- (exclClassifier.equals(AppCreatorDependencySelector.WILDCARD)
- || exclClassifier.equals(artifact.getClassifier()))
- &&
- (exclExt.equals(AppCreatorDependencySelector.WILDCARD) || exclExt.equals(artifact.getExtension()))) {
- return true;
- }
- }
- if (parent != null) {
- DepExclusions parent = this.parent;
- while (parent != null) {
- if (parent.isExcluded(dep)) {
- return true;
- }
- parent = parent.parent;
- }
- }
- return false;
- }
- }
-
- private final int depth;
- //private final Set selected;
- //private final Set childrenProcessed;
- private final Set acceptedScopes;
- //private Dependency lastSelected;
- private final DepExclusions depExclusions;
- //private Map> managedExcl;
-
- public DerivedDependencySelector(boolean debug) {
- this.depth = debug && log.isDebugEnabled() ? 0 : -1;
- //this.selected = new HashSet<>();
- //this.childrenProcessed = new HashSet<>();
- this.acceptedScopes = AppCreatorDependencySelector.APP_SCOPES;
- this.depExclusions = null;
- }
-
- DerivedDependencySelector(boolean debug, Dependency dependency) {
- this.depth = debug && log.isDebugEnabled() ? 0 : -1;
- //this.selected = new HashSet<>();
- //this.childrenProcessed = new HashSet<>();
- if (dependency == null) {
- depExclusions = null;
- } else {
- //childrenProcessed.add(dependency.getArtifact().toString());
- this.depExclusions = dependency.getExclusions().isEmpty() ? null
- : new DepExclusions(null, dependency.getExclusions());
- }
- this.acceptedScopes = AppCreatorDependencySelector.APP_SCOPES;
- }
-
- private DerivedDependencySelector(DerivedDependencySelector parent, Set acceptedScopes,
- DepExclusions depExclusions) {
- this.depth = parent.depth < 0 ? parent.depth : parent.depth + 1;
- //this.selected = parent.selected;
- //this.childrenProcessed = parent.childrenProcessed;
- //this.managedExcl = parent.managedExcl;
- this.acceptedScopes = acceptedScopes;
- this.depExclusions = depExclusions;
- }
-
- @Override
- public boolean selectDependency(Dependency dependency) {
- //System.out.println("selectDependency " + dependency);
-
- if (dependency.isOptional()
- || !acceptedScopes.contains(dependency.getScope())
- || depExclusions != null && depExclusions.isExcluded(dependency)) {
- //System.out.println("Filtered out " + dependency);
- return false;
- }
-
- if (depth >= 0) {
- final StringBuilder buf = new StringBuilder();
- for (int i = 0; i < depth; ++i) {
- buf.append(" ");
- }
- String offset = buf.toString();
- log.debug(offset + dependency);
- //System.out.println(offset + dependency);
- if (!dependency.getExclusions().isEmpty()) {
- log.debug(offset + " Excludes:");
- //System.out.println(offset + " Excludes:");
- buf.append(" - ");
- offset = buf.toString();
- for (Exclusion excl : dependency.getExclusions()) {
- log.debug(offset + excl.getGroupId() + ":" + excl.getArtifactId() + ":" + excl.getClassifier() + ":"
- + excl.getExtension());
- //System.out.println(offset + excl.getGroupId() + ":" + excl.getArtifactId() + ":" + excl.getClassifier() + ":" + excl.getExtension());
- }
- }
- }
- //lastSelected = dependency;
- return true;
- }
-
- @Override
- public DependencySelector deriveChildSelector(DependencyCollectionContext context) {
- //System.out.println("derivedChildSelector " + context.getDependency());
- /*
- * doesn't seem to be relevant to look into the managed deps at the root
- * if(managedExcl == null && depth <= 0) {
- * final List managedDeps = context.getManagedDependencies();
- * if(managedDeps.isEmpty()) {
- * managedExcl = Collections.emptyMap();
- * } else {
- * System.out.println("Managed dependencies");
- * managedExcl = new HashMap<>(managedDeps.size());
- * for(Dependency dep : managedDeps) {
- * final Collection exclusions = dep.getExclusions();
- * if(!exclusions.isEmpty()) {
- * managedExcl.put(getKey(dep.getArtifact()), exclusions);
- * if(depth == 0) {
- * System.out.println(" " + dep);
- * System.out.println(" Excludes:");
- * for (Exclusion excl : exclusions) {
- * System.out.println(" - " + excl.getGroupId() + ":" + excl.getArtifactId() + ":"
- * + excl.getClassifier() + ":" + excl.getExtension());
- * }
- * }
- * }
- * }
- * }
- * }
- */
- final Dependency dependency = context.getDependency();
- /*
- * this condition actually leads to a trouble
- * while the version might not match, the dependencies will still be of the version selected at the end
- * skipping it here will result in the dependency graph transformer removing the dependencies of this artifact from the
- * tree
- * if(lastSelected != null && !lastSelected.getArtifact().getVersion().equals(dependency.getArtifact().getVersion())) {
- * return DisabledDependencySelector.INSTANCE;
- * }
- */
-
- /*
- * if (dependency.isOptional()
- * / *|| !acceptedScopes.contains(dependency.getScope())* /
- * || !childrenProcessed.add(dependency.getArtifact().toString())) {
- * //System.out.println("Filtering out children of " + dependency);
- * return DisabledDependencySelector.INSTANCE;
- * }
- */
-
- if (acceptedScopes.size() != AppCreatorDependencySelector.TRANSITIVE_SCOPES.size()) {
- return new DerivedDependencySelector(this, AppCreatorDependencySelector.TRANSITIVE_SCOPES,
- dependency.getExclusions().isEmpty() ? depExclusions
- : new DepExclusions(depExclusions, dependency.getExclusions()));
- }
- return depth < 0 && dependency.getExclusions().isEmpty() ? this
- : new DerivedDependencySelector(this, acceptedScopes,
- dependency.getExclusions().isEmpty() ? depExclusions
- : new DepExclusions(depExclusions, dependency.getExclusions()));
- }
- /*
- * private static String getKey(Artifact artifact) {
- * StringBuilder sb = new StringBuilder(128);
- * sb.append(artifact.getGroupId());
- * sb.append(':');
- * sb.append(artifact.getArtifactId());
- * sb.append(':');
- * sb.append(artifact.getExtension());
- * if (!artifact.getClassifier().isEmpty()) {
- * sb.append(':');
- * sb.append(artifact.getClassifier());
- * }
- * return sb.toString();
- * }
- */
-}
\ No newline at end of file
diff --git a/core/creator/src/main/java/io/quarkus/creator/resolver/aether/MavenRepoInitializer.java b/core/creator/src/main/java/io/quarkus/creator/resolver/aether/MavenRepoInitializer.java
deleted file mode 100644
index bb0bdda61b958..0000000000000
--- a/core/creator/src/main/java/io/quarkus/creator/resolver/aether/MavenRepoInitializer.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright 2018 Red Hat, Inc. and/or its affiliates
- * and other contributors as indicated by the @author tags.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.quarkus.creator.resolver.aether;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
-import org.apache.maven.settings.Profile;
-import org.apache.maven.settings.Repository;
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.building.DefaultSettingsBuilderFactory;
-import org.apache.maven.settings.building.DefaultSettingsBuildingRequest;
-import org.apache.maven.settings.building.SettingsBuildingException;
-import org.apache.maven.settings.building.SettingsBuildingRequest;
-import org.apache.maven.settings.building.SettingsBuildingResult;
-import org.apache.maven.settings.building.SettingsProblem;
-import org.eclipse.aether.DefaultRepositorySystemSession;
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
-import org.eclipse.aether.impl.DefaultServiceLocator;
-import org.eclipse.aether.repository.Authentication;
-import org.eclipse.aether.repository.LocalRepository;
-import org.eclipse.aether.repository.Proxy;
-import org.eclipse.aether.repository.RemoteRepository;
-import org.eclipse.aether.repository.RepositoryPolicy;
-import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
-import org.eclipse.aether.spi.connector.transport.TransporterFactory;
-import org.eclipse.aether.transport.file.FileTransporterFactory;
-import org.eclipse.aether.transport.http.HttpTransporterFactory;
-import org.eclipse.aether.util.repository.AuthenticationBuilder;
-import org.eclipse.aether.util.repository.DefaultProxySelector;
-import org.jboss.logging.Logger;
-
-import io.quarkus.creator.AppCreatorException;
-import io.quarkus.creator.util.PropertyUtils;
-
-/**
- *
- * @author Alexey Loubyansky
- */
-public class MavenRepoInitializer {
-
- private static final String DOT_M2 = ".m2";
- private static final String MAVEN_HOME = "maven.home";
- private static final String M2_HOME = "M2_HOME";
- private static final String SETTINGS_XML = "settings.xml";
-
- public static final String userHome = PropertyUtils.getUserHome();
- public static final File userMavenConfigurationHome = new File(userHome, DOT_M2);
- public static final String envM2Home = System.getenv(M2_HOME);
- public static final File DEFAULT_USER_SETTINGS_FILE = new File(userMavenConfigurationHome, SETTINGS_XML);
- public static final File DEFAULT_GLOBAL_SETTINGS_FILE = new File(
- PropertyUtils.getProperty(MAVEN_HOME, envM2Home != null ? envM2Home : ""), "conf/settings.xml");
-
- private static RepositorySystem repoSystem;
- private static List remoteRepos;
- private static Settings settings;
-
- private static final Logger log = Logger.getLogger(MavenRepoInitializer.class);
-
- public static RepositorySystem getRepositorySystem() {
- if (repoSystem != null) {
- return repoSystem;
- }
-
- final DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
- locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
- locator.addService(TransporterFactory.class, FileTransporterFactory.class);
- locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
-
- locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {
- @Override
- public void serviceCreationFailed(Class> type, Class> impl, Throwable exception) {
- System.err.println("Service creation failed");
- exception.printStackTrace();
- }
- });
-
- return repoSystem = locator.getService(RepositorySystem.class);
- }
-
- public static DefaultRepositorySystemSession newSession(RepositorySystem system) throws AppCreatorException {
- return newSession(system, getSettings());
- }
-
- public static DefaultRepositorySystemSession newSession(RepositorySystem system, Settings settings) {
- final DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
-
- final org.apache.maven.settings.Proxy proxy = settings.getActiveProxy();
- if (proxy != null) {
- Authentication auth = null;
- if (proxy.getUsername() != null) {
- auth = new AuthenticationBuilder()
- .addUsername(proxy.getUsername())
- .addPassword(proxy.getPassword())
- .build();
- }
- final Proxy aetherProxy = new Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), auth);
- DefaultProxySelector proxySelector = new DefaultProxySelector();
- proxySelector.add(aetherProxy, proxy.getNonProxyHosts());
- session.setProxySelector(proxySelector);
- }
-
- final String localRepoPath = getLocalRepo(settings);
- session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, new LocalRepository(localRepoPath)));
-
- session.setOffline(settings.isOffline());
-
- // uncomment to generate dirty trees
- //session.setDependencyGraphTransformer( null );
-
- return session;
- }
-
- public static List getRemoteRepos() throws AppCreatorException {
- if (remoteRepos != null) {
- return remoteRepos;
- }
- remoteRepos = Collections.unmodifiableList(getRemoteRepos(getSettings()));
- return remoteRepos;
- }
-
- public static List getRemoteRepos(Settings settings) throws AppCreatorException {
-
- final Map profilesMap = settings.getProfilesAsMap();
- final List remotes = new ArrayList<>();
-
- for (String profileName : settings.getActiveProfiles()) {
- final Profile profile = profilesMap.get(profileName);
- final List repositories = profile.getRepositories();
- for (Repository repo : repositories) {
- final RemoteRepository.Builder repoBuilder = new RemoteRepository.Builder(repo.getId(), repo.getLayout(),
- repo.getUrl());
- org.apache.maven.settings.RepositoryPolicy policy = repo.getReleases();
- if (policy != null) {
- repoBuilder.setReleasePolicy(
- new RepositoryPolicy(policy.isEnabled(), policy.getUpdatePolicy(), policy.getChecksumPolicy()));
- }
- policy = repo.getSnapshots();
- if (policy != null) {
- repoBuilder.setSnapshotPolicy(
- new RepositoryPolicy(policy.isEnabled(), policy.getUpdatePolicy(), policy.getChecksumPolicy()));
- }
- remotes.add(repoBuilder.build());
- }
- }
- return remotes;
- }
-
- public static Settings getSettings() throws AppCreatorException {
- if (settings != null) {
- return settings;
- }
- final SettingsBuildingRequest settingsBuildingRequest = new DefaultSettingsBuildingRequest();
- settingsBuildingRequest.setSystemProperties(System.getProperties());
- settingsBuildingRequest.setUserSettingsFile(DEFAULT_USER_SETTINGS_FILE);
- settingsBuildingRequest.setGlobalSettingsFile(DEFAULT_GLOBAL_SETTINGS_FILE);
-
- final Settings effectiveSettings;
- try {
- final SettingsBuildingResult result = new DefaultSettingsBuilderFactory().newInstance()
- .build(settingsBuildingRequest);
- final List problems = result.getProblems();
- if (!problems.isEmpty()) {
- for (SettingsProblem problem : problems) {
- switch (problem.getSeverity()) {
- case ERROR:
- case FATAL:
- throw new AppCreatorException("Settings problem encountered at " + problem.getLocation(),
- problem.getException());
- default:
- log.warn("Settings problem encountered at " + problem.getLocation(), problem.getException());
- }
- }
- }
- effectiveSettings = result.getEffectiveSettings();
- } catch (SettingsBuildingException e) {
- throw new AppCreatorException("Failed to initialize Maven repository settings", e);
- }
-
- settings = effectiveSettings;
- return effectiveSettings;
- }
-
- public static String getLocalRepo(Settings settings) {
- final String localRepo = settings.getLocalRepository();
- return localRepo == null ? getDefaultLocalRepo() : localRepo;
- }
-
- private static String getDefaultLocalRepo() {
- return new File(userMavenConfigurationHome, "repository").getAbsolutePath();
- }
-}
diff --git a/core/creator/src/main/java/io/quarkus/creator/resolver/maven/ResolvedMavenArtifactDeps.java b/core/creator/src/main/java/io/quarkus/creator/resolver/maven/ResolvedMavenArtifactDeps.java
deleted file mode 100644
index 88747ffb3da27..0000000000000
--- a/core/creator/src/main/java/io/quarkus/creator/resolver/maven/ResolvedMavenArtifactDeps.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2018 Red Hat, Inc. and/or its affiliates
- * and other contributors as indicated by the @author tags.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.quarkus.creator.resolver.maven;
-
-import java.io.File;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.maven.artifact.Artifact;
-
-import io.quarkus.creator.AppArtifact;
-import io.quarkus.creator.AppArtifactResolverBase;
-import io.quarkus.creator.AppCreatorException;
-import io.quarkus.creator.AppDependency;
-
-/**
- *
- * @author Alexey Loubyansky
- */
-public class ResolvedMavenArtifactDeps extends AppArtifactResolverBase {
-
- private final String groupId;
- private final String artifactId;
- private final String classifier;
- private final String type;
- private final String version;
- private final List deps;
-
- public ResolvedMavenArtifactDeps(String groupId, String artifactId, String version, Collection artifacts) {
- this(groupId, artifactId, "", version, artifacts);
- }
-
- public ResolvedMavenArtifactDeps(String groupId, String artifactId, String classifier, String version,
- Collection artifacts) {
- this(groupId, artifactId, "", "jar", version, artifacts);
- }
-
- public ResolvedMavenArtifactDeps(String groupId, String artifactId, String classifier, String type, String version,
- Collection artifacts) {
- this.groupId = groupId;
- this.artifactId = artifactId;
- this.classifier = classifier;
- this.type = type;
- this.version = version;
- final List tmp = new ArrayList<>(artifacts.size());
- for (Artifact artifact : artifacts) {
- tmp.add(new AppDependency(toMvnArtifact(artifact), artifact.getScope()));
- }
- deps = Collections.unmodifiableList(tmp);
- }
-
- @Override
- public void relink(AppArtifact artifact, Path path) throws AppCreatorException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void doResolve(AppArtifact coords) throws AppCreatorException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public List collectDependencies(AppArtifact coords) throws AppCreatorException {
- if (!coords.getGroupId().equals(groupId) ||
- !coords.getArtifactId().equals(artifactId) ||
- !coords.getClassifier().equals(classifier) ||
- !coords.getType().equals(type) ||
- !coords.getVersion().equals(version)) {
- throw new AppCreatorException("The resolve can only resolve dependencies for " + groupId + ':' + artifactId + ':'
- + classifier + ':' + type + ':' + version + ": " + coords);
- }
- return deps;
- }
-
- @Override
- public List collectDependencies(AppArtifact root, List deps) throws AppCreatorException {
- throw new UnsupportedOperationException();
- }
-
- private static AppArtifact toMvnArtifact(Artifact artifact) {
- final AppArtifact mvn = new AppArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(),
- artifact.getType(), artifact.getVersion());
- final File file = artifact.getFile();
- if (file != null) {
- setPath(mvn, file.toPath());
- }
- return mvn;
- }
-
- @Override
- public List listLaterVersions(AppArtifact artifact, String upToVersion, boolean inclusive)
- throws AppCreatorException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getNextVersion(AppArtifact artifact, String upToVersion, boolean inclusive) throws AppCreatorException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getLatestVersion(AppArtifact artifact, String upToVersion, boolean inclusive) throws AppCreatorException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/core/creator/src/main/java/io/quarkus/creator/util/PropertyUtils.java b/core/creator/src/main/java/io/quarkus/creator/util/PropertyUtils.java
deleted file mode 100644
index d146d274c1c2c..0000000000000
--- a/core/creator/src/main/java/io/quarkus/creator/util/PropertyUtils.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2018 Red Hat, Inc. and/or its affiliates
- * and other contributors as indicated by the @author tags.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.quarkus.creator.util;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Locale;
-
-/**
- *
- * @author Alexey Loubyansky
- */
-public class PropertyUtils {
-
- private static final String OS_NAME = "os.name";
- private static final String USER_HOME = "user.home";
- private static final String WINDOWS = "windows";
-
- private PropertyUtils() {
- }
-
- public static boolean isWindows() {
- return getProperty(OS_NAME).toLowerCase(Locale.ENGLISH).indexOf(WINDOWS) >= 0;
- }
-
- public static String getUserHome() {
- return getProperty(USER_HOME);
- }
-
- public static String getProperty(final String name, String defValue) {
- final String value = getProperty(name);
- return value == null ? defValue : value;
- }
-
- public static String getProperty(final String name) {
- assert name != null : "name is null";
- final SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- return AccessController.doPrivileged(new PrivilegedAction() {
- @Override
- public String run() {
- return System.getProperty(name);
- }
- });
- } else {
- return System.getProperty(name);
- }
- }
-}
diff --git a/core/creator/src/test/java/io/quarkus/creator/config/test/PersonAddressTestBase.java b/core/creator/src/test/java/io/quarkus/creator/config/test/PersonAddressTestBase.java
index 7d38e20fd440e..c709cbd54e365 100644
--- a/core/creator/src/test/java/io/quarkus/creator/config/test/PersonAddressTestBase.java
+++ b/core/creator/src/test/java/io/quarkus/creator/config/test/PersonAddressTestBase.java
@@ -28,10 +28,10 @@
import org.junit.Test;
+import io.quarkus.bootstrap.util.IoUtils;
import io.quarkus.creator.config.reader.PropertiesConfigReader;
import io.quarkus.creator.config.reader.PropertiesHandler;
import io.quarkus.creator.config.reader.PropertyLine;
-import io.quarkus.creator.util.IoUtils;
/**
*
diff --git a/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForLatestMajorUpdatesTest.java b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForLatestMajorUpdatesTest.java
new file mode 100644
index 0000000000000..c35d6e9a9504a
--- /dev/null
+++ b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForLatestMajorUpdatesTest.java
@@ -0,0 +1,69 @@
+package io.quarkus.creator.phase.curate.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+import io.quarkus.bootstrap.model.AppDependency;
+import io.quarkus.bootstrap.model.AppModel;
+import io.quarkus.bootstrap.resolver.TsArtifact;
+import io.quarkus.bootstrap.resolver.TsQuarkusExt;
+import io.quarkus.creator.AppCreator;
+import io.quarkus.creator.phase.curate.CurateOutcome;
+import io.quarkus.creator.phase.curate.CuratePhase;
+import io.quarkus.creator.phase.curate.VersionUpdate;
+import io.quarkus.creator.phase.curate.VersionUpdateNumber;
+import io.quarkus.creator.phase.runnerjar.test.CreatorOutcomeTestBase;
+
+public class CheckForLatestMajorUpdatesTest extends CreatorOutcomeTestBase {
+
+ @Override
+ protected void initProps(Properties props) {
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE),
+ VersionUpdate.LATEST.getName()); // NONE, next, latest
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE_NUMBER),
+ VersionUpdateNumber.MAJOR.getName()); // major, minor, MICRO
+ }
+
+ @Override
+ protected TsArtifact modelApp() throws Exception {
+ new TsQuarkusExt("ext1", "1.0.1").install(repo);
+ new TsQuarkusExt("ext1", "1.1.0").install(repo);
+ new TsQuarkusExt("ext1", "2.0.0").install(repo);
+ new TsQuarkusExt("ext1", "3.0.0").install(repo);
+ new TsQuarkusExt("ext1", "3.0.1").install(repo);
+ new TsQuarkusExt("ext1", "3.1.0").install(repo);
+ new TsQuarkusExt("ext1", "3.1.1").install(repo);
+
+ return TsArtifact.jar("app")
+ .addDependency(new TsQuarkusExt("ext1", "1.0.0"))
+ .addDependency(TsArtifact.jar("random"))
+ .addDependency(new TsQuarkusExt("ext2", "1.0.0"));
+ }
+
+ @Override
+ protected void testCreator(AppCreator creator) throws Exception {
+ final CurateOutcome outcome = creator.resolveOutcome(CurateOutcome.class);
+
+ assertTrue(outcome.hasUpdatedDeps());
+
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1", "3.1.1").toAppArtifact(), "compile")
+ }), outcome.getUpdatedDeps());
+
+ final AppModel effectiveModel = outcome.getEffectiveModel();
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1", "3.1.1").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("random").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getUserDependencies());
+
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1-deployment", "3.1.1").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2-deployment", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getDeploymentDependencies());
+
+ }
+}
diff --git a/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForLatestMicroUpdatesTest.java b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForLatestMicroUpdatesTest.java
new file mode 100644
index 0000000000000..079189ce4fef0
--- /dev/null
+++ b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForLatestMicroUpdatesTest.java
@@ -0,0 +1,66 @@
+package io.quarkus.creator.phase.curate.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+import io.quarkus.bootstrap.model.AppDependency;
+import io.quarkus.bootstrap.model.AppModel;
+import io.quarkus.bootstrap.resolver.TsArtifact;
+import io.quarkus.bootstrap.resolver.TsQuarkusExt;
+import io.quarkus.creator.AppCreator;
+import io.quarkus.creator.phase.curate.CurateOutcome;
+import io.quarkus.creator.phase.curate.CuratePhase;
+import io.quarkus.creator.phase.curate.VersionUpdate;
+import io.quarkus.creator.phase.curate.VersionUpdateNumber;
+import io.quarkus.creator.phase.runnerjar.test.CreatorOutcomeTestBase;
+
+public class CheckForLatestMicroUpdatesTest extends CreatorOutcomeTestBase {
+
+ @Override
+ protected void initProps(Properties props) {
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE),
+ VersionUpdate.LATEST.getName()); // NONE, next, latest
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE_NUMBER),
+ VersionUpdateNumber.MICRO.getName()); // major, minor, MICRO
+ }
+
+ @Override
+ protected TsArtifact modelApp() throws Exception {
+ new TsQuarkusExt("ext1", "1.0.1").install(repo);
+ new TsQuarkusExt("ext1", "1.0.2").install(repo);
+ new TsQuarkusExt("ext1", "1.1.0").install(repo);
+ new TsQuarkusExt("ext1", "2.0.0").install(repo);
+
+ return TsArtifact.jar("app")
+ .addDependency(new TsQuarkusExt("ext1", "1.0.0"))
+ .addDependency(TsArtifact.jar("random"))
+ .addDependency(new TsQuarkusExt("ext2", "1.0.0"));
+ }
+
+ @Override
+ protected void testCreator(AppCreator creator) throws Exception {
+ final CurateOutcome outcome = creator.resolveOutcome(CurateOutcome.class);
+
+ assertTrue(outcome.hasUpdatedDeps());
+
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1", "1.0.2").toAppArtifact(), "compile")
+ }), outcome.getUpdatedDeps());
+
+ final AppModel effectiveModel = outcome.getEffectiveModel();
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1", "1.0.2").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("random").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getUserDependencies());
+
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1-deployment", "1.0.2").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2-deployment", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getDeploymentDependencies());
+
+ }
+}
diff --git a/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForLatestMinorUpdatesTest.java b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForLatestMinorUpdatesTest.java
new file mode 100644
index 0000000000000..153c79892a3d8
--- /dev/null
+++ b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForLatestMinorUpdatesTest.java
@@ -0,0 +1,67 @@
+package io.quarkus.creator.phase.curate.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+import io.quarkus.bootstrap.model.AppDependency;
+import io.quarkus.bootstrap.model.AppModel;
+import io.quarkus.bootstrap.resolver.TsArtifact;
+import io.quarkus.bootstrap.resolver.TsQuarkusExt;
+import io.quarkus.creator.AppCreator;
+import io.quarkus.creator.phase.curate.CurateOutcome;
+import io.quarkus.creator.phase.curate.CuratePhase;
+import io.quarkus.creator.phase.curate.VersionUpdate;
+import io.quarkus.creator.phase.curate.VersionUpdateNumber;
+import io.quarkus.creator.phase.runnerjar.test.CreatorOutcomeTestBase;
+
+public class CheckForLatestMinorUpdatesTest extends CreatorOutcomeTestBase {
+
+ @Override
+ protected void initProps(Properties props) {
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE),
+ VersionUpdate.LATEST.getName()); // NONE, next, latest
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE_NUMBER),
+ VersionUpdateNumber.MINOR.getName()); // major, minor, MICRO
+ }
+
+ @Override
+ protected TsArtifact modelApp() throws Exception {
+ new TsQuarkusExt("ext1", "1.0.1").install(repo);
+ new TsQuarkusExt("ext1", "1.1.0").install(repo);
+ new TsQuarkusExt("ext1", "1.2.0").install(repo);
+ new TsQuarkusExt("ext1", "1.2.1").install(repo);
+ new TsQuarkusExt("ext1", "2.0.0").install(repo);
+
+ return TsArtifact.jar("app")
+ .addDependency(new TsQuarkusExt("ext1", "1.0.0"))
+ .addDependency(TsArtifact.jar("random"))
+ .addDependency(new TsQuarkusExt("ext2", "1.0.0"));
+ }
+
+ @Override
+ protected void testCreator(AppCreator creator) throws Exception {
+ final CurateOutcome outcome = creator.resolveOutcome(CurateOutcome.class);
+
+ assertTrue(outcome.hasUpdatedDeps());
+
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1", "1.2.1").toAppArtifact(), "compile")
+ }), outcome.getUpdatedDeps());
+
+ final AppModel effectiveModel = outcome.getEffectiveModel();
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1", "1.2.1").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("random").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getUserDependencies());
+
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1-deployment", "1.2.1").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2-deployment", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getDeploymentDependencies());
+
+ }
+}
diff --git a/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForNextMajorUpdatesTest.java b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForNextMajorUpdatesTest.java
new file mode 100644
index 0000000000000..aed6e2cc7fc65
--- /dev/null
+++ b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForNextMajorUpdatesTest.java
@@ -0,0 +1,68 @@
+package io.quarkus.creator.phase.curate.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+import io.quarkus.bootstrap.model.AppDependency;
+import io.quarkus.bootstrap.model.AppModel;
+import io.quarkus.bootstrap.resolver.TsArtifact;
+import io.quarkus.bootstrap.resolver.TsQuarkusExt;
+import io.quarkus.creator.AppCreator;
+import io.quarkus.creator.phase.curate.CurateOutcome;
+import io.quarkus.creator.phase.curate.CuratePhase;
+import io.quarkus.creator.phase.curate.VersionUpdate;
+import io.quarkus.creator.phase.curate.VersionUpdateNumber;
+import io.quarkus.creator.phase.runnerjar.test.CreatorOutcomeTestBase;
+
+public class CheckForNextMajorUpdatesTest extends CreatorOutcomeTestBase {
+
+ @Override
+ protected void initProps(Properties props) {
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE),
+ VersionUpdate.NEXT.getName()); // NONE, next, latest
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE_NUMBER),
+ VersionUpdateNumber.MAJOR.getName()); // major, minor, MICRO
+ }
+
+ @Override
+ protected TsArtifact modelApp() throws Exception {
+ new TsQuarkusExt("ext1", "1.0.1").install(repo);
+ new TsQuarkusExt("ext1", "1.1.0").install(repo);
+ new TsQuarkusExt("ext1", "2.0.0").install(repo);
+ new TsQuarkusExt("ext1", "2.0.1").install(repo);
+ new TsQuarkusExt("ext1", "2.1.0").install(repo);
+ new TsQuarkusExt("ext1", "3.0.0").install(repo);
+
+ return TsArtifact.jar("app")
+ .addDependency(new TsQuarkusExt("ext1", "1.0.0"))
+ .addDependency(TsArtifact.jar("random"))
+ .addDependency(new TsQuarkusExt("ext2", "1.0.0"));
+ }
+
+ @Override
+ protected void testCreator(AppCreator creator) throws Exception {
+ final CurateOutcome outcome = creator.resolveOutcome(CurateOutcome.class);
+
+ assertTrue(outcome.hasUpdatedDeps());
+
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1", "2.0.0").toAppArtifact(), "compile")
+ }), outcome.getUpdatedDeps());
+
+ final AppModel effectiveModel = outcome.getEffectiveModel();
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1", "2.0.0").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("random").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getUserDependencies());
+
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1-deployment", "2.0.0").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2-deployment", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getDeploymentDependencies());
+
+ }
+}
diff --git a/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForNextMicroUpdatesTest.java b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForNextMicroUpdatesTest.java
new file mode 100644
index 0000000000000..66784eaddf9ff
--- /dev/null
+++ b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForNextMicroUpdatesTest.java
@@ -0,0 +1,66 @@
+package io.quarkus.creator.phase.curate.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+import io.quarkus.bootstrap.model.AppDependency;
+import io.quarkus.bootstrap.model.AppModel;
+import io.quarkus.bootstrap.resolver.TsArtifact;
+import io.quarkus.bootstrap.resolver.TsQuarkusExt;
+import io.quarkus.creator.AppCreator;
+import io.quarkus.creator.phase.curate.CurateOutcome;
+import io.quarkus.creator.phase.curate.CuratePhase;
+import io.quarkus.creator.phase.curate.VersionUpdate;
+import io.quarkus.creator.phase.curate.VersionUpdateNumber;
+import io.quarkus.creator.phase.runnerjar.test.CreatorOutcomeTestBase;
+
+public class CheckForNextMicroUpdatesTest extends CreatorOutcomeTestBase {
+
+ @Override
+ protected void initProps(Properties props) {
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE),
+ VersionUpdate.NEXT.getName()); // NONE, next, latest
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE_NUMBER),
+ VersionUpdateNumber.MICRO.getName()); // major, minor, MICRO
+ }
+
+ @Override
+ protected TsArtifact modelApp() throws Exception {
+ new TsQuarkusExt("ext1", "1.0.1").install(repo);
+ new TsQuarkusExt("ext1", "1.0.2").install(repo);
+ new TsQuarkusExt("ext1", "1.1.0").install(repo);
+ new TsQuarkusExt("ext1", "2.0.0").install(repo);
+
+ return TsArtifact.jar("app")
+ .addDependency(new TsQuarkusExt("ext1", "1.0.0"))
+ .addDependency(TsArtifact.jar("random"))
+ .addDependency(new TsQuarkusExt("ext2", "1.0.0"));
+ }
+
+ @Override
+ protected void testCreator(AppCreator creator) throws Exception {
+ final CurateOutcome outcome = creator.resolveOutcome(CurateOutcome.class);
+
+ assertTrue(outcome.hasUpdatedDeps());
+
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1", "1.0.1").toAppArtifact(), "compile")
+ }), outcome.getUpdatedDeps());
+
+ final AppModel effectiveModel = outcome.getEffectiveModel();
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1", "1.0.1").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("random").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getUserDependencies());
+
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1-deployment", "1.0.1").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2-deployment", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getDeploymentDependencies());
+
+ }
+}
diff --git a/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForNextMinorUpdatesTest.java b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForNextMinorUpdatesTest.java
new file mode 100644
index 0000000000000..0a0b5745e31c2
--- /dev/null
+++ b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckForNextMinorUpdatesTest.java
@@ -0,0 +1,67 @@
+package io.quarkus.creator.phase.curate.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+import io.quarkus.bootstrap.model.AppDependency;
+import io.quarkus.bootstrap.model.AppModel;
+import io.quarkus.bootstrap.resolver.TsArtifact;
+import io.quarkus.bootstrap.resolver.TsQuarkusExt;
+import io.quarkus.creator.AppCreator;
+import io.quarkus.creator.phase.curate.CurateOutcome;
+import io.quarkus.creator.phase.curate.CuratePhase;
+import io.quarkus.creator.phase.curate.VersionUpdate;
+import io.quarkus.creator.phase.curate.VersionUpdateNumber;
+import io.quarkus.creator.phase.runnerjar.test.CreatorOutcomeTestBase;
+
+public class CheckForNextMinorUpdatesTest extends CreatorOutcomeTestBase {
+
+ @Override
+ protected void initProps(Properties props) {
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE),
+ VersionUpdate.NEXT.getName()); // NONE, next, latest
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE_NUMBER),
+ VersionUpdateNumber.MINOR.getName()); // major, minor, MICRO
+ }
+
+ @Override
+ protected TsArtifact modelApp() throws Exception {
+ new TsQuarkusExt("ext1", "1.0.1").install(repo);
+ new TsQuarkusExt("ext1", "1.1.0").install(repo);
+ new TsQuarkusExt("ext1", "1.1.1").install(repo);
+ new TsQuarkusExt("ext1", "1.2.0").install(repo);
+ new TsQuarkusExt("ext1", "2.0.0").install(repo);
+
+ return TsArtifact.jar("app")
+ .addDependency(new TsQuarkusExt("ext1", "1.0.0"))
+ .addDependency(TsArtifact.jar("random"))
+ .addDependency(new TsQuarkusExt("ext2", "1.0.0"));
+ }
+
+ @Override
+ protected void testCreator(AppCreator creator) throws Exception {
+ final CurateOutcome outcome = creator.resolveOutcome(CurateOutcome.class);
+
+ assertTrue(outcome.hasUpdatedDeps());
+
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1", "1.1.0").toAppArtifact(), "compile")
+ }), outcome.getUpdatedDeps());
+
+ final AppModel effectiveModel = outcome.getEffectiveModel();
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1", "1.1.0").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("random").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getUserDependencies());
+
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1-deployment", "1.1.0").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2-deployment", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getDeploymentDependencies());
+
+ }
+}
diff --git a/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckUpdatesDisableTest.java b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckUpdatesDisableTest.java
new file mode 100644
index 0000000000000..23f9a80cb0647
--- /dev/null
+++ b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/CheckUpdatesDisableTest.java
@@ -0,0 +1,70 @@
+package io.quarkus.creator.phase.curate.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Properties;
+
+import io.quarkus.bootstrap.model.AppDependency;
+import io.quarkus.bootstrap.model.AppModel;
+import io.quarkus.bootstrap.resolver.TsArtifact;
+import io.quarkus.bootstrap.resolver.TsQuarkusExt;
+import io.quarkus.creator.AppCreator;
+import io.quarkus.creator.phase.curate.CurateOutcome;
+import io.quarkus.creator.phase.curate.CuratePhase;
+import io.quarkus.creator.phase.curate.VersionUpdate;
+import io.quarkus.creator.phase.curate.VersionUpdateNumber;
+import io.quarkus.creator.phase.runnerjar.test.CreatorOutcomeTestBase;
+
+public class CheckUpdatesDisableTest extends CreatorOutcomeTestBase {
+
+ @Override
+ protected void initProps(Properties props) {
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE),
+ VersionUpdate.NONE.getName()); // NONE, next, latest
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE_NUMBER),
+ VersionUpdateNumber.MAJOR.getName()); // major, minor, MICRO
+ }
+
+ @Override
+ protected TsArtifact modelApp() throws Exception {
+ new TsQuarkusExt("ext1", "1.0.1").install(repo);
+ new TsQuarkusExt("ext1", "1.0.2").install(repo);
+ new TsQuarkusExt("ext1", "1.1.0").install(repo);
+ new TsQuarkusExt("ext1", "1.2.0").install(repo);
+ new TsQuarkusExt("ext1", "2.0.0").install(repo);
+ new TsQuarkusExt("ext1", "3.0.0").install(repo);
+ new TsQuarkusExt("ext1", "3.0.1").install(repo);
+ new TsQuarkusExt("ext1", "3.1.0").install(repo);
+ new TsQuarkusExt("ext1", "3.1.1").install(repo);
+
+ return TsArtifact.jar("app")
+ .addDependency(new TsQuarkusExt("ext1", "1.0.0"))
+ .addDependency(TsArtifact.jar("random"))
+ .addDependency(new TsQuarkusExt("ext2", "1.0.0"));
+ }
+
+ @Override
+ protected void testCreator(AppCreator creator) throws Exception {
+ final CurateOutcome outcome = creator.resolveOutcome(CurateOutcome.class);
+
+ assertFalse(outcome.hasUpdatedDeps());
+
+ assertEquals(Collections.emptyList(), outcome.getUpdatedDeps());
+
+ final AppModel effectiveModel = outcome.getEffectiveModel();
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1", "1.0.0").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("random").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getUserDependencies());
+
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1-deployment", "1.0.0").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2-deployment", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getDeploymentDependencies());
+
+ }
+}
diff --git a/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/UpdateToNextMicroAndPersistStateTest.java b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/UpdateToNextMicroAndPersistStateTest.java
new file mode 100644
index 0000000000000..40bc331cc06a9
--- /dev/null
+++ b/core/creator/src/test/java/io/quarkus/creator/phase/curate/test/UpdateToNextMicroAndPersistStateTest.java
@@ -0,0 +1,89 @@
+package io.quarkus.creator.phase.curate.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Properties;
+
+import io.quarkus.bootstrap.model.AppDependency;
+import io.quarkus.bootstrap.model.AppModel;
+import io.quarkus.bootstrap.resolver.TsArtifact;
+import io.quarkus.bootstrap.resolver.TsQuarkusExt;
+import io.quarkus.creator.AppCreator;
+import io.quarkus.creator.phase.curate.CurateOutcome;
+import io.quarkus.creator.phase.curate.CuratePhase;
+import io.quarkus.creator.phase.curate.DependenciesOrigin;
+import io.quarkus.creator.phase.curate.VersionUpdate;
+import io.quarkus.creator.phase.curate.VersionUpdateNumber;
+import io.quarkus.creator.phase.runnerjar.test.CreatorOutcomeTestBase;
+
+public class UpdateToNextMicroAndPersistStateTest extends CreatorOutcomeTestBase {
+
+ private static final String[] EXPECTED_UPDATES = new String[] { "1.0.1", "1.0.2" };
+
+ private int buildNo;
+
+ @Override
+ protected void initProps(Properties props) {
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_DEPS_ORIGIN),
+ DependenciesOrigin.LAST_UPDATE.getName()); // APPLICATION, last-update
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE),
+ VersionUpdate.NEXT.getName()); // NONE, next, latest
+ props.setProperty(CuratePhase.completePropertyName(CuratePhase.CONFIG_PROP_VERSION_UPDATE_NUMBER),
+ VersionUpdateNumber.MICRO.getName()); // major, minor, MICRO
+ }
+
+ @Override
+ protected TsArtifact modelApp() throws Exception {
+ new TsQuarkusExt("ext1", "1.0.1").install(repo);
+ new TsQuarkusExt("ext1", "1.0.2").install(repo);
+ new TsQuarkusExt("ext1", "1.1.0").install(repo);
+ new TsQuarkusExt("ext1", "2.0.0").install(repo);
+
+ return TsArtifact.jar("app")
+ .addDependency(new TsQuarkusExt("ext1", "1.0.0"))
+ .addDependency(TsArtifact.jar("random"))
+ .addDependency(new TsQuarkusExt("ext2", "1.0.0"));
+ }
+
+ @Override
+ protected void testCreator(AppCreator creator) throws Exception {
+
+ final CurateOutcome outcome = creator.resolveOutcome(CurateOutcome.class);
+
+ final String expectedVersion;
+
+ if (buildNo < EXPECTED_UPDATES.length) {
+ expectedVersion = EXPECTED_UPDATES[buildNo];
+ assertTrue(outcome.hasUpdatedDeps());
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1", expectedVersion).toAppArtifact(), "compile")
+ }), outcome.getUpdatedDeps());
+ } else {
+ expectedVersion = EXPECTED_UPDATES[buildNo - 1];
+ assertFalse(outcome.hasUpdatedDeps());
+ assertEquals(Collections.emptyList(), outcome.getUpdatedDeps());
+ }
+
+ final AppModel effectiveModel = outcome.getEffectiveModel();
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1", expectedVersion).toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("random").toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getUserDependencies());
+
+ assertEquals(Arrays.asList(new AppDependency[] {
+ new AppDependency(TsArtifact.jar("ext1-deployment", expectedVersion).toAppArtifact(), "compile"),
+ new AppDependency(TsArtifact.jar("ext2-deployment", "1.0.0").toAppArtifact(), "compile")
+ }), effectiveModel.getDeploymentDependencies());
+
+ outcome.persist(creator);
+
+ if (++buildNo <= EXPECTED_UPDATES.length) {
+ rebuild();
+ }
+ }
+}
diff --git a/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/BasicRunnerJarOutcomeTest.java b/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/BasicRunnerJarOutcomeTest.java
new file mode 100644
index 0000000000000..230cdb26814c6
--- /dev/null
+++ b/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/BasicRunnerJarOutcomeTest.java
@@ -0,0 +1,48 @@
+package io.quarkus.creator.phase.runnerjar.test;
+
+import io.quarkus.bootstrap.resolver.TsArtifact;
+import io.quarkus.bootstrap.resolver.TsDependency;
+import io.quarkus.bootstrap.resolver.TsQuarkusExt;
+
+public class BasicRunnerJarOutcomeTest extends RunnerJarOutcomeTestBase {
+
+ @Override
+ protected TsArtifact modelApp() {
+ final TsQuarkusExt coreExt = new TsQuarkusExt("core-ext");
+ addToExpectedLib(coreExt.getRuntime());
+
+ final TsQuarkusExt ext1 = new TsQuarkusExt("ext1");
+ ext1.addDependency(coreExt);
+ addToExpectedLib(ext1.getRuntime());
+
+ final TsQuarkusExt ext2 = new TsQuarkusExt("ext2");
+ addToExpectedLib(ext2.getRuntime());
+
+ final TsArtifact transitiveDep1 = TsArtifact.jar("transitive1");
+ addToExpectedLib(transitiveDep1);
+
+ final TsArtifact optionalTransitiveDep = TsArtifact.jar("optional-transitive-dep");
+
+ final TsArtifact compileDep = TsArtifact.jar("compile-dep")
+ .addDependency(transitiveDep1)
+ .addDependency(new TsDependency(optionalTransitiveDep, true));
+ addToExpectedLib(compileDep);
+
+ final TsArtifact providedDep = TsArtifact.jar("provided-dep");
+
+ final TsArtifact optionalDep = TsArtifact.jar("optional-dep");
+ addToExpectedLib(optionalDep); // TODO should direct optional deps be included?
+
+ final TsArtifact directRtDep = TsArtifact.jar("runtime-dep");
+ addToExpectedLib(directRtDep);
+
+ final TsArtifact appJar = TsArtifact.jar("app")
+ .addDependency(ext1)
+ .addDependency(ext2)
+ .addDependency(compileDep)
+ .addDependency(new TsDependency(providedDep, "provided"))
+ .addDependency(new TsDependency(optionalDep, true))
+ .addDependency(new TsDependency(directRtDep, "runtime"));
+ return appJar;
+ }
+}
diff --git a/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/CreatorOutcomeTestBase.java b/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/CreatorOutcomeTestBase.java
new file mode 100644
index 0000000000000..20dd0e647eea6
--- /dev/null
+++ b/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/CreatorOutcomeTestBase.java
@@ -0,0 +1,58 @@
+package io.quarkus.creator.phase.runnerjar.test;
+
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Properties;
+
+import org.junit.Test;
+
+import io.quarkus.bootstrap.resolver.ResolverSetupCleanup;
+import io.quarkus.bootstrap.resolver.TsArtifact;
+import io.quarkus.creator.AppCreator;
+import io.quarkus.creator.config.reader.PropertiesConfigReader;
+import io.quarkus.creator.config.reader.PropertiesHandler;
+
+public abstract class CreatorOutcomeTestBase extends ResolverSetupCleanup {
+
+ protected TsArtifact appJar;
+ protected Path propsFile;
+
+ @Test
+ public void test() throws Exception {
+ appJar = modelApp();
+ appJar.install(repo);
+
+ final Properties props = getProperties();
+ propsFile = workDir.resolve("app-creator.properties");
+ try (OutputStream out = Files.newOutputStream(propsFile)) {
+ props.store(out, "Example AppCreator properties");
+ }
+
+ rebuild();
+ }
+
+ protected void rebuild() throws Exception {
+ final PropertiesHandler propsHandler = AppCreator.builder()
+ .setModelResolver(resolver)
+ .setWorkDir(workDir)
+ .setAppJar(resolver.resolve(appJar.toAppArtifact()))
+ .getPropertiesHandler();
+ try (final AppCreator appCreator = PropertiesConfigReader.getInstance(propsHandler).read(propsFile)) {
+ testCreator(appCreator);
+ }
+ }
+
+ protected abstract TsArtifact modelApp() throws Exception;
+
+ protected abstract void testCreator(AppCreator creator) throws Exception;
+
+ private Properties getProperties() {
+ final Properties props = new Properties();
+ initProps(props);
+ return props;
+ }
+
+ protected void initProps(Properties props) {
+ }
+}
diff --git a/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/DirectUserDepsOverrideTransitiveExtDepsTest.java b/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/DirectUserDepsOverrideTransitiveExtDepsTest.java
new file mode 100644
index 0000000000000..078a2c2407f75
--- /dev/null
+++ b/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/DirectUserDepsOverrideTransitiveExtDepsTest.java
@@ -0,0 +1,32 @@
+package io.quarkus.creator.phase.runnerjar.test;
+
+import io.quarkus.bootstrap.resolver.TsArtifact;
+import io.quarkus.bootstrap.resolver.TsQuarkusExt;
+
+public class DirectUserDepsOverrideTransitiveExtDepsTest extends RunnerJarOutcomeTestBase {
+
+ @Override
+ protected TsArtifact modelApp() {
+
+ final TsArtifact common1 = TsArtifact.jar("common", "1");
+
+ final TsQuarkusExt ext1 = new TsQuarkusExt("ext1");
+ ext1.getRuntime().addDependency(common1);
+ addToExpectedLib(ext1.getRuntime());
+
+ final TsArtifact common2 = TsArtifact.jar("common", "2");
+
+ final TsQuarkusExt ext2 = new TsQuarkusExt("ext2");
+ ext2.getRuntime().addDependency(common2);
+ addToExpectedLib(ext2.getRuntime());
+
+ final TsArtifact common3 = TsArtifact.jar("common", "3");
+ addToExpectedLib(common3);
+
+ final TsArtifact appJar = TsArtifact.jar("app")
+ .addDependency(ext1)
+ .addDependency(common3)
+ .addDependency(ext2);
+ return appJar;
+ }
+}
diff --git a/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/FirstTransitiveDepVersionIsTheEffectiveOneTest.java b/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/FirstTransitiveDepVersionIsTheEffectiveOneTest.java
new file mode 100644
index 0000000000000..4ba55f032be78
--- /dev/null
+++ b/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/FirstTransitiveDepVersionIsTheEffectiveOneTest.java
@@ -0,0 +1,35 @@
+package io.quarkus.creator.phase.runnerjar.test;
+
+import io.quarkus.bootstrap.resolver.TsArtifact;
+import io.quarkus.bootstrap.resolver.TsQuarkusExt;
+
+public class FirstTransitiveDepVersionIsTheEffectiveOneTest extends RunnerJarOutcomeTestBase {
+
+ @Override
+ protected TsArtifact modelApp() {
+
+ final TsArtifact common1 = TsArtifact.jar("common", "1");
+ addToExpectedLib(common1);
+
+ final TsQuarkusExt ext1 = new TsQuarkusExt("ext1");
+ ext1.getRuntime().addDependency(common1);
+ addToExpectedLib(ext1.getRuntime());
+
+ final TsArtifact common2 = TsArtifact.jar("common", "2");
+
+ final TsQuarkusExt ext2 = new TsQuarkusExt("ext2");
+ ext2.getRuntime().addDependency(common2);
+ addToExpectedLib(ext2.getRuntime());
+
+ final TsArtifact common3 = TsArtifact.jar("common", "3");
+
+ final TsArtifact directAppDep = TsArtifact.jar("direct-dep").addDependency(common3);
+ addToExpectedLib(directAppDep);
+
+ final TsArtifact appJar = TsArtifact.jar("app")
+ .addDependency(ext1)
+ .addDependency(directAppDep)
+ .addDependency(ext2);
+ return appJar;
+ }
+}
diff --git a/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/RunnerJarOutcomeTestBase.java b/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/RunnerJarOutcomeTestBase.java
new file mode 100644
index 0000000000000..bf4bcada56484
--- /dev/null
+++ b/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/RunnerJarOutcomeTestBase.java
@@ -0,0 +1,102 @@
+package io.quarkus.creator.phase.runnerjar.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.stream.Stream;
+
+import io.quarkus.bootstrap.resolver.TsArtifact;
+import io.quarkus.creator.AppCreator;
+import io.quarkus.creator.phase.runnerjar.RunnerJarOutcome;
+
+public abstract class RunnerJarOutcomeTestBase extends CreatorOutcomeTestBase {
+
+ private static final String LIB_PREFIX = "lib/";
+ private static final String MAIN_CLS = "io.quarkus.runner.GeneratedMain";
+
+ protected List expectedLib = new ArrayList<>();
+
+ protected void addToExpectedLib(TsArtifact entry) {
+ expectedLib.add(entry.getGroupId() + '.' + entry.getArtifactId() + '-' + entry.getVersion() + '.' + entry.getType());
+ }
+
+ @Override
+ protected void testCreator(AppCreator creator) throws Exception {
+ final RunnerJarOutcome outcome = creator.resolveOutcome(RunnerJarOutcome.class);
+
+ final Path libDir = outcome.getLibDir();
+ assertTrue(Files.isDirectory(libDir));
+ final Set actualLib = new HashSet<>();
+ try (Stream stream = Files.list(libDir)) {
+ final Iterator i = stream.iterator();
+ while (i.hasNext()) {
+ actualLib.add(i.next().getFileName().toString());
+ }
+ }
+
+ final Path runnerJar = outcome.getRunnerJar();
+ assertTrue(Files.exists(runnerJar));
+ try (JarFile jar = new JarFile(runnerJar.toFile())) {
+ final Attributes mainAttrs = jar.getManifest().getMainAttributes();
+
+ // assert the main class
+ assertEquals(MAIN_CLS, mainAttrs.getValue("Main-Class"));
+
+ // assert the Class-Path contains all the entries in the lib dir
+ final String cp = mainAttrs.getValue("Class-Path");
+ assertNotNull(cp);
+ String[] cpEntries = cp.trim().split("\\s+");
+ assertEquals(actualLib.size(), cpEntries.length);
+ for (String entry : cpEntries) {
+ assertTrue(entry.startsWith(LIB_PREFIX));
+ assertTrue(actualLib.contains(entry.substring(LIB_PREFIX.length())));
+ }
+ }
+
+ List missingEntries = Collections.emptyList();
+ for (String entry : expectedLib) {
+ if (!actualLib.remove(entry)) {
+ if (missingEntries.isEmpty()) {
+ missingEntries = new ArrayList<>();
+ }
+ missingEntries.add(entry);
+ }
+ }
+
+ StringBuilder buf = null;
+ if (!missingEntries.isEmpty()) {
+ buf = new StringBuilder();
+ buf.append("Missing entries: ").append(missingEntries.get(0));
+ for (int i = 1; i < missingEntries.size(); ++i) {
+ buf.append(", ").append(missingEntries.get(i));
+ }
+ }
+ if (!actualLib.isEmpty()) {
+ if (buf == null) {
+ buf = new StringBuilder();
+ } else {
+ buf.append("; ");
+ }
+ final Iterator i = actualLib.iterator();
+ buf.append("Extra entries: ").append(i.next());
+ while (i.hasNext()) {
+ buf.append(", ").append(i.next());
+ }
+ }
+ if (buf != null) {
+ fail(buf.toString());
+ }
+ }
+}
\ No newline at end of file
diff --git a/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/SimpleExtAndAppCompileDepsTest.java b/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/SimpleExtAndAppCompileDepsTest.java
new file mode 100644
index 0000000000000..1a23ced961708
--- /dev/null
+++ b/core/creator/src/test/java/io/quarkus/creator/phase/runnerjar/test/SimpleExtAndAppCompileDepsTest.java
@@ -0,0 +1,57 @@
+package io.quarkus.creator.phase.runnerjar.test;
+
+import io.quarkus.bootstrap.resolver.TsArtifact;
+import io.quarkus.bootstrap.resolver.TsQuarkusExt;
+
+public class SimpleExtAndAppCompileDepsTest extends RunnerJarOutcomeTestBase {
+
+ @Override
+ protected TsArtifact modelApp() {
+
+ final TsArtifact coreExtRtTransitiveDep = TsArtifact.jar("core-ext-rt-transitive-dep");
+ addToExpectedLib(coreExtRtTransitiveDep);
+
+ final TsArtifact coreExtRtDirectDep = TsArtifact.jar("core-ext-rt-direct-dep").addDependency(coreExtRtTransitiveDep);
+ addToExpectedLib(coreExtRtDirectDep);
+
+ final TsArtifact coreExtDepTransitiveDep = TsArtifact.jar("core-ext-dep-transitive-dep");
+
+ final TsArtifact coreExtDepDirectDep = TsArtifact.jar("core-ext-dep-direct-dep").addDependency(coreExtDepTransitiveDep);
+
+ final TsQuarkusExt coreExt = new TsQuarkusExt("core-ext");
+ coreExt.getRuntime().addDependency(coreExtRtDirectDep);
+ coreExt.getDeployment().addDependency(coreExtDepDirectDep);
+ addToExpectedLib(coreExt.getRuntime());
+
+ final TsArtifact ext1RtTransitiveDep = TsArtifact.jar("ext1-rt-transitive-dep");
+ addToExpectedLib(ext1RtTransitiveDep);
+
+ final TsArtifact ext1RtDirectDep = TsArtifact.jar("ext1-rt-direct-dep").addDependency(ext1RtTransitiveDep);
+ addToExpectedLib(ext1RtDirectDep);
+
+ final TsArtifact ext1DepTransitiveDep = TsArtifact.jar("ext1-dep-transitive-dep");
+
+ final TsArtifact ext1DepDirectDep = TsArtifact.jar("ext1-dep-direct-dep").addDependency(ext1DepTransitiveDep);
+
+ final TsQuarkusExt ext1 = new TsQuarkusExt("ext1");
+ ext1.addDependency(coreExt);
+ ext1.getRuntime().addDependency(ext1RtDirectDep);
+ ext1.getDeployment().addDependency(ext1DepDirectDep);
+ addToExpectedLib(ext1.getRuntime());
+
+ final TsQuarkusExt ext2 = new TsQuarkusExt("ext2");
+ addToExpectedLib(ext2.getRuntime());
+
+ final TsArtifact appTransitiveDep = TsArtifact.jar("app-transitive-dep");
+ addToExpectedLib(appTransitiveDep);
+
+ final TsArtifact appDirectDep = TsArtifact.jar("app-direct-dep").addDependency(appTransitiveDep);
+ addToExpectedLib(appDirectDep);
+
+ final TsArtifact appJar = TsArtifact.jar("app")
+ .addDependency(ext1)
+ .addDependency(ext2)
+ .addDependency(appDirectDep);
+ return appJar;
+ }
+}
diff --git a/core/creator/src/test/java/io/quarkus/creator/resolver/test/TsArtifact.java b/core/creator/src/test/java/io/quarkus/creator/resolver/test/TsArtifact.java
deleted file mode 100644
index a5afc0dfa04fb..0000000000000
--- a/core/creator/src/test/java/io/quarkus/creator/resolver/test/TsArtifact.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2019 Red Hat, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.quarkus.creator.resolver.test;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.maven.model.Model;
-
-import io.quarkus.creator.AppArtifact;
-
-/**
- *
- * @author Alexey Loubyansky
- */
-public class TsArtifact {
-
- static final String DEFAULT_GROUP_ID = "org.quarkus.creator.test";
-
- public static TsArtifact getGa(String groupId, String artifactId) {
- return new TsArtifact(groupId, artifactId, null);
- }
-
- public static TsArtifact getGa(String artifactId) {
- return getGa(DEFAULT_GROUP_ID, artifactId);
- }
-
- protected final String groupId;
- protected final String artifactId;
- protected final String classifier;
- protected final String type;
- protected final String version;
-
- private List deps = Collections.emptyList();
-
- public TsArtifact(String artifactId) {
- this(artifactId, "1");
- }
-
- public TsArtifact(String artifactId, String version) {
- this(DEFAULT_GROUP_ID, artifactId, "", "txt", version);
- }
-
- public TsArtifact(String groupId, String artifactId, String version) {
- this(groupId, artifactId, "", "txt", version);
- }
-
- public TsArtifact(String groupId, String artifactId, String classifier, String type, String version) {
- this.groupId = groupId;
- this.artifactId = artifactId;
- this.classifier = classifier;
- this.type = type;
- this.version = version;
- }
-
- public TsArtifact addDependency(TsArtifact dep) {
- return addDependency(new TsDependency(dep));
- }
-
- public TsArtifact addDependency(TsDependency dep) {
- if (deps.isEmpty()) {
- deps = new ArrayList<>();
- }
- deps.add(dep);
- return this;
- }
-
- public String getArtifactFileName() {
- if (artifactId == null) {
- throw new IllegalArgumentException("artifactId is missing");
- }
- if (version == null) {
- throw new IllegalArgumentException("version is missing");
- }
- if (type == null) {
- throw new IllegalArgumentException("type is missing");
- }
- final StringBuilder fileName = new StringBuilder();
- fileName.append(artifactId).append('-').append(version);
- if (classifier != null && !classifier.isEmpty()) {
- fileName.append('-').append(classifier);
- }
- fileName.append('.').append(type);
- return fileName.toString();
- }
-
- public TsArtifact toPomArtifact() {
- return new TsArtifact(groupId, artifactId, "", "pom", version);
- }
-
- public Model getPomModel() {
- final Model model = new Model();
- model.setModelVersion("4.0.0");
-
- model.setGroupId(groupId);
- model.setArtifactId(artifactId);
- model.setPackaging(type);
- model.setVersion(version);
-
- if (!deps.isEmpty()) {
- for (TsDependency dep : deps) {
- model.addDependency(dep.toPomDependency());
- }
- }
-
- return model;
- }
-
- public AppArtifact toAppArtifact() {
- return new AppArtifact(groupId, artifactId, classifier, type, version);
- }
-}
diff --git a/core/creator/src/test/java/io/quarkus/creator/resolver/test/TsRepoBuilder.java b/core/creator/src/test/java/io/quarkus/creator/resolver/test/TsRepoBuilder.java
deleted file mode 100644
index 9dd5850ac8d5e..0000000000000
--- a/core/creator/src/test/java/io/quarkus/creator/resolver/test/TsRepoBuilder.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2019 Red Hat, Inc. and/or its affiliates
- * and other contributors as indicated by the @author tags.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.quarkus.creator.resolver.test;
-
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-
-import io.quarkus.creator.AppArtifact;
-import io.quarkus.creator.AppCreatorException;
-import io.quarkus.creator.phase.curate.Utils;
-import io.quarkus.creator.resolver.aether.AetherArtifactResolver;
-
-/**
- *
- * @author Alexey Loubyansky
- */
-public class TsRepoBuilder {
-
- private static void error(String message, Throwable t) {
- throw new IllegalStateException(message, t);
- }
-
- public static TsRepoBuilder getInstance(AetherArtifactResolver resolver, Path workDir) {
- return new TsRepoBuilder(resolver, workDir);
- }
-
- private final Path workDir;
- private final AetherArtifactResolver resolver;
-
- private TsRepoBuilder(AetherArtifactResolver resolver, Path workDir) {
- this.resolver = resolver;
- this.workDir = workDir;
- }
-
- public void install(TsArtifact artifact) {
- final Path pomXml = workDir.resolve(artifact.getArtifactFileName() + ".pom");
- try {
- Utils.persistModel(pomXml, artifact.getPomModel());
- } catch (AppCreatorException e) {
- error("Failed to persist pom.xml for " + artifact, e);
- }
- install(artifact.toPomArtifact().toAppArtifact(), pomXml);
- install(artifact.toAppArtifact(), newTxt(artifact));
- }
-
- protected void install(AppArtifact artifact, Path file) {
- try {
- resolver.install(artifact, file);
- } catch (AppCreatorException e) {
- error("Failed to install " + artifact, e);
- }
- }
-
- protected Path newTxt(TsArtifact artifact) {
- final Path tmpFile = workDir.resolve(artifact.getArtifactFileName());
- if (Files.exists(tmpFile)) {
- throw new IllegalStateException("File already exists " + tmpFile);
- }
- try (BufferedWriter writer = Files.newBufferedWriter(tmpFile)) {
- writer.write(tmpFile.getFileName().toString());
- } catch (IOException e) {
- throw new IllegalStateException("Failed to create file " + tmpFile, e);
- }
- return tmpFile;
- }
-
-}
diff --git a/core/deployment/pom.xml b/core/deployment/pom.xml
index e71ce260d8f1b..022d3a3b97453 100644
--- a/core/deployment/pom.xml
+++ b/core/deployment/pom.xml
@@ -27,13 +27,13 @@
../
- quarkus-core
+ quarkus-core-deployment
Quarkus - Core - Deployment
commons-beanutils
- commons-beanutils-core
+ commons-beanutils
org.jboss.invocation
@@ -67,7 +67,12 @@
io.quarkus
- quarkus-core-runtime
+ quarkus-bootstrap-core
+ provided
+
+
+ io.quarkus
+ quarkus-core
io.quarkus.gizmo
@@ -78,6 +83,7 @@
junit
junit
+ test
io.quarkus
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/ApplicationArchiveImpl.java b/core/deployment/src/main/java/io/quarkus/deployment/ApplicationArchiveImpl.java
index 00de7a837e984..12b21b20b21c0 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/ApplicationArchiveImpl.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/ApplicationArchiveImpl.java
@@ -20,9 +20,10 @@
import java.io.IOException;
import java.nio.file.Path;
-import org.jboss.builder.item.MultiBuildItem;
import org.jboss.jandex.IndexView;
+import io.quarkus.builder.item.MultiBuildItem;
+
public final class ApplicationArchiveImpl extends MultiBuildItem implements ApplicationArchive, Closeable {
private final IndexView indexView;
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/ApplicationConfig.java b/core/deployment/src/main/java/io/quarkus/deployment/ApplicationConfig.java
new file mode 100644
index 0000000000000..180ae5ad3a113
--- /dev/null
+++ b/core/deployment/src/main/java/io/quarkus/deployment/ApplicationConfig.java
@@ -0,0 +1,23 @@
+package io.quarkus.deployment;
+
+import io.quarkus.runtime.annotations.ConfigItem;
+import io.quarkus.runtime.annotations.ConfigPhase;
+import io.quarkus.runtime.annotations.ConfigRoot;
+
+@ConfigRoot(phase = ConfigPhase.BUILD_TIME)
+public class ApplicationConfig {
+
+ /**
+ * The name of the application.
+ * If not set, defaults to the name of the project.
+ */
+ @ConfigItem
+ public String name;
+
+ /**
+ * The version of the application.
+ * If not set, defaults to the version of the project
+ */
+ @ConfigItem
+ public String version;
+}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/ApplicationInfoUtil.java b/core/deployment/src/main/java/io/quarkus/deployment/ApplicationInfoUtil.java
new file mode 100644
index 0000000000000..31675942b20aa
--- /dev/null
+++ b/core/deployment/src/main/java/io/quarkus/deployment/ApplicationInfoUtil.java
@@ -0,0 +1,37 @@
+package io.quarkus.deployment;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.Properties;
+
+import io.quarkus.bootstrap.model.AppArtifact;
+
+public final class ApplicationInfoUtil {
+
+ public static final String APPLICATION_INFO_PROPERTIES = "application-info.properties";
+ public static final String META_INF = "META-INF";
+
+ public static final String ARTIFACT_ID_KEY = "artifactId";
+ public static final String VERSION_KEY = "version";
+
+ private ApplicationInfoUtil() {
+ }
+
+ // these properties are used as default values for ApplicationInfoBuildItem
+ public static void writeApplicationInfoProperties(AppArtifact appArtifact, Path appClassesDir) {
+ Properties properties = new Properties();
+ if (appArtifact != null) {
+ properties.setProperty("artifactId", appArtifact.getArtifactId());
+ properties.setProperty("version", appArtifact.getVersion());
+ }
+ try {
+ appClassesDir.resolve(META_INF).toFile().mkdirs();
+ File file = appClassesDir.resolve(META_INF).resolve(APPLICATION_INFO_PROPERTIES).toFile();
+ properties.store(new FileOutputStream(file), "Generated file; do not edit manually");
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/BuildProducerImpl.java b/core/deployment/src/main/java/io/quarkus/deployment/BuildProducerImpl.java
index 237ce2b12fe73..779324933906d 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/BuildProducerImpl.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/BuildProducerImpl.java
@@ -16,9 +16,8 @@
package io.quarkus.deployment;
-import org.jboss.builder.BuildContext;
-import org.jboss.builder.item.BuildItem;
-
+import io.quarkus.builder.BuildContext;
+import io.quarkus.builder.item.BuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
/**
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/Capabilities.java b/core/deployment/src/main/java/io/quarkus/deployment/Capabilities.java
index c242c84c40122..2270b6abf7fe1 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/Capabilities.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/Capabilities.java
@@ -18,7 +18,7 @@
import java.util.Set;
-import org.jboss.builder.item.SimpleBuildItem;
+import io.quarkus.builder.item.SimpleBuildItem;
/**
* The list of capabilities.
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java b/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java
index 41d7f6d2aba9a..4c2f58cd7837e 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java
@@ -23,6 +23,7 @@
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.EnumSet;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.Executor;
@@ -32,31 +33,34 @@
import java.util.function.Function;
import java.util.function.Supplier;
-import org.jboss.builder.BuildChainBuilder;
-import org.jboss.builder.BuildContext;
-import org.jboss.builder.BuildStepBuilder;
-import org.jboss.builder.ConsumeFlag;
-import org.jboss.builder.ConsumeFlags;
-import org.jboss.builder.ProduceFlag;
-import org.jboss.builder.ProduceFlags;
-import org.jboss.builder.item.BuildItem;
-import org.jboss.builder.item.MultiBuildItem;
-import org.jboss.builder.item.SimpleBuildItem;
import org.wildfly.common.function.Functions;
+import io.quarkus.builder.BuildChainBuilder;
+import io.quarkus.builder.BuildContext;
+import io.quarkus.builder.BuildStepBuilder;
+import io.quarkus.builder.ConsumeFlag;
+import io.quarkus.builder.ConsumeFlags;
+import io.quarkus.builder.ProduceFlag;
+import io.quarkus.builder.ProduceFlags;
+import io.quarkus.builder.item.BuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.SimpleBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.AdditionalApplicationArchiveMarkerBuildItem;
+import io.quarkus.deployment.builditem.BuildTimeConfigurationBuildItem;
+import io.quarkus.deployment.builditem.BuildTimeRunTimeFixedConfigurationBuildItem;
import io.quarkus.deployment.builditem.CapabilityBuildItem;
-import io.quarkus.deployment.builditem.ConfigurationBuildItem;
import io.quarkus.deployment.builditem.MainBytecodeRecorderBuildItem;
+import io.quarkus.deployment.builditem.RunTimeConfigurationBuildItem;
import io.quarkus.deployment.builditem.StaticBytecodeRecorderBuildItem;
import io.quarkus.deployment.recording.BytecodeRecorderImpl;
import io.quarkus.deployment.recording.RecorderContext;
import io.quarkus.deployment.util.ReflectUtil;
import io.quarkus.deployment.util.ServiceUtil;
+import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.quarkus.runtime.annotations.Template;
@@ -107,7 +111,7 @@ public static Consumer loadStepsFrom(Class> clazz) {
throw reportError(clazz, "Build step classes must have exactly one constructor");
}
- boolean consumingConfig = false;
+ EnumSet consumingConfigPhases = EnumSet.noneOf(ConfigPhase.class);
final Constructor> constructor = constructors[0];
if (!(Modifier.isPublic(constructor.getModifiers())))
@@ -160,9 +164,22 @@ public static Consumer loadStepsFrom(Class> clazz) {
} else if (rawTypeOf(parameterType) == Executor.class) {
ctorParamFns.add(BuildContext::getExecutor);
} else if (parameterClass.isAnnotationPresent(ConfigRoot.class)) {
- consumingConfig = true;
- ctorParamFns.add(bc -> bc.consume(ConfigurationBuildItem.class).getConfigDefinition()
- .getRealizedInstance(parameterClass));
+ final ConfigRoot annotation = parameterClass.getAnnotation(ConfigRoot.class);
+ final ConfigPhase phase = annotation.phase();
+ consumingConfigPhases.add(phase);
+
+ if (phase == ConfigPhase.BUILD_TIME) {
+ ctorParamFns.add(bc -> bc.consume(BuildTimeConfigurationBuildItem.class).getConfigDefinition()
+ .getRealizedInstance(parameterClass));
+ } else if (phase == ConfigPhase.BUILD_AND_RUN_TIME_FIXED) {
+ ctorParamFns.add(bc -> bc.consume(BuildTimeRunTimeFixedConfigurationBuildItem.class)
+ .getConfigDefinition().getRealizedInstance(parameterClass));
+ } else if (phase == ConfigPhase.RUN_TIME) {
+ ctorParamFns.add(bc -> bc.consume(RunTimeConfigurationBuildItem.class).getConfigDefinition()
+ .getRealizedInstance(parameterClass));
+ } else {
+ throw reportError(parameterClass, "Unknown value for ConfigPhase");
+ }
} else if (isTemplate(parameterClass)) {
throw reportError(parameter, "Bytecode recording templates disallowed on constructor parameters");
} else {
@@ -231,12 +248,34 @@ public static Consumer loadStepsFrom(Class> clazz) {
} else if (fieldClass == Executor.class) {
stepInstanceSetup = stepInstanceSetup.andThen((bc, o) -> ReflectUtil.setFieldVal(field, o, bc.getExecutor()));
} else if (fieldClass.isAnnotationPresent(ConfigRoot.class)) {
- consumingConfig = true;
- stepInstanceSetup = stepInstanceSetup.andThen((bc, o) -> {
- final ConfigurationBuildItem configurationBuildItem = bc.consume(ConfigurationBuildItem.class);
- ReflectUtil.setFieldVal(field, o,
- configurationBuildItem.getConfigDefinition().getRealizedInstance(fieldClass));
- });
+ final ConfigRoot annotation = fieldClass.getAnnotation(ConfigRoot.class);
+ final ConfigPhase phase = annotation.phase();
+ consumingConfigPhases.add(phase);
+
+ if (phase == ConfigPhase.BUILD_TIME) {
+ stepInstanceSetup = stepInstanceSetup.andThen((bc, o) -> {
+ final BuildTimeConfigurationBuildItem configurationBuildItem = bc
+ .consume(BuildTimeConfigurationBuildItem.class);
+ ReflectUtil.setFieldVal(field, o,
+ configurationBuildItem.getConfigDefinition().getRealizedInstance(fieldClass));
+ });
+ } else if (phase == ConfigPhase.BUILD_AND_RUN_TIME_FIXED) {
+ stepInstanceSetup = stepInstanceSetup.andThen((bc, o) -> {
+ final BuildTimeRunTimeFixedConfigurationBuildItem configurationBuildItem = bc
+ .consume(BuildTimeRunTimeFixedConfigurationBuildItem.class);
+ ReflectUtil.setFieldVal(field, o,
+ configurationBuildItem.getConfigDefinition().getRealizedInstance(fieldClass));
+ });
+ } else if (phase == ConfigPhase.RUN_TIME) {
+ stepInstanceSetup = stepInstanceSetup.andThen((bc, o) -> {
+ final RunTimeConfigurationBuildItem configurationBuildItem = bc
+ .consume(RunTimeConfigurationBuildItem.class);
+ ReflectUtil.setFieldVal(field, o,
+ configurationBuildItem.getConfigDefinition().getRealizedInstance(fieldClass));
+ });
+ } else {
+ throw reportError(fieldClass, "Unknown value for ConfigPhase");
+ }
} else if (isTemplate(fieldClass)) {
throw reportError(field, "Bytecode recording templates disallowed on fields");
} else {
@@ -288,7 +327,7 @@ public static Consumer loadStepsFrom(Class> clazz) {
: MainBytecodeRecorderBuildItem.class,
optional ? ProduceFlags.of(ProduceFlag.WEAK) : ProduceFlags.NONE));
}
- boolean methodConsumingConfig = consumingConfig;
+ EnumSet methodConsumingConfigPhases = consumingConfigPhases.clone();
if (methodParameters.length == 0) {
methodParamFns = Collections.emptyList();
} else {
@@ -337,11 +376,31 @@ public static Consumer loadStepsFrom(Class> clazz) {
} else if (rawTypeOf(parameterType) == Executor.class) {
methodParamFns.add((bc, bri) -> bc.getExecutor());
} else if (parameterClass.isAnnotationPresent(ConfigRoot.class)) {
- methodConsumingConfig = true;
- methodParamFns.add((bc, bri) -> {
- final ConfigurationBuildItem configurationBuildItem = bc.consume(ConfigurationBuildItem.class);
- return configurationBuildItem.getConfigDefinition().getRealizedInstance(parameterClass);
- });
+ final ConfigRoot annotation = parameterClass.getAnnotation(ConfigRoot.class);
+ final ConfigPhase phase = annotation.phase();
+ methodConsumingConfigPhases.add(phase);
+
+ if (phase == ConfigPhase.BUILD_TIME) {
+ methodParamFns.add((bc, bri) -> {
+ final BuildTimeConfigurationBuildItem configurationBuildItem = bc
+ .consume(BuildTimeConfigurationBuildItem.class);
+ return configurationBuildItem.getConfigDefinition().getRealizedInstance(parameterClass);
+ });
+ } else if (phase == ConfigPhase.BUILD_AND_RUN_TIME_FIXED) {
+ methodParamFns.add((bc, bri) -> {
+ final BuildTimeRunTimeFixedConfigurationBuildItem configurationBuildItem = bc
+ .consume(BuildTimeRunTimeFixedConfigurationBuildItem.class);
+ return configurationBuildItem.getConfigDefinition().getRealizedInstance(parameterClass);
+ });
+ } else if (phase == ConfigPhase.RUN_TIME) {
+ methodParamFns.add((bc, bri) -> {
+ final RunTimeConfigurationBuildItem configurationBuildItem = bc
+ .consume(RunTimeConfigurationBuildItem.class);
+ return configurationBuildItem.getConfigDefinition().getRealizedInstance(parameterClass);
+ });
+ } else {
+ throw reportError(parameterClass, "Unknown value for ConfigPhase");
+ }
} else if (isTemplate(parameter.getType())) {
if (!isRecorder) {
throw reportError(parameter,
@@ -390,76 +449,89 @@ public static Consumer loadStepsFrom(Class> clazz) {
throw reportError(method, "Unsupported method return type " + returnType);
}
- if (methodConsumingConfig) {
+ if (methodConsumingConfigPhases.contains(ConfigPhase.RUN_TIME)) {
+ if (isRecorder && recordAnnotation.value() == ExecutionTime.STATIC_INIT) {
+ throw reportError(method,
+ "Bytecode recorder is static but an injected config object is declared as run time");
+ }
methodStepConfig = methodStepConfig
- .andThen(bsb -> bsb.consumes(ConfigurationBuildItem.class));
+ .andThen(bsb -> bsb.consumes(RunTimeConfigurationBuildItem.class));
+ }
+ if (methodConsumingConfigPhases.contains(ConfigPhase.BUILD_AND_RUN_TIME_FIXED)) {
+ methodStepConfig = methodStepConfig
+ .andThen(bsb -> bsb.consumes(BuildTimeRunTimeFixedConfigurationBuildItem.class));
+ }
+ if (methodConsumingConfigPhases.contains(ConfigPhase.BUILD_TIME)) {
+ methodStepConfig = methodStepConfig
+ .andThen(bsb -> bsb.consumes(BuildTimeConfigurationBuildItem.class));
}
final Consumer finalStepConfig = stepConfig.andThen(methodStepConfig)
.andThen(BuildStepBuilder::build);
final BiConsumer finalStepInstanceSetup = stepInstanceSetup;
final String name = clazz.getName() + "#" + method.getName();
- chainConfig = chainConfig.andThen(bcb -> finalStepConfig.accept(bcb.addBuildStep(new org.jboss.builder.BuildStep() {
- public void execute(final BuildContext bc) {
- Object[] ctorArgs = new Object[ctorParamFns.size()];
- for (int i = 0; i < ctorArgs.length; i++) {
- ctorArgs[i] = ctorParamFns.get(i).apply(bc);
- }
- Object instance;
- try {
- instance = constructor.newInstance(ctorArgs);
- } catch (InstantiationException e) {
- throw ReflectUtil.toError(e);
- } catch (IllegalAccessException e) {
- throw ReflectUtil.toError(e);
- } catch (InvocationTargetException e) {
- try {
- throw e.getCause();
- } catch (RuntimeException | Error e2) {
- throw e2;
- } catch (Throwable t) {
- throw new IllegalStateException(t);
- }
- }
- finalStepInstanceSetup.accept(bc, instance);
- Object[] methodArgs = new Object[methodParamFns.size()];
- BytecodeRecorderImpl bri = isRecorder
- ? new BytecodeRecorderImpl(recordAnnotation.value() == ExecutionTime.STATIC_INIT,
- clazz.getSimpleName(), method.getName())
- : null;
- for (int i = 0; i < methodArgs.length; i++) {
- methodArgs[i] = methodParamFns.get(i).apply(bc, bri);
- }
- Object result;
- try {
- result = method.invoke(instance, methodArgs);
- } catch (IllegalAccessException e) {
- throw ReflectUtil.toError(e);
- } catch (InvocationTargetException e) {
- try {
- throw e.getCause();
- } catch (RuntimeException | Error e2) {
- throw e2;
- } catch (Throwable t) {
- throw new IllegalStateException(t);
- }
- }
- resultConsumer.accept(bc, result);
- if (isRecorder) {
- // commit recorded data
- if (recordAnnotation.value() == ExecutionTime.STATIC_INIT) {
- bc.produce(new StaticBytecodeRecorderBuildItem(bri));
- } else {
- bc.produce(new MainBytecodeRecorderBuildItem(bri));
- }
+ chainConfig = chainConfig
+ .andThen(bcb -> finalStepConfig.accept(bcb.addBuildStep(new io.quarkus.builder.BuildStep() {
+ public void execute(final BuildContext bc) {
+ Object[] ctorArgs = new Object[ctorParamFns.size()];
+ for (int i = 0; i < ctorArgs.length; i++) {
+ ctorArgs[i] = ctorParamFns.get(i).apply(bc);
+ }
+ Object instance;
+ try {
+ instance = constructor.newInstance(ctorArgs);
+ } catch (InstantiationException e) {
+ throw ReflectUtil.toError(e);
+ } catch (IllegalAccessException e) {
+ throw ReflectUtil.toError(e);
+ } catch (InvocationTargetException e) {
+ try {
+ throw e.getCause();
+ } catch (RuntimeException | Error e2) {
+ throw e2;
+ } catch (Throwable t) {
+ throw new IllegalStateException(t);
+ }
+ }
+ finalStepInstanceSetup.accept(bc, instance);
+ Object[] methodArgs = new Object[methodParamFns.size()];
+ BytecodeRecorderImpl bri = isRecorder
+ ? new BytecodeRecorderImpl(recordAnnotation.value() == ExecutionTime.STATIC_INIT,
+ clazz.getSimpleName(), method.getName())
+ : null;
+ for (int i = 0; i < methodArgs.length; i++) {
+ methodArgs[i] = methodParamFns.get(i).apply(bc, bri);
+ }
+ Object result;
+ try {
+ result = method.invoke(instance, methodArgs);
+ } catch (IllegalAccessException e) {
+ throw ReflectUtil.toError(e);
+ } catch (InvocationTargetException e) {
+ try {
+ throw e.getCause();
+ } catch (RuntimeException | Error e2) {
+ throw e2;
+ } catch (Throwable t) {
+ throw new IllegalStateException(t);
+ }
+ }
+ resultConsumer.accept(bc, result);
+ if (isRecorder) {
+ // commit recorded data
+ if (recordAnnotation.value() == ExecutionTime.STATIC_INIT) {
+ bc.produce(new StaticBytecodeRecorderBuildItem(bri));
+ } else {
+ bc.produce(new MainBytecodeRecorderBuildItem(bri));
+ }
- }
- }
+ }
+ }
- public String toString() {
- return name;
- }
- })));
+ public String toString() {
+ return name;
+ }
+ })));
}
return chainConfig;
}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/QuarkusAugmentor.java b/core/deployment/src/main/java/io/quarkus/deployment/QuarkusAugmentor.java
index 7bc6f6efedd03..d0eb7648a7df1 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/QuarkusAugmentor.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/QuarkusAugmentor.java
@@ -23,15 +23,14 @@
import java.util.Set;
import java.util.function.Consumer;
-import org.jboss.builder.BuildChain;
-import org.jboss.builder.BuildChainBuilder;
-import org.jboss.builder.BuildExecutionBuilder;
-import org.jboss.builder.BuildResult;
-import org.jboss.builder.item.BuildItem;
import org.jboss.logging.Logger;
+import io.quarkus.builder.BuildChain;
+import io.quarkus.builder.BuildChainBuilder;
+import io.quarkus.builder.BuildExecutionBuilder;
+import io.quarkus.builder.BuildResult;
+import io.quarkus.builder.item.BuildItem;
import io.quarkus.deployment.builditem.AdditionalApplicationArchiveBuildItem;
-import io.quarkus.deployment.builditem.AdditionalApplicationArchiveMarkerBuildItem;
import io.quarkus.deployment.builditem.ArchiveRootBuildItem;
import io.quarkus.deployment.builditem.ClassOutputBuildItem;
import io.quarkus.deployment.builditem.ExtensionClassLoaderBuildItem;
@@ -39,7 +38,6 @@
import io.quarkus.deployment.builditem.GeneratedResourceBuildItem;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.builditem.ShutdownContextBuildItem;
-import io.quarkus.deployment.builditem.substrate.SubstrateResourceBuildItem;
import io.quarkus.runtime.LaunchMode;
public class QuarkusAugmentor {
@@ -78,7 +76,6 @@ public BuildResult run() throws Exception {
chainBuilder
.addInitial(QuarkusConfig.class)
- .addInitial(SubstrateResourceBuildItem.class)
.addInitial(ArchiveRootBuildItem.class)
.addInitial(ShutdownContextBuildItem.class)
.addInitial(ClassOutputBuildItem.class)
@@ -98,8 +95,6 @@ public BuildResult run() throws Exception {
BuildChain chain = chainBuilder
.build();
BuildExecutionBuilder execBuilder = chain.createExecutionBuilder("main")
- .produce(new SubstrateResourceBuildItem("META-INF/microprofile-config.properties"))
- .produce(new SubstrateResourceBuildItem("application.properties"))
.produce(QuarkusConfig.INSTANCE)
.produce(new ArchiveRootBuildItem(root))
.produce(new ClassOutputBuildItem(output))
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/QuarkusConfig.java b/core/deployment/src/main/java/io/quarkus/deployment/QuarkusConfig.java
index cde046f974ea9..de94604617876 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/QuarkusConfig.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/QuarkusConfig.java
@@ -24,8 +24,8 @@
import java.util.Set;
import org.eclipse.microprofile.config.ConfigProvider;
-import org.jboss.builder.item.SimpleBuildItem;
+import io.quarkus.builder.item.SimpleBuildItem;
import io.quarkus.deployment.configuration.ConfigurationError;
public final class QuarkusConfig extends SimpleBuildItem {
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/annotations/BuildProducer.java b/core/deployment/src/main/java/io/quarkus/deployment/annotations/BuildProducer.java
index 3ce088e09cb42..5f59db467b6a3 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/annotations/BuildProducer.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/annotations/BuildProducer.java
@@ -1,6 +1,6 @@
package io.quarkus.deployment.annotations;
-import org.jboss.builder.item.BuildItem;
+import io.quarkus.builder.item.BuildItem;
/**
* An interface that can be injected to produce {@link BuildItem} instances
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/annotations/BuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/annotations/BuildStep.java
index bd4a07ff90dd8..22b6e2954d4cc 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/annotations/BuildStep.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/annotations/BuildStep.java
@@ -9,10 +9,9 @@
import java.util.function.Consumer;
import java.util.function.Supplier;
-import org.jboss.builder.item.BuildItem;
-import org.jboss.builder.item.MultiBuildItem;
-import org.jboss.builder.item.SimpleBuildItem;
-
+import io.quarkus.builder.item.BuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.SimpleBuildItem;
import io.quarkus.deployment.recording.BytecodeRecorderImpl;
import io.quarkus.runtime.annotations.Template;
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/annotations/Record.java b/core/deployment/src/main/java/io/quarkus/deployment/annotations/Record.java
index 32e1720eaae5b..360bd97534d74 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/annotations/Record.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/annotations/Record.java
@@ -5,6 +5,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import io.quarkus.builder.item.BuildItem;
+
/**
* Indicates that this {@link BuildStep} method will also output recorded bytecode.
*
@@ -30,7 +32,7 @@
/**
* If this is true then the bytecode produced by this method will be considered to be optional,
- * and will only be created if this build step also produces another {@link org.jboss.builder.item.BuildItem}
+ * and will only be created if this build step also produces another {@link BuildItem}
* that is consumed by the build.
*
* If a method is optional it must be capable of producing at least one other item
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/AdditionalApplicationArchiveBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/AdditionalApplicationArchiveBuildItem.java
index 2ca764c94c407..2a7b6fd212a03 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/AdditionalApplicationArchiveBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/AdditionalApplicationArchiveBuildItem.java
@@ -18,7 +18,7 @@
import java.nio.file.Path;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
/**
* An additional application archive
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/AdditionalApplicationArchiveMarkerBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/AdditionalApplicationArchiveMarkerBuildItem.java
index e19835a2d495f..3ae03c495fb4a 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/AdditionalApplicationArchiveMarkerBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/AdditionalApplicationArchiveMarkerBuildItem.java
@@ -16,7 +16,7 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
/**
* A marker file that if present indicates that a given archive should be treated as an
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/AnnotationProxyBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/AnnotationProxyBuildItem.java
index 0312c22af61aa..c5ff23abe5afa 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/AnnotationProxyBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/AnnotationProxyBuildItem.java
@@ -2,9 +2,9 @@
import java.lang.annotation.Annotation;
-import org.jboss.builder.item.SimpleBuildItem;
import org.jboss.jandex.AnnotationInstance;
+import io.quarkus.builder.item.SimpleBuildItem;
import io.quarkus.deployment.recording.AnnotationProxyProvider;
import io.quarkus.deployment.recording.AnnotationProxyProvider.AnnotationProxyBuilder;
import io.quarkus.runtime.annotations.Template;
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationArchivesBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationArchivesBuildItem.java
index d47101c49c993..71559d71d658b 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationArchivesBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationArchivesBuildItem.java
@@ -21,8 +21,7 @@
import java.util.HashSet;
import java.util.Set;
-import org.jboss.builder.item.SimpleBuildItem;
-
+import io.quarkus.builder.item.SimpleBuildItem;
import io.quarkus.deployment.ApplicationArchive;
//temp class
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationClassNameBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationClassNameBuildItem.java
index 4ebe970008caa..434946c8a1ea3 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationClassNameBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationClassNameBuildItem.java
@@ -16,7 +16,7 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.SimpleBuildItem;
+import io.quarkus.builder.item.SimpleBuildItem;
public final class ApplicationClassNameBuildItem extends SimpleBuildItem {
private final String className;
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationClassPredicateBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationClassPredicateBuildItem.java
new file mode 100644
index 0000000000000..be756de364559
--- /dev/null
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationClassPredicateBuildItem.java
@@ -0,0 +1,22 @@
+package io.quarkus.deployment.builditem;
+
+import java.util.function.Predicate;
+
+import io.quarkus.builder.item.MultiBuildItem;
+
+/**
+ * Makes it possible to identify wiring classes generated for classes from additional hot deployment paths.
+ */
+public final class ApplicationClassPredicateBuildItem extends MultiBuildItem {
+
+ private final Predicate predicate;
+
+ public ApplicationClassPredicateBuildItem(Predicate predicate) {
+ this.predicate = predicate;
+ }
+
+ public boolean test(String name) {
+ return predicate.test(name);
+ }
+
+}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationIndexBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationIndexBuildItem.java
index 35cfa6e1e6a1e..3d2b42c75af08 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationIndexBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationIndexBuildItem.java
@@ -16,9 +16,10 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.SimpleBuildItem;
import org.jboss.jandex.Index;
+import io.quarkus.builder.item.SimpleBuildItem;
+
/**
* The Jandex index of the application root
*/
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationInfoBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationInfoBuildItem.java
new file mode 100644
index 0000000000000..c9a0549e7f00a
--- /dev/null
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ApplicationInfoBuildItem.java
@@ -0,0 +1,24 @@
+package io.quarkus.deployment.builditem;
+
+import io.quarkus.builder.item.SimpleBuildItem;
+
+public final class ApplicationInfoBuildItem extends SimpleBuildItem {
+
+ public static final String UNSET_VALUE = "<>";
+
+ private final String name;
+ private final String version;
+
+ public ApplicationInfoBuildItem(String name, String version) {
+ this.name = name;
+ this.version = version;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ArchiveRootBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ArchiveRootBuildItem.java
index dc82c19d68c5b..a4f18cab668b8 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ArchiveRootBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ArchiveRootBuildItem.java
@@ -18,7 +18,7 @@
import java.nio.file.Path;
-import org.jboss.builder.item.SimpleBuildItem;
+import io.quarkus.builder.item.SimpleBuildItem;
public final class ArchiveRootBuildItem extends SimpleBuildItem {
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ConfigurationBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/BuildTimeConfigurationBuildItem.java
similarity index 64%
rename from core/deployment/src/main/java/io/quarkus/deployment/builditem/ConfigurationBuildItem.java
rename to core/deployment/src/main/java/io/quarkus/deployment/builditem/BuildTimeConfigurationBuildItem.java
index b572d0fcc39e8..70d4c58fb3a1d 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ConfigurationBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/BuildTimeConfigurationBuildItem.java
@@ -1,16 +1,15 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.SimpleBuildItem;
-
+import io.quarkus.builder.item.SimpleBuildItem;
import io.quarkus.deployment.configuration.ConfigDefinition;
/**
* The build item which carries the build time configuration.
*/
-public final class ConfigurationBuildItem extends SimpleBuildItem {
+public final class BuildTimeConfigurationBuildItem extends SimpleBuildItem {
private final ConfigDefinition configDefinition;
- public ConfigurationBuildItem(final ConfigDefinition configDefinition) {
+ public BuildTimeConfigurationBuildItem(final ConfigDefinition configDefinition) {
this.configDefinition = configDefinition;
}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/BuildTimeRunTimeFixedConfigurationBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/BuildTimeRunTimeFixedConfigurationBuildItem.java
new file mode 100644
index 0000000000000..1c129c15a8a7e
--- /dev/null
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/BuildTimeRunTimeFixedConfigurationBuildItem.java
@@ -0,0 +1,19 @@
+package io.quarkus.deployment.builditem;
+
+import io.quarkus.builder.item.SimpleBuildItem;
+import io.quarkus.deployment.configuration.ConfigDefinition;
+
+/**
+ * The build item which carries the build time configuration that is visible from run time.
+ */
+public final class BuildTimeRunTimeFixedConfigurationBuildItem extends SimpleBuildItem {
+ private final ConfigDefinition configDefinition;
+
+ public BuildTimeRunTimeFixedConfigurationBuildItem(final ConfigDefinition configDefinition) {
+ this.configDefinition = configDefinition;
+ }
+
+ public ConfigDefinition getConfigDefinition() {
+ return configDefinition;
+ }
+}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/BytecodeRecorderObjectLoaderBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/BytecodeRecorderObjectLoaderBuildItem.java
index 9cd7848009fb2..937eb65d6052e 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/BytecodeRecorderObjectLoaderBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/BytecodeRecorderObjectLoaderBuildItem.java
@@ -1,7 +1,6 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
-
+import io.quarkus.builder.item.MultiBuildItem;
import io.quarkus.deployment.recording.ObjectLoader;
/**
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/BytecodeTransformerBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/BytecodeTransformerBuildItem.java
index e83039277db56..a55c4cf9f8322 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/BytecodeTransformerBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/BytecodeTransformerBuildItem.java
@@ -18,9 +18,10 @@
import java.util.function.BiFunction;
-import org.jboss.builder.item.MultiBuildItem;
import org.objectweb.asm.ClassVisitor;
+import io.quarkus.builder.item.MultiBuildItem;
+
public final class BytecodeTransformerBuildItem extends MultiBuildItem {
final String classToTransform;
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/CapabilityBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/CapabilityBuildItem.java
index b6f6f8d6aa9b2..bdf21d2acd7b0 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/CapabilityBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/CapabilityBuildItem.java
@@ -16,8 +16,7 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
-
+import io.quarkus.builder.item.MultiBuildItem;
import io.quarkus.deployment.Capabilities;
/**
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ClassOutputBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ClassOutputBuildItem.java
index ffec6b2090894..d81dde0d1be6d 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ClassOutputBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ClassOutputBuildItem.java
@@ -16,8 +16,7 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.SimpleBuildItem;
-
+import io.quarkus.builder.item.SimpleBuildItem;
import io.quarkus.deployment.ClassOutput;
public final class ClassOutputBuildItem extends SimpleBuildItem {
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/CombinedIndexBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/CombinedIndexBuildItem.java
index b401596d417eb..37b2da0c5fbca 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/CombinedIndexBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/CombinedIndexBuildItem.java
@@ -16,9 +16,10 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.SimpleBuildItem;
import org.jboss.jandex.IndexView;
+import io.quarkus.builder.item.SimpleBuildItem;
+
public final class CombinedIndexBuildItem extends SimpleBuildItem {
private final IndexView index;
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ConfigurationCustomConverterBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ConfigurationCustomConverterBuildItem.java
index 2dc178a26509f..7f04d189f5101 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ConfigurationCustomConverterBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ConfigurationCustomConverterBuildItem.java
@@ -1,7 +1,8 @@
package io.quarkus.deployment.builditem;
import org.eclipse.microprofile.config.spi.Converter;
-import org.jboss.builder.item.MultiBuildItem;
+
+import io.quarkus.builder.item.MultiBuildItem;
/**
* A configuration converter to register.
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ConfigurationTypeBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ConfigurationTypeBuildItem.java
index 5bae0a012760d..0820564b4af8d 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ConfigurationTypeBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ConfigurationTypeBuildItem.java
@@ -1,8 +1,9 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
import org.wildfly.common.Assert;
+import io.quarkus.builder.item.MultiBuildItem;
+
/**
* The configuration type build item. Every configuration type should be registered using this build item
* to ensure that the converter is properly loaded in the native image case.
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ExecutorBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ExecutorBuildItem.java
index ad5d348b1ff45..9b860237f5743 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ExecutorBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ExecutorBuildItem.java
@@ -16,20 +16,21 @@
package io.quarkus.deployment.builditem;
-import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
-import org.jboss.builder.item.SimpleBuildItem;
+import io.quarkus.builder.item.SimpleBuildItem;
/**
+ * The main executor for blocking tasks
*/
public final class ExecutorBuildItem extends SimpleBuildItem {
- private final Executor executor;
+ private final ExecutorService executor;
- public ExecutorBuildItem(final Executor executor) {
+ public ExecutorBuildItem(final ExecutorService executor) {
this.executor = executor;
}
- public Executor getExecutorProxy() {
+ public ExecutorService getExecutorProxy() {
return executor;
}
}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ExtensionClassLoaderBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ExtensionClassLoaderBuildItem.java
index f566155ffb111..24bfcad797b25 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ExtensionClassLoaderBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ExtensionClassLoaderBuildItem.java
@@ -1,6 +1,6 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.SimpleBuildItem;
+import io.quarkus.builder.item.SimpleBuildItem;
/**
* The extension class loader.
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ExtensionSslNativeSupportBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ExtensionSslNativeSupportBuildItem.java
index 5686b56b70db4..0e2469dcfd094 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ExtensionSslNativeSupportBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ExtensionSslNativeSupportBuildItem.java
@@ -16,7 +16,7 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
public final class ExtensionSslNativeSupportBuildItem extends MultiBuildItem {
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/FeatureBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/FeatureBuildItem.java
index 6a0927f37fe26..d1ee4f0198514 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/FeatureBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/FeatureBuildItem.java
@@ -2,7 +2,7 @@
import java.util.Objects;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
/**
* Describes a functionality provided by an extension. The info is displayed to users.
@@ -10,21 +10,28 @@
public final class FeatureBuildItem extends MultiBuildItem {
public static final String AGROAL = "agroal";
+ public static final String KUBERNETES = "kubernetes";
public static final String CAMEL_CORE = "camel-core";
public static final String CAMEL_INFINISPAN = "camel-infinispan";
+ public static final String CAMEL_AWS_S3 = "camel-aws-s3";
public static final String CAMEL_NETTY4_HTTP = "camel-netty4-http";
public static final String CAMEL_SALESFORCE = "camel-salesforce";
public static final String CDI = "cdi";
+ public static final String ELASTICSEARCH_REST_CLIENT = "elasticsearch-rest-client";
+ public static final String FLYWAY = "flyway";
public static final String HIBERNATE_ORM = "hibernate-orm";
public static final String HIBERNATE_VALIDATOR = "hibernate-validator";
+ public static final String HIBERNATE_SEARCH_ELASTICSEARCH = "hibernate-search-elasticsearch";
public static final String INFINISPAN_CLIENT = "infinispan-client";
public static final String JAEGER = "jaeger";
public static final String JDBC_H2 = "jdbc-h2";
public static final String JDBC_MARIADB = "jdbc-mariadb";
public static final String JDBC_POSTGRESQL = "jdbc-postgresql";
public static final String JDBC_MSSQL = "jdbc-mssql";
+ public static final String KEYCLOAK = "keycloak";
public static final String KOTLIN = "kotlin";
public static final String NARAYANA_JTA = "narayana-jta";
+ public static final String REACTIVE_PG_CLIENT = "reactive-pg-client";
public static final String RESTEASY = "resteasy";
public static final String RESTEASY_JSONB = "resteasy-jsonb";
public static final String SCHEDULER = "scheduler";
@@ -36,13 +43,15 @@ public final class FeatureBuildItem extends MultiBuildItem {
public static final String SMALLRYE_OPENAPI = "smallrye-openapi";
public static final String SMALLRYE_OPENTRACING = "smallrye-opentracing";
public static final String SMALLRYE_REACTIVE_MESSAGING = "smallrye-reactive-messaging";
- public static final String SMALLRYE_REACTIVE_MESSAGING_KAFKA = "smallrye-reactive-messaging";
+ public static final String SMALLRYE_REACTIVE_MESSAGING_KAFKA = "smallrye-reactive-messaging-kafka";
public static final String SMALLRYE_REACTIVE_STREAMS_OPERATORS = "smallrye-reactive-streams-operators";
public static final String SMALLRYE_REACTIVE_TYPE_CONVERTERS = "smallrye-reactive-type-converters";
public static final String SMALLRYE_REST_CLIENT = "smallrye-rest-client";
public static final String SPRING_DI = "spring-di";
+ public static final String SWAGGER_UI = "swagger-ui";
public static final String UNDERTOW_WEBSOCKETS = "undertow-websockets";
public static final String VERTX = "vertx";
+ public static final String VERTX_WEB = "vertx-web";
private final String info;
@@ -54,4 +63,4 @@ public String getInfo() {
return info;
}
-}
\ No newline at end of file
+}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/GeneratedClassBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/GeneratedClassBuildItem.java
index c2a6d84d96f32..09c5df651a24f 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/GeneratedClassBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/GeneratedClassBuildItem.java
@@ -16,7 +16,7 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
public final class GeneratedClassBuildItem extends MultiBuildItem {
final boolean applicationClass;
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/GeneratedResourceBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/GeneratedResourceBuildItem.java
index 24cb02cb9bf70..c4d10261c859d 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/GeneratedResourceBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/GeneratedResourceBuildItem.java
@@ -16,7 +16,7 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
public final class GeneratedResourceBuildItem extends MultiBuildItem {
final String name;
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/HotDeploymentConfigFileBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/HotDeploymentConfigFileBuildItem.java
index 65548ee7679cf..f4775f8ba029e 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/HotDeploymentConfigFileBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/HotDeploymentConfigFileBuildItem.java
@@ -16,7 +16,7 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
/**
* A configuration file that if modified should result in a hot redeployment when in
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/JavaLibraryPathAdditionalPathBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/JavaLibraryPathAdditionalPathBuildItem.java
index 4e796ca142fe1..af2d4bd6fa548 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/JavaLibraryPathAdditionalPathBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/JavaLibraryPathAdditionalPathBuildItem.java
@@ -1,6 +1,6 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
public final class JavaLibraryPathAdditionalPathBuildItem extends MultiBuildItem {
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/LaunchModeBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/LaunchModeBuildItem.java
index ed97c28d64192..309c36d0185ac 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/LaunchModeBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/LaunchModeBuildItem.java
@@ -1,7 +1,6 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.SimpleBuildItem;
-
+import io.quarkus.builder.item.SimpleBuildItem;
import io.quarkus.runtime.LaunchMode;
/**
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/LogCategoryBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/LogCategoryBuildItem.java
index ebfe047a71583..3d429f51a2bd6 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/LogCategoryBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/LogCategoryBuildItem.java
@@ -2,9 +2,10 @@
import java.util.logging.Level;
-import org.jboss.builder.item.MultiBuildItem;
import org.wildfly.common.Assert;
+import io.quarkus.builder.item.MultiBuildItem;
+
/**
* Establish the default log level of a log category.
*/
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/MainBytecodeRecorderBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/MainBytecodeRecorderBuildItem.java
index ce98040efe694..b13ad5ed99a58 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/MainBytecodeRecorderBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/MainBytecodeRecorderBuildItem.java
@@ -16,8 +16,7 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
-
+import io.quarkus.builder.item.MultiBuildItem;
import io.quarkus.deployment.recording.BytecodeRecorderImpl;
public final class MainBytecodeRecorderBuildItem extends MultiBuildItem {
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/MainClassBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/MainClassBuildItem.java
index dc706561b8162..3d160267c98a6 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/MainClassBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/MainClassBuildItem.java
@@ -16,7 +16,7 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.SimpleBuildItem;
+import io.quarkus.builder.item.SimpleBuildItem;
public final class MainClassBuildItem extends SimpleBuildItem {
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ObjectSubstitutionBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ObjectSubstitutionBuildItem.java
index 5d79f71b6139c..ef465c6f3a84a 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ObjectSubstitutionBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ObjectSubstitutionBuildItem.java
@@ -1,7 +1,6 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
-
+import io.quarkus.builder.item.MultiBuildItem;
import io.quarkus.runtime.ObjectSubstitution;
/**
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ProxyUnwrapperBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ProxyUnwrapperBuildItem.java
index ef0a7487450da..b66e6dfc9c593 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ProxyUnwrapperBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ProxyUnwrapperBuildItem.java
@@ -18,7 +18,7 @@
import java.util.function.Function;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
/**
* A build item that can be used to unwrap CDI or other proxies
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/RunTimeConfigurationBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/RunTimeConfigurationBuildItem.java
new file mode 100644
index 0000000000000..83fe0e8ad0fc1
--- /dev/null
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/RunTimeConfigurationBuildItem.java
@@ -0,0 +1,19 @@
+package io.quarkus.deployment.builditem;
+
+import io.quarkus.builder.item.SimpleBuildItem;
+import io.quarkus.deployment.configuration.ConfigDefinition;
+
+/**
+ * The build item which carries the run time configuration.
+ */
+public final class RunTimeConfigurationBuildItem extends SimpleBuildItem {
+ private final ConfigDefinition configDefinition;
+
+ public RunTimeConfigurationBuildItem(final ConfigDefinition configDefinition) {
+ this.configDefinition = configDefinition;
+ }
+
+ public ConfigDefinition getConfigDefinition() {
+ return configDefinition;
+ }
+}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/RunTimeConfigurationDefaultBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/RunTimeConfigurationDefaultBuildItem.java
index a0d58fbe20435..55aa3d761ed39 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/RunTimeConfigurationDefaultBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/RunTimeConfigurationDefaultBuildItem.java
@@ -1,8 +1,8 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
import org.wildfly.common.Assert;
+import io.quarkus.builder.item.MultiBuildItem;
import io.quarkus.runtime.annotations.ConfigItem;
/**
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/RunTimeConfigurationSourceBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/RunTimeConfigurationSourceBuildItem.java
index ef85d698e3228..afa6885c1b6c4 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/RunTimeConfigurationSourceBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/RunTimeConfigurationSourceBuildItem.java
@@ -2,9 +2,10 @@
import java.util.OptionalInt;
-import org.jboss.builder.item.MultiBuildItem;
import org.wildfly.common.Assert;
+import io.quarkus.builder.item.MultiBuildItem;
+
/**
* Define an additional configuration source which is used at run time.
*/
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ServiceStartBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ServiceStartBuildItem.java
index b7e0ceed9d9c9..d48716a627432 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ServiceStartBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ServiceStartBuildItem.java
@@ -16,8 +16,7 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
-
+import io.quarkus.builder.item.MultiBuildItem;
import io.quarkus.runtime.StartupEvent;
/**
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ShutdownContextBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ShutdownContextBuildItem.java
index 12718bcfb1d57..4481c86ab2327 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/ShutdownContextBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/ShutdownContextBuildItem.java
@@ -16,8 +16,7 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.SimpleBuildItem;
-
+import io.quarkus.builder.item.SimpleBuildItem;
import io.quarkus.deployment.recording.BytecodeRecorderImpl;
import io.quarkus.runtime.ShutdownContext;
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/SslNativeConfigBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/SslNativeConfigBuildItem.java
index f10d438ad4a94..7373929fa7f00 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/SslNativeConfigBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/SslNativeConfigBuildItem.java
@@ -18,7 +18,7 @@
import java.util.Optional;
-import org.jboss.builder.item.SimpleBuildItem;
+import io.quarkus.builder.item.SimpleBuildItem;
public final class SslNativeConfigBuildItem extends SimpleBuildItem {
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/SslTrustStoreSystemPropertyBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/SslTrustStoreSystemPropertyBuildItem.java
index 11c6b95eaf4ae..532e570a8c849 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/SslTrustStoreSystemPropertyBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/SslTrustStoreSystemPropertyBuildItem.java
@@ -1,6 +1,6 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.SimpleBuildItem;
+import io.quarkus.builder.item.SimpleBuildItem;
public final class SslTrustStoreSystemPropertyBuildItem extends SimpleBuildItem {
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/StaticBytecodeRecorderBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/StaticBytecodeRecorderBuildItem.java
index e9494b7b45a17..76dc7b8ef2e46 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/StaticBytecodeRecorderBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/StaticBytecodeRecorderBuildItem.java
@@ -16,8 +16,7 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
-
+import io.quarkus.builder.item.MultiBuildItem;
import io.quarkus.deployment.recording.BytecodeRecorderImpl;
public final class StaticBytecodeRecorderBuildItem extends MultiBuildItem {
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/SystemPropertyBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/SystemPropertyBuildItem.java
index 01467b5f3a4bc..cf82c979d1126 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/SystemPropertyBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/SystemPropertyBuildItem.java
@@ -16,7 +16,7 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
/**
* Represents a system property that will be set immediately on application startup.
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/TestAnnotationBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/TestAnnotationBuildItem.java
new file mode 100644
index 0000000000000..65773ed92f2fb
--- /dev/null
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/TestAnnotationBuildItem.java
@@ -0,0 +1,20 @@
+package io.quarkus.deployment.builditem;
+
+import io.quarkus.builder.item.MultiBuildItem;
+
+/**
+ * This is an optional build item that allows us to track annotations that will define test classes
+ * It is only available during tests
+ */
+public final class TestAnnotationBuildItem extends MultiBuildItem {
+
+ private final String annotationClassName;
+
+ public TestAnnotationBuildItem(String annotationClassName) {
+ this.annotationClassName = annotationClassName;
+ }
+
+ public String getAnnotationClassName() {
+ return annotationClassName;
+ }
+}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/TestClassPredicateBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/TestClassPredicateBuildItem.java
new file mode 100644
index 0000000000000..f918eec5b9c8d
--- /dev/null
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/TestClassPredicateBuildItem.java
@@ -0,0 +1,23 @@
+package io.quarkus.deployment.builditem;
+
+import java.util.function.Predicate;
+
+import io.quarkus.builder.item.SimpleBuildItem;
+
+/**
+ * This is an optional build item that allows extensions to distinguish test classes from application classes. It is only
+ * available during tests.
+ */
+public final class TestClassPredicateBuildItem extends SimpleBuildItem {
+
+ private final Predicate predicate;
+
+ public TestClassPredicateBuildItem(Predicate predicate) {
+ this.predicate = predicate;
+ }
+
+ public Predicate getPredicate() {
+ return predicate;
+ }
+
+}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/WiringClassBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/WiringClassBuildItem.java
index 7083d5447a005..b31bad26fb068 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/WiringClassBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/WiringClassBuildItem.java
@@ -16,7 +16,7 @@
package io.quarkus.deployment.builditem;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
/**
* A generated wiring class
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveClassBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveClassBuildItem.java
index cdce684d3aea0..b39642cd8044a 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveClassBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveClassBuildItem.java
@@ -16,11 +16,13 @@
package io.quarkus.deployment.builditem.substrate;
+import static java.util.Arrays.stream;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
/**
* Used to register a class for reflection in substrate
@@ -31,12 +33,18 @@ public final class ReflectiveClassBuildItem extends MultiBuildItem {
private final boolean methods;
private final boolean fields;
private final boolean constructors;
+ private final boolean finalFieldsWritable;
public ReflectiveClassBuildItem(boolean methods, boolean fields, Class>... className) {
this(true, methods, fields, className);
}
public ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean fields, Class>... className) {
+ this(constructors, methods, fields, false, className);
+ }
+
+ private ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean fields, boolean finalFieldsWritable,
+ Class>... className) {
List names = new ArrayList<>();
for (Class> i : className) {
if (i == null) {
@@ -48,14 +56,19 @@ public ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean f
this.methods = methods;
this.fields = fields;
this.constructors = constructors;
+ this.finalFieldsWritable = finalFieldsWritable;
}
public ReflectiveClassBuildItem(boolean methods, boolean fields, String... className) {
this(true, methods, fields, className);
-
}
public ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean fields, String... className) {
+ this(constructors, methods, fields, false, className);
+ }
+
+ private ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean fields, boolean finalFieldsWritable,
+ String... className) {
for (String i : className) {
if (i == null) {
throw new NullPointerException();
@@ -65,6 +78,7 @@ public ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean f
this.methods = methods;
this.fields = fields;
this.constructors = constructors;
+ this.finalFieldsWritable = finalFieldsWritable;
}
public List getClassNames() {
@@ -82,4 +96,67 @@ public boolean isFields() {
public boolean isConstructors() {
return constructors;
}
+
+ public boolean areFinalFieldsWritable() {
+ return finalFieldsWritable;
+ }
+
+ public static Builder builder(Class>... className) {
+ String[] classNameStrings = stream(className)
+ .map(aClass -> {
+ if (aClass == null) {
+ throw new NullPointerException();
+ }
+ return aClass.getName();
+ })
+ .toArray(String[]::new);
+
+ return new Builder()
+ .className(classNameStrings);
+ }
+
+ public static Builder builder(String... className) {
+ return new Builder()
+ .className(className);
+ }
+
+ public static class Builder {
+ private String[] className;
+ private boolean constructors = true;
+ private boolean methods;
+ private boolean fields;
+ private boolean finalFieldsWritable;
+
+ private Builder() {
+ }
+
+ public Builder className(String[] className) {
+ this.className = className;
+ return this;
+ }
+
+ public Builder constructors(boolean constructors) {
+ this.constructors = constructors;
+ return this;
+ }
+
+ public Builder methods(boolean methods) {
+ this.methods = methods;
+ return this;
+ }
+
+ public Builder fields(boolean fields) {
+ this.fields = fields;
+ return this;
+ }
+
+ public Builder finalFieldsWritable(boolean finalFieldsWritable) {
+ this.finalFieldsWritable = finalFieldsWritable;
+ return this;
+ }
+
+ public ReflectiveClassBuildItem build() {
+ return new ReflectiveClassBuildItem(constructors, methods, fields, finalFieldsWritable, className);
+ }
+ }
}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveFieldBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveFieldBuildItem.java
index 5ffe45cce27a7..2ebb0584e1a3b 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveFieldBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveFieldBuildItem.java
@@ -18,9 +18,10 @@
import java.lang.reflect.Field;
-import org.jboss.builder.item.MultiBuildItem;
import org.jboss.jandex.FieldInfo;
+import io.quarkus.builder.item.MultiBuildItem;
+
public final class ReflectiveFieldBuildItem extends MultiBuildItem {
final String declaringClass;
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveHierarchyBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveHierarchyBuildItem.java
index 1d3efb7577d12..678be658117a0 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveHierarchyBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveHierarchyBuildItem.java
@@ -16,9 +16,10 @@
package io.quarkus.deployment.builditem.substrate;
-import org.jboss.builder.item.MultiBuildItem;
import org.jboss.jandex.Type;
+import io.quarkus.builder.item.MultiBuildItem;
+
/**
* Attempts to register a complete type hierarchy for reflection.
*
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveMethodBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveMethodBuildItem.java
index 9c9bae677e329..9ad97f23c60f6 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveMethodBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ReflectiveMethodBuildItem.java
@@ -20,9 +20,10 @@
import java.util.Arrays;
import java.util.Objects;
-import org.jboss.builder.item.MultiBuildItem;
import org.jboss.jandex.MethodInfo;
+import io.quarkus.builder.item.MultiBuildItem;
+
public final class ReflectiveMethodBuildItem extends MultiBuildItem {
final String declaringClass;
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/RuntimeInitializedClassBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/RuntimeInitializedClassBuildItem.java
index e8ed8324df9b3..8785ab3acb698 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/RuntimeInitializedClassBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/RuntimeInitializedClassBuildItem.java
@@ -16,7 +16,7 @@
package io.quarkus.deployment.builditem.substrate;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
public final class RuntimeInitializedClassBuildItem extends MultiBuildItem {
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/RuntimeReinitializedClassBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/RuntimeReinitializedClassBuildItem.java
index 22dfdb6b34d39..e60e8967174b5 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/RuntimeReinitializedClassBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/RuntimeReinitializedClassBuildItem.java
@@ -16,7 +16,7 @@
package io.quarkus.deployment.builditem.substrate;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
/**
* A class that will be reinitialized at runtime by Substrate. This will result in the static
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ServiceProviderBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ServiceProviderBuildItem.java
index 67f1f1627dc6a..e186d350f935d 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ServiceProviderBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/ServiceProviderBuildItem.java
@@ -20,7 +20,7 @@
import java.util.List;
import java.util.Objects;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
/**
* Represents a Service Provider registration.
@@ -35,8 +35,12 @@ public final class ServiceProviderBuildItem extends MultiBuildItem {
private final List providers;
public ServiceProviderBuildItem(String serviceInterfaceClassName, String... providerClassNames) {
- serviceInterface = Objects.requireNonNull(serviceInterfaceClassName, "The service interface must not be `null`");
- providers = Arrays.asList(Objects.requireNonNull(providerClassNames));
+ this(serviceInterfaceClassName, Arrays.asList(providerClassNames));
+ }
+
+ public ServiceProviderBuildItem(String serviceInterfaceClassName, List providers) {
+ this.serviceInterface = Objects.requireNonNull(serviceInterfaceClassName, "The service interface must not be `null`");
+ this.providers = providers;
// Validation
if (serviceInterface.length() == 0) {
@@ -45,7 +49,7 @@ public ServiceProviderBuildItem(String serviceInterfaceClassName, String... prov
providers.forEach(s -> {
if (s == null || s.length() == 0) {
- throw new IllegalArgumentException("The provider class name cannot be blank");
+ throw new IllegalArgumentException("The provider class name cannot be null or blank");
}
});
}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateConfigBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateConfigBuildItem.java
index ba58ff60a2985..6f042d3af6c47 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateConfigBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateConfigBuildItem.java
@@ -24,7 +24,7 @@
import java.util.Map;
import java.util.Set;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
public final class SubstrateConfigBuildItem extends MultiBuildItem {
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateOutputBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateOutputBuildItem.java
index 06ea474e6b183..347391eca5b3a 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateOutputBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateOutputBuildItem.java
@@ -16,7 +16,7 @@
package io.quarkus.deployment.builditem.substrate;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
public final class SubstrateOutputBuildItem extends MultiBuildItem {
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateProxyDefinitionBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateProxyDefinitionBuildItem.java
index 22d8e8ce51da4..840e4f6a405a0 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateProxyDefinitionBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateProxyDefinitionBuildItem.java
@@ -20,7 +20,7 @@
import java.util.Arrays;
import java.util.List;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
/**
* A build item that represents a {@link java.lang.reflect.Proxy} definition
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateResourceBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateResourceBuildItem.java
index 39c47042f0fdb..a8cd3d425f61e 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateResourceBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateResourceBuildItem.java
@@ -20,7 +20,7 @@
import java.util.Arrays;
import java.util.List;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
/**
* A build item that indicates that a static resource should be included in the native image
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateResourceBundleBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateResourceBundleBuildItem.java
index ac561516f73df..45c3720119e09 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateResourceBundleBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateResourceBundleBuildItem.java
@@ -16,7 +16,7 @@
package io.quarkus.deployment.builditem.substrate;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
/**
* Indicates that a resource bundle should be included in the native image
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateSystemPropertyBuildItem.java b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateSystemPropertyBuildItem.java
index c68f9690b6524..e7638d286375f 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateSystemPropertyBuildItem.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/builditem/substrate/SubstrateSystemPropertyBuildItem.java
@@ -16,7 +16,7 @@
package io.quarkus.deployment.builditem.substrate;
-import org.jboss.builder.item.MultiBuildItem;
+import io.quarkus.builder.item.MultiBuildItem;
/**
* A system property that will be set at native image build time
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/configuration/BooleanConfigType.java b/core/deployment/src/main/java/io/quarkus/deployment/configuration/BooleanConfigType.java
index 170b2f578b03c..ae5bbb3dc4265 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/configuration/BooleanConfigType.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/configuration/BooleanConfigType.java
@@ -4,9 +4,12 @@
import java.util.Optional;
import io.quarkus.deployment.AccessorFinder;
+import io.quarkus.deployment.steps.ConfigurationSetup;
import io.quarkus.gizmo.BytecodeCreator;
+import io.quarkus.gizmo.FieldDescriptor;
import io.quarkus.gizmo.MethodDescriptor;
import io.quarkus.gizmo.ResultHandle;
+import io.quarkus.runtime.configuration.ExpandingConfigSource;
import io.quarkus.runtime.configuration.NameIterator;
import io.smallrye.config.SmallRyeConfig;
@@ -24,21 +27,22 @@ public BooleanConfigType(final String containingName, final CompoundConfigType c
this.defaultValue = defaultValue;
}
- public void acceptConfigurationValue(final NameIterator name, final SmallRyeConfig config) {
+ public void acceptConfigurationValue(final NameIterator name, final ExpandingConfigSource.Cache cache,
+ final SmallRyeConfig config) {
final GroupConfigType container = getContainer(GroupConfigType.class);
if (isConsumeSegment())
name.previous();
- container.acceptConfigurationValueIntoLeaf(this, name, config);
+ container.acceptConfigurationValueIntoLeaf(this, name, cache, config);
// the iterator is not used after this point
// if (isConsumeSegment()) name.next();
}
public void generateAcceptConfigurationValue(final BytecodeCreator body, final ResultHandle name,
- final ResultHandle config) {
+ final ResultHandle cache, final ResultHandle config) {
final GroupConfigType container = getContainer(GroupConfigType.class);
if (isConsumeSegment())
body.invokeVirtualMethod(NI_PREV_METHOD, name);
- container.generateAcceptConfigurationValueIntoLeaf(body, this, name, config);
+ container.generateAcceptConfigurationValueIntoLeaf(body, this, name, cache, config);
// the iterator is not used after this point
// if (isConsumeSegment()) body.invokeVirtualMethod(NI_NEXT_METHOD, name);
}
@@ -47,7 +51,7 @@ public void acceptConfigurationValueIntoGroup(final Object enclosing, final Fiel
final SmallRyeConfig config) {
try {
field.setBoolean(enclosing, config.getOptionalValue(name.toString(), Boolean.class)
- .orElse(config.convert(defaultValue, Boolean.class)).booleanValue());
+ .orElse(Boolean.FALSE).booleanValue());
} catch (IllegalAccessException e) {
throw toError(e);
}
@@ -55,7 +59,7 @@ public void acceptConfigurationValueIntoGroup(final Object enclosing, final Fiel
public void generateAcceptConfigurationValueIntoGroup(final BytecodeCreator body, final ResultHandle enclosing,
final MethodDescriptor setter, final ResultHandle name, final ResultHandle config) {
- // config.getOptionalValue(name.toString(), Boolean.class).orElse(config.convert(defaultValue, Boolean.class)).booleanValue()
+ // config.getOptionalValue(name.toString(), Boolean.class).orElse(Boolean.FALSE).booleanValue()
final ResultHandle optionalValue = body.checkCast(body.invokeVirtualMethod(
SRC_GET_OPT_METHOD,
config,
@@ -63,7 +67,7 @@ public void generateAcceptConfigurationValueIntoGroup(final BytecodeCreator body
OBJ_TO_STRING_METHOD,
name),
body.loadClass(Boolean.class)), Optional.class);
- final ResultHandle convertedDefault = getConvertedDefault(body, config);
+ final ResultHandle convertedDefault = body.readStaticField(FieldDescriptor.of(Boolean.class, "FALSE", Boolean.class));
final ResultHandle defaultedValue = body.checkCast(body.invokeVirtualMethod(
OPT_OR_ELSE_METHOD,
optionalValue,
@@ -72,36 +76,46 @@ public void generateAcceptConfigurationValueIntoGroup(final BytecodeCreator body
body.invokeStaticMethod(setter, enclosing, booleanValue);
}
+ public String getDefaultValueString() {
+ return defaultValue;
+ }
+
public Class> getItemClass() {
return boolean.class;
}
- void getDefaultValueIntoEnclosingGroup(final Object enclosing, final SmallRyeConfig config, final Field field) {
+ void getDefaultValueIntoEnclosingGroup(final Object enclosing, final ExpandingConfigSource.Cache cache,
+ final SmallRyeConfig config, final Field field) {
try {
- field.setBoolean(enclosing, config.convert(defaultValue, Boolean.class).booleanValue());
+ field.setBoolean(enclosing,
+ config.convert(ExpandingConfigSource.expandValue(defaultValue, cache), Boolean.class).booleanValue());
} catch (IllegalAccessException e) {
throw toError(e);
}
}
void generateGetDefaultValueIntoEnclosingGroup(final BytecodeCreator body, final ResultHandle enclosing,
- final MethodDescriptor setter, final ResultHandle config) {
+ final MethodDescriptor setter, final ResultHandle cache, final ResultHandle config) {
final ResultHandle value = body.invokeVirtualMethod(BOOL_VALUE_METHOD,
- body.checkCast(getConvertedDefault(body, config), Boolean.class));
+ body.checkCast(getConvertedDefault(body, cache, config), Boolean.class));
body.invokeStaticMethod(setter, enclosing, value);
}
public ResultHandle writeInitialization(final BytecodeCreator body, final AccessorFinder accessorFinder,
- final ResultHandle smallRyeConfig) {
+ final ResultHandle cache, final ResultHandle smallRyeConfig) {
return body.invokeVirtualMethod(BOOL_VALUE_METHOD,
- body.checkCast(getConvertedDefault(body, smallRyeConfig), Boolean.class));
+ body.checkCast(getConvertedDefault(body, cache, smallRyeConfig), Boolean.class));
}
- private ResultHandle getConvertedDefault(final BytecodeCreator body, final ResultHandle config) {
+ private ResultHandle getConvertedDefault(final BytecodeCreator body, final ResultHandle cache, final ResultHandle config) {
return body.checkCast(body.invokeVirtualMethod(
SRC_CONVERT_METHOD,
config,
- body.load(defaultValue),
+ cache == null ? body.load(defaultValue)
+ : body.invokeStaticMethod(
+ ConfigurationSetup.ECS_EXPAND_VALUE,
+ body.load(defaultValue),
+ cache),
body.loadClass(Boolean.class)), Boolean.class);
}
}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/configuration/CompoundConfigType.java b/core/deployment/src/main/java/io/quarkus/deployment/configuration/CompoundConfigType.java
index 6b75c6e6d5815..4cc3734a8d0d4 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/configuration/CompoundConfigType.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/configuration/CompoundConfigType.java
@@ -2,6 +2,7 @@
import io.quarkus.gizmo.BytecodeCreator;
import io.quarkus.gizmo.ResultHandle;
+import io.quarkus.runtime.configuration.ExpandingConfigSource;
import io.quarkus.runtime.configuration.NameIterator;
import io.smallrye.config.SmallRyeConfig;
@@ -17,14 +18,17 @@ public abstract class CompoundConfigType extends ConfigType {
* Get or create a child instance of this node.
*
* @param name the property name of the child instance (must not be {@code null})
+ * @param cache
* @param config the configuration (must not be {@code null})
* @param self the instance of this node (must not be {@code null})
* @param childName the static child name, or {@code null} if the child name is dynamic
* @return the child instance
*/
- abstract Object getChildObject(NameIterator name, SmallRyeConfig config, Object self, String childName);
+ abstract Object getChildObject(NameIterator name, final ExpandingConfigSource.Cache cache, SmallRyeConfig config,
+ Object self, String childName);
- abstract ResultHandle generateGetChildObject(BytecodeCreator body, ResultHandle name, ResultHandle config,
+ abstract ResultHandle generateGetChildObject(BytecodeCreator body, ResultHandle name, final ResultHandle cache,
+ ResultHandle config,
ResultHandle self, String childName);
/**
@@ -44,15 +48,18 @@ abstract void generateSetChildObject(BytecodeCreator body, ResultHandle name, Re
* Get or create the instance of this root, recursively adding it to its parent if necessary.
*
* @param name the name of this property node (must not be {@code null})
+ * @param cache
* @param config the configuration (must not be {@code null})
* @return the possibly new object instance
*/
- abstract Object getOrCreate(NameIterator name, SmallRyeConfig config);
+ abstract Object getOrCreate(NameIterator name, final ExpandingConfigSource.Cache cache, SmallRyeConfig config);
- abstract ResultHandle generateGetOrCreate(BytecodeCreator body, ResultHandle name, ResultHandle config);
+ abstract ResultHandle generateGetOrCreate(BytecodeCreator body, ResultHandle name, final ResultHandle cache,
+ ResultHandle config);
- abstract void acceptConfigurationValueIntoLeaf(LeafConfigType leafType, NameIterator name, SmallRyeConfig config);
+ abstract void acceptConfigurationValueIntoLeaf(LeafConfigType leafType, NameIterator name,
+ final ExpandingConfigSource.Cache cache, SmallRyeConfig config);
abstract void generateAcceptConfigurationValueIntoLeaf(BytecodeCreator body, LeafConfigType leafType, ResultHandle name,
- ResultHandle config);
+ final ResultHandle cache, ResultHandle config);
}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigDefinition.java b/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigDefinition.java
index beaece45d99df..88bc69dc3d403 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigDefinition.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/configuration/ConfigDefinition.java
@@ -1,7 +1,5 @@
package io.quarkus.deployment.configuration;
-import static io.quarkus.deployment.steps.ConfigurationSetup.CONFIG_ROOT;
-import static io.quarkus.deployment.steps.ConfigurationSetup.CONFIG_ROOT_FIELD;
import static io.quarkus.deployment.util.ReflectUtil.rawTypeOf;
import static io.quarkus.deployment.util.ReflectUtil.rawTypeOfParameter;
import static io.quarkus.deployment.util.ReflectUtil.typeOfParameter;
@@ -27,8 +25,10 @@
import java.util.OptionalDouble;
import java.util.OptionalInt;
import java.util.OptionalLong;
+import java.util.Set;
import java.util.TreeMap;
+import org.jboss.logging.Logger;
import org.objectweb.asm.Opcodes;
import org.wildfly.common.Assert;
@@ -36,6 +36,7 @@
import io.quarkus.gizmo.BytecodeCreator;
import io.quarkus.gizmo.ClassCreator;
import io.quarkus.gizmo.ClassOutput;
+import io.quarkus.gizmo.DescriptorUtils;
import io.quarkus.gizmo.FieldDescriptor;
import io.quarkus.gizmo.MethodCreator;
import io.quarkus.gizmo.MethodDescriptor;
@@ -44,6 +45,7 @@
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
+import io.quarkus.runtime.configuration.ExpandingConfigSource;
import io.quarkus.runtime.configuration.NameIterator;
import io.smallrye.config.SmallRyeConfig;
@@ -52,6 +54,8 @@
* has a root which recursively contains all of the elements within the configuration.
*/
public class ConfigDefinition extends CompoundConfigType {
+ private static final Logger log = Logger.getLogger("io.quarkus.config");
+
public static final String NO_CONTAINING_NAME = "<>";
private final TreeMap rootObjectsByContainingName = new TreeMap<>();
@@ -59,38 +63,46 @@ public class ConfigDefinition extends CompoundConfigType {
private final ConfigPatternMap leafPatterns = new ConfigPatternMap<>();
private final IdentityHashMap