You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2024/09/05 04:03:35 UTC
(dubbo) branch 3.3 updated: Shade dubbo-plugin-loom by default (#14622)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.3 by this push:
new c48e1c08e4 Shade dubbo-plugin-loom by default (#14622)
c48e1c08e4 is described below
commit c48e1c08e4441171027a435964faa1cb70bb3aae
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Thu Sep 5 12:03:29 2024 +0800
Shade dubbo-plugin-loom by default (#14622)
* Shade dubbo-plugin-loom by default
* Fix file test
* Fix file test & dubbo-all-shaded
* Fix file test & dubbo-all-shaded
---
dubbo-distribution/dubbo-all-shaded/pom.xml | 135 +++++++++++++++------
dubbo-distribution/dubbo-all/pom.xml | 25 ++++
.../java/org/apache/dubbo/dependency/FileTest.java | 115 ++++++++++++++++++
3 files changed, 241 insertions(+), 34 deletions(-)
diff --git a/dubbo-distribution/dubbo-all-shaded/pom.xml b/dubbo-distribution/dubbo-all-shaded/pom.xml
index 98bf972a8a..2e06f08271 100644
--- a/dubbo-distribution/dubbo-all-shaded/pom.xml
+++ b/dubbo-distribution/dubbo-all-shaded/pom.xml
@@ -75,6 +75,13 @@
</dependency>
<!-- config-center -->
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-configcenter-file</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-configcenter-zookeeper</artifactId>
@@ -112,96 +119,99 @@
<scope>compile</scope>
<optional>true</optional>
</dependency>
+
+ <!-- metadata -->
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rest-jaxrs</artifactId>
+ <artifactId>dubbo-metadata-api</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rest-spring</artifactId>
+ <artifactId>dubbo-metadata-report-zookeeper</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-triple-servlet</artifactId>
+ <artifactId>dubbo-metadata-report-nacos</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
- <!-- metadata -->
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metadata-api</artifactId>
+ <artifactId>dubbo-metadata-definition-protobuf</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
+
+ <!-- metrics -->
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metadata-report-zookeeper</artifactId>
+ <artifactId>dubbo-metrics-event</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metadata-report-nacos</artifactId>
+ <artifactId>dubbo-metrics-api</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metadata-definition-protobuf</artifactId>
+ <artifactId>dubbo-metrics-default</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
-
- <!-- metrics -->
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metrics-api</artifactId>
+ <artifactId>dubbo-metrics-registry</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metrics-default</artifactId>
+ <artifactId>dubbo-metrics-prometheus</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metrics-registry</artifactId>
+ <artifactId>dubbo-metrics-metadata</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metrics-prometheus</artifactId>
+ <artifactId>dubbo-metrics-config-center</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metrics-metadata</artifactId>
+ <artifactId>dubbo-metrics-netty</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
+
+ <!-- tracing -->
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metrics-config-center</artifactId>
+ <artifactId>dubbo-tracing</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<optional>true</optional>
@@ -252,6 +262,28 @@
<optional>true</optional>
</dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-rest-jaxrs</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-rest-spring</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-triple-servlet</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
+
<!-- registry -->
<dependency>
<groupId>org.apache.dubbo</groupId>
@@ -297,6 +329,20 @@
<scope>compile</scope>
<optional>true</optional>
</dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-remoting-http12</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-remoting-http3</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-netty</artifactId>
@@ -381,28 +427,14 @@
</dependency>
<!-- Transitive dependencies -->
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-all</artifactId>
- <scope>compile</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- </dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ </dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
@@ -415,6 +447,10 @@
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ </dependency>
</dependencies>
<build>
<plugins>
@@ -439,6 +475,7 @@
<include>org.apache.dubbo:dubbo-compatible</include>
<include>org.apache.dubbo:dubbo-config-api</include>
<include>org.apache.dubbo:dubbo-config-spring</include>
+ <include>org.apache.dubbo:dubbo-configcenter-file</include>
<include>org.apache.dubbo:dubbo-configcenter-apollo</include>
<include>org.apache.dubbo:dubbo-configcenter-nacos</include>
<include>org.apache.dubbo:dubbo-configcenter-zookeeper</include>
@@ -448,12 +485,15 @@
<include>org.apache.dubbo:dubbo-metadata-definition-protobuf</include>
<include>org.apache.dubbo:dubbo-metadata-report-nacos</include>
<include>org.apache.dubbo:dubbo-metadata-report-zookeeper</include>
+ <include>org.apache.dubbo:dubbo-metrics-event</include>
<include>org.apache.dubbo:dubbo-metrics-api</include>
<include>org.apache.dubbo:dubbo-metrics-default</include>
<include>org.apache.dubbo:dubbo-metrics-registry</include>
<include>org.apache.dubbo:dubbo-metrics-metadata</include>
<include>org.apache.dubbo:dubbo-metrics-config-center</include>
+ <include>org.apache.dubbo:dubbo-metrics-netty</include>
<include>org.apache.dubbo:dubbo-metrics-prometheus</include>
+ <include>org.apache.dubbo:dubbo-tracing</include>
<include>org.apache.dubbo:dubbo-qos</include>
<include>org.apache.dubbo:dubbo-qos-api</include>
<include>org.apache.dubbo:dubbo-security</include>
@@ -465,6 +505,8 @@
<include>org.apache.dubbo:dubbo-registry-nacos</include>
<include>org.apache.dubbo:dubbo-registry-zookeeper</include>
<include>org.apache.dubbo:dubbo-remoting-api</include>
+ <include>org.apache.dubbo:dubbo-remoting-http12</include>
+ <include>org.apache.dubbo:dubbo-remoting-http3</include>
<include>org.apache.dubbo:dubbo-remoting-netty4</include>
<include>org.apache.dubbo:dubbo-remoting-netty</include>
<include>org.apache.dubbo:dubbo-remoting-zookeeper-curator5</include>
@@ -479,6 +521,7 @@
<include>org.apache.dubbo:dubbo-serialization-hessian2</include>
<include>org.apache.dubbo:dubbo-serialization-fastjson2</include>
<include>org.apache.dubbo:dubbo-serialization-jdk</include>
+ <include>org.apache.dubbo:dubbo-plugin-loom</include>
<include>io.netty:*</include>
</includes>
</artifactSet>
@@ -921,8 +964,32 @@
</build>
<profiles>
+ <profile>
+ <id>loom</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-plugin-loom</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+ </profile>
<profile>
<id>release</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-plugin-loom</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
<build>
<plugins>
<plugin>
diff --git a/dubbo-distribution/dubbo-all/pom.xml b/dubbo-distribution/dubbo-all/pom.xml
index d3b31cc05a..b42a5dcc6a 100644
--- a/dubbo-distribution/dubbo-all/pom.xml
+++ b/dubbo-distribution/dubbo-all/pom.xml
@@ -520,6 +520,7 @@
<include>org.apache.dubbo:dubbo-serialization-hessian2</include>
<include>org.apache.dubbo:dubbo-serialization-fastjson2</include>
<include>org.apache.dubbo:dubbo-serialization-jdk</include>
+ <include>org.apache.dubbo:dubbo-plugin-loom</include>
</includes>
</artifactSet>
<transformers>
@@ -948,8 +949,32 @@
</build>
<profiles>
+ <profile>
+ <id>loom</id>
+ <activation>
+ <jdk>[21,)</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-plugin-loom</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+ </profile>
<profile>
<id>release</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-plugin-loom</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
<build>
<plugins>
<plugin>
diff --git a/dubbo-test/dubbo-test-modules/src/test/java/org/apache/dubbo/dependency/FileTest.java b/dubbo-test/dubbo-test-modules/src/test/java/org/apache/dubbo/dependency/FileTest.java
index 8100d70c2e..f2b152b53c 100644
--- a/dubbo-test/dubbo-test-modules/src/test/java/org/apache/dubbo/dependency/FileTest.java
+++ b/dubbo-test/dubbo-test-modules/src/test/java/org/apache/dubbo/dependency/FileTest.java
@@ -44,6 +44,7 @@ class FileTest {
private static final List<Pattern> ignoredModules = new LinkedList<>();
private static final List<Pattern> ignoredArtifacts = new LinkedList<>();
private static final List<Pattern> ignoredModulesInDubboAll = new LinkedList<>();
+ private static final List<Pattern> ignoredModulesInDubboAllShade = new LinkedList<>();
static {
ignoredModules.add(Pattern.compile("dubbo-apache-release"));
@@ -72,6 +73,8 @@ class FileTest {
ignoredModulesInDubboAll.add(Pattern.compile("dubbo-config-spring6.*"));
ignoredModulesInDubboAll.add(Pattern.compile(".*spring-boot.*"));
ignoredModulesInDubboAll.add(Pattern.compile("dubbo-maven-plugin"));
+
+ ignoredModulesInDubboAllShade.add(Pattern.compile("dubbo-plugin-loom"));
}
@Test
@@ -375,6 +378,10 @@ class FileTest {
if (!artifactIds.contains(artifactId)) {
continue;
}
+ if (ignoredModulesInDubboAllShade.stream()
+ .anyMatch(pattern -> pattern.matcher(artifactId).matches())) {
+ continue;
+ }
if (ignoredModules.stream()
.anyMatch(pattern -> pattern.matcher(artifactId).matches())) {
unexpectedArtifactIds.add(artifactId);
@@ -391,6 +398,114 @@ class FileTest {
+ unexpectedArtifactIds);
}
+ @Test
+ void checkDubboAllNettyShade() throws DocumentException {
+ File baseFile = getBaseFile();
+
+ List<File> poms = new LinkedList<>();
+ readPoms(baseFile, poms);
+
+ SAXReader reader = new SAXReader();
+
+ List<String> artifactIds = poms.stream()
+ .map(f -> {
+ try {
+ return reader.read(f);
+ } catch (DocumentException e) {
+ throw new RuntimeException(e);
+ }
+ })
+ .map(Document::getRootElement)
+ .map(doc -> doc.elementText("artifactId"))
+ .sorted()
+ .collect(Collectors.toList());
+
+ Assertions.assertEquals(poms.size(), artifactIds.size());
+
+ List<String> deployedArtifactIds = poms.stream()
+ .map(f -> {
+ try {
+ return reader.read(f);
+ } catch (DocumentException e) {
+ throw new RuntimeException(e);
+ }
+ })
+ .map(Document::getRootElement)
+ .filter(doc -> Objects.isNull(doc.element("properties"))
+ || (!Objects.equals("true", doc.element("properties").elementText("skip_maven_deploy"))
+ && !Objects.equals(
+ "true", doc.element("properties").elementText("maven.deploy.skip"))))
+ .filter(doc -> !Objects.equals("pom", doc.elementText("packaging")))
+ .map(doc -> doc.elementText("artifactId"))
+ .sorted()
+ .collect(Collectors.toList());
+
+ String dubboAllPath = "dubbo-distribution" + File.separator + "dubbo-all-shaded" + File.separator + "pom.xml";
+ Document dubboAll = reader.read(new File(getBaseFile(), dubboAllPath));
+ List<String> artifactIdsInDubboAll =
+ dubboAll.getRootElement().element("build").element("plugins").elements("plugin").stream()
+ .filter(ele -> ele.elementText("artifactId").equals("maven-shade-plugin"))
+ .map(ele -> ele.element("executions"))
+ .map(ele -> ele.elements("execution"))
+ .flatMap(Collection::stream)
+ .filter(ele -> ele.elementText("phase").equals("package"))
+ .map(ele -> ele.element("configuration"))
+ .map(ele -> ele.element("artifactSet"))
+ .map(ele -> ele.element("includes"))
+ .map(ele -> ele.elements("include"))
+ .flatMap(Collection::stream)
+ .map(Element::getText)
+ .filter(artifactId -> artifactId.startsWith("org.apache.dubbo:"))
+ .map(artifactId -> artifactId.substring("org.apache.dubbo:".length()))
+ .collect(Collectors.toList());
+
+ List<String> expectedArtifactIds = new LinkedList<>(deployedArtifactIds);
+ expectedArtifactIds.removeAll(artifactIdsInDubboAll);
+ expectedArtifactIds.removeIf(artifactId -> ignoredModules.stream()
+ .anyMatch(pattern -> pattern.matcher(artifactId).matches()));
+ expectedArtifactIds.removeIf(artifactId -> ignoredModulesInDubboAll.stream()
+ .anyMatch(pattern -> pattern.matcher(artifactId).matches()));
+
+ Assertions.assertTrue(
+ expectedArtifactIds.isEmpty(),
+ "Newly created modules must be added to dubbo-all-shaded (dubbo-distribution" + File.separator
+ + "dubbo-all-shaded" + File.separator + "pom.xml in shade plugin). Found modules: "
+ + expectedArtifactIds);
+
+ List<String> unexpectedArtifactIds = new LinkedList<>(artifactIdsInDubboAll);
+ unexpectedArtifactIds.removeIf(artifactId -> !artifactIds.contains(artifactId));
+ unexpectedArtifactIds.removeAll(deployedArtifactIds);
+ Assertions.assertTrue(
+ unexpectedArtifactIds.isEmpty(),
+ "Undeploy dependencies should not be added to dubbo-all-shaded (dubbo-distribution" + File.separator
+ + "dubbo-all-shaded" + File.separator + "pom.xml in shade plugin). Found modules: "
+ + unexpectedArtifactIds);
+
+ unexpectedArtifactIds = new LinkedList<>();
+ for (String artifactId : artifactIdsInDubboAll) {
+ if (!artifactIds.contains(artifactId)) {
+ continue;
+ }
+ if (ignoredModulesInDubboAllShade.stream()
+ .anyMatch(pattern -> pattern.matcher(artifactId).matches())) {
+ continue;
+ }
+ if (ignoredModules.stream()
+ .anyMatch(pattern -> pattern.matcher(artifactId).matches())) {
+ unexpectedArtifactIds.add(artifactId);
+ }
+ if (ignoredModulesInDubboAll.stream()
+ .anyMatch(pattern -> pattern.matcher(artifactId).matches())) {
+ unexpectedArtifactIds.add(artifactId);
+ }
+ }
+ Assertions.assertTrue(
+ unexpectedArtifactIds.isEmpty(),
+ "Unexpected dependencies should not be added to dubbo-all-shaded (dubbo-distribution" + File.separator
+ + "dubbo-all-shaded" + File.separator + "pom.xml in shade plugin). Found modules: "
+ + unexpectedArtifactIds);
+ }
+
@Test
void checkDubboTransform() throws DocumentException {
File baseFile = getBaseFile();