You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jh...@apache.org on 2008/11/10 17:04:41 UTC
svn commit: r712685 - in /ant/sandbox/javafront:
src/main/org/apache/ant/javafront/TaskExec.java taskexec.bat taskexec.sh
Author: jhm
Date: Mon Nov 10 08:04:41 2008
New Revision: 712685
URL: http://svn.apache.org/viewvc?rev=712685&view=rev
Log:
Support for AntLibs
Modified:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/TaskExec.java
ant/sandbox/javafront/taskexec.bat
ant/sandbox/javafront/taskexec.sh
Modified: ant/sandbox/javafront/src/main/org/apache/ant/javafront/TaskExec.java
URL: http://svn.apache.org/viewvc/ant/sandbox/javafront/src/main/org/apache/ant/javafront/TaskExec.java?rev=712685&r1=712684&r2=712685&view=diff
==============================================================================
--- ant/sandbox/javafront/src/main/org/apache/ant/javafront/TaskExec.java (original)
+++ ant/sandbox/javafront/src/main/org/apache/ant/javafront/TaskExec.java Mon Nov 10 08:04:41 2008
@@ -47,6 +47,24 @@
* <b> - </b> closes the last open element <br>
* <b> # </b> 'opens' the input of embedded text <br>
* The last arguments closes all open elements.</p>
+ *
+ * You can also use external AntLibs, if <ul>
+ * <li>you add their jar to the classpath using <tt>-lib</tt> option and
+ * <li>load the AntLib using <tt>-xmlns:...</tt> option and
+ * <li>use the xmlns prefix
+ * </ul>
+ * Example:
+ * <pre>
+ * ant ^
+ * -lib build\classes <b>-lib path-to-ivy.jar</b> ^
+ * -main org.apache.ant.javafront.TaskExec ^
+ * <b>-xmlns:ivy=antlib:org.apache.ivy.ant</b> ^
+ * <b>ivy:</b>retrieve ^
+ * organisation junit ^
+ * module junit ^
+ * pattern _ivy/[artifact].[ext] ^
+ * inline true
+ * </pre>
*/
public class TaskExec implements AntMain {
@@ -63,6 +81,8 @@
// Initializing
Project project = initProject();
TagBuilder builder = TagBuilder.forProject(project);
+
+ Hashtable<String,String> antlibs = new Hashtable<String,String>();
// Process the arguments
Stack<Tag> tags = new Stack<Tag>();
@@ -79,10 +99,26 @@
nextIs = NextStatementIs.ATTRIBUTE;
} else if (arg.equals("#")) {
nextIs = NextStatementIs.TEXT;
+ } else if (arg.startsWith("-xmlns:")) {
+ // Register an antlib
+ String xmlns = arg.substring(7);
+ String uri = args[++i];
+ antlibs.put(xmlns, uri);
+ debug("REG : Antlib " + xmlns + " to " + uri);
} else {
switch (nextIs) {
case TAG :
- Tag newTag = builder.tag(arg);
+ Tag newTag;
+ int posSplit = arg.indexOf(":");
+ if (posSplit > -1) {
+ // Build a tag with xmlns
+ String prefix = arg.substring(0, posSplit);
+ String name = arg.substring(posSplit + 1);
+ String uri = antlibs.get(prefix);
+ newTag = builder.tagWithNs(name, uri);
+ } else {
+ newTag = builder.tag(arg);
+ }
tags.push(newTag);
if (current != null) {
// This is not a root element so add it to its parent.
Modified: ant/sandbox/javafront/taskexec.bat
URL: http://svn.apache.org/viewvc/ant/sandbox/javafront/taskexec.bat?rev=712685&r1=712684&r2=712685&view=diff
==============================================================================
--- ant/sandbox/javafront/taskexec.bat (original)
+++ ant/sandbox/javafront/taskexec.bat Mon Nov 10 08:04:41 2008
@@ -16,15 +16,17 @@
REM limitations under the License.
cls
+
+REM Standard start arguments
set START=call ant -lib build\classes -main org.apache.ant.javafront.TaskExec
+
echo ----- Build the library -----
call ant
-
echo ===============================================================================================
echo XML: ^<echo message="Hello World"/^>
echo CMD: echo message "Hello World"
@@ -96,5 +98,22 @@
%START% concat + fileset dir src includes *.properties - + header # Ant Version ${ant.version} - + footer # End of text
-
-:end
\ No newline at end of file
+echo ===============================================================================================
+echo XML: ^<ivy:retrieve xmlns:ivy="antlib:org.apache.ivy.ant" organisation="junit" module="junit" inline="true" pattern="_ivy/[artifact].[ext]"/^>
+echo CMD: -lib path-to-ivy.jar
+echo -xmlns:ivy=antlib:org.apache.ivy.ant
+echo ivy:retrieve organisation junit module junit inline true pattern _ivy/[artifact].[ext]
+echo -----------------------------------------------------------------------------------------------
+md _ivy
+echo ------ First we ^<get^> Ivy -----
+rem %START% get dest _ivy/ivy.jar src http://people.apache.org/~xavier/ivy/ivy-trunk.jar
+echo ------ Then we use Ivy to retrieve JUnit -----
+call ant ^
+ -lib build\classes -lib _ivy ^
+ -main org.apache.ant.javafront.TaskExec ^
+ -xmlns:ivy=antlib:org.apache.ivy.ant ^
+ ivy:retrieve ^
+ organisation junit ^
+ module junit ^
+ pattern _ivy/[artifact].[ext] ^
+ inline true
Modified: ant/sandbox/javafront/taskexec.sh
URL: http://svn.apache.org/viewvc/ant/sandbox/javafront/taskexec.sh?rev=712685&r1=712684&r2=712685&view=diff
==============================================================================
--- ant/sandbox/javafront/taskexec.sh (original)
+++ ant/sandbox/javafront/taskexec.sh Mon Nov 10 08:04:41 2008
@@ -97,3 +97,15 @@
echo CMD: concat + fileset dir src includes *.properties - + header # Ant Version ${ant.version} - + footer # End of text
echo '---------------------------------------------------------------------------------------------'
StartAnt concat + fileset dir src includes *.properties - + header # Ant Version ${ant.version} - + footer # End of text
+
+
+echo '============================================================================================='
+echo XML: ^<ivy:retrieve xmlns:ivy="antlib:org.apache.ivy.ant" organisation="junit" module="junit" inline="true" pattern="_ivy/[artifact].[ext]"/^>
+echo CMD: ivy:retrieve organisation junit module junit inline true pattern _ivy/[artifact].[ext]
+echo '---------------------------------------------------------------------------------------------'
+mkdir _ivy
+echo '------ First we ^<get^> Ivy -----'
+rem %START% get dest _ivy/ivy.jar src http://people.apache.org/~xavier/ivy/ivy-trunk.jar
+echo '------ Then we use Ivy to retrieve JUnit -----'
+ant -lib build/classes -lib _ivy -main org.apache.ant.javafront.TaskExec -xmlns:ivy=antlib:org.apache.ivy.ant ivy:retrieve organisation junit module junit pattern _ivy/[artifact].[ext] inline true
+