Author: alexsmirnov
Date: 2007-12-10 21:13:36 -0500 (Mon, 10 Dec 2007)
New Revision: 4686
Added:
trunk/cdk/maven-cdk-plugin/src/main/resources/templates/xcss.vm
trunk/cdk/maven-cdk-plugin/src/main/resources/templates12/xcss.vm
Modified:
trunk/cdk/generator/pom.xml
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java
trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyTest.java
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java
trunk/framework/impl/pom.xml
trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/web.xml
trunk/ui/assembly/pom.xml
Log:
Generate united script and css for a project
Modified: trunk/cdk/generator/pom.xml
===================================================================
--- trunk/cdk/generator/pom.xml 2007-12-11 00:35:09 UTC (rev 4685)
+++ trunk/cdk/generator/pom.xml 2007-12-11 02:13:36 UTC (rev 4686)
@@ -1,4 +1,6 @@
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>cdk</artifactId>
<groupId>org.richfaces</groupId>
@@ -77,11 +79,11 @@
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.1_3</version>
- </dependency>
- <dependency>
- <groupId>wutka</groupId>
- <artifactId>dtdparser</artifactId>
- <version>1.21</version>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>wutka</groupId>
+ <artifactId>dtdparser</artifactId>
+ <version>1.21</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java 2007-12-11
00:35:09 UTC (rev 4685)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java 2007-12-11
02:13:36 UTC (rev 4686)
@@ -31,7 +31,9 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.ErrorListener;
import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
@@ -70,12 +72,24 @@
* @throws ParsingException
*/
public void loadXML(InputStream input) throws ParsingException {
+ loadXML(input,false);
+ }
+
+
+ /**
+ * Load XML document and parse it into DOM.
+ *
+ * @param input
+ * @throws ParsingException
+ */
+ public void loadXML(InputStream input, boolean namespaceAware) throws ParsingException
{
try {
// Create Document Builder Factory
DocumentBuilderFactory docFactory = DocumentBuilderFactory
.newInstance();
docFactory.setValidating(false);
+ docFactory.setNamespaceAware(namespaceAware);
// Create Document Builder
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
@@ -146,6 +160,27 @@
TransformerFactory transformerFactory = TransformerFactory
.newInstance();
Transformer transformer = transformerFactory.newTransformer();
+ transformer.setErrorListener(new ErrorListener(){
+
+ public void error(TransformerException exception)
+ throws TransformerException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void fatalError(TransformerException exception)
+ throws TransformerException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void warning(TransformerException exception)
+ throws TransformerException {
+ // TODO Auto-generated method stub
+
+ }
+
+ });
transformer.setOutputProperty("omit-xml-declaration", "yes");
StringWriter out = new StringWriter();
StreamResult result = new StreamResult(out);
Modified: trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyTest.java
===================================================================
--- trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyTest.java 2007-12-11
00:35:09 UTC (rev 4685)
+++ trunk/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyTest.java 2007-12-11
02:13:36 UTC (rev 4686)
@@ -185,4 +185,23 @@
assertTrue(e.getMessage(),false);
}
}
+
+ public void testGetContentWithNS() throws Exception {
+ String xml = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
+ + "<f:faces-config xmlns=\"http://foo.bar\"
xmlns:f=\"http://foo.baz\">"
+ + "<f:component><test
f:foo=\"xxx\">blabla</test></f:component>"
+ + "</f:faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+ body.loadXML(in,true);
+ try {
+ assertEquals(
+ "<f:component xmlns:f=\"http://foo.baz\"><test
f:foo=\"xxx\"
xmlns=\"http://foo.bar\">blabla</test></f:component>",
+ body.getContent());
+ } catch (ParsingException e) {
+ e.printStackTrace();
+ assertTrue(e.getMessage(),false);
+ }
+
+ }
}
Modified:
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java
===================================================================
---
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java 2007-12-11
00:35:09 UTC (rev 4685)
+++
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java 2007-12-11
02:13:36 UTC (rev 4686)
@@ -90,6 +90,8 @@
private static final String RESOURCES_CONFIG_TEMPLATE =
"resources-config.vm";
+ private static final String XCSS_TEMPLATE = "xcss.vm";
+
private static final String TLD_TEMPLATE = "tld.vm";
private static final String TAGLIB_TEMPLATE = "taglib.vm";
@@ -156,6 +158,11 @@
private File buildDirectory;
/**
+ * @parameter default-value="${project.build.directory}/modules"
+ */
+ private File modulesDirectory;
+
+ /**
* The directory for compiled classes.
*
* @parameter expression="${project.build.directory}/pom.xml"
@@ -188,8 +195,21 @@
*/
private String includeTaglib = "META-INF/*.taglib.xml";
+ /**
+ * @parameter
+ */
+ private String includeXcss = "**/*.xcss";
/**
+ * @parameter
+ */
+ private String commonStyle;
+
+ /**
+ * @parameter
+ */
+ private String templateXpath;
+ /**
*
*/
public AssemblyLibraryMojo() {
@@ -214,7 +234,13 @@
"META-INF/resources-config.xml");
mergeXML(models, "META-INF/resources-config.xml",
RESOURCES_CONFIG_TEMPLATE, "/resource-config/resource",
- "name/text()", new VelocityContext(), resourcesConfig);
+ "name/text()", new VelocityContext(), resourcesConfig, false);
+ if (null != commonStyle) {
+ File commonXcss = new File(outputDirectory, commonStyle);
+ mergeXML(models, includeXcss, XCSS_TEMPLATE, templateXpath, null,
+ new VelocityContext(), commonXcss, true);
+
+ }
if (null != library.getTaglibs() && library.getTaglibs().length > 0) {
for (int i = 0; i < library.getTaglibs().length; i++) {
Taglib taglib = library.getTaglibs()[i];
@@ -238,7 +264,10 @@
.hasNext();) {
Model model = (Model) iterator.next();
String id = model.getArtifactId();
- if((includeModules == null || Arrays.binarySearch(includeModules,
id)>=0)&&(excludeModules == null || Arrays.binarySearch(excludeModules,
id)<0)){
+ if ((includeModules == null || Arrays.binarySearch(
+ includeModules, id) >= 0)
+ && (excludeModules == null || Arrays
+ .binarySearch(excludeModules, id) < 0)) {
taglibModels.add(model);
}
}
@@ -256,25 +285,27 @@
*/
private void generateTaglib(List models, Taglib taglib)
throws MojoExecutionException {
- getLog().debug("Assembly taglib for uri " + taglib.getUri()+" with short
name "+taglib.getShortName());
+ getLog().debug(
+ "Assembly taglib for uri " + taglib.getUri()
+ + " with short name " + taglib.getShortName());
VelocityContext taglibContext = new VelocityContext();
taglibContext.put("taglib", taglib);
// Build includes/excludes Xpath condition
String nameTag = "name";
createTagCondition(taglib, nameTag);
- File tld = new File(outputDirectory, "META-INF/"
- + taglib.getTaglib() + ".tld");
- getLog().debug("Write JSP taglib "+tld.getPath());
+ File tld = new File(outputDirectory, "META-INF/" + taglib.getTaglib()
+ + ".tld");
+ getLog().debug("Write JSP taglib " + tld.getPath());
mergeXML(models, includeTld, TLD_TEMPLATE, "/taglib/tag"
+ createTagCondition(taglib, "name") + " | /taglib/listener",
- null, new VelocityContext(taglibContext), tld);
+ null, new VelocityContext(taglibContext), tld, false);
File faceletsTaglib = new File(outputDirectory, "META-INF/"
+ taglib.getTaglib() + ".taglib.xml");
mergeXML(models, includeTaglib, TAGLIB_TEMPLATE, "/facelet-taglib/tag"
+ createTagCondition(taglib, "tag-name")
+ " | /facelet-taglib/function", null, new VelocityContext(
- taglibContext), faceletsTaglib);
- getLog().debug("Write Facelets taglib "+faceletsTaglib.getPath());
+ taglibContext), faceletsTaglib, false);
+ getLog().debug("Write Facelets taglib " + faceletsTaglib.getPath());
}
/**
@@ -393,7 +424,7 @@
Artifact artifact = factory.createBuildArtifact(model.getGroupId(),
model.getArtifactId(), model.getVersion(), model
.getPackaging());
- File moduleDir = new File(buildDirectory, model.getArtifactId());
+ File moduleDir = new File(modulesDirectory, model.getArtifactId());
unpackArtifact(artifact, moduleDir, true);
artifact = factory
.createArtifactWithClassifier(model.getGroupId(), model
@@ -425,7 +456,7 @@
.addAll(projectsDependencies.values());
writePom(generatedProject);
project.setDependencies(new ArrayList(projectsDependencies.values()));
-// project.setFile(generatedPom);
+ // project.setFile(generatedPom);
}
/**
@@ -480,7 +511,7 @@
}
for (Iterator iter = models.iterator(); iter.hasNext();) {
Model model = (Model) iter.next();
- File moduleFacesConfig = new File(buildDirectory, model
+ File moduleFacesConfig = new File(modulesDirectory, model
.getArtifactId()
+ "/META-INF/faces-config.xml");
if (moduleFacesConfig.exists()) {
@@ -538,22 +569,23 @@
* XPath expression fof common part of result file.
* @param keyXPath -
* XPath expression for key part of common parts
+ * @param context -
+ * Velocity context for template processing.
+ * @param namespaceAware TODO
* @param keySet -
* {@link Set} to check for duplicate keys. Must not be null
- * @param context -
- * Velocity context for template processing.
* @throws MojoExecutionException
*/
private void mergeXML(List models, String filename, String templateName,
String commonXpath, String keyXPath, VelocityContext context,
- File target) throws MojoExecutionException {
+ File target, boolean namespaceAware) throws MojoExecutionException {
Set<String> keySet = new HashSet<String>();
StringBuffer content = new StringBuffer();
List<XMLBody> xmls = new ArrayList<XMLBody>(models.size());
String[] split = filename.split(",");
for (Iterator iter = models.iterator(); iter.hasNext();) {
Model model = (Model) iter.next();
- File moduleDir = new File(buildDirectory, model.getArtifactId());
+ File moduleDir = new File(modulesDirectory, model.getArtifactId());
DirectoryScanner ds = new DirectoryScanner();
ds.setFollowSymlinks(true);
ds.setBasedir(moduleDir);
@@ -568,7 +600,7 @@
+ model.getArtifactId());
XMLBody configBody = new XMLBody();
try {
- configBody.loadXML(new FileInputStream(moduleFacesConfig));
+ configBody.loadXML(new FileInputStream(moduleFacesConfig),namespaceAware);
xmls.add(configBody);
if (commonXpath != null) {
if (keyXPath == null) {
Added: trunk/cdk/maven-cdk-plugin/src/main/resources/templates/xcss.vm
===================================================================
--- trunk/cdk/maven-cdk-plugin/src/main/resources/templates/xcss.vm
(rev 0)
+++ trunk/cdk/maven-cdk-plugin/src/main/resources/templates/xcss.vm 2007-12-11 02:13:36
UTC (rev 4686)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:template
xmlns:f='http:/jsf.exadel.com/template'
+
xmlns:u='http:/jsf.exadel.com/template/util'
+
xmlns="http://www.w3.org/1999/xhtml" >
+${content}
+</f:template>
\ No newline at end of file
Added: trunk/cdk/maven-cdk-plugin/src/main/resources/templates12/xcss.vm
===================================================================
--- trunk/cdk/maven-cdk-plugin/src/main/resources/templates12/xcss.vm
(rev 0)
+++ trunk/cdk/maven-cdk-plugin/src/main/resources/templates12/xcss.vm 2007-12-11 02:13:36
UTC (rev 4686)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:template
xmlns:f='http:/jsf.exadel.com/template'
+
xmlns:u='http:/jsf.exadel.com/template/util'
+
xmlns="http://www.w3.org/1999/xhtml" >
+${content}
+</f:template>
\ No newline at end of file
Modified: trunk/framework/impl/pom.xml
===================================================================
--- trunk/framework/impl/pom.xml 2007-12-11 00:35:09 UTC (rev 4685)
+++ trunk/framework/impl/pom.xml 2007-12-11 02:13:36 UTC (rev 4686)
@@ -64,37 +64,55 @@
</resourceRoot>
</configuration>
</execution>
+ <execution>
+ <id>framevork-javascript</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <copy todir="target/classes/org/ajax4jsf"
file="target/compressed/framework.pack.js"/>
+ </tasks>
+ </configuration>
+ </execution>
</executions>
</plugin>
<plugin>
<groupId>net.sf.alchim</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
- <executions><!--
+ <executions>
<execution>
<goals>
<goal>compress</goal>
</goals>
- </execution>-->
+ </execution>
</executions>
<configuration>
<nosuffix>false</nosuffix>
<outputDirectory>${project.build.directory}/compressed/</outputDirectory>
- <blaBla>foo</blaBla>
<aggregations>
<aggregation>
<!-- remove files after aggregation (default: false)
<removeIncluded>true</removeIncluded>
-->
<!-- insert new line after each concatenation (default: false) -->
- <insertNewLine>false</insertNewLine>
+ <insertNewLine>true</insertNewLine>
<output>${project.build.directory}/compressed/framework.pack.js</output>
<!-- files to include, path relative to output's directory or
absolute path-->
<includes>
- <include>**/*.js</include>
+
<include>${project.build.directory}/compressed/org/ajax4jsf/javascript/scripts/prototype-min.js</include>
+
<include>${project.build.directory}/compressed/org/ajax4jsf/javascript/scripts/AJAX-min.js</include>
+
<include>${project.build.directory}/compressed/org/ajax4jsf/javascript/scripts/dnd-min.js</include>
+
<include>${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/scriptaculous/scriptaculous-min.js</include>
+ <include>**/*-min.js</include>
</includes>
<!-- files to exclude, path relative to output's directory -->
<excludes>
<exclude>**/*.pack.js</exclude>
+ <!-- exclude parts of the scriptaculous, so big file already included
-->
+
<exclude>${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/scriptaculous/*.js</exclude>
+
<exclude>${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/jquery.jcarousel-min.js</exclude>
<exclude>**/compressed.css</exclude>
</excludes>
</aggregation>
Modified: trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/web.xml 2007-12-11 00:35:09 UTC
(rev 4685)
+++ trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/web.xml 2007-12-11 02:13:36 UTC
(rev 4686)
@@ -42,7 +42,16 @@
<context-param>
<param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
<param-value>NEKO</param-value>
- </context-param>
+ </context-param>
+ <context-param>
+ <param-name>org.richfaces.LoadStyleStrategy</param-name>
+ <param-value>ALL</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.richfaces.LoadScriptStrategy</param-name>
+ <param-value>ALL</param-value>
+ </context-param>
+
<filter>
<display-name>Ajax4jsf Filter</display-name>
<filter-name>ajax4jsf</filter-name>
Modified: trunk/ui/assembly/pom.xml
===================================================================
--- trunk/ui/assembly/pom.xml 2007-12-11 00:35:09 UTC (rev 4685)
+++ trunk/ui/assembly/pom.xml 2007-12-11 02:13:36 UTC (rev 4686)
@@ -1,4 +1,6 @@
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>ui</artifactId>
<groupId>org.richfaces</groupId>
@@ -57,7 +59,9 @@
<includeModules>core</includeModules>
</taglib>
</taglibs>
- </library>
+ </library><!--
+ <templateXpath>/*[local-name()='template']/*</templateXpath>
+ --><commonStyle>org/richfaces/skin.xcss</commonStyle>
</configuration>
<executions>
<execution>
@@ -123,7 +127,7 @@
</execution>
</executions>
<configuration>
- <javadocVersion>1.5</javadocVersion>
+ <javadocVersion>1.5</javadocVersion>
</configuration>
</plugin>
<plugin>
@@ -197,7 +201,75 @@
</outputDirectory>
</configuration>
</plugin>
- </plugins>
+ <plugin>
+ <groupId>net.sf.alchim</groupId>
+ <artifactId>yuicompressor-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compress</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <nosuffix>false</nosuffix>
+ <outputDirectory>
+ ${project.build.directory}/compressed/
+ </outputDirectory>
+ <aggregations>
+ <aggregation>
+ <!-- remove files after aggregation (default: false)
+ <removeIncluded>true</removeIncluded>
+ -->
+ <!-- insert new line after each concatenation (default: false) -->
+ <insertNewLine>true</insertNewLine>
+ <output>
+ ${project.build.directory}/compressed/ui.pack.js
+ </output>
+ <!-- files to include, path relative to output's directory or absolute
path-->
+ <includes><!--
+ <include>
+ ${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/scriptaculous/scriptaculous-min.js
+ </include>
+ --><include>**/*-min.js</include>
+ </includes>
+ <!-- files to exclude, path relative to output's directory -->
+ <excludes>
+ <exclude>**/*.pack.js</exclude>
+ <!--
+ <exclude>
+ ${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/jquery.jcarousel-min.js
+ </exclude>
+ -->
+ <exclude>**/scriptaculo*</exclude>
+ <exclude>**/scriptaculo*/**</exclude>
+ </excludes>
+ </aggregation>
+ </aggregations><!--
+ <warSourceDirectory>${project.build.directory}/modules</warSourceDirectory>
+ <webappDirectory>${project.build.directory}/compressed</webappDirectory>
+ --><includes>
+ <include>**/*.js</include>
+ </includes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>framevork-javascript</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <copy todir="target/classes/org/richfaces"
file="target/compressed/ui.pack.js"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin> </plugins>
</build>
<dependencies />
</project>
\ No newline at end of file