Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

First step to extract Maven-specific parts from the bootstrap core #9828

Merged
merged 1 commit into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import org.jboss.logging.Logger;

import io.quarkus.bootstrap.BootstrapException;
import io.quarkus.bootstrap.app.CuratedApplication;
import io.quarkus.bootstrap.model.AppArtifactKey;
import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException;
import io.quarkus.bootstrap.resolver.maven.workspace.LocalProject;

@SuppressWarnings("unused")
Expand All @@ -32,7 +32,7 @@ public void accept(CuratedApplication curatedApplication, Map<String, Object> st
}
devModeContext.getAdditionalModules().add(toModule(module.getValue()));
}
} catch (BootstrapException e) {
} catch (BootstrapMavenException e) {
log.error("Failed to load workspace, hot reload will not be available", e);
}

Expand Down
1 change: 1 addition & 0 deletions core/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
<parentFirstArtifact>org.graalvm.nativeimage:svm</parentFirstArtifact>
<parentFirstArtifact>io.quarkus:quarkus-bootstrap-core</parentFirstArtifact>
<parentFirstArtifact>io.quarkus:quarkus-development-mode-spi</parentFirstArtifact>
<parentFirstArtifact>io.quarkus:quarkus-bootstrap-app-model</parentFirstArtifact>
<parentFirstArtifact>org.jboss.logmanager:jboss-logmanager-embedded</parentFirstArtifact>
<parentFirstArtifact>org.jboss.logging:jboss-logging</parentFirstArtifact>
<parentFirstArtifact>org.ow2.asm:asm</parentFirstArtifact>
Expand Down
5 changes: 5 additions & 0 deletions devtools/gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ repositories {
mavenCentral()
}

configurations.all {
exclude group: 'io.quarkus', module: 'quarkus-bootstrap-maven-resolver'
}

