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 2014/11/26 20:54:34 UTC

[1/3] ant git commit: junitreport: Expose classpath and factory of internal XSLTProcess task.

Repository: ant
Updated Branches:
  refs/heads/master fae798e81 -> c8edc8e0f


junitreport: Expose classpath and factory of internal XSLTProcess task.

This patch creates the nested XSLTProcess at creation of the
AggregateTransformer, not upon execution of the transformation.  This way it
is much easier to simply wrap parts of the interface I'd like to expose,
like the new <classpath> and <factory> nested elements, but also the
existing <param> elements.

I haven't called XSLTProcess.init(), as the previous code didn't do that
either.  I don't fully understand the difference between init() and a
constructor, but it might be a good thing to init the task somewhere.

The approach I chose is something like a whitelist delegation: the
XSLTProcess is a private member, and only selected methods of its interface
are wrapped and thus exposed to be configured.  As an alternative, one could
do something like a blacklist delegation by deriving a class from
XSLTProcess and forbidding access to certain settings by ovverriding the
corresponding methods and throwing exceptions therein.  In that case, one
might even turn the class derived from XSLTProcess into a nested <xslt>
element, which would be probably much clearer, as it would be configured in
the same way that a top-level <xslt> task is.  I didn't choose this approach
in my patch for now.


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/95ea95ce
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/95ea95ce
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/95ea95ce

Branch: refs/heads/master
Commit: 95ea95ce56b27a68660a04bcfa8abde2add0dcf3
Parents: fae798e
Author: Martin von Gagern <Ma...@gmx.net>
Authored: Wed Nov 26 13:50:50 2014 +0100
Committer: Martin von Gagern <Ma...@gmx.net>
Committed: Wed Nov 26 13:50:50 2014 +0100

----------------------------------------------------------------------
 manual/Tasks/junitreport.html                   |  9 ++++
 manual/Tasks/style.html                         |  4 +-
 .../optional/junit/AggregateTransformer.java    | 44 ++++++++++++--------
 3 files changed, 38 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/95ea95ce/manual/Tasks/junitreport.html
----------------------------------------------------------------------
diff --git a/manual/Tasks/junitreport.html b/manual/Tasks/junitreport.html
index cdf171e..365afe6 100644
--- a/manual/Tasks/junitreport.html
+++ b/manual/Tasks/junitreport.html
@@ -167,6 +167,15 @@ These tags can pass XSL parameters to the stylesheet.
   </tr>
 </table>
 
+<h4>classpath</h4>
+<p><em>Since Ant 1.10.</em>
+Like for the <a href="../CoreTasks/style.html#classpath">XSLT task</a>,
+a nested &lt;classpath&gt; will be used to load the processor.</p>
+
+<h4>factory</h4>
+<p><em>Since Ant 1.10.</em>
+Like for the <a href="../CoreTasks/style.html#factory">XSLT task</a>,
+a nested &lt;factory&gt; can be used to specify factory settings.</p>
 
 
 <h3>Example of report</h3>

http://git-wip-us.apache.org/repos/asf/ant/blob/95ea95ce/manual/Tasks/style.html
----------------------------------------------------------------------
diff --git a/manual/Tasks/style.html b/manual/Tasks/style.html
index 6e2a2a5..f02b98e 100644
--- a/manual/Tasks/style.html
+++ b/manual/Tasks/style.html
@@ -269,7 +269,7 @@ collection</a></h4>
 should be applied to.  Use a nested mapper and the task's destdir
 attribute to specify the output files.</p>
 
-<h4>classpath</h4>
+<h4><a name="classpath">classpath</a></h4>
 <p>The classpath to load the processor from can be specified via a
 nested <code>&lt;classpath&gt;</code>, as well - that is, a
 <a href="../using.html#path">path</a>-like structure.</p>
@@ -372,7 +372,7 @@ XSLT specifications</a>.
 </table>
 </blockquote>
 
-<h4>factory ('trax' processors only)</h4>
+<h4><a name="factory">factory ('trax' processors only)</a></h4>
 Used to specify factory settings.
 <blockquote>
 <h4>Parameters</h4>

http://git-wip-us.apache.org/repos/asf/ant/blob/95ea95ce/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
index 46c4406..c22bbc8 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
@@ -37,6 +37,7 @@ import org.apache.tools.ant.taskdefs.Delete;
 import org.apache.tools.ant.taskdefs.TempFile;
 import org.apache.tools.ant.taskdefs.XSLTProcess;
 import org.apache.tools.ant.types.EnumeratedAttribute;
+import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.resources.FileResource;
 import org.apache.tools.ant.types.resources.URLResource;
