Skip to content

Commit

Permalink
Merge branch 'main' into issue44857
Browse files Browse the repository at this point in the history
  • Loading branch information
starksm64 authored Dec 7, 2024
2 parents 0e6bade + 18110f8 commit 29b775a
Show file tree
Hide file tree
Showing 74 changed files with 3,041 additions and 1,204 deletions.
22 changes: 18 additions & 4 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<javax.inject.version>1</javax.inject.version>
<parsson.version>1.1.7</parsson.version>
<resteasy-microprofile.version>3.0.0.Final</resteasy-microprofile.version>
<resteasy-spring-web.version>3.1.3.Final</resteasy-spring-web.version>
<resteasy-spring-web.version>3.2.0.Final</resteasy-spring-web.version>
<resteasy.version>6.2.11.Final</resteasy.version>
<opentelemetry-instrumentation.version>2.8.0-alpha</opentelemetry-instrumentation.version>
<opentelemetry-semconv.version>1.27.0-alpha</opentelemetry-semconv.version>
Expand All @@ -46,7 +46,7 @@
<microprofile-jwt.version>2.1</microprofile-jwt.version>
<microprofile-lra.version>2.0</microprofile-lra.version>
<microprofile-openapi.version>4.0.2</microprofile-openapi.version>
<smallrye-common.version>2.8.0</smallrye-common.version>
<smallrye-common.version>2.9.0</smallrye-common.version>
<smallrye-config.version>3.10.2</smallrye-config.version>
<smallrye-health.version>4.1.0</smallrye-health.version>
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
Expand Down Expand Up @@ -157,7 +157,7 @@
<dekorate.version>4.1.4</dekorate.version> <!-- Please check with Java Operator SDK team before updating -->
<maven-invoker.version>3.2.0</maven-invoker.version>
<awaitility.version>4.2.2</awaitility.version>
<jboss-logmanager.version>3.1.0.Final</jboss-logmanager.version>
<jboss-logmanager.version>3.1.1.Final</jboss-logmanager.version>
<flyway.version>11.0.1</flyway.version>
<yasson.version>3.0.4</yasson.version>
<!-- liquibase-mongodb is not released everytime with liquibase anymore, but the two versions need to be compatible -->
Expand All @@ -182,7 +182,7 @@
<checker-qual.version>3.48.3</checker-qual.version>
<error-prone-annotations.version>2.36.0</error-prone-annotations.version>
<jib-core.version>0.27.2</jib-core.version>
<google-http-client.version>1.45.1</google-http-client.version>
<google-http-client.version>1.45.2</google-http-client.version>
<scram-client.version>2.1</scram-client.version>
<picocli.version>4.7.6</picocli.version>
<google-cloud-functions.version>1.1.4</google-cloud-functions.version>
Expand Down Expand Up @@ -219,6 +219,7 @@
<prometheus.version>0.16.0</prometheus.version>
<!-- Dev UI -->
<importmap.version>1.0.11</importmap.version>
<webauthn4j.version>0.28.0.RELEASE</webauthn4j.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -6509,6 +6510,18 @@
<version>${project.version}</version>
</dependency>

<!-- WebAuthn4J -->
<dependency>
<groupId>com.webauthn4j</groupId>
<artifactId>webauthn4j-core-async</artifactId>
<version>${webauthn4j.version}</version>
</dependency>
<dependency>
<groupId>com.webauthn4j</groupId>
<artifactId>webauthn4j-metadata-async</artifactId>
<version>${webauthn4j.version}</version>
</dependency>

<!-- Relocations -->
<dependency>
<groupId>io.quarkus</groupId>
Expand All @@ -6532,6 +6545,7 @@
<version>${project.version}</version>
</dependency>
<!-- End of Relocations, please put new extensions above this list -->

</dependencies>
</dependencyManagement>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.maven;

import java.io.IOException;
import java.lang.reflect.Method;
import java.nio.file.Path;
import java.util.List;
Expand All @@ -16,6 +17,7 @@
import io.quarkus.bootstrap.app.CuratedApplication;
import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
import io.quarkus.bootstrap.model.ApplicationModel;
import io.quarkus.bootstrap.util.BootstrapUtils;
import io.quarkus.maven.dependency.ArtifactCoords;
import io.quarkus.paths.PathCollection;
import io.quarkus.paths.PathList;
Expand All @@ -31,8 +33,11 @@ public class GenerateCodeMojo extends QuarkusBootstrapMojo {
* Skip the execution of this mojo
*/
@Parameter(defaultValue = "false", property = "quarkus.generate-code.skip", alias = "quarkus.prepare.skip")
private boolean skipSourceGeneration = false;
boolean skipSourceGeneration = false;

/**
* Application launch mode for which to generate the source code.
*/
@Parameter(defaultValue = "NORMAL", property = "launchMode")
String mode;

Expand All @@ -55,9 +60,8 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException {
path -> mavenProject().addCompileSourceRoot(path.toString()), false);
}

