Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use <schemas> parameter #1

Open
wiibaa opened this issue Mar 23, 2011 · 1 comment
Open

Cannot use <schemas> parameter #1

wiibaa opened this issue Mar 23, 2011 · 1 comment

Comments

@wiibaa
Copy link

wiibaa commented Mar 23, 2011

Hello,
I started using your plugin to integrate schemaspy doc to my maven site.
It works great for one schema, but I cannot use it for several schemas at a time.
I navigated in this plugin sources and schemaspy sources to found it out.
The issue is that when -schemas parameter is passed to schemaspy, MultipleSchemaAnalyzer will be called to create a global index html page and generate the doc for each schema, to do so in fact, several command lines with -schema (without "s") are generated and ran but this generation step call Config.getLoadedFromJar() that assumes that schemaspy jar is the only one of the classpath thus doing :
public static String getLoadedFromJar() {
String classpath = System.getProperty("java.class.path");
return new StringTokenizer(classpath, File.pathSeparator).nextToken();
}

But under maven run, this call fetch the classworld.jar of maven,so all commandline generated are invalid.
I come to you hoping you may find a solution inside the plugin itself or can interact with the author of schemaspy about this.
Many Thanks.

@sturton
Copy link
Contributor

sturton commented May 13, 2012

There are 2 problems:-

  1. SchemaSpy code generates incorrect command lines (this issue)
  2. Packaged JAR file does not have Main class defined.

Fixes

SchemaSpy code - get calling JAR from here
Missing Main class - change pom.xml

primary:maven-schemaspy-plugin.git.2 sturton$ git diff 
diff --git a/pom.xml b/pom.xml
index 59369aa..73c47af 100644
--- a/pom.xml
+++ b/pom.xml
@@ -131,6 +131,23 @@
         </configuration>
       </plugin>

+      <!-- Define the Main class of the output JAR file -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>2.3.1</version>
+        <configuration>
+          <archive>
+            <manifest>
+              <mainClass>net.sourceforge.schemaspy.Main</mainClass>
+            </manifest>
+            <manifestEntries>
+              <Implementation-Build>${buildNumber}</Implementation-Build>
+            </manifestEntries>
+          </archive>
+        </configuration>
+      </plugin>
+
     </plugins>
     <extensions>
       <extension>
diff --git a/src/main/java/net/sourceforge/schemaspy/Config.java b/src/main/java/net/sourceforge/schemaspy/Config.java
index 3bde8f3..3c9932c 100644
--- a/src/main/java/net/sourceforge/schemaspy/Config.java
+++ b/src/main/java/net/sourceforge/schemaspy/Config.java
@@ -28,6 +28,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.net.URLDecoder;
 import java.sql.DatabaseMetaData;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -1210,7 +1211,22 @@ public class Config

     public static String getLoadedFromJar() {
         String classpath = System.getProperty("java.class.path");
-        return new StringTokenizer(classpath, File.pathSeparator).nextToken();
+        String loadedFrom = new StringTokenizer(classpath, File.pathSeparator).nextToken();
+       String path = Config.class.getProtectionDomain().getCodeSource().getLocation().getPath();
+       String decodedPath = null ;
+       try {
+               decodedPath = URLDecoder.decode(path, "UTF-8");
+        }
+       catch (java.io.UnsupportedEncodingException uee) {
+               System.err.println("unsupported encoding exception caught");
+        }
+       System.err.println("classpath="+classpath);
+       System.err.println("loadedFrom="+loadedFrom);
+       System.err.println("path="+path);
+       System.err.println("decodedPath="+decodedPath);
+        return decodedPath ;
+        //return loadedFrom ;
+        //return new StringTokenizer(classpath, File.pathSeparator).nextToken();
     }

     /**
@@ -1718,4 +1734,4 @@ public class Config

         return params;
     }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants