ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r709205 - in /ant/sandbox/javafront/src: etc/examples/Simple3.java main/org/apache/ant/javafront/builder/PropertyBuilder.java main/org/apache/ant/javafront/builder/TagBuilder.java
Date Thu, 30 Oct 2008 16:51:47 GMT
Author: bodewig
Date: Thu Oct 30 09:51:46 2008
New Revision: 709205

URL: http://svn.apache.org/viewvc?rev=709205&view=rev
Log:
A more complex builder

Added:
    ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/PropertyBuilder.java 
 (with props)
Modified:
    ant/sandbox/javafront/src/etc/examples/Simple3.java
    ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/TagBuilder.java

Modified: ant/sandbox/javafront/src/etc/examples/Simple3.java
URL: http://svn.apache.org/viewvc/ant/sandbox/javafront/src/etc/examples/Simple3.java?rev=709205&r1=709204&r2=709205&view=diff
==============================================================================
--- ant/sandbox/javafront/src/etc/examples/Simple3.java (original)
+++ ant/sandbox/javafront/src/etc/examples/Simple3.java Thu Oct 30 09:51:46 2008
@@ -22,7 +22,7 @@
 import org.apache.tools.ant.Project;
 import org.apache.ant.javafront.builder.TagBuilder;
 
-@AntProject(Name="simple3", BaseDir="..")
+@AntProject(Name="simple3", BaseDir="..", DefaultTarget="hello")
 public class Simple3 {
     private Project p;
 
@@ -30,11 +30,17 @@
         this.p = p;
     }
 
-    @AntTarget
+    @AntTarget(Name="-setup")
+    public void setup() {
+        TagBuilder.forProject(p)
+            .newProperty().withName("world").andValue("world").execute();
+    }
+
+    @AntTarget(Depends="-setup")
     public void hello() {
         TagBuilder.forProject(p)
             .newTag("echo")
-            .withAttribute("message", "Hello, world!")
+            .withAttribute("message", "Hello, ${world}!")
             .execute();
     }
 }

Added: ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/PropertyBuilder.java
URL: http://svn.apache.org/viewvc/ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/PropertyBuilder.java?rev=709205&view=auto
==============================================================================
--- ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/PropertyBuilder.java (added)
+++ ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/PropertyBuilder.java Thu
Oct 30 09:51:46 2008
@@ -0,0 +1,42 @@
+/*
+ *  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.javafront.builder;
+
+import org.apache.tools.ant.Project;
+
+public class PropertyBuilder extends Tag<PropertyBuilder> {
+    public PropertyBuilder(Project p) {
+        super(p, "property");
+    }
+
+    public PropertyWithNameBuilder withName(String name) {
+        withAttribute("name", name);
+        return new PropertyWithNameBuilder();
+    }
+
+    public class PropertyWithNameBuilder {
+        public PropertyBuilder andValue(String value) {
+            withAttribute("value", value);
+            return PropertyBuilder.this;
+        }
+        public PropertyBuilder andLocation(String value) {
+            withAttribute("location", value);
+            return PropertyBuilder.this;
+        }
+    }
+}
\ No newline at end of file

Propchange: ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/PropertyBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/TagBuilder.java
URL: http://svn.apache.org/viewvc/ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/TagBuilder.java?rev=709205&r1=709204&r2=709205&view=diff
==============================================================================
--- ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/TagBuilder.java (original)
+++ ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/TagBuilder.java Thu Oct
30 09:51:46 2008
@@ -35,10 +35,13 @@
     }
 
     /**
-     * Collects information for a giben task/type.
+     * Collects information for a given task/type.
      */
     public Tag newTag(String name) {
         return new Tag(project, name);
     }
 
+    public PropertyBuilder newProperty() {
+        return new PropertyBuilder(project);
+    }
 }
\ No newline at end of file



Mime
View raw message