]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-3150: Resolve classpath for binary distribution
authorSimon Steiner <ssteiner@apache.org>
Fri, 15 Sep 2023 15:18:01 +0000 (16:18 +0100)
committerSimon Steiner <ssteiner@apache.org>
Fri, 15 Sep 2023 15:18:01 +0000 (16:18 +0100)
fop-core/src/main/java/org/apache/fop/cli/Main.java
fop/pom.xml

index a14d20c78b086c7dd4d5c6d7a389ed43bc60b0ad..ca9443adec4b22e3bb58ee5900763d42bb529ca6 100644 (file)
@@ -27,6 +27,7 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.commons.io.IOUtils;
@@ -62,22 +63,18 @@ public final class Main {
         } else {
             buildDir = new File(baseDir, "build");
         }
-        File fopJar = new File(buildDir, "fop.jar");
-        if (!fopJar.exists()) {
-            fopJar = new File(baseDir, "fop.jar");
-        }
-        if (!fopJar.exists()) {
-            throw new RuntimeException("fop.jar not found in directory: "
-                    + baseDir.getAbsolutePath() + " (or below)");
-        }
-        List jars = new java.util.ArrayList();
-        jars.add(fopJar.toURI().toURL());
-        File[] files;
+        List jars = new ArrayList();
         FileFilter filter = new FileFilter() {
             public boolean accept(File pathname) {
                 return pathname.getName().endsWith(".jar");
             }
         };
+        File[] files = buildDir.listFiles(filter);
+        if (files != null) {
+            for (File file : files) {
+                jars.add(file.toURI().toURL());
+            }
+        }
         File libDir = new File(baseDir, "lib");
         if (!libDir.exists()) {
             libDir = baseDir;
@@ -97,12 +94,7 @@ public final class Main {
                 }
             }
         }
-        URL[] urls = (URL[])jars.toArray(new URL[jars.size()]);
-        /*
-        for (int i = 0, c = urls.length; i < c; i++) {
-            System.out.println(urls[i]);
-        }*/
-        return urls;
+        return (URL[])jars.toArray(new URL[jars.size()]);
     }
 
     /**
index de896f2ba582e7b3928a26db2ee3d9e97c35896f..5845e1f2c4977320d14abaea0df32d21d87a4112 100644 (file)
@@ -47,6 +47,7 @@
         <configuration>
           <archive>
             <manifest>
+              <addClasspath>true</addClasspath>
               <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
               <mainClass>org.apache.fop.cli.Main</mainClass>
             </manifest>