Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/delibero.git

Fixed issue with logger not being found (added resources directory to Gradle build file).

AuthorDave Jarvis <email>
Date2015-02-01 15:14:59 GMT-0800
Commit5a291f770622e300e7eaf057893a2b71d82c432f
Parentafc1723
build.gradle
sourceSets {
main {
- //output.resourcesDir = "$buildDir/resources"
output.classesDir = "$buildDir/classes"
java {
srcDir "source/java"
}
- //resources {
- //srcDir "resources"
- //}
+ // Ensure the logger properties file can be found
+ resources {
+ srcDirs = ['resources']
+ }
}
}
run.dependsOn( [createServletMap, buildMenu] )
-dependencies {
+eependencies {
// Authentication and authorization
compile "org.apache.shiro:shiro-core:1.2.3"
compile "org.eclipse.jetty:jetty-servlet:9.2.6.v20141205"
compile "org.eclipse.jetty:jetty-webapp:9.2.6.v20141205"
-
- // Logging, security, and persistence are cross-cutting concerns
- //compile "org.aspectj:aspectjrt:1.8.4"
// Logging
resources/WEB-INF/web.xml
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<listener>
- <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
+ <listener-class>
+ org.apache.shiro.web.env.EnvironmentLoaderListener
+ </listener-class>
</listener>
source/java/to/discuss/Main.java
import java.io.InputStream;
import java.io.IOException;
+import java.io.File;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
import java.util.Map;
configureServletMap();
configureServletDefault();
+ }
+
+ /**
+ * Adds the directories returned from getResourcePaths to the classpath.
+ * This avoids having to make an explicit dependency on the logger.
+ */
+ protected void configureClasspath() throws MalformedURLException {
+ Thread.currentThread().setContextClassLoader( createClassLoader() );
}
"source/xsl"
};
+ }
+
+ protected URL[] getResourceURLs() throws MalformedURLException {
+ String[] resources = getResourcePaths();
+ URL[] result = new URL[ resources.length ];
+ int index = 0;
+
+ for( String resource : resources ) {
+ result[ index ] = toURI( resource ).toURL();
+ }
+
+ return result;
+ }
+
+ protected URI toURI( String resource ) throws MalformedURLException {
+ return (new File( resource )).toURI();
+ }
+
+ protected ClassLoader createClassLoader() throws MalformedURLException {
+ return new URLClassLoader( getResourceURLs(), getClassLoader() );
+ }
+
+ protected ClassLoader getClassLoader() {
+ return Thread.currentThread().getContextClassLoader();
}
Delta46 lines added, 9 lines removed, 37-line increase