2002/css-validator/org/w3c/css/css StyleSheetGenerator.java,1.20,1.21

Update of /sources/public/2002/css-validator/org/w3c/css/css
In directory hutz:/tmp/cvs-serv23130/org/w3c/css/css

Modified Files:
	StyleSheetGenerator.java 
Log Message:
jar issue hopefully fixed: lib dir needs to be in the same dir as css-validator.jar. If in this directory you also have org/w3c/css/css/something.properties, this file will be used instead of the one bundled in the jar. Last but not least, it should be possible to run java -jar /my/path/css-validator.jar from anywhere

Index: StyleSheetGenerator.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleSheetGenerator.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- StyleSheetGenerator.java	20 Jan 2009 13:58:53 -0000	1.20
+++ StyleSheetGenerator.java	21 Jan 2009 17:46:37 -0000	1.21
@@ -74,6 +74,19 @@
             System.err.println("org.w3c.css.css.StyleSheetGeneratorHTML: couldn't load URLs properties ");
             System.err.println("  " + e.toString());
         }
+
+        try {
+            Velocity.setProperty(Velocity.RESOURCE_LOADER, "file");
+            Velocity.addProperty(Velocity.RESOURCE_LOADER, "jar");
+            Velocity.setProperty("jar." + Velocity.RESOURCE_LOADER + ".class", "org.apache.velocity.runtime.resource.loader.JarResourceLoader");
+            URL jarFile = StyleSheetGenerator.class.getResource("/css-validator.jar");
+            if(jarFile != null) {
+                Velocity.setProperty( "jar." + Velocity.RESOURCE_LOADER + ".path", "jar:" + jarFile);
+            }
+            Velocity.init();
+        } catch(Exception e) {
+            System.err.println("Failed to initialize Velocity. Validator might not work as expected.");
+        }
     }
 	
     public StyleSheetGenerator(String title, StyleSheet style, String document, int warningLevel) {

Received on Wednesday, 21 January 2009 17:46:49 UTC