Skip to content

Commit

Permalink
Merge pull request #44450 from gsmet/3.16.3-backports-1
Browse files Browse the repository at this point in the history
[3.16] 3.16.3 backports 1
  • Loading branch information
gsmet authored Nov 13, 2024
2 parents 1ab8406 + 76a0ed6 commit 8bbe797
Show file tree
Hide file tree
Showing 69 changed files with 1,424 additions and 251 deletions.
47 changes: 47 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,53 @@ Thus, it is recommended to use the following approach:
Due to Quarkus being a large repository, having to rebuild the entire project every time a change is made isn't very
productive. The following Maven tips can vastly speed up development when working on a specific extension.

#### Using mvnd

[mvnd](https://github.com/apache/maven-mvnd) is a daemon for Maven providing faster builds.
It parallelizes your builds by default and makes sure the output is consistent even for a parallelized build.

You can https://github.com/apache/maven-mvnd?tab=readme-ov-file#how-to-install-mvnd[install mvnd] with SDKMAN!, Homebrew...

mvnd is a good companion for your Quarkus builds.

Make sure you install the latest mvnd 1.0.x which embeds Maven 3.x as Quarkus does not support Maven 4 yet.
Once it is installed, you can use `mvnd` in your Maven command lines instead of the typical `mvn` or `./mvnw`.

If anything goes wrong, you can stop the daemon and start fresh with `mvnd --stop`.

#### Using aliases

While building with `-Dquickly` or `-DquicklyDocs` is practical when contributing your first patches,
if you contribute to Quarkus often, it is recommended to have your own aliases - for instance to make sure your build is parallelized.

Here are a couple of useful aliases that are good starting points - and that you will need to adapt to your environment:

- `build-fast`: build the Quarkus artifacts and install them
- `build-docs`: run from the root of the project, build the documentation
- `format`: format the source code following our coding conventions
- `qss`: run the Quarkus CLI from a snapshot (make sure you build the artifacts first)

- If using mvnd

```sh
alias build-fast="mvnd -e -DskipDocs -DskipTests -DskipITs -Dinvoker.skip -DskipExtensionValidation -Dskip.gradle.tests -Dtruststore.skip clean install"
alias build-docs="mvnd -e -DskipTests -DskipITs -Dinvoker.skip -DskipExtensionValidation -Dskip.gradle.tests -Dtruststore.skip -Dno-test-modules -Dasciidoctor.fail-if=DEBUG clean install"
alias format="mvnd process-sources -Denforcer.skip -Dprotoc.skip"
alias qss="java -jar ${HOME}/git/quarkus/devtools/cli/target/quarkus-cli-999-SNAPSHOT-runner.jar"
```

- If using plain Maven

```sh
alias build-fast="mvn -T0.8C -e -DskipDocs -DskipTests -DskipITs -Dinvoker.skip -DskipExtensionValidation -Dskip.gradle.tests -Dtruststore.skip clean install"
alias build-docs="mvn -T0.8C -e -DskipTests -DskipITs -Dinvoker.skip -DskipExtensionValidation -Dskip.gradle.tests -Dtruststore.skip -Dno-test-modules -Dasciidoctor.fail-if=DEBUG clean install"
alias format="mvn -T0.8C process-sources -Denforcer.skip -Dprotoc.skip"
alias qss="java -jar ${HOME}/git/quarkus/devtools/cli/target/quarkus-cli-999-SNAPSHOT-runner.jar"
```

Using `./mvnw` is often not practical in this case as you might want to call these aliases from a nested directory.
[gum](https://andresalmiray.com/gum-the-gradle-maven-wrapper/) might be useful in this case.

#### Building all modules of an extension

Let's say you want to make changes to the `Jackson` extension. This extension contains the `deployment`, `runtime`
Expand Down
4 changes: 2 additions & 2 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parsson.version>1.1.7</parsson.version>
<resteasy-microprofile.version>2.1.5.Final</resteasy-microprofile.version>
<resteasy-spring-web.version>3.1.3.Final</resteasy-spring-web.version>
<resteasy.version>6.2.10.Final</resteasy.version>
<resteasy.version>6.2.11.Final</resteasy.version>
<opentracing.version>0.33.0</opentracing.version>
<opentracing-jdbc.version>0.2.4</opentracing-jdbc.version>
<opentracing-kafka.version>0.1.15</opentracing-kafka.version>
Expand All @@ -37,7 +37,7 @@
<opentelemetry-alpha.version>2.8.0-alpha</opentelemetry-alpha.version>
<opentelemetry-semconv.version>1.27.0-alpha</opentelemetry-semconv.version>
<quarkus-http.version>5.3.3</quarkus-http.version>
<micrometer.version>1.13.6</micrometer.version><!-- keep in sync with hdrhistogram -->
<micrometer.version>1.13.7</micrometer.version><!-- keep in sync with hdrhistogram -->
<hdrhistogram.version>2.2.2</hdrhistogram.version><!-- keep in sync with micrometer -->
<google-auth.version>0.22.0</google-auth.version>
<graphql-java.version>22.2</graphql-java.version> <!-- keep in sync with smallrye-graphql -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ private BuildResult runAugment(boolean firstRun, Set<String> changedResources,
.setTargetDir(quarkusBootstrap.getTargetDirectory())
.setDeploymentClassLoader(deploymentClassLoader)
.setBuildSystemProperties(quarkusBootstrap.getBuildSystemProperties())
.setRuntimeProperties(quarkusBootstrap.getRuntimeProperties())
.setEffectiveModel(curatedApplication.getApplicationModel())
.setDependencyInfoProvider(quarkusBootstrap.getDependencyInfoProvider());
if (quarkusBootstrap.getBaseName() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.Set;
import java.util.function.Consumer;
Expand Down Expand Up @@ -70,7 +71,6 @@
import io.quarkus.fs.util.ZipUtils;
import io.quarkus.gradle.tooling.ToolingUtils;
import io.quarkus.gradle.workspace.descriptors.DefaultProjectDescriptor;
import io.quarkus.gradle.workspace.descriptors.ProjectDescriptor;
import io.quarkus.gradle.workspace.descriptors.ProjectDescriptor.TaskType;
import io.quarkus.maven.dependency.ArtifactCoords;
import io.quarkus.maven.dependency.ArtifactDependency;
Expand Down Expand Up @@ -194,10 +194,13 @@ private ResolvedDependencyBuilder getProjectArtifact() {
.setBuildDir(getLayout().getBuildDirectory().getAsFile().get().toPath())
.setBuildFile(getProjectBuildFile().getAsFile().get().toPath());

ProjectDescriptor projectDescriptor = getProjectDescriptor().get();
initProjectModule(projectDescriptor, mainModule, ArtifactSources.MAIN, DEFAULT_CLASSIFIER);
DefaultProjectDescriptor projectDescriptor = getProjectDescriptor().get();

initProjectModule(projectDescriptor, mainModule, ArtifactSources.MAIN, DEFAULT_CLASSIFIER,
getProjectDescriptor().get().getSourceSetTasksRaw());
if (getLaunchMode().get().isDevOrTest()) {
initProjectModule(projectDescriptor, mainModule, ArtifactSources.TEST, "tests");
initProjectModule(projectDescriptor, mainModule, ArtifactSources.TEST, "tests",
getProjectDescriptor().get().getSourceSetTasksRaw());
}
final PathList.Builder paths = PathList.builder();
collectDestinationDirs(mainModule.getMainSources().getSourceDirs(), paths);
Expand All @@ -206,8 +209,8 @@ private ResolvedDependencyBuilder getProjectArtifact() {
return appArtifact.setWorkspaceModule(mainModule).setResolvedPaths(paths.build());
}

private static void initProjectModule(ProjectDescriptor projectDescriptor, WorkspaceModule.Mutable module,
String sourceSetName, String classifier) {
private static void initProjectModule(DefaultProjectDescriptor projectDescriptor, WorkspaceModule.Mutable module,
String sourceSetName, String classifier, Map<String, Set<String>> sourceSetTasksRaw) {
List<SourceDir> sourceDirs = new ArrayList<>();
List<SourceDir> resources = new ArrayList<>();
Set<String> tasks = projectDescriptor.getTasksForSourceSet(sourceSetName.isEmpty()
Expand All @@ -223,6 +226,23 @@ private static void initProjectModule(ProjectDescriptor projectDescriptor, Works
resources.add(new DefaultSourceDir(source, destDir, null));
}
}

// Issue https://github.com/quarkusio/quarkus/issues/44384
// no java sources are detected for compileJava before grpc configuration
// so we need to verify if the destination source for the task exist and add it manually
boolean containsJavaCompile = sourceDirs.stream()
.anyMatch(sourceDir -> "compileJava".equals(sourceDir.getValue("compiler", String.class)));
if (!containsJavaCompile && sourceSetTasksRaw.get("compileJava") != null) {

sourceSetTasksRaw.get("compileJava").forEach(s -> {
File output = new File(s);
if (output.exists() && Objects.requireNonNull(output.listFiles()).length > 0) {
sourceDirs.add(
new DefaultSourceDir(output.toPath(), output.toPath(), null, Map.of("compiler", "compileJava")));
}
});

}
module.addArtifactSources(new DefaultArtifactSources(classifier, sourceDirs, resources));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ public class DefaultProjectDescriptor implements Serializable, ProjectDescriptor

private final Map<String, QuarkusTaskDescriptor> tasks;
private final Map<String, Set<String>> sourceSetTasks;
private final Map<String, Set<String>> sourceSetTasksRaw;

public DefaultProjectDescriptor(File projectDir, File buildDir, File buildFile, Map<String, QuarkusTaskDescriptor> tasks,
Map<String, Set<String>> sourceSetTasks) {
Map<String, Set<String>> sourceSetTasks, Map<String, Set<String>> sourceSetTasksRaw) {
this.projectDir = projectDir;
this.buildDir = buildDir;
this.buildFile = buildFile;
this.tasks = tasks;
this.sourceSetTasks = sourceSetTasks;
this.sourceSetTasksRaw = sourceSetTasksRaw;
}

@Override
Expand All @@ -47,6 +49,10 @@ public Map<String, Set<String>> getSourceSetTasks() {
return sourceSetTasks;
}

public Map<String, Set<String>> getSourceSetTasksRaw() {
return sourceSetTasksRaw;
}

public Map<String, QuarkusTaskDescriptor> getTasks() {
return tasks;
}
Expand Down Expand Up @@ -81,7 +87,8 @@ public DefaultProjectDescriptor withSourceSetView(Set<String> acceptedSourceSets
Map<String, QuarkusTaskDescriptor> filteredTasks = tasks.entrySet().stream()
.filter(e -> filteredSourceSets.values().stream().anyMatch(tasks -> tasks.contains(e.getKey())))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> a, TreeMap::new));
return new DefaultProjectDescriptor(projectDir, buildDir, buildFile, filteredTasks, filteredSourceSets);
return new DefaultProjectDescriptor(projectDir, buildDir, buildFile, filteredTasks, filteredSourceSets,
sourceSetTasksRaw);
}

@Override
Expand All @@ -92,6 +99,7 @@ public String toString() {
",\nbuildFile=" + buildFile +
",\ntasks=" + tasks +
",\nsourceSetTasks=" + sourceSetTasks +
",\nsourceSetTasksRaw=" + sourceSetTasksRaw +
"\n}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ public class ProjectDescriptorBuilder {
private final File buildFile;
private final Map<String, QuarkusTaskDescriptor> tasks;
private final Map<String, Set<String>> sourceSetTasks;
private final Map<String, Set<String>> sourceSetTasksRaw;
private final Set<String> collectOnlySourceSets;

private ProjectDescriptorBuilder(Project project, Set<String> collectOnlySourceSets) {
this.tasks = new LinkedHashMap<>();
this.sourceSetTasks = new LinkedHashMap<>();
this.sourceSetTasksRaw = new LinkedHashMap<>();
this.buildFile = project.getBuildFile();
this.projectDir = project.getLayout().getProjectDirectory().getAsFile();
this.buildDir = project.getLayout().getBuildDirectory().get().getAsFile();
Expand All @@ -59,7 +61,8 @@ public static Provider<DefaultProjectDescriptor> buildForApp(Project target) {
builder.buildDir,
builder.buildFile,
builder.tasks,
builder.sourceSetTasks));
builder.sourceSetTasks,
builder.sourceSetTasksRaw));
}

public static Provider<DefaultProjectDescriptor> buildForDependency(Project target) {
Expand All @@ -76,10 +79,14 @@ public static Provider<DefaultProjectDescriptor> buildForDependency(Project targ
builder.buildDir,
builder.buildFile,
builder.tasks,
builder.sourceSetTasks));
builder.sourceSetTasks,
builder.sourceSetTasksRaw));
}

