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();
- }
-
- @Override
- protected void doResolve(AppArtifact artifact) throws AppCreatorException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/core/creator/src/main/java/io/quarkus/creator/demo/AppCreatorDemo.java b/core/creator/src/main/java/io/quarkus/creator/demo/AppCreatorDemo.java
index 879248c0abc9f..c9274ca535c00 100644
--- a/core/creator/src/main/java/io/quarkus/creator/demo/AppCreatorDemo.java
+++ b/core/creator/src/main/java/io/quarkus/creator/demo/AppCreatorDemo.java
@@ -28,6 +28,8 @@
import java.util.List;
import java.util.Set;
+import io.quarkus.bootstrap.util.IoUtils;
+import io.quarkus.bootstrap.util.PropertyUtils;
import io.quarkus.creator.AppCreator;
import io.quarkus.creator.phase.augment.AugmentPhase;
import io.quarkus.creator.phase.curate.CuratePhase;
@@ -35,8 +37,6 @@
import io.quarkus.creator.phase.nativeimage.NativeImagePhase;
import io.quarkus.creator.phase.runnerjar.RunnerJarOutcome;
import io.quarkus.creator.phase.runnerjar.RunnerJarPhase;
-import io.quarkus.creator.util.IoUtils;
-import io.quarkus.creator.util.PropertyUtils;
/**
*
diff --git a/core/creator/src/main/java/io/quarkus/creator/demo/CheckUpdatesDemo.java b/core/creator/src/main/java/io/quarkus/creator/demo/CheckUpdatesDemo.java
index 571a49a977802..3b616987cd51a 100644
--- a/core/creator/src/main/java/io/quarkus/creator/demo/CheckUpdatesDemo.java
+++ b/core/creator/src/main/java/io/quarkus/creator/demo/CheckUpdatesDemo.java
@@ -19,8 +19,8 @@
import java.util.Properties;
+import io.quarkus.bootstrap.model.AppDependency;
import io.quarkus.creator.AppCreator;
-import io.quarkus.creator.AppDependency;
import io.quarkus.creator.phase.curate.CurateOutcome;
import io.quarkus.creator.phase.curate.CuratePhase;
import io.quarkus.creator.phase.curate.VersionUpdate;
diff --git a/core/creator/src/main/java/io/quarkus/creator/demo/ConfigDemoBase.java b/core/creator/src/main/java/io/quarkus/creator/demo/ConfigDemoBase.java
index 241cc8f073e6e..43651e7a903b8 100644
--- a/core/creator/src/main/java/io/quarkus/creator/demo/ConfigDemoBase.java
+++ b/core/creator/src/main/java/io/quarkus/creator/demo/ConfigDemoBase.java
@@ -30,12 +30,12 @@
import java.util.Properties;
import java.util.Set;
+import io.quarkus.bootstrap.util.IoUtils;
+import io.quarkus.bootstrap.util.PropertyUtils;
import io.quarkus.creator.AppCreator;
import io.quarkus.creator.config.reader.PropertiesConfigReader;
import io.quarkus.creator.config.reader.PropertiesHandler;
import io.quarkus.creator.phase.curate.CuratePhase;
-import io.quarkus.creator.util.IoUtils;
-import io.quarkus.creator.util.PropertyUtils;
/**
*
@@ -51,7 +51,7 @@ public ConfigDemoBase() {
public void run() throws Exception {
- final long startTime = System.currentTimeMillis();
+ //final long startTime = System.nanoTime();
final Path appJar = getAppJar();
if (!Files.exists(appJar)) {
@@ -78,9 +78,7 @@ public void run() throws Exception {
}
}
- final long time = System.currentTimeMillis() - startTime;
- final long seconds = time / 1000;
- System.out.println("Done in " + seconds + "." + (time - seconds * 1000) + " seconds");
+ //System.out.println(IoUtils.tookTime("Demo", startTime));
}
protected void demo(AppCreator creator) throws Exception {
diff --git a/core/creator/src/main/java/io/quarkus/creator/demo/NativeImageOutcomeDemo.java b/core/creator/src/main/java/io/quarkus/creator/demo/NativeImageOutcomeDemo.java
index 8e762bd021c91..ae51830f8d955 100644
--- a/core/creator/src/main/java/io/quarkus/creator/demo/NativeImageOutcomeDemo.java
+++ b/core/creator/src/main/java/io/quarkus/creator/demo/NativeImageOutcomeDemo.java
@@ -22,7 +22,7 @@
import java.util.Properties;
import io.quarkus.creator.AppCreator;
-import io.quarkus.creator.phase.nativeimage.NativeImageOutcome;
+import io.quarkus.creator.phase.runnerjar.RunnerJarOutcome;
/**
*
@@ -46,8 +46,14 @@ protected void initProps(Properties props) {
props.setProperty("native-image.disable-reports", "true");
}
+ @Override
+ protected boolean isLogLibDiff() {
+ return true;
+ }
+
@Override
public void demo(AppCreator creator) throws Exception {
- creator.resolveOutcome(NativeImageOutcome.class);
+ //creator.resolveOutcome(NativeImageOutcome.class);
+ creator.resolveOutcome(RunnerJarOutcome.class);
}
}
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..b0dce67f3b82c 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}
*
@@ -49,15 +47,4 @@ public interface AugmentOutcome {
* @return directory containing generated classes
*/
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.
- *
- * @param dep application dependency
- * @return true if the dependency was whitelisted, otherwise - false
- */
- boolean isWhitelisted(AppDependency dep);
}
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..02739144df0ec 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,18 @@
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.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
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,8 +36,6 @@
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;
@@ -52,18 +44,18 @@
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.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.ClassOutput;
import io.quarkus.deployment.QuarkusAugmentor;
import io.quarkus.deployment.QuarkusClassWriter;
@@ -81,17 +73,12 @@
*/
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 Path outputDir;
private Path appClassesDir;
private Path transformedClassesDir;
private Path wiringClassesDir;
- private Set whitelist = new HashSet<>();
/**
* Output directory for the outcome of this phase.
@@ -159,11 +146,6 @@ public Path getWiringClassesDir() {
return wiringClassesDir;
}
- @Override
- public boolean isWhitelisted(AppDependency dep) {
- return whitelist.contains(getDependencyConflictId(dep.getArtifact()));
- }
-
@Override
public void register(OutcomeProviderRegistration registration) throws AppCreatorException {
registration.provides(AugmentOutcome.class);
@@ -177,7 +159,7 @@ 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) {
@@ -215,71 +197,26 @@ 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
@@ -407,31 +344,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;
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..0ce23bcfc0ae1 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,14 +139,18 @@ 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() {
@@ -170,9 +167,10 @@ public void persist(AppCreator ctx) throws AppCreatorException {
final Path stateDir = ctx.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..0bd6193219d46 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
@@ -35,17 +35,22 @@
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.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.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;
/**
*
@@ -153,75 +158,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 +243,37 @@ 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 = ModelUtils.getUpdateCandidates(ModelUtils.readAppModel(appJar, appArtifact).getDependencies(),
+ initialDepsList.getAllDependencies(), updateGroupIds);
+ } catch (IOException | BootstrapDependencyProcessingException e) {
+ throw new AppCreatorException("Failed to determine the list of dependencies to update", e);
+ }
+ final UpdateDiscovery ud = new DefaultUpdateDiscovery(modelResolver, updateNumber);
List availableUpdates = null;
int i = 0;
while (i < appDeps.size()) {
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..308233899b647 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, 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 {
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/nativeimage/NativeImagePhase.java b/core/creator/src/main/java/io/quarkus/creator/phase/nativeimage/NativeImagePhase.java
index a31cfde44452c..a5e3c5ef4b5cb 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
@@ -38,6 +38,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 +47,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;
/**
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 4c7022388fc6f..b22f85c50213b 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,7 +31,6 @@
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.Collections;
@@ -47,19 +46,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 +69,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);
@@ -82,13 +80,14 @@ public class RunnerJarPhase implements AppCreationPhase, RunnerJ
"META-INF/NOTICE",
"META-INF/LICENSE.txt",
"META-INF/NOTICE.txt",
- "dependencies.runtime",
"META-INF/README",
"META-INF/quarkus-config-roots.list",
"META-INF/DEPENDENCIES",
"META-INF/beans.xml",
"META-INF/quarkus-javadoc.properties",
- "LICENSE")));
+ "LICENSE",
+ "quarqus/quarkus-extension.properties",
+ "quarqus/quarkus-deployment-dependency.graph")));
private Path outputDir;
private Path libDir;
@@ -184,7 +183,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 = appState.getAppArtifact().getPath().getFileName().toString();
int i = name.lastIndexOf('.');
if (i > 0) {
finalName = name.substring(0, i);
@@ -220,24 +219,22 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
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<>();
+ 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;
+ throw new IllegalStateException("Dependency on com.oracle.substratevm:svm");
}
final Path resolvedDep = depResolver.resolve(depArtifact);
if (uberJar) {
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/deployment/pom.xml b/core/deployment/pom.xml
index 9354d4be9321e..707a1071d1a53 100644
--- a/core/deployment/pom.xml
+++ b/core/deployment/pom.xml
@@ -27,7 +27,7 @@
../
- quarkus-core
+ quarkus-core-deployment
Quarkus - Core - Deployment
@@ -65,9 +65,14 @@
org.ow2.asm
asm
+
+ io.quarkus.bootstrap
+ bootstrap-core
+ provided
+
io.quarkus
- quarkus-core-runtime
+ quarkus-core
io.quarkus.gizmo
diff --git a/core/devmode/pom.xml b/core/devmode/pom.xml
index ef2345c3ea92c..49452486a4c6a 100644
--- a/core/devmode/pom.xml
+++ b/core/devmode/pom.xml
@@ -32,7 +32,7 @@
io.quarkus
- quarkus-core
+ quarkus-core-deployment
org.jboss.logmanager
diff --git a/core/runtime/pom.xml b/core/runtime/pom.xml
index 55df1d12f7908..fa102cffb3537 100644
--- a/core/runtime/pom.xml
+++ b/core/runtime/pom.xml
@@ -27,7 +27,7 @@
../
- quarkus-core-runtime
+ quarkus-core
Quarkus - Core - Runtime
@@ -109,6 +109,10 @@
+
+ io.quarkus.bootstrap
+ bootstrap-maven-plugin
+
org.apache.maven.plugins
maven-compiler-plugin
@@ -131,9 +135,6 @@
-
- maven-dependency-plugin
-
diff --git a/core/test-extension/deployment/pom.xml b/core/test-extension/deployment/pom.xml
index 6e9055913d444..c9f2064acb8b7 100644
--- a/core/test-extension/deployment/pom.xml
+++ b/core/test-extension/deployment/pom.xml
@@ -25,7 +25,7 @@
4.0.0
- quarkus-test-extension
+ quarkus-test-extension-deployment
Quarkus - Core - Test Extension - Deployment
@@ -35,19 +35,19 @@
io.quarkus
- quarkus-core
+ quarkus-core-deployment
io.quarkus
- quarkus-arc
+ quarkus-arc-deployment
io.quarkus
- quarkus-undertow-runtime
+ quarkus-undertow
io.quarkus
- quarkus-test-extension-runtime
+ quarkus-test-extension
999-SNAPSHOT
diff --git a/core/test-extension/runtime/pom.xml b/core/test-extension/runtime/pom.xml
index 441fae4a13c3e..a7802423a9180 100644
--- a/core/test-extension/runtime/pom.xml
+++ b/core/test-extension/runtime/pom.xml
@@ -25,13 +25,13 @@
4.0.0
- quarkus-test-extension-runtime
+ quarkus-test-extension
Quarkus - Core - Test Extension - Runtime
io.quarkus
- quarkus-arc-runtime
+ quarkus-arc
com.oracle.substratevm
@@ -51,14 +51,15 @@
io.quarkus
- quarkus-core-runtime
+ quarkus-core
- maven-dependency-plugin
+ io.quarkus.bootstrap
+ bootstrap-maven-plugin
maven-compiler-plugin
diff --git a/devtools/common/pom.xml b/devtools/common/pom.xml
index 81bde12a3cd21..6b30fdb069c95 100644
--- a/devtools/common/pom.xml
+++ b/devtools/common/pom.xml
@@ -53,6 +53,12 @@
io.quarkus
quarkus-devtools-common-core
+
org.apache.maven
maven-plugin-api
diff --git a/devtools/gradle-it/pom.xml b/devtools/gradle-it/pom.xml
index ac8f0419efe22..fc16038c3fb8e 100644
--- a/devtools/gradle-it/pom.xml
+++ b/devtools/gradle-it/pom.xml
@@ -36,6 +36,12 @@
io.rest-assured
rest-assured
test
+
+
+ org.apache.commons
+ commons-lang3
+
+