dependencies {
api gradleApi()

implementation "io.quarkus:quarkus-bootstrap-core:${version}"
implementation "io.quarkus:quarkus-devtools-common:${version}"
implementation "io.quarkus:quarkus-platform-descriptor-json:${version}"
Expand Down
6 changes: 6 additions & 0 deletions devtools/gradle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bootstrap-core</artifactId>
<exclusions>
<exclusion>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bootstrap-maven-resolver</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.eclipse.aether.repository.RemoteRepository;
import org.fusesource.jansi.Ansi;

import io.quarkus.bootstrap.resolver.AppModelResolverException;
import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
import io.quarkus.cli.commands.AddExtensions;
import io.quarkus.cli.commands.CreateProject;
Expand Down Expand Up @@ -144,7 +143,7 @@ public void execute() throws MojoExecutionException {
.setRepositorySystem(repoSystem)
.setRepositorySystemSession(repoSession)
.setRemoteRepositories(repos).build();
} catch (AppModelResolverException e1) {
} catch (Exception e1) {
throw new MojoExecutionException("Failed to initialize Maven artifact resolver", e1);
}
final QuarkusPlatformDescriptor platform = CreateUtils.resolvePlatformDescriptor(bomGroupId, bomArtifactId, bomVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import io.quarkus.bootstrap.app.CuratedApplication;
import io.quarkus.bootstrap.app.QuarkusBootstrap;
import io.quarkus.bootstrap.model.AppArtifact;
import io.quarkus.bootstrap.resolver.AppModelResolverException;
import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
import io.quarkus.runner.bootstrap.GenerateConfigTask;

Expand Down Expand Up @@ -148,12 +147,9 @@ public void execute() throws MojoExecutionException {
Path configFile = new File(target, name).toPath();
curatedApplication.runInAugmentClassLoader(GenerateConfigTask.class.getName(),
Collections.singletonMap(GenerateConfigTask.CONFIG_FILE, configFile));

} catch (Exception e) {
throw new MojoExecutionException("Failed to generate config file", e);
}
} catch (AppModelResolverException e) {
throw new RuntimeException(e);
} catch (Exception e) {
throw new MojoExecutionException("Failed to generate config file", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.eclipse.aether.repository.RemoteRepository;

import io.quarkus.bootstrap.BootstrapConstants;
import io.quarkus.bootstrap.resolver.AppModelResolverException;
import io.quarkus.bootstrap.resolver.BootstrapAppModelResolver;
import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
import io.quarkus.dependencies.Extension;
Expand Down Expand Up @@ -84,7 +83,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
.setRepositorySystemSession(repoSession)
.setRemoteRepositories(repos)
.build();
} catch (AppModelResolverException e) {
} catch (Exception e) {
throw new MojoExecutionException("Failed to initialize maven artifact resolver", e);
}

Expand Down Expand Up @@ -135,7 +134,7 @@ private Map<String, Artifact> collectBomExtensions(MavenArtifactResolver mvn, fi
final List<Dependency> bomDeps;
try {
bomDeps = mvn.resolveDescriptor(platformBom).getManagedDependencies();
} catch (AppModelResolverException e) {
} catch (Exception e) {
throw new MojoExecutionException("Failed to resolve platform BOM " + platformBom, e);
}

Expand All @@ -151,7 +150,7 @@ private Map<String, Artifact> collectBomExtensions(MavenArtifactResolver mvn, fi
}
try {
analyzeArtifact(mvn.resolve(artifact).getArtifact(), bomExtensions);
} catch (AppModelResolverException e) {
} catch (Exception e) {
getLog().warn("Failed to resolve " + artifact + " from managed dependencies of BOM " + platformBom);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
import io.quarkus.annotation.processor.generate_doc.ConfigDocSection;
import io.quarkus.annotation.processor.generate_doc.ConfigDocWriter;
import io.quarkus.annotation.processor.generate_doc.DocGeneratorUtil;
import io.quarkus.bootstrap.resolver.AppModelResolverException;
import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException;
import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
import io.quarkus.docs.generation.ExtensionJson.Extension;

public class AllConfigGenerator {
public static void main(String[] args) throws AppModelResolverException, IOException {
public static void main(String[] args) throws BootstrapMavenException, IOException {
if (args.length != 2) {
// exit 1 will break Maven
throw new IllegalArgumentException("Usage: <version> <extension.json>");
Expand Down
28 changes: 28 additions & 0 deletions independent-projects/bootstrap/app-model/pom.xml
Original file line number Diff line number Diff line change
@@ -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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quarkus-bootstrap-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-bootstrap-app-model</artifactId>
<name>Quarkus - Bootstrap - App Model</name>

<dependencies>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>commons-logging-jboss-logging</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.quarkus.bootstrap.model;

import io.quarkus.bootstrap.BootstrapConstants;
import java.io.Serializable;

/**
Expand All @@ -10,8 +9,8 @@
*/
public class AppArtifactCoords implements Serializable {

public static final String TYPE_JAR = BootstrapConstants.JAR;
public static final String TYPE_POM = BootstrapConstants.POM;
public static final String TYPE_JAR = "jar";
public static final String TYPE_POM = "pom";

public static AppArtifactCoords fromString(String str) {
return new AppArtifactCoords(split(str, new String[5]));
Expand Down Expand Up @@ -44,7 +43,7 @@ protected AppArtifactCoords(String[] parts) {
}

public AppArtifactCoords(String groupId, String artifactId, String version) {
this(groupId, artifactId, BootstrapConstants.EMPTY, TYPE_JAR, version);
this(groupId, artifactId, "", TYPE_JAR, version);
}

public AppArtifactCoords(String groupId, String artifactId, String type, String version) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.quarkus.bootstrap.model;

import io.quarkus.bootstrap.BootstrapConstants;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
Expand All @@ -18,6 +17,10 @@
*/
public class AppModel implements Serializable {

public static final String PARENT_FIRST_ARTIFACTS = "parent-first-artifacts";
public static final String EXCLUDED_ARTIFACTS = "excluded-artifacts";
public static final String LESSER_PRIORITY_ARTIFACTS = "lesser-priority-artifacts";

private static final Logger log = Logger.getLogger(AppModel.class);

private final AppArtifact appArtifact;
Expand Down Expand Up @@ -177,22 +180,22 @@ public Builder addLesserPriorityArtifacts(List<AppArtifactKey> deps) {
* @param props The quarkus-extension.properties file
*/
public void handleExtensionProperties(Properties props, String extension) {
String parentFirst = props.getProperty(BootstrapConstants.PARENT_FIRST_ARTIFACTS);
String parentFirst = props.getProperty(PARENT_FIRST_ARTIFACTS);
if (parentFirst != null) {
String[] artifacts = parentFirst.split(",");
for (String artifact : artifacts) {
parentFirstArtifacts.add(new AppArtifactKey(artifact.split(":")));
}
}
String excluded = props.getProperty(BootstrapConstants.EXCLUDED_ARTIFACTS);
String excluded = props.getProperty(EXCLUDED_ARTIFACTS);
if (excluded != null) {
String[] artifacts = excluded.split(",");
for (String artifact : artifacts) {
excludedArtifacts.add(new AppArtifactKey(artifact.split(":")));
log.debugf("Extension %s is excluding %s", extension, artifact);
}
}
String lesserPriority = props.getProperty(BootstrapConstants.LESSER_PRIORITY_ARTIFACTS);
String lesserPriority = props.getProperty(LESSER_PRIORITY_ARTIFACTS);
if (lesserPriority != null) {
String[] artifacts = lesserPriority.split(",");
for (String artifact : artifacts) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.quarkus.bootstrap.resolver.workspace;

import io.quarkus.bootstrap.model.PathsCollection;
import java.nio.file.Path;

/**
* Represents an outcome of the build for a specific set of sources and resources.
*/
public interface BuildOutput {

Path getOutputDir();

PathsCollection getSourcesDirs();

PathsCollection getResourcesDirs();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.quarkus.bootstrap.resolver.workspace;

import io.quarkus.bootstrap.model.AppArtifactKey;
import java.util.Collection;

public interface Workspace<M extends WorkspaceProject> {

default M getProject(String groupId, String artifactId) {
return getProject(new AppArtifactKey(groupId, artifactId));
}

M getProject(AppArtifactKey key);

Collection<M> getAllProjects();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package io.quarkus.bootstrap.resolver.workspace;

import io.quarkus.bootstrap.model.AppArtifact;
import io.quarkus.bootstrap.model.AppArtifactKey;
import java.nio.file.Path;
import java.util.Collection;

/**
* Represents a project in a workspace
*/
public interface WorkspaceProject {

String getGroupId();

String getArtifactId();

String getVersion();

/**
* Project location on the filesystem
*
* @return project location
*/
Path getDir();

/**
* Project's key consisting of its group and artifact IDs
*
* @return project's key
*/
AppArtifactKey getKey();

/**
* Where the main build output can be located and from which
* sources and resources it was produced
*
* @return main build output
*/
Collection<BuildOutput> getMainOutput();

/**
* Where the test build output can be located and from which
* sources and resources it was produced
*
* @return test build output
*/
Collection<BuildOutput> getTestOutput();

default AppArtifact getAppArtifact(String extension) {
return getAppArtifact("", extension);
}

default AppArtifact getAppArtifact(String classifier, String extension) {
return new AppArtifact(getGroupId(), getArtifactId(), classifier, extension, getVersion());
}
}
Loading