Author: nbelaevski
Date: 2010-08-09 13:47:05 -0400 (Mon, 09 Aug 2010)
New Revision: 18519
Modified:
root/sandbox/cdk/maven-resources-plugin/src/it/richfaces-application/pom.xml
root/sandbox/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/ProcessMojo.java
root/sandbox/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java
Log:
Minor updates in static resources handling
Modified: root/sandbox/cdk/maven-resources-plugin/src/it/richfaces-application/pom.xml
===================================================================
---
root/sandbox/cdk/maven-resources-plugin/src/it/richfaces-application/pom.xml 2010-08-09
17:46:24 UTC (rev 18518)
+++
root/sandbox/cdk/maven-resources-plugin/src/it/richfaces-application/pom.xml 2010-08-09
17:47:05 UTC (rev 18519)
@@ -39,15 +39,15 @@
<fileNameMappings>
<property>
<name>^\Qorg.richfaces.renderkit.html\E</name>
- <value>org.richfaces/images/</value>
+ <value>org.richfaces/images</value>
</property>
<property>
<name>^\Qorg.richfaces.renderkit.html.images\E</name>
- <value>org.richfaces/images/</value>
+ <value>org.richfaces/images</value>
</property>
<property>
<name>^css/</name>
- <value>org.richfaces/css/</value>
+ <value>org.richfaces/css</value>
</property>
</fileNameMappings>
</configuration>
Modified:
root/sandbox/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/ProcessMojo.java
===================================================================
---
root/sandbox/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/ProcessMojo.java 2010-08-09
17:46:24 UTC (rev 18518)
+++
root/sandbox/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/ProcessMojo.java 2010-08-09
17:47:05 UTC (rev 18519)
@@ -263,18 +263,20 @@
scanDynamicResources(cpResources);
scanStaticResources(resourceRoots);
- File outputDirFile = new File(outputDir);
- if (!outputDirFile.exists()) {
- outputDirFile = new File(project.getBuild().getDirectory(), outputDir);
+ File resourceOutputDir = new File(outputDir);
+ if (!resourceOutputDir.exists()) {
+ resourceOutputDir = new File(project.getBuild().getDirectory(),
outputDir);
}
+ File resourceMappingDir = new File(project.getBuild().getOutputDirectory());
+
ResourceHandler resourceHandler = new DynamicResourceHandler(new
StaticResourceHandler(resourceRoots));
// TODO set webroot
faces = new FacesImpl(null, new
FileNameMapperImpl(Maps.fromProperties(fileNameMappings)), resourceHandler);
faces.start();
- ResourceWriterImpl resourceWriter = new ResourceWriterImpl(outputDirFile);
+ ResourceWriterImpl resourceWriter = new ResourceWriterImpl(resourceOutputDir,
resourceMappingDir);
ResourceTaskFactoryImpl taskFactory = new ResourceTaskFactoryImpl(faces);
taskFactory.setResourceWriter(resourceWriter);
Modified:
root/sandbox/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java
===================================================================
---
root/sandbox/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java 2010-08-09
17:46:24 UTC (rev 18518)
+++
root/sandbox/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java 2010-08-09
17:47:05 UTC (rev 18519)
@@ -29,15 +29,16 @@
import java.io.InputStream;
import java.util.Map;
import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
import javax.faces.application.Resource;
import org.richfaces.application.ServiceTracker;
import org.richfaces.cdk.FileNameMapper;
import org.richfaces.cdk.ResourceWriter;
+import org.richfaces.resource.ResourceFactory;
import com.google.common.base.Strings;
+import com.google.common.collect.Maps;
import com.google.common.io.ByteStreams;
/**
@@ -46,13 +47,16 @@
*/
public class ResourceWriterImpl implements ResourceWriter {
- private File baseDir;
+ private File resourceContentsDir;
- private Map<String, String> processedResources = new
ConcurrentHashMap<String, String>();
+ private File resourceMappingDir;
- public ResourceWriterImpl(File baseDir) {
- this.baseDir = baseDir;
- baseDir.mkdirs();
+ private Map<String, String> processedResources = Maps.newConcurrentMap();
+
+ public ResourceWriterImpl(File resourceContentsDir, File resourceMappingDir) {
+ this.resourceContentsDir = resourceContentsDir;
+ this.resourceMappingDir = resourceMappingDir;
+ resourceContentsDir.mkdirs();
}
private String getResourceQualifier(Resource resource) {
@@ -65,9 +69,9 @@
private File getRoot(String rootName) {
if (!Strings.isNullOrEmpty(rootName)) {
- return new File(baseDir, rootName);
+ return new File(resourceContentsDir, rootName);
} else {
- return baseDir;
+ return resourceContentsDir;
}
}
@@ -118,7 +122,8 @@
//TODO separate mappings file location
FileOutputStream fos = null;
try {
- File mappingsFile = new File(baseDir,
"org.richfaces/resource-mappings.properties");
+ File mappingsFile = new File(resourceMappingDir,
ResourceFactory.STATIC_RESOURCE_MAPPINGS);
+ mappingsFile.delete();
mappingsFile.getParentFile().mkdirs();
mappingsFile.createNewFile();