void generateCode(PathCollection sourceParents,
Consumer<Path> sourceRegistrar,
boolean test) throws MojoFailureException, MojoExecutionException {
void generateCode(PathCollection sourceParents, Consumer<Path> sourceRegistrar, boolean test)
throws MojoExecutionException {

final LaunchMode launchMode;
if (test) {
Expand Down Expand Up @@ -97,13 +101,31 @@ void generateCode(PathCollection sourceParents,
if (deploymentClassLoader != null) {
deploymentClassLoader.close();
}
// in case of test mode, we can't share the bootstrapped app with the testing plugins, so we are closing it right away
// In case of the test mode, we can't share the application model with the test plugins, so we are closing it right away,
// but we are serializing the application model so the test plugins can deserialize it from disk instead of re-initializing
// the resolver and re-resolving it as part of the test bootstrap
if (test && curatedApplication != null) {
curatedApplication.close();
var appModel = curatedApplication.getApplicationModel();
closeApplication(LaunchMode.TEST);
if (isSerializeTestModel()) {
final int workspaceId = getWorkspaceId();
if (workspaceId != 0) {
try {
BootstrapUtils.writeAppModelWithWorkspaceId(appModel, workspaceId, BootstrapUtils
.getSerializedTestAppModelPath(Path.of(mavenProject().getBuild().getDirectory())));
} catch (IOException e) {
getLog().warn("Failed to serialize application model", e);
}
}
}
}
}
}

protected boolean isSerializeTestModel() {
return false;
}

protected PathCollection getParentDirs(List<String> sourceDirs) {
if (sourceDirs.size() == 1) {
return PathList.of(Path.of(sourceDirs.get(0)).getParent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,29 @@
import org.apache.maven.plugin.MojoFailureException;
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 io.quarkus.bootstrap.app.CuratedApplication;
import io.quarkus.bootstrap.model.ApplicationModel;
import io.quarkus.builder.Json;
import io.quarkus.maven.dependency.ResolvedDependency;
import io.quarkus.runtime.LaunchMode;

@Mojo(name = "generate-code-tests", defaultPhase = LifecyclePhase.GENERATE_TEST_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, threadSafe = true)
public class GenerateCodeTestsMojo extends GenerateCodeMojo {

/**
* A switch that enables or disables serialization of an {@link ApplicationModel} to a file for tests.
* Deserializing an application model when bootstrapping Quarkus tests has a performance advantage in that
* the tests will not have to initialize a Maven resolver and re-resolve the application model, which may save,
* depending on a project, ~80-95% of time on {@link ApplicationModel} resolution.
* <p>
* Serialization of the test model is enabled by default.
*/
@Parameter(property = "quarkus.generate-code.serialize-test-model", defaultValue = "true")
boolean serializeTestModel;

@Override
protected void doExecute() throws MojoExecutionException, MojoFailureException {
generateCode(getParentDirs(mavenProject().getTestCompileSourceRoots()),
Expand All @@ -32,6 +46,11 @@ protected void doExecute() throws MojoExecutionException, MojoFailureException {
}
}

@Override
protected boolean isSerializeTestModel() {
return serializeTestModel;
}

private boolean isTestWithNativeAgent() {
String value = System.getProperty("quarkus.test.integration-test-profile");
if ("test-with-native-agent".equals(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,20 @@ protected CuratedApplication bootstrapApplication(LaunchMode mode) throws MojoEx
return bootstrapProvider.bootstrapApplication(this, mode);
}

protected void closeApplication(LaunchMode mode) {
bootstrapProvider.closeApplication(this, mode);
}

/**
* Workspace ID associated with a given bootstrap mojo.
* If the returned value is {@code 0}, a workspace was not associated with the bootstrap mojo.
*
* @return workspace ID associated with a given bootstrap mojo
*/
protected int getWorkspaceId() {
return bootstrapProvider.getWorkspaceId(this);
}

protected CuratedApplication bootstrapApplication(LaunchMode mode, Consumer<QuarkusBootstrap.Builder> builderCustomizer)
throws MojoExecutionException {
return bootstrapProvider.bootstrapApplication(this, mode, builderCustomizer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import io.quarkus.bootstrap.resolver.maven.EffectiveModelResolver;
import io.quarkus.bootstrap.resolver.maven.IncubatingApplicationModelResolver;
import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
import io.quarkus.bootstrap.resolver.maven.workspace.LocalProject;
import io.quarkus.maven.components.ManifestSection;
import io.quarkus.maven.components.QuarkusWorkspaceProvider;
import io.quarkus.maven.dependency.ArtifactCoords;
Expand Down Expand Up @@ -138,6 +139,21 @@ public CuratedApplication bootstrapApplication(QuarkusBootstrapMojo mojo, Launch
return bootstrapper(mojo).bootstrapApplication(mojo, mode, builderCustomizer);
}

public void closeApplication(QuarkusBootstrapMojo mojo, LaunchMode mode) {
bootstrapper(mojo).closeApplication(mode);
}

/**
* Workspace ID associated with a given bootstrap mojo.
* If the returned value is {@code 0}, a workspace was not associated with the bootstrap mojo.
*
* @param mojo bootstrap mojo
* @return workspace ID associated with a given bootstrap mojo
*/
public int getWorkspaceId(QuarkusBootstrapMojo mojo) {
return bootstrapper(mojo).workspaceId;
}

public ApplicationModel getResolvedApplicationModel(ArtifactKey projectId, LaunchMode mode, String bootstrapId) {
if (appBootstrapProviders.size() == 0) {
return null;
Expand Down Expand Up @@ -180,14 +196,15 @@ private static boolean isWorkspaceDiscovery(QuarkusBootstrapMojo mojo) {

public class QuarkusMavenAppBootstrap implements Closeable {

private int workspaceId;
private CuratedApplication prodApp;
private CuratedApplication devApp;
private CuratedApplication testApp;

private MavenArtifactResolver artifactResolver(QuarkusBootstrapMojo mojo, LaunchMode mode) {
try {
if (mode == LaunchMode.DEVELOPMENT || mode == LaunchMode.TEST || isWorkspaceDiscovery(mojo)) {
return workspaceProvider.createArtifactResolver(
var resolver = workspaceProvider.createArtifactResolver(
BootstrapMavenContext.config()
// it's important to pass user settings in case the process was not launched using the original mvn script
// for example using org.codehaus.plexus.classworlds.launcher.Launcher
Expand All @@ -199,6 +216,11 @@ private MavenArtifactResolver artifactResolver(QuarkusBootstrapMojo mojo, Launch
.setRemoteRepositories(mojo.remoteRepositories())
.setEffectiveModelBuilder(BootstrapMavenContextConfig
.getEffectiveModelBuilderProperty(mojo.mavenProject().getProperties())));
final LocalProject currentProject = resolver.getMavenContext().getCurrentProject();
if (currentProject != null && workspaceId == 0) {
workspaceId = currentProject.getWorkspace().getId();
}
return resolver;
}
// PROD packaging mode with workspace discovery disabled
return MavenArtifactResolver.builder()
Expand Down Expand Up @@ -376,6 +398,23 @@ protected CuratedApplication bootstrapApplication(QuarkusBootstrapMojo mojo, Lau
return prodApp == null ? prodApp = doBootstrap(mojo, mode, builderCustomizer) : prodApp;
}

protected void closeApplication(LaunchMode mode) {
if (mode == LaunchMode.DEVELOPMENT) {
if (devApp != null) {
devApp.close();
devApp = null;
}
} else if (mode == LaunchMode.TEST) {
if (testApp != null) {
testApp.close();
testApp = null;
}
} else if (prodApp != null) {
prodApp.close();
prodApp = null;
}
}

protected ArtifactCoords managingProject(QuarkusBootstrapMojo mojo) {
if (mojo.appArtifactCoords() == null) {
return null;
Expand Down
Binary file modified docs/src/main/asciidoc/images/webauthn-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/main/asciidoc/images/webauthn-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/main/asciidoc/images/webauthn-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/main/asciidoc/images/webauthn-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/src/main/asciidoc/images/webauthn-custom-login.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/src/main/asciidoc/images/webauthn-custom-register.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/src/main/asciidoc/images/webauthn-login.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/src/main/asciidoc/images/webauthn-register.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 29b775a

Please sign in to comment.