Skip to content

Commit 1bc01ba

Browse files
authored
Merge pull request w3c#100 from w3c/sideshowbarker/velocity-classpath-resource-loader
Make css-validator.jar CLI runnable anywhere
2 parents ea5d295 + ee2e6d6 commit 1bc01ba

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

build.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,13 @@
116116
windowtitle="W3C CSS Validator API"/>
117117
</target>
118118

119-
<target name="jar" depends="build" description="Creates the lib archive">
119+
<target name="jar" depends="build" description="Creates the lib archive with all dependency jars included">
120120
<delete file="${jar.file}"/>
121121
<jar jarfile="${jar.file}" basedir="build" excludes="org/**/*.java">
122122
<zipgroupfileset dir="lib" includes="*.jar"/>
123123
<include name="org/**"/>
124124
<manifest>
125125
<attribute name="Main-Class" value="org.w3c.css.css.CssValidator"/>
126-
<attribute name="Class-path" value=". lib/commons-beanutils-1.9.2.jar lib/commons-collections-3.2.1.jar lib/commons-digester-1.8.1.jar lib/commons-text-1.1.jar lib/commons-logging-1.1.1.jar lib/jigsaw-2.2.6.jar lib/tagsoup-1.2.1.jar lib/velocity-1.7.jar lib/velocity-tools-generic-2.0.jar lib/xercesImpl-2.11.0.jar lib/xml-apis-1.4.01.jar lib/htmlparser-1.4.1.jar"/>
127126
</manifest>
128127
</jar>
129128
</target>

org/w3c/css/css/StyleSheetGenerator.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import org.apache.velocity.app.Velocity;
66
import org.apache.velocity.exception.ParseErrorException;
77
import org.apache.velocity.exception.ResourceNotFoundException;
8+
import org.apache.velocity.runtime.RuntimeConstants;
9+
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
810
import org.apache.velocity.tools.ToolManager;
911
import org.w3c.css.error.ErrorReportHTML;
1012
import org.w3c.css.parser.CssError;
@@ -83,17 +85,10 @@ public class StyleSheetGenerator extends StyleReport {
8385
}
8486

8587
try {
86-
Velocity.setProperty(Velocity.RESOURCE_LOADER, "file");
87-
Velocity.addProperty(Velocity.RESOURCE_LOADER, "jar");
88-
Velocity.setProperty("jar." + Velocity.RESOURCE_LOADER + ".class",
89-
"org.apache.velocity.runtime.resource.loader.JarResourceLoader");
90-
URL path = StyleSheetGenerator.class.getResource("/");
91-
if (path != null) {
92-
Velocity.addProperty("file." + Velocity.RESOURCE_LOADER +
93-
".path", path.getFile());
94-
Velocity.setProperty("jar." + Velocity.RESOURCE_LOADER + ".path",
95-
"jar:" + path + "css-validator.jar");
96-
}
88+
Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER,
89+
"classpath");
90+
Velocity.setProperty("classpath.resource.loader.class",
91+
ClasspathResourceLoader.class.getName());
9792
Velocity.init();
9893
velocityToolManager = new ToolManager();
9994
velocityToolManager.configure("org/w3c/css/css/velocity-tools.xml");

0 commit comments

Comments
 (0)