Author: jvelociter
Date: 2008-02-03 23:01:17 +0100 (Sun, 03 Feb 2008)
New Revision: 7285

Added:
   xwiki-products/xwiki-watch/trunk/gwt/
   xwiki-products/xwiki-watch/trunk/gwt/src/assemble/
   xwiki-products/xwiki-watch/trunk/gwt/src/assemble/watch.xml
   xwiki-products/xwiki-watch/trunk/tools/
   xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/
   xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/pom.xml
   xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/
   xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/
   xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/
   xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/
   
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/
   
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/xwiki/
   
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/xwiki/tool/
   
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/xwiki/tool/doc/
   
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/xwiki/tool/doc/AbstractDocumentMojo.java
   
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/xwiki/tool/doc/AttachMojo.java
   
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/xwiki/tool/doc/SetPropertyMojo.java
   xwiki-products/xwiki-watch/trunk/tools/pom.xml
Removed:
   xwiki-products/xwiki-watch/trunk/web/
Modified:
   
xwiki-products/xwiki-watch/trunk/distribution/hsqldb/src/assemble/application.xml
   xwiki-products/xwiki-watch/trunk/distribution/pom.xml
   xwiki-products/xwiki-watch/trunk/gwt/pom.xml
   xwiki-products/xwiki-watch/trunk/pom.xml
   xwiki-products/xwiki-watch/trunk/wiki/pom.xml
Log:
XWATCH-99 Embed XWatch GWT code in a zip in the generated wiki xar

* Introduce a maven plugin that loads a document from XML, can attach a file to 
it and write it back to XML. The plugin can also set 
XWiki object String properties.

* Renamed module "web" in "gwt". The gwt module doesn't depend on 
enterprise-web war anymore, and is packaged as a zip. The generated 
zip is dynamically attached to WatchCode.GWT with the fore-mentionned mojo when 
building watch wiki.



Modified: 
xwiki-products/xwiki-watch/trunk/distribution/hsqldb/src/assemble/application.xml
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/distribution/hsqldb/src/assemble/application.xml
   2008-02-03 17:14:46 UTC (rev 7284)
+++ 
xwiki-products/xwiki-watch/trunk/distribution/hsqldb/src/assemble/application.xml
   2008-02-03 22:01:17 UTC (rev 7285)
@@ -32,7 +32,7 @@
            not specified -->
       <outputFileNameMapping></outputFileNameMapping>
       <includes>
-        <include>com.xpn.xwiki.products:xwiki-watch</include>
+        <include>com.xpn.xwiki.products:xwiki-enterprise-web</include>
       </includes>
       <outputDirectory>webapps/xwiki</outputDirectory>
       <unpack>true</unpack>

Modified: xwiki-products/xwiki-watch/trunk/distribution/pom.xml
===================================================================
--- xwiki-products/xwiki-watch/trunk/distribution/pom.xml       2008-02-03 
17:14:46 UTC (rev 7284)
+++ xwiki-products/xwiki-watch/trunk/distribution/pom.xml       2008-02-03 
22:01:17 UTC (rev 7285)
@@ -36,8 +36,8 @@
   <dependencies>
     <dependency>
       <groupId>com.xpn.xwiki.products</groupId>
-      <artifactId>xwiki-watch</artifactId>
-      <version>${pom.version}</version>
+      <artifactId>xwiki-enterprise-web</artifactId>
+      <version>${platform.web.version}</version>
       <type>war</type>
     </dependency>
     <dependency>

Copied: xwiki-products/xwiki-watch/trunk/gwt (from rev 7257, 
xwiki-products/xwiki-watch/trunk/web)

