You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2007/03/07 23:02:23 UTC
svn commit: r515794 - in
/cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src:
main/java/org/apache/cocoon/maven/rcl/ test/java/org/apache/cocoon/maven/rcl/
test/resources/org/apache/cocoon/maven/rcl/
Author: reinhard
Date: Wed Mar 7 14:02:22 2007
New Revision: 515794
URL: http://svn.apache.org/viewvc?view=rev&rev=515794
Log:
- make it possible to exclude artifacts from the RCL by
setting %exclude-lib property referencing groupId:artifactId
- unit test
Modified:
cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/ReloadingWebappMojo.java
cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/RwmProperties.java
cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/test/java/org/apache/cocoon/maven/rcl/RwmPropertiesTest.java
cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/test/resources/org/apache/cocoon/maven/rcl/rcl.properties
Modified: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/ReloadingWebappMojo.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/ReloadingWebappMojo.java?view=diff&rev=515794&r1=515793&r2=515794
==============================================================================
--- cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/ReloadingWebappMojo.java (original)
+++ cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/ReloadingWebappMojo.java Wed Mar 7 14:02:22 2007
@@ -227,19 +227,24 @@
File urlClConfFile = createPath(new File(webAppBaseDir, WEB_INF_RCL_URLCL_CONF));
try {
FileWriter fw = new FileWriter(urlClConfFile);
+ Set excludeLibProps = props.getExcludedLibProps();
+
for(Iterator aIt = props.getClassesDirs().iterator(); aIt.hasNext();) {
String dir = (String) aIt.next();
fw.write(dir + "\n");
- this.getLog().debug("Adding classes-dir to URLClassLoader configuration: " + dir);
+ this.getLog().debug("Adding classes-dir (URLClassLoader configuration): " + dir);
}
Set artifacts = project.getArtifacts();
ScopeArtifactFilter filter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
Artifact artifact = (Artifact) iter.next();
- if (!artifact.isOptional() && filter.include(artifact)) {
+ if (!artifact.isOptional() && filter.include(artifact) &&
+ !excludeLibProps.contains(artifact.getGroupId() + ":" + artifact.getArtifactId())) {
fw.write(artifact.getFile().toURL().toExternalForm() + "\n");
- this.getLog().debug("Adding dependency to URLClassLoader configuration: " + artifact.getArtifactId());
+ this.getLog().debug("Adding library (URLClassLoader configuration): " + artifact.getArtifactId());
+ } else {
+ this.getLog().debug("Skipping library (URLClassLoader configuration): " + artifact.getArtifactId());
}
}
fw.close();
Modified: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/RwmProperties.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/RwmProperties.java?view=diff&rev=515794&r1=515793&r2=515794
==============================================================================
--- cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/RwmProperties.java (original)
+++ cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/main/java/org/apache/cocoon/maven/rcl/RwmProperties.java Wed Mar 7 14:02:22 2007
@@ -33,6 +33,7 @@
private static final String COB_INF_DIR = "src/main/resources/COB-INF";
private static final String BLOCK_CONTEXT_URL_PARAM = "/contextPath";
private static final String CLASSES_DIR = "%classes-dir";
+ private static final String EXCLUDE_LIB = "%exclude-lib";
private static final String TARGET_CLASSES_DIR = "target/classes";
private Configuration props;
@@ -42,9 +43,40 @@
}
public Set getClassesDirs() throws MojoExecutionException {
- return getFilteredPropertiesValuesAsSet(CLASSES_DIR);
+ Set returnSet = new HashSet();
+ for (Iterator rclIt = props.getKeys(); rclIt.hasNext();) {
+ String key = (String) rclIt.next();
+ if (key.endsWith(CLASSES_DIR)) {
+ String[] values = this.props.getStringArray(key);
+ for (int i = 0; i < values.length; i++) {
+ String path = values[i];
+ String url = null;
+ try {
+ url = new File(path).toURL().toExternalForm();
+ } catch (MalformedURLException e) {
+ throw new MojoExecutionException("Can't create URL to " + path, e);
+ }
+ returnSet.add(url);
+ }
+ }
+ }
+ return returnSet;
}
+ public Set getExcludedLibProps() throws MojoExecutionException {
+ Set returnSet = new HashSet();
+ for (Iterator rclIt = props.getKeys(); rclIt.hasNext();) {
+ String key = (String) rclIt.next();
+ if (key.endsWith(EXCLUDE_LIB)) {
+ String[] values = this.props.getStringArray(key);
+ for (int i = 0; i < values.length; i++) {
+ returnSet.add(values[i]);
+ }
+ }
+ }
+ return returnSet;
+ }
+
public Properties getSpringProperties() throws MojoExecutionException {
Properties springProps = new Properties();
for(Iterator rclIt = props.getKeys(); rclIt.hasNext();) {
@@ -97,33 +129,13 @@
}
return springProps;
}
-
- private Set getFilteredPropertiesValuesAsSet(String filter) throws MojoExecutionException {
- Set returnSet = new HashSet();
- for (Iterator rclIt = props.getKeys(); rclIt.hasNext();) {
- String key = (String) rclIt.next();
- if (key.endsWith(filter)) {
- String[] values = this.props.getStringArray(key);
- for (int i = 0; i < values.length; i++) {
- String path = values[i];
- String url = null;
- try {
- url = new File(path).toURL().toExternalForm();
- } catch (MalformedURLException e) {
- throw new MojoExecutionException("Can't create URL to " + path, e);
- }
- returnSet.add(url);
- }
- }
- }
- return returnSet;
- }
public Properties getCocoonProperties() {
Properties cocoonProps = new Properties();
for(Iterator rclIt = props.getKeys(); rclIt.hasNext();) {
String key = (String) rclIt.next();
if(key.indexOf(CLASSES_DIR) == -1 &&
+ key.indexOf(EXCLUDE_LIB) == -1 &&
key.indexOf('/') == -1) {
cocoonProps.put(key, this.props.getString(key));
}
Modified: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/test/java/org/apache/cocoon/maven/rcl/RwmPropertiesTest.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/test/java/org/apache/cocoon/maven/rcl/RwmPropertiesTest.java?view=diff&rev=515794&r1=515793&r2=515794
==============================================================================
--- cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/test/java/org/apache/cocoon/maven/rcl/RwmPropertiesTest.java (original)
+++ cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/test/java/org/apache/cocoon/maven/rcl/RwmPropertiesTest.java Wed Mar 7 14:02:22 2007
@@ -59,6 +59,13 @@
assertEquals("interpolatedValue:A", cocooonProps.getProperty("b"));
}
+ public void testLoadExcludedLibs() throws Exception {
+ RwmProperties p = createTestProperties();
+ Set as = p.getExcludedLibProps();
+ assertEquals(2, as.size());
+ assertTrue(as.contains("com.mygroup:myartifact"));
+ }
+
public void testLoadingBasedirs() throws Exception {
RwmProperties p = createTestProperties();
Set as = p.getClassesDirs();
Modified: cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/test/resources/org/apache/cocoon/maven/rcl/rcl.properties
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/test/resources/org/apache/cocoon/maven/rcl/rcl.properties?view=diff&rev=515794&r1=515793&r2=515794
==============================================================================
--- cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/test/resources/org/apache/cocoon/maven/rcl/rcl.properties (original)
+++ cocoon/trunk/tools/cocoon-rcl/cocoon-rcl-plugin/src/test/resources/org/apache/cocoon/maven/rcl/rcl.properties Wed Mar 7 14:02:22 2007
@@ -27,6 +27,8 @@
%classes-dir=C:/blah
%classes-dir=X:/foo
%classes-dir=/nix/foo
+%exclude-lib=com.mygroup:myartifact
+%exclude-lib=com.mygroup:myartifact1
b=interpolatedValue:${a}
a=A
org.apache.cocoon.someBean/someProperty=5