You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2009/05/05 16:28:36 UTC

svn commit: r771741 - in /ant/antlibs/dotnet/trunk: changes.xml docs/index.html docs/tallow.html src/main/org/apache/ant/dotnet/wix/TallowTask.java

Author: bodewig
Date: Tue May  5 14:28:35 2009
New Revision: 771741

URL: http://svn.apache.org/viewvc?rev=771741&view=rev
Log:
Add a tallow task, submitted by zhihengz AT hotmail DOT com.  PR 47078

Added:
    ant/antlibs/dotnet/trunk/docs/tallow.html   (with props)
    ant/antlibs/dotnet/trunk/src/main/org/apache/ant/dotnet/wix/TallowTask.java   (with props)
Modified:
    ant/antlibs/dotnet/trunk/changes.xml
    ant/antlibs/dotnet/trunk/docs/index.html

Modified: ant/antlibs/dotnet/trunk/changes.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/dotnet/trunk/changes.xml?rev=771741&r1=771740&r2=771741&view=diff
==============================================================================
--- ant/antlibs/dotnet/trunk/changes.xml (original)
+++ ant/antlibs/dotnet/trunk/changes.xml Tue May  5 14:28:35 2009
@@ -38,6 +38,10 @@
     </properties>
 
     <release version="SVN trunk" date="unpublished">
+      <action type="add" issue="47078">
+        A new tallow task has been added to ease creation of WiX built
+        installers.
+      </action>
       <action type="update" issue="46968">
         The wix task has new nested elements that allow users to send
         addtional command line arguments to candle and light.

Modified: ant/antlibs/dotnet/trunk/docs/index.html
URL: http://svn.apache.org/viewvc/ant/antlibs/dotnet/trunk/docs/index.html?rev=771741&r1=771740&r2=771741&view=diff
==============================================================================
--- ant/antlibs/dotnet/trunk/docs/index.html (original)
+++ ant/antlibs/dotnet/trunk/docs/index.html Tue May  5 14:28:35 2009
@@ -160,6 +160,9 @@
       <li><a href="wix.html">wix</a> - execute candle and/or light of
       the WiX toolset.</li>
 
+      <li><a href="tallow.html">tallow</a> - execute tallow of the WiX
+      toolset.</li>
+
       <li><a href="nunit.html">nunit</a> - execute the
       nunit-console.exe <a href="http://www.nunit.org/">NUnit</a>
       test runner.</li>