Modified: xwiki-products/xwiki-watch/trunk/gwt/pom.xml
===================================================================
--- xwiki-products/xwiki-watch/trunk/web/pom.xml        2008-02-01 11:42:29 UTC 
(rev 7257)
+++ xwiki-products/xwiki-watch/trunk/gwt/pom.xml        2008-02-03 22:01:17 UTC 
(rev 7285)
@@ -5,10 +5,10 @@
     <artifactId>xwiki-watch-parent</artifactId>
     <version>1.0-SNAPSHOT</version>
   </parent>
-  <artifactId>xwiki-watch</artifactId>
-  <name>XWiki Products - Watch - Web</name>
-  <packaging>war</packaging>
-  <description>XWiki Products - Watch - Web</description>
+  <artifactId>xwiki-watch-gwt</artifactId>
+  <name>XWiki Products - Watch - GWT</name>
+  <packaging>pom</packaging>
+  <description>XWiki Products - Watch - GWT</description>
   <properties>
     <gwtVersion>1.3.3</gwtVersion>
   </properties>
@@ -38,12 +38,6 @@
       <artifactId>junit</artifactId>
       <version>3.8.2</version>
     </dependency> 
-   <dependency>
-      <groupId>com.xpn.xwiki.platform</groupId>
-      <artifactId>xwiki-core</artifactId>
-      <version>${platform.core.version}</version>
-      <scope>provided</scope>
-    </dependency>
     <dependency>
       <groupId>com.xpn.xwiki.platform</groupId>
       <artifactId>xwiki-web-gwt</artifactId>
@@ -55,14 +49,15 @@
       <version>${platform.web.version}</version>
       <classifier>sources</classifier>
     </dependency>
-    <dependency>
-      <groupId>com.xpn.xwiki.platform</groupId>
-      <artifactId>xwiki-web-standard</artifactId>
-      <version>${platform.web.version}</version>
-      <type>war</type>
-    </dependency>
   </dependencies>
   <build>
+    <extensions>
+      <extension>
+           <groupId>com.xpn.xwiki.products</groupId>
+        <artifactId>xwiki-watch-build-zip-plugin</artifactId>
+               <version>1.0-SNAPSHOT</version>
+         </extension>
+       </extensions>
     <plugins>
       <!-- Download and unpack the GWT compiler -->
       <plugin>
@@ -92,10 +87,15 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
-        <configuration>
-          <source>1.4</source>
-          <target>1.4</target>
-        </configuration>
+        <executions>
+          <execution>
+            <phase>compile</phase>
+            <configuration>
+              <source>1.4</source>
+              <target>1.4</target>
+            </configuration>
+           </execution>
+        </executions>
       </plugin>
       <plugin>
         <groupId>com.totsp.gwt</groupId>
@@ -119,58 +119,31 @@
           </execution>
         </executions>
       </plugin>
-      <!-- Inject XWiki's configuration (only xwiki.cfg, not 
hibernate.cfg.xml) -->
-      <plugin>
+         <plugin>
         <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-remote-resources-plugin</artifactId>