@@ -90,11 +91,11 @@ public class AggregateTransformer {
     protected File toDir;
 
     /**
-     * The params that will be sent to the XSL transformation
+     * The internal XSLT task used to perform the transformation.
      *
-     * @since Ant 1.7
+     * @since Ant 1.10
      */
-    private List params;
+    private XSLTProcess xsltTask;
 
     /**
      * Instance of a utility class to use for file operations.
@@ -129,7 +130,8 @@ public class AggregateTransformer {
      */
     public AggregateTransformer(Task task) {
         this.task = task;
-        params = new Vector();
+        xsltTask = new XSLTProcess();
+        xsltTask.bindToOwner(task);
     }
 
     /**
@@ -209,9 +211,27 @@ public class AggregateTransformer {
      * @since Ant 1.7
      */
     public XSLTProcess.Param createParam() {
-        XSLTProcess.Param p = new XSLTProcess.Param();
-        params.add(p);
-        return p;
+        return xsltTask.createParam();
+    }
+
+    /**
+     * Creates a classpath to be used for the internal XSLT task.
+     *
+     * @return the classpath to be configured
+     * @since Ant 1.10
+     */
+    public Path createClasspath() {
+        return xsltTask.createClasspath();
+    }
+
+    /**
+     * Creates a factory configuration to be used for the internal XSLT task.
+     *
+     * @return the factory description to be configured
+     * @since Ant 1.10
+     */
+    public XSLTProcess.Factory createFactory() {
+        return xsltTask.createFactory();
     }
 
     /**
@@ -225,9 +245,6 @@ public class AggregateTransformer {
         TempFile tempFileTask = new TempFile();
         tempFileTask.bindToOwner(task);
 
-        XSLTProcess xsltTask = new XSLTProcess();
-        xsltTask.bindToOwner(task);
-
         xsltTask.setXslResource(getStylesheet());
 
         // acrobatic cast.
@@ -245,13 +262,6 @@ public class AggregateTransformer {
             outputFile = new File(toDir, "junit-noframes.html");
         }
         xsltTask.setOut(outputFile);
-        for (Iterator i = params.iterator(); i.hasNext();) {
-            XSLTProcess.Param param = (XSLTProcess.Param) i.next();
-            XSLTProcess.Param newParam = xsltTask.createParam();
-            newParam.setProject(task.getProject());
-            newParam.setName(param.getName());
-            newParam.setExpression(param.getExpression());
-        }
         XSLTProcess.Param paramx = xsltTask.createParam();
         paramx.setProject(task.getProject());
         paramx.setName("output.dir");


[2/3] ant git commit: fix for Bugzilla 47002 by Martin van Gagern - closes #3

Posted by bo...@apache.org.
fix for Bugzilla 47002 by Martin van Gagern - closes #3


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/d8a51e9f
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/d8a51e9f
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/d8a51e9f

Branch: refs/heads/master
Commit: d8a51e9fd4e17cbcdcbce0cb014291ca0f16bcbf
Parents: 95ea95c
Author: Stefan Bodewig <bo...@apache.org>
Authored: Wed Nov 26 20:43:08 2014 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Wed Nov 26 20:43:08 2014 +0100

----------------------------------------------------------------------
 WHATSNEW | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/d8a51e9f/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index 4cc9c83..79670f3 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -49,6 +49,9 @@ Fixed bugs:
    contains spaces.
    github pull request #1
 
+ * <junitreport> now supports nested <classpath> and <factory> elements.
+   Bugzilla Report 47002
+
 Other changes:
 --------------
 


[3/3] ant git commit: make sure AggregateTransformer knows its task when running the test

Posted by bo...@apache.org.
make sure AggregateTransformer knows its task when running the test


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/c8edc8e0
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/c8edc8e0
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/c8edc8e0

Branch: refs/heads/master
Commit: c8edc8e0f46dd3747ae60e4de9ba4370e8f0075f
Parents: d8a51e9
Author: Stefan Bodewig <bo...@apache.org>
Authored: Wed Nov 26 20:53:47 2014 +0100
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Wed Nov 26 20:53:47 2014 +0100

----------------------------------------------------------------------
 .../taskdefs/optional/junit/XMLResultAggregatorTest.java  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/c8edc8e0/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregatorTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregatorTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregatorTest.java
index faa323a..da67fec 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregatorTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregatorTest.java
@@ -59,11 +59,6 @@ public class XMLResultAggregatorTest {
         }
         XMLResultAggregator task = new XMLResultAggregator();
         task.setTodir(d);
-        AggregateTransformer report = task.createReport();
-        report.setTodir(d);
-        FileSet fs = new FileSet();
-        fs.setFile(xml);
-        task.addFileSet(fs);
         Project project = new Project();
         DefaultLogger logger = new DefaultLogger();
         logger.setOutputPrintStream(System.out);
@@ -72,6 +67,11 @@ public class XMLResultAggregatorTest {
         project.addBuildListener(logger);
         project.init();
         task.setProject(project);
+        AggregateTransformer report = task.createReport();
+        report.setTodir(d);
+        FileSet fs = new FileSet();
+        fs.setFile(xml);
+        task.addFileSet(fs);
         /* getResourceAsStream override unnecessary on JDK 7. Ought to work around JAXP #6723276 in JDK 6, but causes a TypeCheckError in FunctionCall for reasons TBD:
         Thread.currentThread().setContextClassLoader(new ClassLoader(ClassLoader.getSystemClassLoader().getParent()) {
             public InputStream getResourceAsStream(String name) {