private void readConfigurationFor(AbstractCompile task) {
sourceSetTasksRaw.computeIfAbsent(task.getName(), s -> new HashSet<>())
.add(task.getDestinationDirectory().getAsFile().get().getAbsolutePath());

if (task.getEnabled() && !task.getSource().isEmpty()) {
File destDir = task.getDestinationDirectory().getAsFile().get();
task.getSource().visit(fileVisitDetails -> {
Expand Down
11 changes: 11 additions & 0 deletions devtools/gradle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@
<gradle.task>assemble</gradle.task>
</properties>
</profile>
<profile>
<id>quickly-docs-build</id>
<activation>
<property>
<name>quicklyDocs</name>
</property>
</activation>
<properties>
<gradle.task>assemble</gradle.task>
</properties>
</profile>
<profile>
<!-- separate "quickly" profile for CI to keep local "quickly" demands separated from CI demands -->
<id>quick-build-ci</id>
Expand Down
15 changes: 10 additions & 5 deletions docs/src/main/asciidoc/funqy-gcp-functions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ You will have a single JAR inside the `target/deployment` repository that contai
Then you will be able to use `gcloud` to deploy your function to Google Cloud.
The `gcloud` command will be different depending on which event triggers your function.

NOTE: We will use the Java 17 runtime but you can switch to the Java 21 runtime by using `--runtime=java21` instead of `--runtime=java17` on the deploy commands.
NOTE: We will use the Java 21 runtime, but you can switch to the Java 17 runtime by using `--runtime=java17` instead of `--runtime=java21` on the deploy commands.

[WARNING]
====
Expand All @@ -168,7 +168,7 @@ Use this command to deploy to Google Cloud Functions:
----
gcloud functions deploy quarkus-example-funky-pubsub \
--entry-point=io.quarkus.funqy.gcp.functions.FunqyBackgroundFunction \
--runtime=java17 --trigger-resource hello_topic --trigger-event google.pubsub.topic.publish \
--runtime=java21 --trigger-resource hello_topic --trigger-event google.pubsub.topic.publish \
--source=target/deployment
----

Expand Down Expand Up @@ -205,7 +205,7 @@ Then, use this command to deploy to Google Cloud Functions:
----
gcloud functions deploy quarkus-example-funky-storage \
--entry-point=io.quarkus.funqy.gcp.functions.FunqyBackgroundFunction \
--runtime=java17 --trigger-resource quarkus-hello --trigger-event google.storage.object.finalize \
--runtime=java21 --trigger-resource quarkus-hello --trigger-event google.storage.object.finalize \
--source=target/deployment
----

Expand Down Expand Up @@ -246,7 +246,7 @@ Then, use this command to deploy to Google Cloud Functions:
----
gcloud functions deploy quarkus-example-cloud-event --gen2 \
--entry-point=io.quarkus.funqy.gcp.functions.FunqyCloudEventsFunction \
--runtime=java17 --trigger-bucket=example-cloud-event --source=target/deployment
--runtime=java21 --trigger-bucket=example-cloud-event --source=target/deployment
----

[IMPORTANT]
Expand Down Expand Up @@ -371,7 +371,7 @@ This will call your cloud events function with an event on the `"MY_FILE.txt` fi

Quarkus provides built-in support for testing your Funqy Google Cloud functions via the `quarkus-test-google-cloud-functions` dependency.

To use it, you must add the following test dependency in your `pom.xml`.
To use it, you must add the following test dependencies in your `pom.xml`.

[source,xml]
----
Expand All @@ -380,6 +380,11 @@ To use it, you must add the following test dependency in your `pom.xml`.
<artifactId>quarkus-test-google-cloud-functions</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
----

This extension provides a `@WithFunction` annotation that can be used to annotate `@QuarkusTest` test cases to start a Cloud Function invoker before you test cases and stop it at the end.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/gcp-functions-http.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ The result of the previous command is a single JAR file inside the `target/deplo

Then you will be able to use `gcloud` to deploy your function to Google Cloud.

NOTE: We will use the Java 17 runtime but you can switch to the Java 21 runtime by using `--runtime=java21` instead of `--runtime=java17` on the deploy commands.
NOTE: We will use the Java 21 runtime, but you can switch to the Java 17 runtime by using `--runtime=java17` instead of `--runtime=java21` on the deploy commands.

[source,bash]
----
gcloud functions deploy quarkus-example-http \
--entry-point=io.quarkus.gcp.functions.http.QuarkusHttpFunction \
--runtime=java17 --trigger-http --allow-unauthenticated --source=target/deployment
--runtime=java21 --trigger-http --allow-unauthenticated --source=target/deployment
----

[IMPORTANT]
Expand Down
15 changes: 10 additions & 5 deletions docs/src/main/asciidoc/gcp-functions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ The result of the previous command is a single JAR file inside the `target/deplo
Then you will be able to use `gcloud` to deploy your function to Google Cloud.
The `gcloud` command will be different depending on which event triggers your function.

NOTE: We will use the Java 17 runtime but you can switch to the Java 21 runtime by using `--runtime=java21` instead of `--runtime=java17` on the deploy commands.
NOTE: We will use the Java 21 runtime but you can switch to the Java 17 runtime by using `--runtime=java17` instead of `--runtime=java21` on the deploy commands.

[WARNING]
====
Expand All @@ -262,7 +262,7 @@ This is an example command to deploy your `HttpFunction` to Google Cloud:
----
gcloud functions deploy quarkus-example-http \
--entry-point=io.quarkus.gcp.functions.QuarkusHttpFunction \
--runtime=java17 --trigger-http --allow-unauthenticated --source=target/deployment
--runtime=java21 --trigger-http --allow-unauthenticated --source=target/deployment
----

[IMPORTANT]
Expand All @@ -289,7 +289,7 @@ it needs to use `--trigger-event google.storage.object.finalize` and the `--trig
gcloud functions deploy quarkus-example-storage \
--entry-point=io.quarkus.gcp.functions.QuarkusBackgroundFunction \
--trigger-resource quarkus-hello --trigger-event google.storage.object.finalize \
--runtime=java17 --source=target/deployment
--runtime=java21 --source=target/deployment
----

[IMPORTANT]
Expand All @@ -315,7 +315,7 @@ it needs to use `--trigger-event google.pubsub.topic.publish` and the `--trigger
----
gcloud functions deploy quarkus-example-pubsub \
--entry-point=io.quarkus.gcp.functions.QuarkusBackgroundFunction \
--runtime=java17 --trigger-resource hello_topic --trigger-event google.pubsub.topic.publish --source=target/deployment
--runtime=java21 --trigger-resource hello_topic --trigger-event google.pubsub.topic.publish --source=target/deployment
----

[IMPORTANT]
Expand All @@ -341,7 +341,7 @@ it needs to use `--trigger-bucket` parameter with the name of a previously creat
----
gcloud functions deploy quarkus-example-cloud-event --gen2 \
--entry-point=io.quarkus.gcp.functions.QuarkusCloudEventsFunction \
--runtime=java17 --trigger-bucket=example-cloud-event --source=target/deployment
--runtime=java21 --trigger-bucket=example-cloud-event --source=target/deployment
----

[IMPORTANT]
Expand Down Expand Up @@ -485,6 +485,11 @@ To use it, you must add the following test dependency in your `pom.xml`.
<artifactId>quarkus-test-google-cloud-functions</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
----

This extension provides a `@WithFunction` annotation that can be used to annotate `@QuarkusTest` test cases to start a Cloud Function invoker before you test cases and stop it at the end.
Expand Down
Loading

0 comments on commit 8bbe797

Please sign in to comment.