mirror of
https://github.com/jlengrand/quarkus.git
synced 2026-03-10 08:41:22 +00:00
This fixes list (and also add) extensions commands in Gradle (by using the descriptor stored in a ThreadLocal) and in Maven (by properly resolving the BOM coordinates)
This commit is contained in:
committed by
Guillaume Smet
parent
8d9e3feb6e
commit
aa6ae88685
@@ -86,23 +86,20 @@ public abstract class BuildFileMojoBase extends AbstractMojo {
|
||||
continue;
|
||||
}
|
||||
// We don't know which BOM is the platform one, so we are trying every BOM here
|
||||
String bomVersion = dep.getVersion();
|
||||
if (bomVersion.startsWith("${") && bomVersion.endsWith("}")) {
|
||||
final String prop = bomVersion.substring(2, bomVersion.length() - 1);
|
||||
bomVersion = mvnBuild.getProperty(prop);
|
||||
if (bomVersion == null) {
|
||||
getLog().debug("Failed to resolve version of " + dep);
|
||||
continue;
|
||||
}
|
||||
final String bomVersion = resolveValue(dep.getVersion(), buildFile);
|
||||
final String bomGroupId = resolveValue(dep.getGroupId(), buildFile);
|
||||
final String bomArtifactId = resolveValue(dep.getArtifactId(), buildFile);
|
||||
if (bomVersion == null || bomGroupId == null || bomArtifactId == null) {
|
||||
continue;
|
||||
}
|
||||
Artifact jsonArtifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getClassifier(),
|
||||
"json", bomVersion);
|
||||
|
||||
Artifact jsonArtifact = new DefaultArtifact(bomGroupId, bomArtifactId, null, "json", bomVersion);
|
||||
try {
|
||||
jsonArtifact = mvn.resolve(jsonArtifact).getArtifact();
|
||||
} catch (Exception e) {
|
||||
log.debug("Failed to resolve JSON descriptor as %s", jsonArtifact);
|
||||
jsonArtifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId() + "-descriptor-json",
|
||||
dep.getClassifier(), "json", bomVersion);
|
||||
jsonArtifact = new DefaultArtifact(bomGroupId, bomArtifactId + "-descriptor-json", null, "json",
|
||||
bomVersion);
|
||||
try {
|
||||
jsonArtifact = mvn.resolve(jsonArtifact).getArtifact();
|
||||
} catch (Exception e1) {
|
||||
@@ -113,7 +110,6 @@ public abstract class BuildFileMojoBase extends AbstractMojo {
|
||||
descrArtifact = jsonArtifact;
|
||||
break;
|
||||
}
|
||||
|
||||
if (descrArtifact != null) {
|
||||
log.debug("Quarkus platform JSON descriptor resolved from %s", descrArtifact);
|
||||
final QuarkusPlatformDescriptor platform = QuarkusJsonPlatformDescriptorResolver.newInstance()
|
||||
@@ -153,4 +149,15 @@ public abstract class BuildFileMojoBase extends AbstractMojo {
|
||||
}
|
||||
|
||||
protected abstract void doExecute(BuildFile buildFile) throws MojoExecutionException;
|
||||
|
||||
private String resolveValue(String expr, BuildFile buildFile) throws IOException {
|
||||
if (expr.startsWith("${") && expr.endsWith("}")) {
|
||||
final String v = buildFile.getProperty(expr.substring(2, expr.length() - 1));
|
||||
if (v == null) {
|
||||
getLog().debug("Failed to resolve version of " + v);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import io.quarkus.cli.commands.writer.ProjectWriter;
|
||||
import io.quarkus.dependencies.Extension;
|
||||
import io.quarkus.generators.BuildTool;
|
||||
import io.quarkus.maven.utilities.MojoUtils;
|
||||
import io.quarkus.platform.tools.config.QuarkusPlatformConfig;
|
||||
|
||||
public class AddExtensions {
|
||||
|
||||
@@ -55,9 +54,9 @@ public class AddExtensions {
|
||||
if (matchesNameOrArtifactId.size() == 1) {
|
||||
return new SelectionResult(matchesNameOrArtifactId, true);
|
||||
}
|
||||
|
||||
|
||||
extensions = extensions.stream().filter(e -> !e.isUnlisted()).collect(Collectors.toList());
|
||||
|
||||
|
||||
// Try short names
|
||||
Set<Extension> matchesShortName = extensions.stream().filter(extension -> matchesShortName(extension, q))
|
||||
.collect(Collectors.toSet());
|
||||
@@ -238,6 +237,6 @@ public class AddExtensions {
|
||||
}
|
||||
|
||||
private List<Dependency> getDependenciesFromBom() {
|
||||
return QuarkusPlatformConfig.getGlobalDefault().getPlatformDescriptor().getManagedDependencies();
|
||||
return MojoUtils.getPlatformDescriptor().getManagedDependencies();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import io.quarkus.generators.BuildTool;
|
||||
import io.quarkus.generators.ProjectGenerator;
|
||||
import io.quarkus.generators.SourceType;
|
||||
import io.quarkus.maven.utilities.MojoUtils;
|
||||
import io.quarkus.platform.tools.config.QuarkusPlatformConfig;
|
||||
|
||||
public class BasicRestProjectGenerator implements ProjectGenerator {
|
||||
|
||||
@@ -124,7 +123,7 @@ public class BasicRestProjectGenerator implements ProjectGenerator {
|
||||
throws IOException {
|
||||
if (!writer.exists(outputFilePath)) {
|
||||
String path = templateName;
|
||||
String template = QuarkusPlatformConfig.getGlobalDefault().getPlatformDescriptor().getTemplate(path);
|
||||
String template = MojoUtils.getPlatformDescriptor().getTemplate(path);
|
||||
if (template == null) {
|
||||
throw new IOException("Template resource is missing: " + path);
|
||||
}
|
||||
|
||||
@@ -67,10 +67,10 @@ public class MojoUtils {
|
||||
|
||||
private static Properties properties;
|
||||
|
||||
private static QuarkusPlatformDescriptor platformDescr;
|
||||
|
||||
private static QuarkusPlatformDescriptor getPlatformDescriptor() {
|
||||
return platformDescr == null ? platformDescr = QuarkusPlatformConfig.getGlobalDefault().getPlatformDescriptor() : platformDescr;
|
||||
public static QuarkusPlatformDescriptor getPlatformDescriptor() {
|
||||
return QuarkusPlatformConfig.hasThreadLocal()
|
||||
? QuarkusPlatformConfig.getThreadLocal().getPlatformDescriptor()
|
||||
: QuarkusPlatformConfig.getGlobalDefault().getPlatformDescriptor();
|
||||
}
|
||||
|
||||
private static Properties getProperties() {
|
||||
@@ -269,7 +269,7 @@ public class MojoUtils {
|
||||
}
|
||||
|
||||
public static List<Extension> loadExtensions() {
|
||||
return QuarkusPlatformConfig.getGlobalDefault().getPlatformDescriptor().getExtensions();
|
||||
return getPlatformDescriptor().getExtensions();
|
||||
}
|
||||
|
||||
public static String credentials(final Dependency d) {
|
||||
|
||||
Reference in New Issue
Block a user