ソースを参照

优化模块信息

zhouhao 6 年 前
コミット
42c6bf16cf

+ 14 - 5
hsweb-commons/hsweb-commons-utils/src/main/java/org/hswebframework/web/ModuleUtils.java

@@ -9,6 +9,7 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
 import org.springframework.util.ClassUtils;
 import org.springframework.util.StringUtils;
 
+import java.security.ProtectionDomain;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -49,13 +50,21 @@ public abstract class ModuleUtils {
     }
 
     public static String getClassPath(Class type) {
-        String path = type.getResource("").getPath();
-        String packages = type.getPackage().getName();
-        return getClassPath(path, packages);
+
+        return getClassPath(type.getResource("").getPath(), type.getPackage().getName());
     }
 
     public static String getClassPath(String path, String packages) {
-        int pos = path.contains("!/") ? 3 : path.endsWith("/") ? 2 : 1;
+        if (path.endsWith(".jar")) {
+            return path;
+        }
+        boolean isJar = path.contains("!/") && path.contains(".jar");
+
+        if (isJar) {
+            return path.substring(0, path.lastIndexOf(".jar") + 4);
+        }
+
+        int pos = path.endsWith("/") ? 2 : 1;
         return path.substring(0, path.length() - packages.length() - pos);
     }
 
@@ -102,7 +111,7 @@ public abstract class ModuleUtils {
 
         public String getGitLocation() {
             String gitCommitHash = this.gitCommitHash;
-            if (gitCommitHash.contains("$")) {
+            if (gitCommitHash == null || gitCommitHash.contains("$")) {
                 gitCommitHash = "master";
             }
             return gitRepository + "/blob/" + gitCommitHash + "/" + path + "/";

+ 1 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local/src/main/resources/hsweb-module.json

@@ -1,7 +1,7 @@
 {
   "groupId": "${project.groupId}",
   "artifactId": "${project.artifactId}",
-  "path": "hsweb-system/hsweb-system-authorization",
+  "path": "hsweb-system/hsweb-system-authorization/hsweb-system-authorization-local",
   "gitCommitHash": "${git.commit.hash}",
   "gitRepository": "http://github.com/hs-web/hsweb-framework",
   "version": "${project.version}",

+ 8 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/pom.xml

@@ -11,7 +11,14 @@
 
     <artifactId>hsweb-system-authorization-web</artifactId>
     <description>业务模块-权限管理WEB API模块</description>
-
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
+    </build>
     <dependencies>
         <dependency>
             <groupId>javax.servlet</groupId>

+ 9 - 0
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web/src/main/resources/hsweb-module.json

@@ -0,0 +1,9 @@
+{
+  "groupId": "${project.groupId}",
+  "artifactId": "${project.artifactId}",
+  "path": "hsweb-system/hsweb-system-authorization/hsweb-system-authorization-web",
+  "gitCommitHash": "${git.commit.hash}",
+  "gitRepository": "http://github.com/hs-web/hsweb-framework",
+  "version": "${project.version}",
+  "comment": "权限管理Web层"
+}