Author: nbelaevski
Date: 2007-04-30 17:09:07 -0400 (Mon, 30 Apr 2007)
New Revision: 143
Modified:
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AbstractCDKMojo.java
Log:
JSF Version detection failed due to wrong classloading. Fixed
Modified:
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AbstractCDKMojo.java
===================================================================
---
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AbstractCDKMojo.java 2007-04-30
20:58:02 UTC (rev 142)
+++
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AbstractCDKMojo.java 2007-04-30
21:09:07 UTC (rev 143)
@@ -28,7 +28,6 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@@ -92,12 +91,12 @@
* @parameter
expression="${project.build.directory}/generated-component/java"
*/
protected File outputJavaDirectory;
-
+
/**
* @parameter
expression="${project.build.directory}/generated-component/test"
*/
protected File outputTestsDirectory;
-
+
/**
* Directory where the output Java Files will be located.
*
@@ -149,7 +148,7 @@
}
if (null == library.getPrefix()) {
library.setPrefix(project.getGroupId());
-
+
}
if (null == library.getDescription()) {
library.setDescription(project.getDescription());
@@ -157,9 +156,8 @@
if( null == library.getJsfVersion()){
String version = Library.JSF11;
// Check version-specific methods in UIComponent class
- ClassLoader loader = createProjectClassLoader(project);
try {
- Class componentClass =
loader.loadClass("javax.faces.component.UIComponent");
+ Class componentClass = createProjectClassLoader(project,
false).loadClass("javax.faces.component.UIComponent");
Method[] methods = componentClass.getDeclaredMethods();
for (int i = 0; i < methods.length; i++) {
if("encodeAll".equals(methods[i].getName())){
@@ -200,7 +198,7 @@
}
if (null == taglib.getDisplayName()) {
taglib.setDisplayName(project.getDescription());
-
+
}
if( null == taglib.getJspVersion()){
// Jsf 1.2 can use JSP 2.1 only, other - 2.0
@@ -220,15 +218,15 @@
url = url + "/" + project.getArtifactId();
}
taglib.setUri(url);
-
+
}
if (null == taglib.getShortName()) {
taglib.setShortName(project.getArtifactId());
-
+
}
return taglib;
}
-
+
protected void writeParsedTemplate(String templateName, VelocityContext context, File
configFile) throws IOException, ResourceNotFoundException, ParseErrorException,
MethodInvocationException, Exception {
File dir = configFile.getParentFile();
if(!dir.exists()){
@@ -241,30 +239,39 @@
fileWriter.flush();
fileWriter.close();
}
-
-
- protected ClassLoader createProjectClassLoader(MavenProject project) {
+
+ protected ClassLoader createProjectClassLoader(MavenProject project, boolean useCCL) {
ClassLoader classLoader = Thread.currentThread()
- .getContextClassLoader();
+ .getContextClassLoader();
try {
List compileClasspathElements = project
- .getCompileClasspathElements();
+ .getCompileClasspathElements();
String outputDirectory = project.getBuild().getOutputDirectory();
URL[] urls = new URL[compileClasspathElements.size() + 1];
int i = 0;
urls[i++] = new File(outputDirectory).toURL();
for (Iterator iter = compileClasspathElements.iterator(); iter
- .hasNext();) {
+ .hasNext();) {
String element = (String) iter.next();
urls[i++] = new File(element).toURL();
}
- classLoader = new URLClassLoader(urls, classLoader);
+
+ if (useCCL) {
+ classLoader = new URLClassLoader(urls, classLoader);
+ } else {
+ classLoader = new URLClassLoader(urls);
+ }
} catch (MalformedURLException e) {
getLog().error("Bad URL in classpath", e);
} catch (DependencyResolutionRequiredException e) {
getLog().error("Dependencies not resolved ", e);
}
+
return classLoader;
}
-}
+ protected ClassLoader createProjectClassLoader(MavenProject project) {
+ return createProjectClassLoader(project, true);
+ }
+
+}
\ No newline at end of file
Show replies by date