mirror of
https://github.com/jlengrand/quarkus.git
synced 2026-03-10 08:41:22 +00:00
Extracting common devtools from Quarkus core repo
This commit is contained in:
committed by
Guillaume Smet
parent
c43dc61b89
commit
addcaeb8b2
@@ -96,7 +96,22 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-devtools-common-core</artifactId>
|
||||
<artifactId>quarkus-platform-descriptor-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-platform-descriptor-legacy</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-platform-descriptor-json</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-devtools-templates</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>quarkus-core-extensions-json</artifactId>
|
||||
<artifactId>quarkus-bom-descriptor-json</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>Quarkus - Core Extensions JSON</name>
|
||||
|
||||
@@ -19,14 +19,6 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>${nexus-staging-maven-plugin.version}</version>
|
||||
<configuration>
|
||||
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-maven-plugin</artifactId>
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-devtools-common-core</artifactId>
|
||||
<artifactId>quarkus-platform-descriptor-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
|
||||
@@ -23,7 +23,7 @@ repositories {
|
||||
dependencies {
|
||||
compile "io.quarkus:quarkus-bootstrap-core:${version}"
|
||||
compile "io.quarkus:quarkus-devtools-common:${version}"
|
||||
compile "io.quarkus:quarkus-devtools-common-core:${version}"
|
||||
compile "io.quarkus:quarkus-platform-descriptor-legacy:${version}"
|
||||
compile "io.quarkus:quarkus-development-mode:${version}"
|
||||
compile "io.quarkus:quarkus-creator:${version}"
|
||||
compile "org.gradle:gradle-tooling-api:5.5.1"
|
||||
|
||||
@@ -53,14 +53,12 @@
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-devtools-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-devtools-common-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<artifactId>quarkus-platform-descriptor-legacy</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-development-mode</artifactId>
|
||||
<version>${project.version}</version>
|
||||
@@ -70,7 +68,7 @@
|
||||
<artifactId>quarkus-creator</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
|
||||
@@ -32,6 +32,14 @@
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-devtools-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-platform-descriptor-legacy</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-platform-descriptor-json</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.quarkus.maven;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@@ -8,16 +7,15 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import io.quarkus.cli.commands.AddExtensionResult;
|
||||
import io.quarkus.cli.commands.AddExtensions;
|
||||
import io.quarkus.cli.commands.file.BuildFile;
|
||||
import io.quarkus.cli.commands.writer.FileProjectWriter;
|
||||
import io.quarkus.generators.BuildTool;
|
||||
|
||||
/**
|
||||
* Allow adding an extension to an existing pom.xml file.
|
||||
@@ -26,13 +24,7 @@ import io.quarkus.cli.commands.writer.FileProjectWriter;
|
||||
* parameters.
|
||||
*/
|
||||
@Mojo(name = "add-extension")
|
||||
public class AddExtensionMojo extends AbstractMojo {
|
||||
|
||||
/**
|
||||
* The Maven project which will define and configure the quarkus-maven-plugin
|
||||
*/
|
||||
@Parameter(defaultValue = "${project}")
|
||||
protected MavenProject project;
|
||||
public class AddExtensionMojo extends BuildFileMojoBase {
|
||||
|
||||
/**
|
||||
* The list of extensions to be added.
|
||||
@@ -47,31 +39,51 @@ public class AddExtensionMojo extends AbstractMojo {
|
||||
String extension;
|
||||
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException {
|
||||
protected void validateParameters() throws MojoExecutionException {
|
||||
if ((StringUtils.isBlank(extension) && (extensions == null || extensions.isEmpty())) // None are set
|
||||
|| (!StringUtils.isBlank(extension) && extensions != null && !extensions.isEmpty())) { // Both are set
|
||||
throw new MojoExecutionException("Either the `extension` or `extensions` parameter must be set");
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> ext = new HashSet<>();
|
||||
if (extensions != null && !extensions.isEmpty()) {
|
||||
ext.addAll(extensions);
|
||||
} else {
|
||||
// Parse the "extension" just in case it contains several comma-separated values
|
||||
// https://github.com/quarkusio/quarkus/issues/2393
|
||||
ext.addAll(Arrays.stream(extension.split(",")).map(s -> s.trim()).collect(Collectors.toSet()));
|
||||
}
|
||||
@Override
|
||||
public void doExecute(BuildFile buildFile) throws MojoExecutionException {
|
||||
|
||||
boolean closeBuildFile = false;
|
||||
try {
|
||||
Model model = project.getOriginalModel().clone();
|
||||
File pomFile = new File(model.getPomFile().getAbsolutePath());
|
||||
AddExtensionResult result = new AddExtensions(new FileProjectWriter(pomFile.getParentFile()))
|
||||
.addExtensions(ext.stream().map(String::trim).collect(Collectors.toSet()));
|
||||
if (!result.succeeded()) {
|
||||
throw new MojoExecutionException("Unable to add extensions");
|
||||
if (buildFile == null) {
|
||||
try {
|
||||
buildFile = BuildTool.MAVEN.createBuildFile(new FileProjectWriter(project.getBasedir()));
|
||||
} catch (IOException e) {
|
||||
throw new MojoExecutionException("Failed initialize project configuration tools", e);
|
||||
}
|
||||
}
|
||||
Set<String> ext = new HashSet<>();
|
||||
if (extensions != null && !extensions.isEmpty()) {
|
||||
ext.addAll(extensions);
|
||||
} else {
|
||||
// Parse the "extension" just in case it contains several comma-separated values
|
||||
// https://github.com/quarkusio/quarkus/issues/2393
|
||||
ext.addAll(Arrays.stream(extension.split(",")).map(s -> s.trim()).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
try {
|
||||
final AddExtensionResult result = new AddExtensions(buildFile)
|
||||
.addExtensions(ext.stream().map(String::trim).collect(Collectors.toSet()));
|
||||
if (!result.succeeded()) {
|
||||
throw new MojoExecutionException("Unable to add extensions");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new MojoExecutionException("Unable to update the pom.xml file", e);
|
||||
}
|
||||
} finally {
|
||||
if (closeBuildFile && buildFile != null) {
|
||||
try {
|
||||
buildFile.close();
|
||||
} catch (IOException e) {
|
||||
getLog().debug("Failed to close " + buildFile, e);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new MojoExecutionException("Unable to update the pom.xml file", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
package io.quarkus.maven;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.Component;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
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.repository.RemoteRepository;
|
||||
|
||||
import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
|
||||
import io.quarkus.cli.commands.file.BuildFile;
|
||||
import io.quarkus.cli.commands.file.GradleBuildFile;
|
||||
import io.quarkus.cli.commands.file.MavenBuildFile;
|
||||
import io.quarkus.cli.commands.writer.FileProjectWriter;
|
||||
import io.quarkus.platform.tools.config.QuarkusPlatformConfig;
|
||||
|
||||
public abstract class BuildFileMojoBase extends AbstractMojo {
|
||||
|
||||
@Parameter(defaultValue = "${project}")
|
||||
protected MavenProject project;
|
||||
|
||||
@Component
|
||||
protected RepositorySystem repoSystem;
|
||||
|
||||
@Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
|
||||
protected RepositorySystemSession repoSession;
|
||||
|
||||
@Parameter(defaultValue = "${project.remoteProjectRepositories}", readonly = true, required = true)
|
||||
protected List<RemoteRepository> repos;
|
||||
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException {
|
||||
|
||||
validateParameters();
|
||||
|
||||
final MavenArtifactResolver mvn;
|
||||
try {
|
||||
mvn = MavenArtifactResolver.builder().setRepositorySystem(repoSystem).setRepositorySystemSession(repoSession)
|
||||
.setRemoteRepositories(repos).build();
|
||||
} catch (Exception e) {
|
||||
throw new MojoExecutionException("Failed to initialize maven artifact resolver", e);
|
||||
}
|
||||
|
||||
BuildFile buildFile = null;
|
||||
try {
|
||||
if (project.getFile() != null) {
|
||||
// Maven project
|
||||
@SuppressWarnings("resource")
|
||||
final MavenBuildFile mvnBuild = new MavenBuildFile(new FileProjectWriter(project.getBasedir()));
|
||||
buildFile = mvnBuild;
|
||||
|
||||
if (QuarkusPlatformConfig.hasGlobalDefault()) {
|
||||
getLog().warn("The Quarkus platform default configuration has already been initialized.");
|
||||
} else {
|
||||
Artifact descrArtifact = null;
|
||||
for (Dependency dep : mvnBuild.getManagedDependencies()) {
|
||||
if (!dep.getScope().equals("import") && !dep.getType().equals("pom")) {
|
||||
continue;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
Artifact jsonArtifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getClassifier(),
|
||||
"json", bomVersion);
|
||||
try {
|
||||
jsonArtifact = mvn.resolve(jsonArtifact).getArtifact();
|
||||
} catch (Exception e) {
|
||||
getLog().debug("Failed to resolve JSON descriptor as " + jsonArtifact);
|
||||
jsonArtifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId() + "-descriptor-json",
|
||||
dep.getClassifier(), "json", bomVersion);
|
||||
try {
|
||||
jsonArtifact = mvn.resolve(jsonArtifact).getArtifact();
|
||||
} catch (Exception e1) {
|
||||
getLog().debug("Failed to resolve JSON descriptor as " + jsonArtifact);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
descrArtifact = jsonArtifact;
|
||||
break;
|
||||
}
|
||||
|
||||
if (descrArtifact != null) {
|
||||
getLog().debug("Quarkus platform JSON descriptor artifact: " + descrArtifact);
|
||||
CreateUtils.setupQuarkusJsonPlatformDescriptor(mvn, descrArtifact, getLog());
|
||||
}
|
||||
}
|
||||
} else if (new File(project.getBasedir(), "build.gradle").exists()
|
||||
|| new File(project.getBasedir(), "build.gradle.kts").exists()) {
|
||||
// Gradle project
|
||||
buildFile = new GradleBuildFile(new FileProjectWriter(project.getBasedir()));
|
||||
}
|
||||
|
||||
if (!QuarkusPlatformConfig.hasGlobalDefault()) {
|
||||
CreateUtils.setupQuarkusJsonPlatformDescriptor(mvn,
|
||||
new DefaultArtifact(CreateUtils.DEFAULT_PLATFORM_GROUP_ID, CreateUtils.DEFAULT_PLATFORM_ARTIFACT_ID,
|
||||
null, "json", CreateUtils.resolvePluginInfo(BuildFileMojoBase.class).getVersion()),
|
||||
getLog());
|
||||
}
|
||||
|
||||
doExecute(buildFile);
|
||||
} catch (IOException e) {
|
||||
throw new MojoExecutionException("Failed to initialize project reading tools", e);
|
||||
} finally {
|
||||
if (buildFile != null) {
|
||||
try {
|
||||
buildFile.close();
|
||||
} catch (IOException e) {
|
||||
getLog().debug("Failed to close " + buildFile, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void validateParameters() throws MojoExecutionException {
|
||||
}
|
||||
|
||||
protected abstract void doExecute(BuildFile buildFile) throws MojoExecutionException;
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
@@ -35,6 +36,9 @@ import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.apache.maven.project.DefaultProjectBuildingRequest;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuilder;
|
||||
import org.eclipse.aether.RepositorySystem;
|
||||
import org.eclipse.aether.RepositorySystemSession;
|
||||
import org.eclipse.aether.repository.RemoteRepository;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
|
||||
import io.quarkus.cli.commands.AddExtensionResult;
|
||||
@@ -54,7 +58,11 @@ import io.quarkus.maven.utilities.MojoUtils;
|
||||
@Mojo(name = "create", requiresProject = false)
|
||||
public class CreateProjectMojo extends AbstractMojo {
|
||||
|
||||
public static final String PLUGIN_KEY = MojoUtils.getPluginGroupId() + ":" + MojoUtils.getPluginArtifactId();
|
||||
private static String pluginKey;
|
||||
|
||||
public static String getPluginKey() {
|
||||
return pluginKey == null ? pluginKey = MojoUtils.getPluginGroupId() + ":" + MojoUtils.getPluginArtifactId() : pluginKey;
|
||||
}
|
||||
|
||||
private static final String DEFAULT_GROUP_ID = "org.acme.quarkus.sample";
|
||||
|
||||
@@ -70,6 +78,15 @@ public class CreateProjectMojo extends AbstractMojo {
|
||||
@Parameter(property = "projectVersion")
|
||||
private String projectVersion;
|
||||
|
||||
@Parameter(property = "platformGroupId", defaultValue = CreateUtils.DEFAULT_PLATFORM_GROUP_ID)
|
||||
private String platformGroupId;
|
||||
|
||||
@Parameter(property = "platformArtifactId", defaultValue = CreateUtils.DEFAULT_PLATFORM_ARTIFACT_ID)
|
||||
private String platformArtifactId;
|
||||
|
||||
@Parameter(property = "platformVersion", required = false)
|
||||
private String platformVersion;
|
||||
|
||||
@Parameter(property = "path")
|
||||
private String path;
|
||||
|
||||
@@ -97,8 +114,21 @@ public class CreateProjectMojo extends AbstractMojo {
|
||||
@Component
|
||||
private ProjectBuilder projectBuilder;
|
||||
|
||||
@Component
|
||||
private RepositorySystem repoSystem;
|
||||
|
||||
@Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
|
||||
private RepositorySystemSession repoSession;
|
||||
|
||||
@Parameter(defaultValue = "${project.remoteProjectRepositories}", readonly = true, required = true)
|
||||
private List<RemoteRepository> repos;
|
||||
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException {
|
||||
|
||||
CreateUtils.setupQuarkusJsonPlatformDescriptor(repoSystem, repoSession, repos, platformGroupId, platformArtifactId,
|
||||
platformVersion, getLog());
|
||||
|
||||
// We detect the Maven version during the project generation to indicate the user immediately that the installed
|
||||
// version may not be supported.
|
||||
mavenVersionEnforcer.ensureMavenVersion(getLog(), session);
|
||||
@@ -179,7 +209,8 @@ public class CreateProjectMojo extends AbstractMojo {
|
||||
if (success) {
|
||||
printUserInstructions(projectRoot);
|
||||
} else {
|
||||
throw new MojoExecutionException("the project was created but it was unable to add the extensions");
|
||||
throw new MojoExecutionException(
|
||||
"The project was created but (some of) the requested extensions couldn't be added.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,46 @@
|
||||
package io.quarkus.maven;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
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.repository.RemoteRepository;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import io.quarkus.bootstrap.resolver.AppModelResolverException;
|
||||
import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
|
||||
import io.quarkus.bootstrap.util.ZipUtils;
|
||||
import io.quarkus.platform.descriptor.QuarkusPlatformDescriptor;
|
||||
import io.quarkus.platform.descriptor.loader.QuarkusPlatformDescriptorLoaderContext;
|
||||
import io.quarkus.platform.descriptor.loader.json.util.QuarkusJsonDescriptorUtils;
|
||||
import io.quarkus.platform.descriptor.loader.legacy.QuarkusLegacyPlatformDescriptor;
|
||||
import io.quarkus.platform.descriptor.loader.legacy.QuarkusLegacyPlatformDescriptorLoader;
|
||||
import io.quarkus.platform.tools.MessageWriter;
|
||||
import io.quarkus.platform.tools.config.QuarkusPlatformConfig;
|
||||
import io.quarkus.platform.tools.maven.MojoMessageWriter;
|
||||
|
||||
public final class CreateUtils {
|
||||
|
||||
public static final String DEFAULT_PLATFORM_GROUP_ID = "io.quarkus";
|
||||
public static final String DEFAULT_PLATFORM_ARTIFACT_ID = "quarkus-bom-descriptor-json";
|
||||
|
||||
private CreateUtils() {
|
||||
//Not to be constructed
|
||||
}
|
||||
@@ -13,4 +50,157 @@ public final class CreateUtils {
|
||||
className.substring(className.lastIndexOf(".") + 1));
|
||||
return "/" + resourceClassName[0].toLowerCase();
|
||||
}
|
||||
|
||||
public static void setupQuarkusJsonPlatformDescriptor(
|
||||
RepositorySystem repoSystem, RepositorySystemSession repoSession, List<RemoteRepository> repos,
|
||||
String platformGroupId, String platformArtifactId, String defaultPlatformVersion,
|
||||
final Log log)
|
||||
throws MojoExecutionException {
|
||||
|
||||
final MavenArtifactResolver mvn;
|
||||
try {
|
||||
mvn = MavenArtifactResolver.builder()
|
||||
.setRepositorySystem(repoSystem)
|
||||
.setRepositorySystemSession(repoSession)
|
||||
.setRemoteRepositories(repos)
|
||||
.build();
|
||||
} catch (AppModelResolverException e) {
|
||||
throw new MojoExecutionException("Failed to initialize artifact resolver", e);
|
||||
}
|
||||
|
||||
final Artifact platformArtifact = new DefaultArtifact(platformGroupId, platformArtifactId, null, "json",
|
||||
defaultPlatformVersion);
|
||||
|
||||
setupQuarkusJsonPlatformDescriptor(mvn, platformArtifact, log);
|
||||
}
|
||||
|
||||
public static void setupQuarkusJsonPlatformDescriptor(MavenArtifactResolver mvn, Artifact platformArtifact, final Log log)
|
||||
throws MojoExecutionException {
|
||||
|
||||
if (platformArtifact.getVersion() == null || platformArtifact.getVersion().isEmpty()) {
|
||||
platformArtifact = platformArtifact.setVersion(resolvePluginInfo(CreateUtils.class).getVersion());
|
||||
}
|
||||
|
||||
final MessageWriter msgWriter = new MojoMessageWriter(log);
|
||||
QuarkusPlatformDescriptor platformDescr;
|
||||
try {
|
||||
platformDescr = QuarkusJsonDescriptorUtils.loadDescriptor(mvn, platformArtifact, msgWriter);
|
||||
} catch (Throwable t) {
|
||||
log.warn(
|
||||
"The JSON platform descriptor couldn't be loaded for " + platformArtifact
|
||||
+ ". Falling back to the legacy platform descriptor.");
|
||||
platformDescr = newLegacyDescriptor(msgWriter);
|
||||
}
|
||||
QuarkusPlatformConfig.defaultConfigBuilder()
|
||||
.setPlatformDescriptor(platformDescr)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static void setupQuarkusLegacyPlatformDescriptor(Log log) {
|
||||
QuarkusPlatformConfig.defaultConfigBuilder()
|
||||
.setPlatformDescriptor(newLegacyDescriptor(new MojoMessageWriter(log)))
|
||||
.build();
|
||||
}
|
||||
|
||||
private static QuarkusLegacyPlatformDescriptor newLegacyDescriptor(final MessageWriter msgWriter) {
|
||||
return new QuarkusLegacyPlatformDescriptorLoader().load(new QuarkusPlatformDescriptorLoaderContext() {
|
||||
@Override
|
||||
public MessageWriter getMessageWriter() {
|
||||
return msgWriter;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Plugin resolvePluginInfo(Class<?> cls) throws MojoExecutionException {
|
||||
final String pluginClassPath = cls.getName().replace('.', '/') + ".class";
|
||||
URL url = Thread.currentThread().getContextClassLoader().getResource(pluginClassPath);
|
||||
if (url == null) {
|
||||
throw new MojoExecutionException("Failed to locate the origin of " + cls);
|
||||
}
|
||||
String classLocation = url.toExternalForm();
|
||||
if (url.getProtocol().equals("jar")) {
|
||||
classLocation = classLocation.substring(4, classLocation.length() - pluginClassPath.length() - 2);
|
||||
try (FileSystem fs = ZipUtils.newFileSystem(toPath(classLocation))) {
|
||||
return resolvePluginInfo(fs.getPath("META-INF", "maven", "plugin.xml"));
|
||||
} catch (Exception e) {
|
||||
throw new MojoExecutionException("Failed to resolve plugin version for " + classLocation, e);
|
||||
}
|
||||
} else {
|
||||
classLocation = classLocation.substring(0, classLocation.length() - pluginClassPath.length());
|
||||
return resolvePluginInfo(toPath(classLocation));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Plugin resolvePluginInfo(Path pluginXml) throws MojoExecutionException {
|
||||
if (!Files.exists(pluginXml)) {
|
||||
throw new MojoExecutionException("Failed to locate " + pluginXml);
|
||||
}
|
||||
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
try {
|
||||
final DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
try (InputStream is = Files.newInputStream(pluginXml)) {
|
||||
final Document doc = db.parse(is);
|
||||
final Node pluginNode = getElement(doc.getChildNodes(), "plugin");
|
||||
final Plugin plugin = new Plugin();
|
||||
plugin.setGroupId(getChildElementTextValue(pluginNode, "groupId"));
|
||||
plugin.setArtifactId(getChildElementTextValue(pluginNode, "artifactId"));
|
||||
plugin.setVersion(getChildElementTextValue(pluginNode, "version"));
|
||||
return plugin;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
throw new MojoExecutionException("Failed to parse " + pluginXml, t);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getChildElementTextValue(final Node parentNode, String childName) throws MojoExecutionException {
|
||||
final Node node = getElement(parentNode.getChildNodes(), childName);
|
||||
final String text = getText(node);
|
||||
if (text.isEmpty()) {
|
||||
throw new MojoExecutionException(
|
||||
"The " + parentNode.getNodeName() + " element description is missing child " + childName);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private static Path toPath(String classLocation) throws MojoExecutionException {
|
||||
try {
|
||||
return Paths.get(new URL(classLocation).toURI());
|
||||
} catch (Throwable e) {
|
||||
throw new MojoExecutionException(
|
||||
"Failed to create an instance of " + Path.class.getName() + " from " + classLocation, e);
|
||||
}
|
||||
}
|
||||
|
||||
private static Node getElement(NodeList nodeList, String name) throws MojoExecutionException {
|
||||
for (int i = 0; i < nodeList.getLength(); ++i) {
|
||||
final Node item = nodeList.item(i);
|
||||
if (item.getNodeType() == Node.ELEMENT_NODE
|
||||
&& (name.equals(item.getNodeName()) || name.equals(item.getLocalName()))) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
throw new MojoExecutionException("Failed to locate element " + name);
|
||||
}
|
||||
|
||||
private static String getText(Node node) {
|
||||
if (!node.hasChildNodes()) {
|
||||
return "";
|
||||
}
|
||||
StringBuffer result = new StringBuffer();
|
||||
NodeList list = node.getChildNodes();
|
||||
for (int i = 0; i < list.getLength(); i++) {
|
||||
Node subnode = list.item(i);
|
||||
if (subnode.getNodeType() == Node.TEXT_NODE) {
|
||||
result.append(subnode.getNodeValue());
|
||||
} else if (subnode.getNodeType() == Node.CDATA_SECTION_NODE) {
|
||||
result.append(subnode.getNodeValue());
|
||||
} else if (subnode.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
|
||||
// Recurse into the subtree for text
|
||||
// (and ignore comments)
|
||||
result.append(getText(subnode));
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,6 +165,15 @@ public class GenerateExtensionsJsonMojo extends AbstractMojo {
|
||||
}
|
||||
final Path p = metaInfDir.resolve(BootstrapConstants.EXTENSION_PROPS_JSON_FILE_NAME);
|
||||
if (!Files.exists(p)) {
|
||||
final Path props = metaInfDir.resolve(BootstrapConstants.DESCRIPTOR_FILE_NAME);
|
||||
if (Files.exists(props)) {
|
||||
extJsonBuilder.add(Json.createObjectBuilder()
|
||||
.add("artifactId", artifact.getArtifactId())
|
||||
.add("groupId", artifact.getGroupId())
|
||||
.add("version", artifact.getVersion())
|
||||
.add("name", artifact.getArtifactId())
|
||||
.build());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
processPlatformArtifact(artifact, p, extJsonBuilder);
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
package io.quarkus.maven;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
import io.quarkus.cli.commands.ListExtensions;
|
||||
import io.quarkus.cli.commands.file.BuildFile;
|
||||
import io.quarkus.cli.commands.file.GradleBuildFile;
|
||||
import io.quarkus.cli.commands.file.MavenBuildFile;
|
||||
import io.quarkus.cli.commands.writer.FileProjectWriter;
|
||||
|
||||
/**
|
||||
* List the available extensions.
|
||||
@@ -22,13 +16,7 @@ import io.quarkus.cli.commands.writer.FileProjectWriter;
|
||||
* You can list all extension or just installable. Choose between 3 output formats: name, concise and full.
|
||||
*/
|
||||
@Mojo(name = "list-extensions", requiresProject = false)
|
||||
public class ListExtensionsMojo extends AbstractMojo {
|
||||
|
||||
/**
|
||||
* The Maven project which will define and configure the quarkus-maven-plugin
|
||||
*/
|
||||
@Parameter(defaultValue = "${project}")
|
||||
protected MavenProject project;
|
||||
public class ListExtensionsMojo extends BuildFileMojoBase {
|
||||
|
||||
/**
|
||||
* List all extensions or just the installable.
|
||||
@@ -50,25 +38,11 @@ public class ListExtensionsMojo extends AbstractMojo {
|
||||
protected String searchPattern;
|
||||
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException {
|
||||
public void doExecute(BuildFile buildFile) throws MojoExecutionException {
|
||||
try {
|
||||
FileProjectWriter writer = null;
|
||||
BuildFile buildFile = null;
|
||||
// Even when we have no pom, the project is not null, but it's set to `org.apache.maven:standalone-pom:1`
|
||||
// So we need to also check for the project's file (the pom.xml file).
|
||||
if (project != null && project.getFile() != null) {
|
||||
writer = new FileProjectWriter(project.getBasedir());
|
||||
if (new File(project.getBasedir(), "build.gradle").exists()
|
||||
|| new File(project.getBasedir(), "build.gradle.kts").exists()) {
|
||||
buildFile = new GradleBuildFile(writer);
|
||||
} else {
|
||||
buildFile = new MavenBuildFile(writer);
|
||||
}
|
||||
}
|
||||
new ListExtensions(buildFile).listExtensions(all, format,
|
||||
searchPattern);
|
||||
new ListExtensions(buildFile).listExtensions(all, format, searchPattern);
|
||||
} catch (IOException e) {
|
||||
throw new MojoExecutionException("Unable to list extensions", e);
|
||||
throw new MojoExecutionException("Failed to list extensions", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package io.quarkus.platform.tools.maven;
|
||||
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
|
||||
import io.quarkus.platform.tools.MessageWriter;
|
||||
|
||||
public class MojoMessageWriter implements MessageWriter {
|
||||
|
||||
private final Log log;
|
||||
|
||||
public MojoMessageWriter(Log log) {
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String msg) {
|
||||
log.info(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String msg) {
|
||||
log.error(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugEnabled() {
|
||||
return log.isDebugEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String msg) {
|
||||
log.debug(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String msg) {
|
||||
log.warn(msg);
|
||||
}
|
||||
}
|
||||
38
devtools/platform-descriptor-json/pom.xml
Normal file
38
devtools/platform-descriptor-json/pom.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-devtools-all</artifactId>
|
||||
<version>999-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>quarkus-platform-descriptor-json</artifactId>
|
||||
<name>Quarkus - Dev tools - Platform Descriptor - JSON</name>
|
||||
|
||||
<build>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-devtools-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-devtools-templates</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-bootstrap-core</artifactId>
|
||||
</dependency>
|
||||
<!-- extensions reader -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,8 @@
|
||||
package io.quarkus.platform.descriptor.loader.json.impl;
|
||||
|
||||
public class QuarkusJsonPlatformBom {
|
||||
|
||||
public String groupId;
|
||||
public String artifactId;
|
||||
public String version;
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package io.quarkus.platform.descriptor.loader.json.impl;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
|
||||
import io.quarkus.bootstrap.util.ZipUtils;
|
||||
import io.quarkus.dependencies.Extension;
|
||||
import io.quarkus.platform.descriptor.QuarkusPlatformDescriptor;
|
||||
import io.quarkus.platform.descriptor.ResourceInputStreamConsumer;
|
||||
import io.quarkus.platform.tools.DefaultMessageWriter;
|
||||
import io.quarkus.platform.tools.MessageWriter;
|
||||
|
||||
public class QuarkusJsonPlatformDescriptor implements QuarkusPlatformDescriptor {
|
||||
|
||||
private String bomGroupId;
|
||||
private String bomArtifactId;
|
||||
private String bomVersion;
|
||||
private String quarkusVersion;
|
||||
|
||||
private List<Extension> extensions = Collections.emptyList();
|
||||
private List<Dependency> managedDeps = Collections.emptyList();
|
||||
private Path templatesJar;
|
||||
private MessageWriter log;
|
||||
|
||||
public QuarkusJsonPlatformDescriptor() {
|
||||
}
|
||||
|
||||
public void setBom(QuarkusJsonPlatformBom bom) {
|
||||
bomGroupId = bom.groupId;
|
||||
bomArtifactId = bom.artifactId;
|
||||
bomVersion = bom.version;
|
||||
}
|
||||
|
||||
public void setExtensions(List<Extension> extensions) {
|
||||
this.extensions = extensions;
|
||||
}
|
||||
|
||||
void setManagedDependencies(List<Dependency> managedDeps) {
|
||||
this.managedDeps = managedDeps;
|
||||
}
|
||||
|
||||
void setTemplatesJar(Path templatesJar) {
|
||||
this.templatesJar = templatesJar;
|
||||
}
|
||||
|
||||
void setMessageWriter(MessageWriter log) {
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
void setQuarkusVersion(String quarkusVersion) {
|
||||
this.quarkusVersion = quarkusVersion;
|
||||
}
|
||||
|
||||
private MessageWriter getLog() {
|
||||
return log == null ? log = new DefaultMessageWriter() : log;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBomGroupId() {
|
||||
return bomGroupId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBomArtifactId() {
|
||||
return bomArtifactId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBomVersion() {
|
||||
return bomVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuarkusVersion() {
|
||||
return quarkusVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dependency> getManagedDependencies() {
|
||||
return managedDeps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Extension> getExtensions() {
|
||||
return extensions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplate(String name) {
|
||||
getLog().debug("Loading Quarkus project template %s", name);
|
||||
if (templatesJar == null) {
|
||||
return null;
|
||||
}
|
||||
try (FileSystem fs = ZipUtils.newFileSystem(templatesJar)) {
|
||||
final Path p = fs.getPath(name);
|
||||
if (!Files.exists(p)) {
|
||||
throw new RuntimeException("Failed to locate template " + name + " in " + templatesJar);
|
||||
}
|
||||
try (BufferedReader reader = Files.newBufferedReader(p)) {
|
||||
return reader.lines().collect(Collectors.joining("\n"));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to resolve template " + name, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T loadResource(String name, ResourceInputStreamConsumer<T> consumer) throws IOException {
|
||||
getLog().debug("Loading Quarkus platform resource %s", name);
|
||||
try (FileSystem fs = ZipUtils.newFileSystem(templatesJar)) {
|
||||
final Path p = fs.getPath(name);
|
||||
if (!Files.exists(p)) {
|
||||
throw new IOException("Failed to locate resource " + name);
|
||||
}
|
||||
try (InputStream is = Files.newInputStream(p)) {
|
||||
return consumer.handle(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package io.quarkus.platform.descriptor.loader.json.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.aether.artifact.Artifact;
|
||||
import org.eclipse.aether.artifact.DefaultArtifact;
|
||||
import org.eclipse.aether.graph.Dependency;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import io.quarkus.bootstrap.resolver.AppModelResolverException;
|
||||
import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
|
||||
import io.quarkus.platform.descriptor.loader.json.QuarkusJsonPlatformDescriptorLoader;
|
||||
import io.quarkus.platform.descriptor.loader.json.QuarkusJsonPlatformDescriptorLoaderContext;
|
||||
|
||||
public class QuarkusJsonPlatformDescriptorLoaderImpl
|
||||
implements QuarkusJsonPlatformDescriptorLoader<QuarkusJsonPlatformDescriptor> {
|
||||
|
||||
private static final String IO_QUARKUS = "io.quarkus";
|
||||
private static final String TEMPLATES_ARTIFACT_ID = "quarkus-devtools-templates";
|
||||
private static final String QUARKUS_CORE_ARTIFACT_ID = "quarkus-core";
|
||||
|
||||
@Override
|
||||
public QuarkusJsonPlatformDescriptor load(QuarkusJsonPlatformDescriptorLoaderContext context) {
|
||||
context.getMessageWriter().debug("Loading Platform Descriptor from JSON %s", context.getJsonDescriptorFile());
|
||||
final QuarkusJsonPlatformDescriptor platform;
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper()
|
||||
.enable(JsonParser.Feature.ALLOW_COMMENTS)
|
||||
.enable(JsonParser.Feature.ALLOW_NUMERIC_LEADING_ZEROS);
|
||||
try (InputStream is = Files.newInputStream(context.getJsonDescriptorFile())) {
|
||||
platform = mapper.readValue(is, QuarkusJsonPlatformDescriptor.class);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Unable to load " + context.getJsonDescriptorFile(), e);
|
||||
}
|
||||
|
||||
final DefaultArtifact platformBom = new DefaultArtifact(platform.getBomGroupId(), platform.getBomArtifactId(), null,
|
||||
"pom", platform.getBomVersion());
|
||||
String quarkusVersion = null;
|
||||
try {
|
||||
final List<Dependency> managedDeps = context.getMavenArtifactResolver().resolveDescriptor(platformBom)
|
||||
.getManagedDependencies();
|
||||
final List<org.apache.maven.model.Dependency> convertedDeps = new ArrayList<>(managedDeps.size());
|
||||
for (Dependency dep : managedDeps) {
|
||||
final org.apache.maven.model.Dependency converted = new org.apache.maven.model.Dependency();
|
||||
convertedDeps.add(converted);
|
||||
final Artifact artifact = dep.getArtifact();
|
||||
converted.setGroupId(artifact.getGroupId());
|
||||
converted.setArtifactId(artifact.getArtifactId());
|
||||
converted.setVersion(artifact.getVersion());
|
||||
converted.setClassifier(artifact.getClassifier());
|
||||
converted.setType(artifact.getExtension());
|
||||
converted.setScope(dep.getScope());
|
||||
converted.setOptional(dep.isOptional());
|
||||
// exclusions aren't added yet
|
||||
|
||||
if (artifact.getArtifactId().equals(QUARKUS_CORE_ARTIFACT_ID)
|
||||
&& artifact.getGroupId().equals(IO_QUARKUS)) {
|
||||
quarkusVersion = artifact.getVersion();
|
||||
}
|
||||
}
|
||||
platform.setManagedDependencies(convertedDeps);
|
||||
} catch (AppModelResolverException e) {
|
||||
throw new RuntimeException("Failed to read descriptor of " + platformBom, e);
|
||||
}
|
||||
|
||||
if (quarkusVersion == null) {
|
||||
throw new RuntimeException("Failed to determine the Quarkus version for the platform " + platformBom);
|
||||
}
|
||||
platform.setTemplatesJar(resolveArtifact(context.getMavenArtifactResolver(),
|
||||
new DefaultArtifact(IO_QUARKUS, TEMPLATES_ARTIFACT_ID, null, "jar", quarkusVersion)));
|
||||
platform.setQuarkusVersion(quarkusVersion);
|
||||
platform.setMessageWriter(context.getMessageWriter());
|
||||
|
||||
return platform;
|
||||
}
|
||||
|
||||
private static Path resolveArtifact(MavenArtifactResolver mvn, Artifact artifact) {
|
||||
try {
|
||||
return mvn.resolve(artifact).getArtifact().getFile().toPath();
|
||||
} catch (AppModelResolverException e) {
|
||||
throw new RuntimeException("Failed to resolve " + artifact, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package io.quarkus.platform.descriptor.loader.json.util;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.eclipse.aether.artifact.Artifact;
|
||||
|
||||
import io.quarkus.bootstrap.resolver.AppModelResolverException;
|
||||
import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
|
||||
import io.quarkus.platform.descriptor.loader.json.QuarkusJsonPlatformDescriptorLoaderContext;
|
||||
import io.quarkus.platform.descriptor.loader.json.impl.QuarkusJsonPlatformDescriptor;
|
||||
import io.quarkus.platform.descriptor.loader.json.impl.QuarkusJsonPlatformDescriptorLoaderImpl;
|
||||
import io.quarkus.platform.tools.DefaultMessageWriter;
|
||||
import io.quarkus.platform.tools.MessageWriter;
|
||||
|
||||
public class QuarkusJsonDescriptorUtils {
|
||||
|
||||
public static QuarkusJsonPlatformDescriptor loadDescriptor(MavenArtifactResolver mvn, Artifact jsonArtifact) {
|
||||
return loadDescriptor(mvn, jsonArtifact, new DefaultMessageWriter());
|
||||
}
|
||||
|
||||
public static QuarkusJsonPlatformDescriptor loadDescriptor(MavenArtifactResolver mvn, Artifact jsonArtifact,
|
||||
final MessageWriter log) {
|
||||
try {
|
||||
jsonArtifact = mvn.resolve(jsonArtifact).getArtifact();
|
||||
} catch (AppModelResolverException e1) {
|
||||
throw new RuntimeException("Failed to resolve Quarkus platform JSON descriptor " + jsonArtifact, e1);
|
||||
}
|
||||
final Path platformJson = jsonArtifact.getFile().toPath();
|
||||
|
||||
log.debug("Quarkus platform JSON descriptor %s", jsonArtifact);
|
||||
return new QuarkusJsonPlatformDescriptorLoaderImpl()
|
||||
.load(new QuarkusJsonPlatformDescriptorLoaderContext() {
|
||||
|
||||
@Override
|
||||
public MessageWriter getMessageWriter() {
|
||||
return log;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getJsonDescriptorFile() {
|
||||
return platformJson;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MavenArtifactResolver getMavenArtifactResolver() {
|
||||
return mvn;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
io.quarkus.platform.descriptor.loader.json.impl.QuarkusJsonPlatformDescriptorLoaderImpl
|
||||
55
devtools/platform-descriptor-legacy/pom.xml
Normal file
55
devtools/platform-descriptor-legacy/pom.xml
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-devtools-all</artifactId>
|
||||
<version>999-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>quarkus-platform-descriptor-legacy</artifactId>
|
||||
<name>Quarkus - Dev tools - Platform Descriptor - Legacy</name>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/filtered</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${project.basedir}/../../bom/runtime</directory>
|
||||
<targetPath>quarkus-bom</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<includes>
|
||||
<include>pom.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-platform-descriptor-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-devtools-templates</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-bootstrap-core</artifactId>
|
||||
</dependency>
|
||||
<!-- extensions reader -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -6,7 +6,8 @@
|
||||
"database-connection-pool"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-agroal"
|
||||
"artifactId": "quarkus-agroal",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Amazon DynamoDB",
|
||||
@@ -17,7 +18,8 @@
|
||||
"amazon"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-amazon-dynamodb"
|
||||
"artifactId": "quarkus-amazon-dynamodb",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Apache Kafka Client",
|
||||
@@ -25,7 +27,8 @@
|
||||
"kafka"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-kafka-client"
|
||||
"artifactId": "quarkus-kafka-client",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Apache Kafka Streams",
|
||||
@@ -34,7 +37,8 @@
|
||||
"kafka-streams"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-kafka-streams"
|
||||
"artifactId": "quarkus-kafka-streams",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Apache Tika",
|
||||
@@ -43,7 +47,8 @@
|
||||
"parser"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-tika"
|
||||
"artifactId": "quarkus-tika",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Arc",
|
||||
@@ -56,6 +61,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-arc",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/cdi-reference"
|
||||
},
|
||||
{
|
||||
@@ -66,7 +72,8 @@
|
||||
"amazon"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-amazon-lambda"
|
||||
"artifactId": "quarkus-amazon-lambda",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Artemis Core",
|
||||
@@ -75,7 +82,8 @@
|
||||
"artemis"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-artemis-core"
|
||||
"artifactId": "quarkus-artemis-core",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Artemis JMS",
|
||||
@@ -84,7 +92,8 @@
|
||||
"artemis"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-artemis-jms"
|
||||
"artifactId": "quarkus-artemis-jms",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Flyway",
|
||||
@@ -95,6 +104,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-flyway",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/flyway-guide"
|
||||
},
|
||||
{
|
||||
@@ -107,6 +117,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-hibernate-orm",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/hibernate-orm-guide"
|
||||
},
|
||||
{
|
||||
@@ -119,6 +130,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-hibernate-orm-panache",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/hibernate-orm-panache-guide"
|
||||
},
|
||||
{
|
||||
@@ -132,6 +144,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-hibernate-search-elasticsearch",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/hibernate-search-guide"
|
||||
},
|
||||
{
|
||||
@@ -144,6 +157,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-hibernate-validator",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/validation-guide"
|
||||
},
|
||||
{
|
||||
@@ -155,6 +169,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-infinispan-client",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/infinispan-client-guide"
|
||||
},
|
||||
{
|
||||
@@ -175,7 +190,8 @@
|
||||
"h2"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-jdbc-h2"
|
||||
"artifactId": "quarkus-jdbc-h2",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "JDBC Driver - MariaDB",
|
||||
@@ -185,7 +201,8 @@
|
||||
"mariadb"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-jdbc-mariadb"
|
||||
"artifactId": "quarkus-jdbc-mariadb",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "JDBC Driver - MySQL",
|
||||
@@ -195,7 +212,8 @@
|
||||
"mysql"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-jdbc-mysql"
|
||||
"artifactId": "quarkus-jdbc-mysql",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "JDBC Driver - PostgreSQL",
|
||||
@@ -205,7 +223,8 @@
|
||||
"postgresql"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-jdbc-postgresql"
|
||||
"artifactId": "quarkus-jdbc-postgresql",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "JDBC Driver - Microsoft SQL Server",
|
||||
@@ -216,7 +235,8 @@
|
||||
"sql-server"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-jdbc-mssql"
|
||||
"artifactId": "quarkus-jdbc-mssql",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Jackson",
|
||||
@@ -225,7 +245,8 @@
|
||||
"json"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-jackson"
|
||||
"artifactId": "quarkus-jackson",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "JAXB",
|
||||
@@ -233,7 +254,8 @@
|
||||
"jaxb"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-jaxb"
|
||||
"artifactId": "quarkus-jaxb",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "JGit",
|
||||
@@ -241,7 +263,8 @@
|
||||
"git"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-jgit"
|
||||
"artifactId": "quarkus-jgit",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "JSON-B",
|
||||
@@ -252,6 +275,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-jsonb",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/rest-json-guide"
|
||||
},
|
||||
{
|
||||
@@ -262,7 +286,8 @@
|
||||
"json"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-jsonp"
|
||||
"artifactId": "quarkus-jsonp",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "OpenID Connect",
|
||||
@@ -272,6 +297,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-oidc",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/oidc-guide"
|
||||
},
|
||||
{
|
||||
@@ -283,6 +309,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-kogito",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/kogito-guide"
|
||||
},
|
||||
{
|
||||
@@ -292,6 +319,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-kotlin",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/kotlin"
|
||||
},
|
||||
{
|
||||
@@ -301,6 +329,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-kubernetes",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/kubernetes-guide"
|
||||
},
|
||||
{
|
||||
@@ -309,7 +338,8 @@
|
||||
"kubernetes-client"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-kubernetes-client"
|
||||
"artifactId": "quarkus-kubernetes-client",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Mailer",
|
||||
@@ -319,6 +349,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-mailer",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/sending-emails"
|
||||
},
|
||||
{
|
||||
@@ -330,7 +361,8 @@
|
||||
"datastore"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-mongodb-client"
|
||||
"artifactId": "quarkus-mongodb-client",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "MongoDB with Panache",
|
||||
@@ -342,7 +374,8 @@
|
||||
"panache"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-mongodb-panache"
|
||||
"artifactId": "quarkus-mongodb-panache",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Narayana JTA - Transaction manager",
|
||||
@@ -357,6 +390,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-narayana-jta",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/transaction-guide"
|
||||
},
|
||||
{
|
||||
@@ -373,6 +407,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-narayana-stm",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/stm-guide"
|
||||
},
|
||||
{
|
||||
@@ -384,7 +419,8 @@
|
||||
"datastore"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-neo4j"
|
||||
"artifactId": "quarkus-neo4j",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Reactive PostgreSQL Client",
|
||||
@@ -398,7 +434,8 @@
|
||||
"postgresql"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-reactive-pg-client"
|
||||
"artifactId": "quarkus-reactive-pg-client",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Reactive MySQL Client",
|
||||
@@ -412,7 +449,8 @@
|
||||
"mysql"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-reactive-mysql-client"
|
||||
"artifactId": "quarkus-reactive-mysql-client",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "RESTEasy",
|
||||
@@ -425,6 +463,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-resteasy",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/rest-json-guide"
|
||||
},
|
||||
{
|
||||
@@ -436,7 +475,8 @@
|
||||
"jaxb"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-resteasy-jaxb"
|
||||
"artifactId": "quarkus-resteasy-jaxb",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "RESTEasy - Jackson",
|
||||
@@ -450,7 +490,8 @@
|
||||
"jackson"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-resteasy-jackson"
|
||||
"artifactId": "quarkus-resteasy-jackson",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "RESTEasy - JSON-B",
|
||||
@@ -465,6 +506,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-resteasy-jsonb",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/rest-json-guide"
|
||||
},
|
||||
{
|
||||
@@ -473,7 +515,8 @@
|
||||
"scala"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-scala"
|
||||
"artifactId": "quarkus-scala",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Scheduler",
|
||||
@@ -484,6 +527,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-scheduler",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/scheduled-guide"
|
||||
},
|
||||
{
|
||||
@@ -493,6 +537,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-elytron-security-properties-file",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/elytron-properties-guide"
|
||||
},
|
||||
{
|
||||
@@ -502,7 +547,8 @@
|
||||
"jdbc"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-elytron-security-jdbc"
|
||||
"artifactId": "quarkus-elytron-security-jdbc",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Security OAuth2",
|
||||
@@ -511,7 +557,8 @@
|
||||
"oauth2"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-elytron-security-oauth2"
|
||||
"artifactId": "quarkus-elytron-security-oauth2",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "SmallRye Context Propagation",
|
||||
@@ -524,7 +571,8 @@
|
||||
"reactive"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-smallrye-context-propagation"
|
||||
"artifactId": "quarkus-smallrye-context-propagation",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "SmallRye Fault Tolerance",
|
||||
@@ -536,7 +584,8 @@
|
||||
"bulkhead"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-smallrye-fault-tolerance"
|
||||
"artifactId": "quarkus-smallrye-fault-tolerance",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "SmallRye Health",
|
||||
@@ -550,6 +599,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-smallrye-health",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/health-guide"
|
||||
},
|
||||
{
|
||||
@@ -562,6 +612,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-smallrye-jwt",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/jwt-guide"
|
||||
},
|
||||
{
|
||||
@@ -576,6 +627,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-smallrye-metrics",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/metrics-guide"
|
||||
},
|
||||
{
|
||||
@@ -587,6 +639,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-smallrye-openapi",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/openapi-swaggerui-guide"
|
||||
},
|
||||
{
|
||||
@@ -600,6 +653,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-smallrye-opentracing",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/opentracing-guide"
|
||||
},
|
||||
{
|
||||
@@ -614,7 +668,8 @@
|
||||
"reactive"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-smallrye-reactive-streams-operators"
|
||||
"artifactId": "quarkus-smallrye-reactive-streams-operators",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "SmallRye Reactive Type Converters",
|
||||
@@ -627,7 +682,8 @@
|
||||
"reactive"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-smallrye-reactive-type-converters"
|
||||
"artifactId": "quarkus-smallrye-reactive-type-converters",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "SmallRye Reactive Messaging",
|
||||
@@ -638,6 +694,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-smallrye-reactive-messaging",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/async-message-passing"
|
||||
},
|
||||
{
|
||||
@@ -649,6 +706,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-smallrye-reactive-messaging-kafka",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/kafka-guide"
|
||||
},
|
||||
{
|
||||
@@ -659,6 +717,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-smallrye-reactive-messaging-amqp",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/amqp-guide"
|
||||
},
|
||||
{
|
||||
@@ -668,7 +727,8 @@
|
||||
"reactive-mqtt"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-smallrye-reactive-messaging-mqtt"
|
||||
"artifactId": "quarkus-smallrye-reactive-messaging-mqtt",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "REST Client",
|
||||
@@ -679,6 +739,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-rest-client",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/rest-client-guide"
|
||||
},
|
||||
{
|
||||
@@ -688,6 +749,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-spring-di",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/spring-di-guide"
|
||||
},
|
||||
{
|
||||
@@ -697,6 +759,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-spring-web",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/spring-web-guide"
|
||||
},
|
||||
{
|
||||
@@ -706,6 +769,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-spring-data-jpa",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/spring-data-jpa-guide"
|
||||
},
|
||||
{
|
||||
@@ -715,6 +779,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-swagger-ui",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/openapi-swaggerui-guide"
|
||||
},
|
||||
{
|
||||
@@ -725,7 +790,8 @@
|
||||
"servlet"
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-undertow"
|
||||
"artifactId": "quarkus-undertow",
|
||||
"version": "${project.version}"
|
||||
},
|
||||
{
|
||||
"name": "Undertow WebSockets",
|
||||
@@ -740,6 +806,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-undertow-websockets",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/websocket-guide"
|
||||
},
|
||||
{
|
||||
@@ -761,6 +828,7 @@
|
||||
],
|
||||
"groupId": "io.quarkus",
|
||||
"artifactId": "quarkus-vertx",
|
||||
"version": "${project.version}",
|
||||
"guide": "https://quarkus.io/guides/using-vertx"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,166 @@
|
||||
package io.quarkus.platform.descriptor.loader.legacy;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import io.quarkus.dependencies.Extension;
|
||||
import io.quarkus.platform.descriptor.QuarkusPlatformDescriptor;
|
||||
import io.quarkus.platform.descriptor.ResourceInputStreamConsumer;
|
||||
import io.quarkus.platform.tools.MessageWriter;
|
||||
|
||||
public class QuarkusLegacyPlatformDescriptor implements QuarkusPlatformDescriptor {
|
||||
|
||||
private final ClassLoader cl;
|
||||
private final String groupId;
|
||||
private final String artifactId;
|
||||
private final String version;
|
||||
private final List<Extension> extensions;
|
||||
private final List<Dependency> managedDeps;
|
||||
private final MessageWriter log;
|
||||
|
||||
public QuarkusLegacyPlatformDescriptor(ClassLoader cl, MessageWriter log) {
|
||||
this.cl = cl;
|
||||
this.log = log;
|
||||
|
||||
// Resolve the BOM model
|
||||
InputStream is = cl.getResourceAsStream("quarkus-bom/pom.xml");
|
||||
if (is == null) {
|
||||
throw new RuntimeException("Failed to locate quarkus-bom/pom.xml");
|
||||
}
|
||||
final Model bomModel;
|
||||
try {
|
||||
bomModel = new MavenXpp3Reader().read(is);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to parse application POM model", e);
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
groupId = resolveGroupId(bomModel);
|
||||
artifactId = bomModel.getArtifactId();
|
||||
version = resolveVersion(bomModel);
|
||||
managedDeps = bomModel.getDependencyManagement().getDependencies(); // This is raw but that's exactly how it used to be
|
||||
|
||||
// Load extensions
|
||||
is = cl.getResourceAsStream("extensions.json");
|
||||
if (is == null) {
|
||||
throw new RuntimeException("Failed to locate quarkus-bom/pom.xml");
|
||||
}
|
||||
ObjectMapper mapper = new ObjectMapper()
|
||||
.enable(JsonParser.Feature.ALLOW_COMMENTS)
|
||||
.enable(JsonParser.Feature.ALLOW_NUMERIC_LEADING_ZEROS);
|
||||
try {
|
||||
extensions = mapper.readValue(
|
||||
is,
|
||||
new TypeReference<List<Extension>>() {
|
||||
// Do nothing.
|
||||
});
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed parse extensions.json", e);
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBomGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBomArtifactId() {
|
||||
return artifactId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBomVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuarkusVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dependency> getManagedDependencies() {
|
||||
return managedDeps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Extension> getExtensions() {
|
||||
return extensions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplate(String name) {
|
||||
log.debug("[Legacy Quarkus Platform Descriptor] Loading Quarkus project template %s", name);
|
||||
InputStream is = cl.getResourceAsStream(name);
|
||||
if (is == null) {
|
||||
throw new RuntimeException("Failed to locate template " + name);
|
||||
}
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
|
||||
return reader.lines().collect(Collectors.joining("\n"));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to read template " + name, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T loadResource(String name, ResourceInputStreamConsumer<T> consumer) throws IOException {
|
||||
log.debug("[Legacy Quarkus Platform Descriptor] Loading Quarkus platform resource %s", name);
|
||||
InputStream is = cl.getResourceAsStream(name);
|
||||
if (is == null) {
|
||||
throw new IOException("Failed to locate resource " + name);
|
||||
}
|
||||
try {
|
||||
return consumer.handle(is);
|
||||
} finally {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
|
||||
private static String resolveGroupId(Model model) {
|
||||
String groupId = model.getGroupId();
|
||||
if (groupId != null) {
|
||||
return groupId;
|
||||
}
|
||||
groupId = model.getParent() == null ? null : model.getParent().getGroupId();
|
||||
if (groupId == null) {
|
||||
throw new IllegalStateException("Failed to resolve groupId for the platform BOM");
|
||||
}
|
||||
return groupId;
|
||||
}
|
||||
|
||||
private static String resolveVersion(Model model) {
|
||||
String version = model.getVersion();
|
||||
if (version != null) {
|
||||
return version;
|
||||
}
|
||||
version = model.getParent() == null ? null : model.getParent().getVersion();
|
||||
if (version == null) {
|
||||
throw new IllegalStateException("Failed to resolve version for the platform BOM");
|
||||
}
|
||||
return version;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package io.quarkus.platform.descriptor.loader.legacy;
|
||||
|
||||
import io.quarkus.platform.descriptor.loader.QuarkusPlatformDescriptorLoader;
|
||||
import io.quarkus.platform.descriptor.loader.QuarkusPlatformDescriptorLoaderContext;
|
||||
|
||||
public class QuarkusLegacyPlatformDescriptorLoader
|
||||
implements QuarkusPlatformDescriptorLoader<QuarkusLegacyPlatformDescriptor, QuarkusPlatformDescriptorLoaderContext> {
|
||||
|
||||
@Override
|
||||
public QuarkusLegacyPlatformDescriptor load(QuarkusPlatformDescriptorLoaderContext context) {
|
||||
context.getMessageWriter().debug("Loading legacy Quarkus Core Platform descriptor");
|
||||
return new QuarkusLegacyPlatformDescriptor(Thread.currentThread().getContextClassLoader(), context.getMessageWriter());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
io.quarkus.platform.descriptor.loader.legacy.QuarkusLegacyPlatformDescriptorLoader
|
||||
@@ -20,13 +20,14 @@
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>core-extensions-json</module>
|
||||
<module>common-core</module>
|
||||
<module>bom-descriptor-json</module>
|
||||
<module>platform-descriptor-json</module>
|
||||
<module>platform-descriptor-legacy</module>
|
||||
<module>extension-plugin</module>
|
||||
<module>common</module>
|
||||
<module>maven</module>
|
||||
<module>gradle</module>
|
||||
<module>aesh</module>
|
||||
<module>reflection-agent</module>
|
||||
<module>templates</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
||||
28
devtools/templates/pom.xml
Normal file
28
devtools/templates/pom.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-devtools-all</artifactId>
|
||||
<version>999-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>quarkus-devtools-templates</artifactId>
|
||||
<name>Quarkus - Dev tools - Templates</name>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/filtered</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1,6 +1,5 @@
|
||||
# Values used in the generated projects
|
||||
doc-root=https://quarkus.io
|
||||
bom-artifactId=quarkus-bom
|
||||
# Versions defined in jboss-parent
|
||||
rest-assured-version=${rest-assured.version}
|
||||
compiler-plugin-version=${compiler-plugin.version}
|
||||
@@ -20,9 +20,9 @@
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${plugin_groupId}</groupId>
|
||||
<groupId>${bom_groupId}</groupId>
|
||||
<artifactId>${bom_artifactId}</artifactId>
|
||||
<version>${quarkus.version}</version>
|
||||
<version>${bom_version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
@@ -219,4 +219,4 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
</project>
|
||||
@@ -43,7 +43,7 @@ public class AllConfigGenerator {
|
||||
String version = args[0];
|
||||
|
||||
// This is where we produce the entire list of extensions
|
||||
File jsonFile = new File("devtools/core-extensions-json/target/extensions.json");
|
||||
File jsonFile = new File("devtools/bom-descriptor-json/target/extensions.json");
|
||||
if (!jsonFile.exists()) {
|
||||
System.err.println("WARNING: could not generate all-config file because extensions list is missing: " + jsonFile);
|
||||
System.exit(0);
|
||||
@@ -199,4 +199,4 @@ public class AllConfigGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,4 +12,4 @@ public class ExtensionJson {
|
||||
public static class Extension {
|
||||
public String name, groupId, artifactId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
{
|
||||
"name": "Amazon DynamoDB",
|
||||
"name": "Amazon DynamoDB client",
|
||||
"labels": [
|
||||
"dynamodb",
|
||||
"dynamo",
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
<artifactId>quarkus-arc</artifactId>
|
||||
<name>Quarkus - ArC - Runtime</name>
|
||||
<description>Build time CDI dependency injection</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
{
|
||||
"name": "Arc",
|
||||
"name": "ArC",
|
||||
"shortName": "CDI",
|
||||
"labels": [
|
||||
"arc",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
{
|
||||
"name": "JDBC based Security",
|
||||
"name": "Elytron Security JDBC Realm",
|
||||
"labels": [
|
||||
"security",
|
||||
"jdbc"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
{
|
||||
"name": "Security OAuth2",
|
||||
"name": "Elytron Security OAuth 2.0",
|
||||
"labels": [
|
||||
"security",
|
||||
"oauth2"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
{
|
||||
"name": "MongoDB Client",
|
||||
"name": "MongoDB client",
|
||||
"labels": [
|
||||
"mongo",
|
||||
"mongodb",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
{
|
||||
"name": "Reactive MySQL Client",
|
||||
"name": "Reactive MySQL client",
|
||||
"labels": [
|
||||
"eclipse-vert.x",
|
||||
"vertx",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
{
|
||||
"name": "Reactive PostgreSQL Client",
|
||||
"name": "Reactive PostgreSQL client",
|
||||
"labels": [
|
||||
"eclipse-vert.x",
|
||||
"vertx",
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
<artifactId>quarkus-rest-client</artifactId>
|
||||
<name>Quarkus - REST client - Runtime</name>
|
||||
<description>Call REST services</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
{
|
||||
"name": "RESTEasy - Jackson",
|
||||
"name": "RESTEasy Jackson",
|
||||
"labels": [
|
||||
"resteasy-jackson",
|
||||
"jaxrs-json",
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
<artifactId>quarkus-resteasy-jsonb</artifactId>
|
||||
<name>Quarkus - RESTEasy - JSON-B - Runtime</name>
|
||||
<description>JSON-B serialization support for RESTEasy</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
{
|
||||
"name": "RESTEasy - JSON-B",
|
||||
"name": "RESTEasy JSON-B",
|
||||
"labels": [
|
||||
"resteasy-jsonb",
|
||||
"jaxrs-json",
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
<artifactId>quarkus-resteasy</artifactId>
|
||||
<name>Quarkus - RESTEasy - Runtime</name>
|
||||
<description>REST framework implementing JAX-RS and more</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
{
|
||||
"name": "RESTEasy",
|
||||
"name": "RESTEasy JAX-RS",
|
||||
"shortName": "jax-rs",
|
||||
"labels": [
|
||||
"resteasy",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
{
|
||||
"name": "Scheduler",
|
||||
"name": "Scheduler - tasks",
|
||||
"labels": [
|
||||
"scheduler",
|
||||
"tasks",
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
<artifactId>quarkus-smallrye-jwt</artifactId>
|
||||
<name>Quarkus - SmallRye JWT - Runtime</name>
|
||||
<description>Secure your applications with JSON Web Token</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
<artifactId>quarkus-smallrye-openapi</artifactId>
|
||||
<name>Quarkus - SmallRye OpenAPI - Runtime</name>
|
||||
<description>Document your REST APIs with OpenAPI - comes with Swagger UI</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
{
|
||||
"name": "Quarkus Extension for Spring Data API",
|
||||
"name": "Quarkus Extension for Spring Data JPA API",
|
||||
"labels": [
|
||||
"spring-data"
|
||||
],
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
<artifactId>quarkus-undertow-websockets</artifactId>
|
||||
<name>Quarkus - Undertow - WebSockets - Runtime</name>
|
||||
<description>WebSocket support</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
<artifactId>quarkus-undertow</artifactId>
|
||||
<name>Quarkus - Undertow - Runtime</name>
|
||||
<description>Support for servlets</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
{
|
||||
"name": "Undertow",
|
||||
"name": "Undertow Servlet",
|
||||
"shortName": "servlet",
|
||||
"labels": [
|
||||
"undertow",
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.eclipse.aether.RepositorySystem;
|
||||
import org.eclipse.aether.RepositorySystemSession;
|
||||
import org.eclipse.aether.repository.RemoteRepository;
|
||||
@@ -72,15 +73,12 @@ public class ExtensionDescriptorMojo extends AbstractMojo {
|
||||
@Parameter(required = true, defaultValue = "${project.groupId}:${project.artifactId}-deployment:${project.version}")
|
||||
private String deployment;
|
||||
|
||||
@Parameter(readonly = true, required = true, defaultValue = "${project.groupId}")
|
||||
private String projectGroupId;
|
||||
|
||||
@Parameter(readonly = true, required = true, defaultValue = "${project.artifactId}")
|
||||
private String projectArtifactId;
|
||||
|
||||
@Parameter(required = true, defaultValue = "${project.build.outputDirectory}/META-INF/quarkus-extension.json")
|
||||
private File extensionJson;
|
||||
|
||||
@Parameter(defaultValue = "${project}")
|
||||
protected MavenProject project;
|
||||
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException {
|
||||
|
||||
@@ -98,16 +96,13 @@ public class ExtensionDescriptorMojo extends AbstractMojo {
|
||||
|
||||
// extension.json
|
||||
JsonObject extObject;
|
||||
boolean groupIdProvided = false;
|
||||
boolean artifactIdProvided = false;
|
||||
if(extensionJson == null) {
|
||||
extensionJson = new File(outputDirectory, "META-INF" + File.separator + BootstrapConstants.EXTENSION_PROPS_JSON_FILE_NAME);
|
||||
}
|
||||
|
||||
if(extensionJson.exists()) {
|
||||
try(BufferedReader reader = Files.newBufferedReader(extensionJson.toPath())) {
|
||||
extObject = Json.parse(reader).asObject();
|
||||
groupIdProvided = extObject.get("groupId") != null;
|
||||
artifactIdProvided = extObject.get("artifactId") != null;
|
||||
} catch (IOException e) {
|
||||
throw new MojoExecutionException("Failed to parse " + extensionJson, e);
|
||||
}
|
||||
@@ -115,11 +110,48 @@ public class ExtensionDescriptorMojo extends AbstractMojo {
|
||||
extObject = Json.object();
|
||||
}
|
||||
|
||||
if(!groupIdProvided) {
|
||||
extObject.add("groupId", projectGroupId);
|
||||
if(extObject.get("groupId") == null) {
|
||||
extObject.add("groupId", project.getGroupId());
|
||||
}
|
||||
if(!artifactIdProvided) {
|
||||
extObject.add("artifactId", projectArtifactId);
|
||||
if(extObject.get("artifactId") == null) {
|
||||
extObject.add("artifactId", project.getArtifactId());
|
||||
}
|
||||
if(extObject.get("version") == null) {
|
||||
extObject.add("version", project.getVersion());
|
||||
}
|
||||
if (extObject.get("name") == null) {
|
||||
if (project.getName() != null) {
|
||||
extObject.add("name", project.getName());
|
||||
} else {
|
||||
String defaultName = extObject.getString("artifactId", null);
|
||||
int i = 0;
|
||||
if (defaultName.startsWith("quarkus-")) {
|
||||
i = "quarkus-".length();
|
||||
}
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
boolean startWord = true;
|
||||
while (i < defaultName.length()) {
|
||||
final char c = defaultName.charAt(i++);
|
||||
if (c == '-') {
|
||||
if (!startWord) {
|
||||
buf.append(' ');
|
||||
startWord = true;
|
||||
}
|
||||
} else if (startWord) {
|
||||
buf.append(Character.toUpperCase(c));
|
||||
startWord = false;
|
||||
} else {
|
||||
buf.append(c);
|
||||
}
|
||||
}
|
||||
defaultName = buf.toString();
|
||||
getLog().warn("Extension name has not been provided for " + extObject.getString("groupId", null) + ":"
|
||||
+ extObject.getString("artifactId", null) + "! Using '" + defaultName + "' as the default one.");
|
||||
extObject.set("name", defaultName);
|
||||
}
|
||||
}
|
||||
if(extObject.get("description") == null && project.getDescription() != null) {
|
||||
extObject.add("description", project.getDescription());
|
||||
}
|
||||
|
||||
try (BufferedWriter bw = Files.newBufferedWriter(output.resolve(BootstrapConstants.EXTENSION_PROPS_JSON_FILE_NAME))) {
|
||||
|
||||
@@ -6,59 +6,23 @@
|
||||
|
||||
<parent>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-devtools-all</artifactId>
|
||||
<artifactId>quarkus-tools-parent</artifactId>
|
||||
<version>999-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>quarkus-devtools-common</artifactId>
|
||||
<name>Quarkus - Dev tools - Common Code</name>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/filtered</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${project.basedir}/../../bom/runtime</directory>
|
||||
<targetPath>quarkus-bom</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<includes>
|
||||
<include>pom.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-extension-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-extension-list</id>
|
||||
<goals>
|
||||
<goal>extension-list</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<name>Quarkus - Dev tools - Common</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-devtools-common-core</artifactId>
|
||||
<artifactId>quarkus-bootstrap-core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-platform-descriptor-api</artifactId>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
@@ -86,6 +50,16 @@
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-devtools-templates</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-platform-descriptor-legacy</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- extensions reader -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
@@ -1,7 +1,5 @@
|
||||
package io.quarkus.cli.commands;
|
||||
|
||||
import static io.quarkus.maven.utilities.MojoUtils.readPom;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -19,6 +17,7 @@ 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 {
|
||||
|
||||
@@ -236,13 +235,6 @@ public class AddExtensions {
|
||||
}
|
||||
|
||||
private List<Dependency> getDependenciesFromBom() {
|
||||
try {
|
||||
return readPom(getClass().getResourceAsStream("/quarkus-bom/pom.xml"))
|
||||
.getDependencyManagement()
|
||||
.getDependencies();
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Unable to read the BOM file: " + e.getMessage(), e);
|
||||
}
|
||||
return QuarkusPlatformConfig.getGlobalDefault().getPlatformDescriptor().getManagedDependencies();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package io.quarkus.cli.commands;
|
||||
|
||||
import static io.quarkus.generators.ProjectGenerator.BOM_ARTIFACT_ID;
|
||||
import static io.quarkus.generators.ProjectGenerator.BOM_GROUP_ID;
|
||||
import static io.quarkus.generators.ProjectGenerator.BOM_VERSION;
|
||||
import static io.quarkus.generators.ProjectGenerator.BUILD_FILE;
|
||||
import static io.quarkus.generators.ProjectGenerator.CLASS_NAME;
|
||||
import static io.quarkus.generators.ProjectGenerator.IS_SPRING;
|
||||
@@ -9,7 +12,11 @@ import static io.quarkus.generators.ProjectGenerator.PROJECT_GROUP_ID;
|
||||
import static io.quarkus.generators.ProjectGenerator.PROJECT_VERSION;
|
||||
import static io.quarkus.generators.ProjectGenerator.QUARKUS_VERSION;
|
||||
import static io.quarkus.generators.ProjectGenerator.SOURCE_TYPE;
|
||||
import static io.quarkus.maven.utilities.MojoUtils.getBomGroupId;
|
||||
import static io.quarkus.maven.utilities.MojoUtils.getBomArtifactId;
|
||||
import static io.quarkus.maven.utilities.MojoUtils.getBomVersionForTemplate;
|
||||
import static io.quarkus.maven.utilities.MojoUtils.getPluginVersion;
|
||||
import static io.quarkus.maven.utilities.MojoUtils.getQuarkusVersion;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
@@ -102,7 +109,10 @@ public class CreateProject {
|
||||
context.put(PROJECT_GROUP_ID, groupId);
|
||||
context.put(PROJECT_ARTIFACT_ID, artifactId);
|
||||
context.put(PROJECT_VERSION, version);
|
||||
context.put(QUARKUS_VERSION, getPluginVersion());
|
||||
context.put(BOM_GROUP_ID, getBomGroupId());
|
||||
context.put(BOM_ARTIFACT_ID, getBomArtifactId());
|
||||
context.put(BOM_VERSION, getBomVersionForTemplate());
|
||||
context.put(QUARKUS_VERSION, getQuarkusVersion());
|
||||
context.put(SOURCE_TYPE, sourceType);
|
||||
context.put(BUILD_FILE, getBuildFile());
|
||||
|
||||
@@ -97,7 +97,6 @@ public class ListExtensions {
|
||||
|
||||
private void display(Extension extension, final Map<String, Dependency> installed, boolean all,
|
||||
Consumer<String[]> formatter) {
|
||||
|
||||
if (!all && installed.containsKey(String.format("%s:%s", extension.getGroupId(), extension.getArtifactId()))) {
|
||||
return;
|
||||
}
|
||||
@@ -39,9 +39,16 @@ public abstract class BuildFile implements Closeable {
|
||||
public boolean addDependency(List<Dependency> dependenciesFromBom, Extension extension) throws IOException {
|
||||
if (!hasDependency(extension)) {
|
||||
PRINTER.ok(" Adding extension " + extension.managementKey());
|
||||
addDependencyInBuildFile(extension
|
||||
.toDependency(containsBOM() &&
|
||||
isDefinedInBom(dependenciesFromBom, extension)));
|
||||
Dependency dep;
|
||||
if(containsBOM() && isDefinedInBom(dependenciesFromBom, extension)) {
|
||||
dep = extension.toDependency(true);
|
||||
} else {
|
||||
dep = extension.toDependency(false);
|
||||
if(getProperty(MojoUtils.QUARKUS_VERSION_PROPERTY_NAME) != null) {
|
||||
dep.setVersion(MojoUtils.QUARKUS_VERSION_PROPERTY);
|
||||
}
|
||||
}
|
||||
addDependencyInBuildFile(dep);
|
||||
return true;
|
||||
} else {
|
||||
PRINTER.noop(" Skipping already present extension " + extension.managementKey());
|
||||
@@ -92,6 +99,7 @@ public abstract class BuildFile implements Closeable {
|
||||
|
||||
if (dependencies != null) {
|
||||
final List<Dependency> listed = dependencies.stream()
|
||||
// THIS ASSUMES EXTENSIONS' groupId is always 'io.quarkus' which is wrong
|
||||
.filter(new QuarkusDependencyPredicate())
|
||||
.collect(toList());
|
||||
|
||||
@@ -116,8 +124,7 @@ public abstract class BuildFile implements Closeable {
|
||||
|
||||
protected abstract List<Dependency> getManagedDependencies() throws IOException;
|
||||
|
||||
public abstract void completeFile(String groupId, String artifactId, String version)
|
||||
throws IOException;
|
||||
public abstract void completeFile(String groupId, String artifactId, String version) throws IOException;
|
||||
|
||||
public BuildTool getBuildTool() {
|
||||
return buildTool;
|
||||
@@ -13,8 +13,6 @@ import java.util.Scanner;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
import io.quarkus.cli.commands.writer.ProjectWriter;
|
||||
import io.quarkus.dependencies.Extension;
|
||||
import io.quarkus.generators.BuildTool;
|
||||
@@ -35,14 +33,14 @@ public class GradleBuildFile extends BuildFile {
|
||||
public void close() throws IOException {
|
||||
write(SETTINGS_GRADLE_PATH, getModel().getSettingsContent());
|
||||
write(BUILD_GRADLE_PATH, getModel().getBuildContent());
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
try ( ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||
getModel().getPropertiesContent().store(out, "Gradle properties");
|
||||
write(GRADLE_PROPERTIES_PATH, out.toString(StandardCharsets.UTF_8.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeFile(String groupId, String artifactId, String version)
|
||||
throws IOException {
|
||||
public void completeFile(String groupId, String artifactId, String version) throws IOException {
|
||||
completeSettingsContent(artifactId);
|
||||
completeBuildContent(groupId, version);
|
||||
completeProperties();
|
||||
@@ -3,6 +3,8 @@ package io.quarkus.cli.commands.file;
|
||||
import static io.quarkus.maven.utilities.MojoUtils.QUARKUS_VERSION_PROPERTY;
|
||||
import static io.quarkus.maven.utilities.MojoUtils.configuration;
|
||||
import static io.quarkus.maven.utilities.MojoUtils.getBomArtifactId;
|
||||
import static io.quarkus.maven.utilities.MojoUtils.getBomGroupId;
|
||||
import static io.quarkus.maven.utilities.MojoUtils.getBomVersionForTemplate;
|
||||
import static io.quarkus.maven.utilities.MojoUtils.getPluginArtifactId;
|
||||
import static io.quarkus.maven.utilities.MojoUtils.getPluginGroupId;
|
||||
import static io.quarkus.maven.utilities.MojoUtils.getPluginVersion;
|
||||
@@ -51,29 +53,35 @@ public class MavenBuildFile extends BuildFile {
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
ByteArrayOutputStream pomOutputStream = new ByteArrayOutputStream();
|
||||
MojoUtils.write(getModel(), pomOutputStream);
|
||||
write(BuildTool.MAVEN.getDependenciesFile(), pomOutputStream.toString("UTF-8"));
|
||||
if(getModel() == null) {
|
||||
return;
|
||||
}
|
||||
try (ByteArrayOutputStream pomOutputStream = new ByteArrayOutputStream()) {
|
||||
MojoUtils.write(getModel(), pomOutputStream);
|
||||
write(BuildTool.MAVEN.getDependenciesFile(), pomOutputStream.toString("UTF-8"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addDependencyInBuildFile(Dependency dependency) throws IOException {
|
||||
getModel().addDependency(dependency);
|
||||
if(getModel() != null) {
|
||||
getModel().addDependency(dependency);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasDependency(Extension extension) throws IOException {
|
||||
return MojoUtils.hasDependency(getModel(), extension.getGroupId(), extension.getArtifactId());
|
||||
return getModel() != null && MojoUtils.hasDependency(getModel(), extension.getGroupId(), extension.getArtifactId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dependency> getDependencies() throws IOException {
|
||||
return getModel().getDependencies();
|
||||
return getModel() == null ? Collections.emptyList() : getModel().getDependencies();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean containsBOM() throws IOException {
|
||||
if (getModel().getDependencyManagement() == null) {
|
||||
if(getModel() == null || getModel().getDependencyManagement() == null) {
|
||||
return false;
|
||||
}
|
||||
List<Dependency> dependencies = getModel().getDependencyManagement().getDependencies();
|
||||
@@ -86,8 +94,7 @@ public class MavenBuildFile extends BuildFile {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeFile(String groupId, String artifactId, String version)
|
||||
throws IOException {
|
||||
public void completeFile(String groupId, String artifactId, String version) throws IOException {
|
||||
addVersionProperty();
|
||||
addBom();
|
||||
addMainPluginConfig();
|
||||
@@ -102,15 +109,15 @@ public class MavenBuildFile extends BuildFile {
|
||||
getModel().setDependencyManagement(dm);
|
||||
} else {
|
||||
hasBom = dm.getDependencies().stream()
|
||||
.anyMatch(d -> d.getGroupId().equals(getPluginGroupId()) &&
|
||||
.anyMatch(d -> d.getGroupId().equals(getBomGroupId()) &&
|
||||
d.getArtifactId().equals(getBomArtifactId()));
|
||||
}
|
||||
|
||||
if (!hasBom) {
|
||||
Dependency bom = new Dependency();
|
||||
bom.setGroupId(getPluginGroupId());
|
||||
bom.setGroupId(getBomGroupId());
|
||||
bom.setArtifactId(getBomArtifactId());
|
||||
bom.setVersion(QUARKUS_VERSION_PROPERTY);
|
||||
bom.setVersion(getBomVersionForTemplate());
|
||||
bom.setType("pom");
|
||||
bom.setScope("import");
|
||||
|
||||
@@ -162,6 +169,9 @@ public class MavenBuildFile extends BuildFile {
|
||||
}
|
||||
|
||||
private boolean hasPlugin() throws IOException {
|
||||
if(getModel() == null) {
|
||||
return false;
|
||||
}
|
||||
List<Plugin> plugins = null;
|
||||
final Build build = getModel().getBuild();
|
||||
if (build != null) {
|
||||
@@ -181,11 +191,12 @@ public class MavenBuildFile extends BuildFile {
|
||||
}
|
||||
|
||||
private void addPluginManagementSection(Plugin plugin) throws IOException {
|
||||
if (getModel().getBuild() != null && getModel().getBuild().getPluginManagement() != null) {
|
||||
if (getModel().getBuild().getPluginManagement().getPlugins() == null) {
|
||||
getModel().getBuild().getPluginManagement().setPlugins(new ArrayList<>());
|
||||
final Build build = getModel().getBuild();
|
||||
if (build != null && build.getPluginManagement() != null) {
|
||||
if (build.getPluginManagement().getPlugins() == null) {
|
||||
build.getPluginManagement().setPlugins(new ArrayList<>());
|
||||
}
|
||||
getModel().getBuild().getPluginManagement().getPlugins().add(plugin);
|
||||
build.getPluginManagement().getPlugins().add(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,11 +222,14 @@ public class MavenBuildFile extends BuildFile {
|
||||
}
|
||||
|
||||
private boolean isParentPom() throws IOException {
|
||||
return "pom".equals(getModel().getPackaging());
|
||||
return getModel() != null && "pom".equals(getModel().getPackaging());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Dependency> getManagedDependencies() throws IOException {
|
||||
public List<Dependency> getManagedDependencies() throws IOException {
|
||||
if(getModel() == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final DependencyManagement managed = getModel().getDependencyManagement();
|
||||
return managed != null ? managed.getDependencies()
|
||||
: Collections.emptyList();
|
||||
@@ -223,6 +237,9 @@ public class MavenBuildFile extends BuildFile {
|
||||
|
||||
@Override
|
||||
public String getProperty(String propertyName) throws IOException {
|
||||
if(getModel() == null) {
|
||||
return null;
|
||||
}
|
||||
return getModel().getProperties().getProperty(propertyName);
|
||||
}
|
||||
|
||||
@@ -232,5 +249,4 @@ public class MavenBuildFile extends BuildFile {
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,9 @@ import java.util.Map;
|
||||
import io.quarkus.cli.commands.writer.ProjectWriter;
|
||||
|
||||
public interface ProjectGenerator {
|
||||
String BOM_GROUP_ID = "bom_groupId";
|
||||
String BOM_ARTIFACT_ID = "bom_artifactId";
|
||||
String BOM_VERSION = "bom_version";
|
||||
String PROJECT_GROUP_ID = "project_groupId";
|
||||
String PROJECT_ARTIFACT_ID = "project_artifactId";
|
||||
String PROJECT_VERSION = "project_version";
|
||||
@@ -2,24 +2,18 @@ package io.quarkus.generators.rest;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.quarkus.cli.commands.file.BuildFile;
|
||||
import io.quarkus.cli.commands.writer.ProjectWriter;
|
||||
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 {
|
||||
|
||||
@@ -126,23 +120,17 @@ public class BasicRestProjectGenerator implements ProjectGenerator {
|
||||
final String resourceType)
|
||||
throws IOException {
|
||||
if (!writer.exists(outputFilePath)) {
|
||||
String path = templateName.startsWith("/") ? templateName : "/" + templateName;
|
||||
URL resource = getClass().getResource(path);
|
||||
if (resource == null) {
|
||||
String path = templateName;//templateName.startsWith("/") ? templateName : "/" + templateName;
|
||||
String template = QuarkusPlatformConfig.getGlobalDefault().getPlatformDescriptor().getTemplate(path);
|
||||
if (template == null) {
|
||||
throw new IOException("Template resource is missing: " + path);
|
||||
}
|
||||
try (
|
||||
InputStream resourceStream = resource.openStream();
|
||||
InputStreamReader streamReader = new InputStreamReader(resourceStream, StandardCharsets.UTF_8);
|
||||
BufferedReader bufferedReader = new BufferedReader(streamReader)) {
|
||||
String template = bufferedReader.lines().collect(Collectors.joining("\n"));
|
||||
for (Entry<String, Object> e : context.entrySet()) {
|
||||
if (e.getValue() != null) { // Exclude null values (classname and path can be null)
|
||||
template = template.replace(format("${%s}", e.getKey()), e.getValue().toString());
|
||||
}
|
||||
for (Entry<String, Object> e : context.entrySet()) {
|
||||
if (e.getValue() != null) { // Exclude null values (classname and path can be null)
|
||||
template = template.replace(format("${%s}", e.getKey()), e.getValue().toString());
|
||||
}
|
||||
writer.write(outputFilePath, template);
|
||||
}
|
||||
writer.write(outputFilePath, template);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
@@ -21,11 +20,9 @@ import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import io.quarkus.dependencies.Extension;
|
||||
import io.quarkus.platform.descriptor.QuarkusPlatformDescriptor;
|
||||
import io.quarkus.platform.tools.config.QuarkusPlatformConfig;
|
||||
|
||||
/**
|
||||
* @author kameshs
|
||||
@@ -40,22 +37,39 @@ public class MojoUtils {
|
||||
public static final String KOTLIN_EXTENSION_NAME = "kotlin";
|
||||
public static final String SCALA_EXTENSION_NAME = "scala";
|
||||
|
||||
private static final String PLUGIN_VERSION_PROPERTY_NAME = "quarkus.version";
|
||||
public static final String QUARKUS_VERSION_PROPERTY = "${" + PLUGIN_VERSION_PROPERTY_NAME + "}";
|
||||
public static final String QUARKUS_VERSION_PROPERTY_NAME = "quarkus.version";
|
||||
public static final String QUARKUS_VERSION_PROPERTY = "${" + QUARKUS_VERSION_PROPERTY_NAME + "}";
|
||||
|
||||
private static final Properties properties = new Properties();
|
||||
private static Properties properties;
|
||||
|
||||
private static QuarkusPlatformDescriptor platformDescr;
|
||||
|
||||
private static QuarkusPlatformDescriptor getPlatformDescriptor() {
|
||||
return platformDescr == null ? platformDescr = QuarkusPlatformConfig.getGlobalDefault().getPlatformDescriptor() : platformDescr;
|
||||
}
|
||||
|
||||
private static Properties getProperties() {
|
||||
if(properties == null) {
|
||||
try {
|
||||
properties = getPlatformDescriptor().loadResource("quarkus.properties", is -> {
|
||||
final Properties props = new Properties();
|
||||
props.load(is);
|
||||
return props;
|
||||
});
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("The quarkus.properties file cannot be read", e);
|
||||
}
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
private MojoUtils() {
|
||||
// Avoid direct instantiation
|
||||
}
|
||||
|
||||
static {
|
||||
loadProperties();
|
||||
}
|
||||
|
||||
public static Map<String, String> getAllProperties() {
|
||||
Map<String, String> all = new HashMap<>();
|
||||
properties.stringPropertyNames().forEach(s -> all.put(s, properties.getProperty(s)));
|
||||
getProperties().stringPropertyNames().forEach(s -> all.put(s, getProperties().getProperty(s)));
|
||||
return all;
|
||||
}
|
||||
|
||||
@@ -68,11 +82,32 @@ public class MojoUtils {
|
||||
}
|
||||
|
||||
public static String getPluginVersion() {
|
||||
return get("plugin-version");
|
||||
return getPlatformDescriptor().getQuarkusVersion();
|
||||
}
|
||||
|
||||
public static String getBomArtifactId() {
|
||||
return get("bom-artifactId");
|
||||
return getPlatformDescriptor().getBomArtifactId();
|
||||
}
|
||||
|
||||
public static String getBomGroupId() {
|
||||
return getPlatformDescriptor().getBomGroupId();
|
||||
}
|
||||
|
||||
public static String getBomVersion() {
|
||||
return getPlatformDescriptor().getBomVersion();
|
||||
}
|
||||
|
||||
public static String getBomVersionForTemplate() {
|
||||
final String v = getBomVersion();
|
||||
if(v.equals(getQuarkusVersion())) {
|
||||
// this might not always work but at this point we're assuming the bom is coming from Quarkus itself
|
||||
return QUARKUS_VERSION_PROPERTY;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
public static String getQuarkusVersion() {
|
||||
return getPlatformDescriptor().getQuarkusVersion();
|
||||
}
|
||||
|
||||
public static String getProposedMavenVersion() {
|
||||
@@ -87,18 +122,8 @@ public class MojoUtils {
|
||||
return get("gradle-wrapper-version");
|
||||
}
|
||||
|
||||
private static void loadProperties() {
|
||||
URL url = MojoUtils.class.getClassLoader().getResource("quarkus.properties");
|
||||
Objects.requireNonNull(url);
|
||||
try (InputStream in = url.openStream()) {
|
||||
properties.load(in);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("The quarkus.properties file cannot be read", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String get(String key) {
|
||||
return properties.getProperty(key);
|
||||
return getProperties().getProperty(key);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,21 +263,7 @@ public class MojoUtils {
|
||||
}
|
||||
|
||||
public static List<Extension> loadExtensions() {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper()
|
||||
.enable(JsonParser.Feature.ALLOW_COMMENTS)
|
||||
.enable(JsonParser.Feature.ALLOW_NUMERIC_LEADING_ZEROS);
|
||||
List<Extension> extensions = mapper.readValue(
|
||||
MojoUtils.class.getClassLoader().getResourceAsStream("extensions.json"),
|
||||
new TypeReference<List<Extension>>() {
|
||||
// Do nothing.
|
||||
});
|
||||
//TODO This is temporary until "extensions.json" is the generated version
|
||||
extensions.forEach(e -> e.setVersion(MojoUtils.QUARKUS_VERSION_PROPERTY));
|
||||
return extensions;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Unable to load the extensions.json file", e);
|
||||
}
|
||||
return QuarkusPlatformConfig.getGlobalDefault().getPlatformDescriptor().getExtensions();
|
||||
}
|
||||
|
||||
public static String credentials(final Dependency d) {
|
||||
@@ -261,8 +272,8 @@ public class MojoUtils {
|
||||
|
||||
public static boolean checkProjectForMavenBuildPlugin(MavenProject project) {
|
||||
for (Plugin plugin : project.getBuildPlugins()) {
|
||||
if (plugin.getGroupId().equals(MojoUtils.getPluginGroupId())
|
||||
&& plugin.getArtifactId().equals(MojoUtils.getPluginArtifactId())) {
|
||||
if (plugin.getGroupId().equals("io.quarkus")
|
||||
&& plugin.getArtifactId().equals("quarkus-maven-plugin")) {
|
||||
for (PluginExecution pluginExecution : plugin.getExecutions()) {
|
||||
if (pluginExecution.getGoals().contains("build")) {
|
||||
return true;
|
||||
@@ -1,7 +1,5 @@
|
||||
package io.quarkus.maven.utilities;
|
||||
|
||||
import static io.quarkus.maven.utilities.MojoUtils.getPluginGroupId;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
@@ -9,6 +7,6 @@ import org.apache.maven.model.Dependency;
|
||||
public class QuarkusDependencyPredicate implements Predicate<Dependency> {
|
||||
@Override
|
||||
public boolean test(final Dependency d) {
|
||||
return d.getGroupId().equalsIgnoreCase(getPluginGroupId());
|
||||
return d.getGroupId().equalsIgnoreCase("io.quarkus");
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user