-        <executions>
-          <execution>
-            <!-- The remote resources plugin adds its output directory as a 
resource directory
-                 so that the Maven resources plugin copies these resources to 
target/classes.
-                 However copying them to target/classes will make them appear 
in WEB-INF/classes
-                 in the generated WAR since the WAR plugin copies resources in 
target/classes in
-                 WEB-INF/classes. Thus to prevent this we're binding this 
execution to a phase
-                 that comes after the execution of the resources plugin (which 
executes in the
-                 process-resources phase). Thus this remote resources plugin 
will execute just
-                 after the resources plugin and the resources won't be copied, 
which is why we're
-                 adding a webResource configuration element below in the WAR 
plugin's
-                 configuration. -->
-            <phase>process-resources</phase>
-            <goals>
-              <goal>process</goal>
-            </goals>
-          </execution>
-        </executions>
-        <configuration>
-          <resourceBundles>
-            
<resourceBundle>com.xpn.xwiki.platform:xwiki-configuration-resources:${platform.tools.version}</resourceBundle>
-          </resourceBundles>
-          <properties>
-            <xwikiCfgPlugins>
-              com.xpn.xwiki.plugin.feed.FeedPlugin,\
-             com.xpn.xwiki.plugin.zipexplorer.ZipExplorerPlugin,\
-             com.xpn.xwiki.plugin.packaging.PackagePlugin,\
-             com.xpn.xwiki.plugin.autotag.AutoTagPlugin
-            </xwikiCfgPlugins>
-          </properties>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-war-plugin</artifactId>
-        <configuration>
-          <webResources>
-            <resource>
-              
<directory>${project.build.directory}/maven-shared-archive-resources</directory>
-              <targetPath>WEB-INF</targetPath>
-              <includes>
-                <include>xwiki.cfg</include>
-              </includes>
-            </resource>
-          </webResources>
-        </configuration>
-      </plugin>
+               <artifactId>maven-assembly-plugin</artifactId>
+               <executions>
+                 <execution>
+                   <phase>package</phase>
+                       <goals>
+                         <goal>assembly</goal>
+                       </goals>
+               <configuration>
+                     <descriptors>
+                       <descriptor>src/assemble/watch.xml</descriptor>
+                     </descriptors>
+                   </configuration>
+                 </execution>
+           </executions>
+         </plugin>
     </plugins>
+       <!--
+    <resources>
+      <resource>
+        
<directory>${basedir}/target/${pom.artifactId}-${pom.version}</directory>
+      </resource>
+    </resources>
+       -->
   </build>
   <profiles>
     <profile>

Added: xwiki-products/xwiki-watch/trunk/gwt/src/assemble/watch.xml
===================================================================
--- xwiki-products/xwiki-watch/trunk/gwt/src/assemble/watch.xml                 
        (rev 0)
+++ xwiki-products/xwiki-watch/trunk/gwt/src/assemble/watch.xml 2008-02-03 
22:01:17 UTC (rev 7285)
@@ -0,0 +1,34 @@
+<!--
+ *
+ *  See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+-->
+
+<assembly>
+  <formats>
+    <format>zip</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <fileSets>
+    <fileSet>
+         
<directory>${basedir}/target/${pom.artifactId}-${pom.version}</directory>
+      <outputDirectory>/</outputDirectory>
+    </fileSet>
+  </fileSets>
+</assembly>

Modified: xwiki-products/xwiki-watch/trunk/pom.xml
===================================================================
--- xwiki-products/xwiki-watch/trunk/pom.xml    2008-02-03 17:14:46 UTC (rev 
7284)
+++ xwiki-products/xwiki-watch/trunk/pom.xml    2008-02-03 22:01:17 UTC (rev 
7285)
@@ -49,7 +49,8 @@
     <product.enterprise.version>1.3-SNAPSHOT</product.enterprise.version>
   </properties>
   <modules>
-    <module>web</module>
+    <module>gwt</module>
+       <module>tools</module>
     <module>wiki</module>
     <module>database</module>
     <module>distribution</module>
@@ -69,7 +70,7 @@
         <artifactId>xwiki-build-xar-handlers</artifactId>
         <version>${platform.tools.version}</version>
       </extension>
-    </extensions>
+       </extensions>
     <plugins>
       <plugin>
         <groupId>com.xpn.xwiki.platform</groupId>

Added: xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/pom.xml
===================================================================
--- xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/pom.xml             
                (rev 0)