Added: ant/antlibs/dotnet/trunk/docs/tallow.html
URL: http://svn.apache.org/viewvc/ant/antlibs/dotnet/trunk/docs/tallow.html?rev=771741&view=auto
==============================================================================
--- ant/antlibs/dotnet/trunk/docs/tallow.html (added)
+++ ant/antlibs/dotnet/trunk/docs/tallow.html Tue May  5 14:28:35 2009
@@ -0,0 +1,113 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+ 
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<html>
+  <head>
+    <meta http-equiv="Content-Language" content="en-us"></meta>
+    <link rel="stylesheet" type="text/css" href="style.css">
+    <title>Tallow Task</title>
+  </head>
+
+  <body>
+    <h2>tallow</h2>
+
+    <h3>Description</h3>
+
+    <p>Runs tallow from the <a
+    href="http://sourceforge.net/projects/wix">Wix</a> toolset
+    </p>
+
+    <h3>Parameters</h3>
+    <table border="1" cellpadding="2" cellspacing="0">
+      <tr>
+        <td valign="top"><b>Attribute</b></td>
+        <td valign="top"><b>Description</b></td>
+        <td align="center" valign="top"><b>Required</b></td>
+      </tr>
+      <tr>
+        <td valign="top">source</td>
+        <td valign="top">The single source directory to process.</td>
+        <td align="center">Either this or at least one nested
+        &lt;sources&gt; set.</td>
+      </tr>
+      <tr>
+        <td valign="top">target</td>
+        <td valign="top">The expected target file.</td>
+        <td align="center">Yes</td>
+      </tr>
+      <tr>
+        <td valign="top">vm</td>
+        <td valign="top">Same as <a
+            href="dotnetexec.html">dotnetexec</a>'s vm attribute.
+          Specify the framework to use.</td>
+        <td align="center">No.</td>
+      </tr>
+      <tr>
+        <td valign="top">wixHome</td>
+        <td valign="top">Installation directory of WiX.</td>
+        <td align="center">No - Ant will assume WiX is on your PATH
+        otherwise.</td>
+      </tr>
+    </table>
+
+    <h3>Parameters specified as nested elements</h3>
+
+    <h4>sources</h4>
+
+    <p>Specify source directories that shall be passed on the command line.
+    This is a <a
+    href="http://ant.apache.org/manual/CoreTypes/dirset.html">dirset</a>.</p>
+
+    <h4>arg</h4>
+
+    <p>Specifies additional arguments for talow</p>
+
+    <p><code>arg</code> is
+      a <a href="http://ant.apache.org/manual/using.html#arg">command
+        line argument</a>.</p>
+
+    <h3>Examples</h3>
+
+    <p>Create <code>product.wxs</code> from <code>product</code> directory:</p>
+
+    <pre>
+      &lt;tallow source="product" target="product.wxs"/&gt;
+    </pre>
+
+    <p>Create <code>product.wxs</code> from <code>bin</code>,<code>docs</code>,
+    and <code>conf</code> under <code>product</code> directory:</p>
+
+    <pre>
+      &lt;tallow target="bin.wxs"/&gt;
+        &lt;sources dir="product", includes="bin,docs,conf"/&gt;
+      &lt;/tallow&gt;
+    </pre>
+
+    <p>Create <code>product.wxs</code> from <code>bin</code>,<code>docs</code>,
+    and <code>conf</code> under <code>product</code> directory:, and
+    set all files <code>vital</code>
+    </p>
+
+    <pre>
+      &lt;tallow target="bin.wxs"/&gt;
+        &lt;sources dir="product", includes="bin,docs,conf"/&gt;
+        &lt;arg value="-dav"/&gt;
+      &lt;/tallow&gt;
+    </pre>
+  </body>
+</html>

