Author: fgiust Date: Fri Dec 30 02:59:11 2005 New Revision: 360068 URL: http://svn.apache.org/viewcvs?rev=360068&view=rev Log: hack for MCHECKSTYLE-10 checkstyle always use the thread context classloader for resources, so we have to fix it...
Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java?rev=360068&r1=360067&r2=360068&view=diff ============================================================================== --- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java (original) +++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java Fri Dec 30 02:59:11 2005 @@ -450,8 +450,16 @@ ModuleFactory moduleFactory; Configuration config; CheckstyleResults results; + + ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); + try { + // checkstyle will always use the context classloader in order to load resources (dtds), + // so we have to fix it + ClassLoader checkstyleClassLoader = PackageNamesLoader.class.getClassLoader(); + Thread.currentThread().setContextClassLoader( checkstyleClassLoader ); + moduleFactory = getModuleFactory(); config = ConfigurationLoader.loadConfiguration( configFile, new PropertiesExpander( overridingProperties ) ); results = executeCheckstyle( config, moduleFactory ); @@ -462,14 +470,15 @@ } ResourceBundle bundle = getBundle( locale ); - generateReportStatics(); generateMainReport( results, config, moduleFactory, bundle ); - - if( enableRSS ) + if ( enableRSS ) { generateRSS( results ); } + + // be sure to restore original context classloader + Thread.currentThread().setContextClassLoader( currentClassLoader ); } private void generateReportStatics()