+++ xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/pom.xml     
2008-02-03 22:01:17 UTC (rev 7285)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ *
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+-->
+
+<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";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>com.xpn.xwiki.products</groupId>
+    <artifactId>xwiki-watch-build-tools</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>xwiki-watch-build-doc-plugin</artifactId>
+  <name>XWiki Products - Watch - Tools - Doc Plugin</name>
+  <packaging>maven-plugin</packaging>
+  <description>A Maven plugin to load XWiki documents from XML and perform 
file attachment or setting object properties, before writting the document back 
to XML</description>
+  <dependencies>
+    <dependency>
+      <groupId>com.xpn.xwiki.platform</groupId>
+      <artifactId>xwiki-core</artifactId>
+      <version>1.3-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <!-- Note: Needed to create a XWikiDocument, and xwiki-core does not 
provide it anymore.  -->
+      <version>2.4</version>
+    </dependency>      
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+      </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-archiver</artifactId>
+      <version>2.2</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-artifact</artifactId>
+      <version>2.0</version>
+    </dependency>
+  </dependencies>
+</project>

Added: 
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/xwiki/tool/doc/AbstractDocumentMojo.java
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/xwiki/tool/doc/AbstractDocumentMojo.java
                              (rev 0)
+++ 
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/xwiki/tool/doc/AbstractDocumentMojo.java
      2008-02-03 22:01:17 UTC (rev 7285)
@@ -0,0 +1,113 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.tool.doc;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+import com.xpn.xwiki.doc.XWikiDocument;
+
+/**
+ * An abstract Mojo that knows how to load a XWikiDocument from XML and to 
write XML from a
+ * XWikiDocument
+ * 
+ * @version $Id: $
+ */
+public abstract class AbstractDocumentMojo extends AbstractMojo
+{
+    
+    /**
+     * The maven project.
+     * 
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    private MavenProject project;
+
+    /**
+     * Loads a XWikiDocument from a XML file
+     * 
+     * @param file the xml file to load
+     * @return the XWiki document loaded from XML
+     * @throws MojoExecutionException
+     */
+    protected XWikiDocument loadFromXML(File file) throws 
MojoExecutionException
+    {
+        XWikiDocument doc = new XWikiDocument();
+        FileInputStream fis;
+        try {
+            fis = new FileInputStream(file);
+            doc.fromXML(fis);
+            fis.close();
+            return doc;
+        } catch (Exception e) {
+            throw new MojoExecutionException("Error loading XWikiDocument [" + 
file + "]", e);
+        }
+    }
+
+    /**
+     * Write a XWiki document to a XML file
+     * 
+     * @param doc the document to write XML for
+     * @param file the file to write the document to
+     * @throws MojoExecutionException
+     */
+    protected void writeToXML(XWikiDocument doc, File file) throws 
MojoExecutionException
+    {
+        try {
+            FileWriter fw = new FileWriter(file);
+            // write to XML the document, its object and attachments 
+            // but without rendering and without versions
+            // A null context does the trick if the document
+            // has been properly loaded.
+            fw.write(doc.toXML(true, false, true, false, null));
+            fw.close();
+        } catch (Exception e) {
+            throw new MojoExecutionException("Error writing XML for 
XWikiDocument [" + file + "]",
+                e);
+        }
+    }
+
+    /**
+     * Obtain the output file for a Wiki document
+     * 
+     * @param document the document to get the output file of
+     * @return the File for that document in the build output directory
+     * @throws MojoExecutionException
+     */
+    protected File getOutputFileForDocument(File document) throws 
MojoExecutionException
+    {
+        File targetDir = new 
File(this.project.getBuild().getOutputDirectory());
+        if (!targetDir.exists()) {
+            targetDir.mkdirs();
+        }
+        File spaceDir = new File(targetDir, 
document.getParentFile().getName());
+        if (!spaceDir.exists()) {
+            spaceDir.mkdirs();
+        }
+        return new File(targetDir, spaceDir.getName() + "/" + 
document.getName());
+    }
+}

Added: 
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/xwiki/tool/doc/AttachMojo.java
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/xwiki/tool/doc/AttachMojo.java
                                (rev 0)
+++ 
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/xwiki/tool/doc/AttachMojo.java
        2008-02-03 22:01:17 UTC (rev 7285)
