getExcludedPackages() {
+ return excludedPackages;
+ }
+}
diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java
index 6b689ebafa229..52cc343e7753e 100644
--- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java
+++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java
@@ -1,9 +1,12 @@
package io.quarkus.arc.deployment;
import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
@@ -27,6 +30,10 @@
* Note that this processor is a best-effort because it only operates on {@code ApplicationArchivesBuildItem} which
* means that if a 3rd party library isn't indexed, we aren't able to detect it even though it can still be a part of
* resulting application. See also {@code io.quarkus.arc.processor.BeanArchives.IndexWrapper}.
+ *
+ * This processor can be configured by users and extensions to skip validation for certain packages hence avoiding the
+ * warning in logs.
+ * See also {@link ArcConfig#ignoredSplitPackages} and {@link IgnoreSplitPackageBuildItem}
*/
public class SplitPackageProcessor {
@@ -47,9 +54,21 @@ public boolean test(String packageName) {
@BuildStep
void splitPackageDetection(ApplicationArchivesBuildItem archivesBuildItem,
+ ArcConfig config,
+ List excludedPackages,
// Dummy producer to make sure the build step executes
BuildProducer dummy) {
Map> packageToArchiveMap = new HashMap<>();
+
+ // build up exclusion predicates from user defined config and extensions
+ List packageSkipPredicates = new ArrayList<>();
+ if (config.ignoredSplitPackages.isPresent()) {
+ packageSkipPredicates.addAll(initPredicates(config.ignoredSplitPackages.get()));
+ }
+ for (IgnoreSplitPackageBuildItem exclusionBuildItem : excludedPackages) {
+ packageSkipPredicates.addAll(initPredicates(exclusionBuildItem.getExcludedPackages()));
+ }
+
// for all app archives
for (ApplicationArchive archive : archivesBuildItem.getAllApplicationArchives()) {
// and for each known class in each archive
@@ -70,6 +89,18 @@ void splitPackageDetection(ApplicationArchivesBuildItem archivesBuildItem,
continue;
}
+ // skip packages based on pre-built predicates
+ boolean skipEvaluation = false;
+ for (Predicate predicate : packageSkipPredicates) {
+ if (predicate.test(packageName)) {
+ skipEvaluation = true;
+ break;
+ }
+ }
+ if (skipEvaluation) {
+ continue;
+ }
+
Set applicationArchives = packageToArchiveMap.get(packageName);
if (applicationArchives.size() > 1) {
splitPackagesWarning.append("\n- \"" + packageName + "\" found in ");
@@ -107,4 +138,30 @@ void splitPackageDetection(ApplicationArchivesBuildItem archivesBuildItem,
"Following packages were detected in multiple archives: %s", splitPackagesWarning.toString());
}
}
+
+ private List> initPredicates(Collection exclusions) {
+ final String packMatch = ".*";
+ List> predicates = new ArrayList<>();
+ for (String exclusionExpression : exclusions) {
+ if (exclusionExpression.endsWith(packMatch)) {
+ // Package ends with ".*"
+ final String pack = exclusionExpression.substring(0, exclusionExpression.length() - packMatch.length());
+ predicates.add(new Predicate() {
+ @Override
+ public boolean test(String packageName) {
+ return packageName.startsWith(pack);
+ }
+ });
+ } else {
+ // Standard full package name
+ predicates.add(new Predicate() {
+ @Override
+ public boolean test(String packageName) {
+ return packageName.equals(exclusionExpression);
+ }
+ });
+ }
+ }
+ return predicates;
+ }
}