This is an automated email from the ASF dual-hosted git repository.

crazyhzm pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.2 by this push:
     new 523a4189b8 Move dubbo versions file from META-INF/versions to 
META-INF/dubbo-version (#14247)
523a4189b8 is described below

commit 523a4189b8a7233c926eab1218daf627a3e870b8
Author: liaozan <[email protected]>
AuthorDate: Tue Jun 4 22:59:16 2024 +0800

    Move dubbo versions file from META-INF/versions to META-INF/dubbo-version 
(#14247)
    
    * Move dubbo versions file from META-INF/versions to META-INF/dubbo-versions
    
    * Make 'META-INF/dubbo-versions' as constants
---
 .../main/java/org/apache/dubbo/common/Version.java |  8 ++++---
 .../dubbo/common/constants/CommonConstants.java    | 26 ++++++++++++++++++++--
 .../apache/dubbo/common/version/VersionTest.java   |  9 ++++----
 .../java/org/apache/dubbo/dependency/FileTest.java |  4 +++-
 pom.xml                                            |  4 ++--
 5 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/Version.java 
b/dubbo-common/src/main/java/org/apache/dubbo/common/Version.java
index 90f2b70704..5c436fd345 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/Version.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/Version.java
@@ -16,6 +16,7 @@
  */
 package org.apache.dubbo.common;
 
+import org.apache.dubbo.common.constants.CommonConstants;
 import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
 import org.apache.dubbo.common.logger.LoggerFactory;
 import org.apache.dubbo.common.utils.StringUtils;
@@ -84,7 +85,8 @@ public final class Version {
     }
 
     private static void tryLoadVersionFromResource() throws IOException {
-        Enumeration<URL> configLoader = 
Version.class.getClassLoader().getResources("META-INF/versions/dubbo-common");
+        Enumeration<URL> configLoader =
+                
Version.class.getClassLoader().getResources(CommonConstants.DUBBO_VERSIONS_KEY 
+ "/dubbo-common");
         if (configLoader.hasMoreElements()) {
             URL url = configLoader.nextElement();
             try (BufferedReader reader =
@@ -312,7 +314,7 @@ public final class Version {
 
     private static void checkArtifact(String artifactId) throws IOException {
         Enumeration<URL> artifactEnumeration =
-                
Version.class.getClassLoader().getResources("META-INF/versions/" + artifactId);
+                
Version.class.getClassLoader().getResources(CommonConstants.DUBBO_VERSIONS_KEY 
+ artifactId);
         while (artifactEnumeration.hasMoreElements()) {
             URL url = artifactEnumeration.nextElement();
             try (BufferedReader reader =
@@ -348,7 +350,7 @@ public final class Version {
 
     private static Set<String> loadArtifactIds() throws IOException {
         Enumeration<URL> artifactsEnumeration =
-                
Version.class.getClassLoader().getResources("META-INF/versions/.artifacts");
+                
Version.class.getClassLoader().getResources(CommonConstants.DUBBO_VERSIONS_KEY 
+ "/.artifacts");
         Set<String> artifactIds = new HashSet<>();
         while (artifactsEnumeration.hasMoreElements()) {
             URL url = artifactsEnumeration.nextElement();
diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
 
b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
index e026499418..704b30c74c 100644
--- 
a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
+++ 
b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
@@ -24,6 +24,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.regex.Pattern;
 
 public interface CommonConstants {
+
     String DUBBO = "dubbo";
 
     String TRIPLE = "tri";
@@ -267,12 +268,14 @@ public interface CommonConstants {
     String $INVOKE = "$invoke";
 
     String $INVOKE_ASYNC = "$invokeAsync";
+
     String GENERIC_PARAMETER_DESC = 
"Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;";
 
     /**
      * echo call
      */
     String $ECHO = "$echo";
+
     /**
      * package version in the manifest
      */
@@ -283,12 +286,19 @@ public interface CommonConstants {
     int MAX_PROXY_COUNT = 65535;
 
     String MONITOR_KEY = "monitor";
+
     String BACKGROUND_KEY = "background";
+
     String CLUSTER_KEY = "cluster";
+
     String USERNAME_KEY = "username";
+
     String PASSWORD_KEY = "password";
+
     String HOST_KEY = "host";
+
     String PORT_KEY = "port";
+
     String DUBBO_IP_TO_BIND = "DUBBO_IP_TO_BIND";
 
     /**
@@ -308,21 +318,29 @@ public interface CommonConstants {
     String SHUTDOWN_WAIT_SECONDS_KEY = "dubbo.service.shutdown.wait.seconds";
 
     String SHUTDOWN_WAIT_KEY = "dubbo.service.shutdown.wait";
+
     String DUBBO_PROTOCOL = "dubbo";
 
     String DUBBO_LABELS = "dubbo.labels";
+
     String DUBBO_ENV_KEYS = "dubbo.env.keys";
 
     String CONFIG_CONFIGFILE_KEY = "config-file";
+
     String CONFIG_ENABLE_KEY = "highest-priority";
+
     String CONFIG_NAMESPACE_KEY = "namespace";
+
     String CHECK_KEY = "check";
 
     String BACKLOG_KEY = "backlog";
 
     String HEARTBEAT_EVENT = null;
+
     String MOCK_HEARTBEAT_EVENT = "H";
+
     String READONLY_EVENT = "R";
+
     String WRITEABLE_EVENT = "W";
 
     String REFERENCE_FILTER_KEY = "reference.filter";
@@ -459,6 +477,7 @@ public interface CommonConstants {
     String REGISTRY_DELAY_NOTIFICATION_KEY = "delay-notification";
 
     String CACHE_CLEAR_TASK_INTERVAL = 
"dubbo.application.url.cache.task.interval";
+
     String CACHE_CLEAR_WAITING_THRESHOLD = 
"dubbo.application.url.cache.clear.waiting";
 
     String CLUSTER_INTERCEPTOR_COMPATIBLE_KEY = 
"dubbo.application.cluster.interceptor.compatible";
@@ -615,17 +634,18 @@ public interface CommonConstants {
     String SERVICE_EXECUTOR = "service-executor";
 
     String EXECUTOR_MANAGEMENT_MODE = "executor-management-mode";
+
     String EXECUTOR_MANAGEMENT_MODE_DEFAULT = "default";
+
     String EXECUTOR_MANAGEMENT_MODE_ISOLATION = "isolation";
 
     /**
-     *
      * used in JVMUtil.java ,Control stack print lines, default is 32 lines
-     *
      */
     String DUBBO_JSTACK_MAXLINE = "dubbo.jstack-dump.max-line";
 
     String ENCODE_IN_IO_THREAD_KEY = "encode.in.io";
+
     boolean DEFAULT_ENCODE_IN_IO_THREAD = false;
 
     /**
@@ -648,4 +668,6 @@ public interface CommonConstants {
     String DUBBO2_COMPACT_ENABLE = "dubbo.compact.enable";
 
     String ZOOKEEPER_ENSEMBLE_TRACKER_KEY = "zookeeper.ensemble.tracker";
+
+    String DUBBO_VERSIONS_KEY = "META-INF/dubbo-versions";
 }
diff --git 
a/dubbo-common/src/test/java/org/apache/dubbo/common/version/VersionTest.java 
b/dubbo-common/src/test/java/org/apache/dubbo/common/version/VersionTest.java
index 69dd5dbb08..0c37dc79c7 100644
--- 
a/dubbo-common/src/test/java/org/apache/dubbo/common/version/VersionTest.java
+++ 
b/dubbo-common/src/test/java/org/apache/dubbo/common/version/VersionTest.java
@@ -17,6 +17,7 @@
 package org.apache.dubbo.common.version;
 
 import org.apache.dubbo.common.Version;
+import org.apache.dubbo.common.constants.CommonConstants;
 
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -110,7 +111,7 @@ class VersionTest {
         ClassLoader classLoader = new ClassLoader(originClassLoader) {
             @Override
             public Class<?> loadClass(String name) throws 
ClassNotFoundException {
-                if (name.equals("org.apache.dubbo.common.Version")) {
+                if ("org.apache.dubbo.common.Version".equals(name)) {
                     return findClass(name);
                 }
                 return super.loadClass(name);
@@ -145,15 +146,13 @@ class VersionTest {
 
             @Override
             public Enumeration<URL> getResources(String name) throws 
IOException {
-
-                if (name.equals("META-INF/versions/dubbo-common")) {
+                if (name.equals(CommonConstants.DUBBO_VERSIONS_KEY + 
"/dubbo-common")) {
                     return 
super.getResources("META-INF/test-versions/dubbo-common");
                 }
                 return super.getResources(name);
             }
         };
-        Class<?> versionClass = 
classLoader.loadClass("org.apache.dubbo.common.Version");
-        return versionClass;
+        return classLoader.loadClass("org.apache.dubbo.common.Version");
     }
 
     @Test
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 209a25ff58..be443f2c94 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
@@ -16,6 +16,8 @@
  */
 package org.apache.dubbo.dependency;
 
+import org.apache.dubbo.common.constants.CommonConstants;
+
 import java.io.File;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
@@ -133,7 +135,7 @@ class FileTest {
         List<String> artifactIdsInRoot = IOUtils.readLines(
                 this.getClass()
                         .getClassLoader()
-                        .getResource("META-INF/versions/.artifacts")
+                        .getResource(CommonConstants.DUBBO_VERSIONS_KEY + 
"/.artifacts")
                         .openStream(),
                 StandardCharsets.UTF_8);
         artifactIdsInRoot.removeIf(s -> s.startsWith("#"));
diff --git a/pom.xml b/pom.xml
index 472134a92a..52e9cf3eb4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -253,7 +253,7 @@
         </includes>
       </resource>
       <resource>
-        <targetPath>META-INF/versions</targetPath>
+        <targetPath>META-INF/dubbo-versions</targetPath>
         <filtering>false</filtering>
         <directory>${maven.multiModuleProjectDirectory}</directory>
         <includes>
@@ -430,7 +430,7 @@
             <configuration>
               <failOnError>true</failOnError>
               <target>
-                <property name="version_file" 
value="${project.build.outputDirectory}/META-INF/versions/${project.artifactId}"
 />
+                <property name="version_file" 
value="${project.build.outputDirectory}/META-INF/dubbo-versions/${project.artifactId}"
 />
                 <!-- get the current version of dubbo -->
                 <echo file="${version_file}" 
message="revision=${revision}${line.separator}" />
                 <!-- attach the artifact id -->

Reply via email to