@@ -0,0 +1,116 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.tool.doc;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.List;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+import com.xpn.xwiki.doc.XWikiAttachment;
+import com.xpn.xwiki.doc.XWikiDocument;
+
+/**
+ * Attach a file to a XWiki document
+ * 
+ * @version $Id: $
+ * @goal attach
+ */
+public class AttachMojo extends AbstractDocumentMojo
+{
+    /**
+     * The attachment author
+     * 
+     * @parameter expression="XWiki.Admin"
+     */
+    private String author;
+
+    /**
+     * The file to attach
+     * 
+     * @parameter
+     * @required
+     */
+    private File file;
+
+    /**
+     * Document to attach to
+     * 
+     * @parameter
+     * @required
+     */
+    private File document;
+
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        try {
+            XWikiDocument doc = loadFromXML(document);
+            
+            // Create a XWiki attachment from the file
+            XWikiAttachment attachment = createAttachment(file, author);
+
+            // Add the attachment to the document attachments list
+            List attachlist = doc.getAttachmentList();
+            attachlist.add(attachment);
+            doc.setAttachmentList(attachlist);
+
+            // output the file
+            File outputFile = this.getOutputFileForDocument(document);
+            writeToXML(doc, outputFile);
+
+        } catch (Exception e) {
+            throw new MojoExecutionException("Error while attaching the file", 
e);
+        }
+    }
+
+    /**
+     * Create a XWikiAttachment from a File
+     * 
+     * @param file the file to create the attachment from
+     * @return the attachment
+     * @throws MojoExecutionException
+     */
+    private XWikiAttachment createAttachment(File file, String author) throws 
MojoExecutionException
+    {
+        try {
+            // Create an empty attachment
+            XWikiAttachment attachment = new XWikiAttachment();
+
+            // Read the file data. I don't know if it's the proper way of 
doing this.
+            // Could possibly not handle huge files
+            byte[] data = new byte[(int) file.length()];
+            FileInputStream fis = new FileInputStream(file);
+            fis.read(data);
+            fis.close();
+
+            // Feed the attachment
+            attachment.setContent(data);
+            attachment.setAuthor(author);
+            attachment.setFilename(file.getName());
+
+            return attachment;
+        } catch (Exception e) {
+            throw new MojoExecutionException("Error while creating attachment 
for file ["
+                + file.getName() + "]", e);
+        }
+    }
+}

Added: 
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/xwiki/tool/doc/SetPropertyMojo.java
===================================================================
--- 
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/xwiki/tool/doc/SetPropertyMojo.java
                           (rev 0)
+++ 
xwiki-products/xwiki-watch/trunk/tools/build-doc-plugin/src/main/java/com/xpn/xwiki/tool/doc/SetPropertyMojo.java
   2008-02-03 22:01:17 UTC (rev 7285)
@@ -0,0 +1,100 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.tool.doc;
+
+import java.io.File;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+
+import com.xpn.xwiki.doc.XWikiDocument;
+import com.xpn.xwiki.objects.BaseObject;
+
+/**
+ * Set/Change a string property in a XWiki Object
+ * 
+ * @version $Id: $
+ * @goal setproperty
+ * @phase package
+ */
+public class SetPropertyMojo extends AbstractDocumentMojo
+{
+    
+    /**
+     * The document holding the object
+     * 
+     * @parameter expression="${basedir}/target/classes/XWiki/XWikiPreferences"
+     */
+    private File document;
+    
+    /**
+     * The class name of the object to write the property value to
+     * 
+     * @parameter expression="XWiki.XWikiPreferences"
+     */
+    private String className;
+    
+    /**
+     * The object id to write the property value to
+     * 
+     * @parameter expression="0"
+     */
+    private int objectId;
+    
+    /**
+     * The property name
+     * 
+     * @parameter
+     * @required
+     */
+    private String propName;
+    
+    /**
+     * The property value to write
+     * 
+     * @parameter
+     * @required
+     */
+    private String propValue;
+    
+    /**
+     * Append the value to the existing one
+     * 
+     * @parameter expression="false"
+     */
+    private boolean append;    
+    
+    
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        XWikiDocument doc = loadFromXML(document);
+        BaseObject bo = doc.getObject(className, objectId);
+        if(append){
+            propValue += bo.getStringValue(propName);
+        }   
+        bo.setStringValue(propName, propValue);
+        
+        File outputFile = getOutputFileForDocument(document);
+        
+        writeToXML(doc, outputFile);
+    }
+
+}