Propchange: ant/antlibs/dotnet/trunk/docs/tallow.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ant/antlibs/dotnet/trunk/src/main/org/apache/ant/dotnet/wix/TallowTask.java
URL: http://svn.apache.org/viewvc/ant/antlibs/dotnet/trunk/src/main/org/apache/ant/dotnet/wix/TallowTask.java?rev=771741&view=auto
==============================================================================
--- ant/antlibs/dotnet/trunk/src/main/org/apache/ant/dotnet/wix/TallowTask.java (added)
+++ ant/antlibs/dotnet/trunk/src/main/org/apache/ant/dotnet/wix/TallowTask.java Tue May  5 14:28:35 2009
@@ -0,0 +1,220 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.ant.dotnet.wix;
+
+import org.apache.ant.dotnet.DotNetExecTask;
+import org.apache.ant.dotnet.build.AbstractBuildTask;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.Commandline;
+import org.apache.tools.ant.types.DirSet;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * Task to run the tallow on packaging content to create a wxs file
+ *
+ * @see http://sf.net/projects/wix
+ */
+public class TallowTask extends Task {
+
+    /**
+     * The vm attribute - if given.
+     */
+    private String vm;
+
+    /**
+     * The source dirs.
+     */
+    private ArrayList sources = new ArrayList();
+
+    /**
+     * A single source file.
+     */
+    private File source;
+
+    /**
+     * The target file.
+     */
+    private File target;
+
+    /**
+     * Where is WiX installed?
+     */
+    private File wixHome = null;
+    /**
+     * addtional command line arguments for tallow.
+     */
+    private Commandline cmdl = new Commandline();
+
+    public TallowTask() {
+        super();
+    }
+
+    /**
+     * Set the name of the executable for the virtual machine.
+     *
+     * @param value the name of the executable for the virtual machine
+     */
+    public void setVm(String value) {
+        this.vm = value;
+    }
+
+    /**
+     * The main source file.
+     *
+     * <p><code>tallow</code> may include more directories than this one,
+     * the main source is the one passed on the command line.</p>
+     *
+     * @param File object of the main source file.
+     */
+    public void setSource(File f) {
+        source = f;
+    }
+
+    /**
+     * The main target file.
+     *
+     * @param File object of the main target file.
+     */
+    public void setTarget(File f) {
+        target = f;
+    }
+
+    /**
+     * A set of source files.
+     */
+    public void addSources(DirSet ds) {
+        sources.add(ds);
+    }
+    /**
+     * Sets the installation directory of WiX.
+     *
+     * <p>If omitted, Ant will assume that WiX's executables can be
+     * found on the PATH.</p>
+     */
+    public void setWixHome(File f) {
+        wixHome = f;
+    }
+    /**
+     * Adds a command-line argument for tallow.exe.
+     *
+     * @return new command line argument created.
+     */
+    public Commandline.Argument createArg() {
+        return cmdl.createArgument();
+    }
+    public void execute() {
+
+        Collection grabbedDirs = grabSources();
+
+        if (target == null) {
+            throw new BuildException("You must specify the target if you want"
+                                     + " to run tallow.");
+        }
+        runTallow(grabbedDirs);
+    }
+
+    private Collection grabSources() {
+
+        Set r = new HashSet();
+
+        if (source != null) {
+
+            if (!source.exists()) {
+                throw new BuildException("Source " + source
+                                         + " doesn't exist.");
+            } else if (!source.isDirectory()) {
+
+                throw new BuildException("Source " + source
+                                         + " is not directory.");
+            }
+
+            r.add(source);
+
+        } else if (sources.size() == 0) {
+            throw new BuildException("You must specify at least one source"
+                                     + " file.");
+        } else {
+            Iterator iter = sources.iterator();
+            while (iter.hasNext()) {
+                DirSet ds = (DirSet) iter.next();
+                DirectoryScanner scanner = ds.getDirectoryScanner(getProject());
+                String[] f = scanner.getIncludedDirectories();
+                File base = ds.getDir(getProject());
+                for (int i = 0; i < f.length; i++) {
+                    r.add(new File(base, f[i]));
+                }
+            }
+            if (r.isEmpty()) {
+                throw new BuildException("No sources found");
+            }
+        }
+
+        return r;
+    }
+    /**
+     * Run tallow passing all files of the collection on the command line.
+     */
+    private void runTallow(Collection s) {
+        run(wixExecutable("tallow.exe"), s, target, cmdl);
+    }
+    /**
+     * returns an absolute path for the given executable if wixHome
+     * has been specified, the given name otherwise.
+     */
+    private String wixExecutable(String name) {
+        return wixHome == null ? name
+            : new File(wixHome, name).getAbsolutePath();
+    }
+
+    /**
+     * Runs the specified command passing all files of the collection
+     * on the command line - potentially adding an /out parameter.
+     */
+    private void run(String executable, Collection s, File target,
+                     Commandline cmdl) {
+        DotNetExecTask exec = 
+            DotNetExecTask.getTask(this, vm, executable, null);
+        exec.setFailonerror(true);
+        exec.setTaskType("wix");
+
+        exec.createArg().setValue("/nologo");
+
+        Iterator iter = s.iterator();
+        while (iter.hasNext()) {
+            File f = (File) iter.next();
+            exec.createArg().setValue("-d");
+            exec.createArg().setValue(f.getAbsolutePath());
+        }
+        String[] extraArgs = cmdl.getArguments();
+        for (int i = 0; i < extraArgs.length; i++) {
+            exec.createArg().setValue(extraArgs[i]);
+        }
+        exec.setOutput (target);
+
+        exec.execute();
+    }
+}

Propchange: ant/antlibs/dotnet/trunk/src/main/org/apache/ant/dotnet/wix/TallowTask.java
------------------------------------------------------------------------------
    svn:eol-style = native