Added: xwiki-products/xwiki-watch/trunk/tools/pom.xml
===================================================================
--- xwiki-products/xwiki-watch/trunk/tools/pom.xml                              
(rev 0)
+++ xwiki-products/xwiki-watch/trunk/tools/pom.xml      2008-02-03 22:01:17 UTC 
(rev 7285)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ *
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+-->
+
+<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";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>com.xpn.xwiki.products</groupId>
+    <artifactId>xwiki-watch-parent</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>xwiki-watch-build-tools</artifactId>
+  <name>XWiki Products - Watch - Tools</name>
+  <packaging>pom</packaging>
+  <description>XWiki Products - Watch - Tools</description>
+  <modules>
+    <module>build-doc-plugin</module>
+  </modules>
+</project>

Modified: xwiki-products/xwiki-watch/trunk/wiki/pom.xml
===================================================================
--- xwiki-products/xwiki-watch/trunk/wiki/pom.xml       2008-02-03 17:14:46 UTC 
(rev 7284)
+++ xwiki-products/xwiki-watch/trunk/wiki/pom.xml       2008-02-03 22:01:17 UTC 
(rev 7285)
@@ -40,9 +40,14 @@
       <version>${product.enterprise.version}</version>
       <type>xar</type>
     </dependency>
+       <dependency>
+      <groupId>com.xpn.xwiki.products</groupId>
+         <artifactId>xwiki-watch-gwt</artifactId>
+         <version>${pom.version}</version>
+         <type>zip</type>
+       </dependency>
   </dependencies>
   <build>
-  <!--
     <resources>
       <resource>
         <directory>${basedir}/src/main/resources</directory>
@@ -51,6 +56,55 @@
         </excludes>
       </resource>
     </resources>
-  -->
+       <plugins>
+         <!--
+        Step 1: copy the GWT zip to the target directory
+         -->
+         <plugin>
+           <groupId>org.apache.maven.plugins</groupId>
+               <artifactId>maven-dependency-plugin</artifactId>
+               <executions>
+                 <execution>
+                   <goals>
+                         <goal>copy</goal>
+                       </goals>
+                       <configuration>
+                         <artifactItems>
+                           <artifactItem>
+                                 <groupId>com.xpn.xwiki.products</groupId>
+                                 <artifactId>xwiki-watch-gwt</artifactId>
+                                 <version>${pom.version}</version>
+                                 <type>zip</type>
+                                 <overWrite>true</overWrite>
+                                 
<outputDirectory>${project.build.directory}/gwt</outputDirectory>
+                                 <destFileName>watch.zip</destFileName>
+                               </artifactItem>
+                         </artifactItems>
+                       </configuration>
+                 </execution>
+               </executions>
+         </plugin>
+      <plugin>
+         <!--
+               Step 2: Attach watch JS-compiled code and resources zip
+                to WatchCode.GWT document.
+      -->
+        <groupId>com.xpn.xwiki.platform</groupId>
+        <artifactId>xwiki-build-doc-plugin</artifactId>
+        <executions>
+             <execution>
+            <phase>generate-resources</phase>
+                       <id>attach-watch-zip</id>
+            <goals>
+              <goal>attach</goal>
+            </goals>
+                       <configuration>
+              <file>${project.build.directory}/gwt/watch.zip</file>
+              <document>${basedir}/src/main/resources/WatchCode/GWT</document>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
   </build>
 </project>

_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to