Author: bodewig
Date: Fri Oct 31 03:31:40 2008
New Revision: 709376
URL: http://svn.apache.org/viewvc?rev=709376&view=rev
Log:
reduce number of keystrokes
Added:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/DeleteBuilder.java
(with props)
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/EchoBuilder.java
(with props)
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/MkdirBuilder.java
(with props)
Modified:
ant/sandbox/javafront/src/etc/examples/AntUnitTest.java
ant/sandbox/javafront/src/etc/examples/Simple3.java
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/Tag.java
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/TagBuilder.java
Modified: ant/sandbox/javafront/src/etc/examples/AntUnitTest.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/src/etc/examples/AntUnitTest.java?rev=709376&r1=709375&r2=709376&view=diff
==============================================================================
--- ant/sandbox/javafront/src/etc/examples/AntUnitTest.java (original)
+++ ant/sandbox/javafront/src/etc/examples/AntUnitTest.java Fri Oct 31 03:31:40
2008
@@ -22,50 +22,55 @@
import org.apache.ant.javafront.annotations.AntTarget;
import org.apache.tools.ant.Project;
+import static org.apache.ant.javafront.builder.EchoBuilder.echoMessage;
+import static org.apache.ant.javafront.builder.DeleteBuilder.deleteDir;
+import static org.apache.ant.javafront.builder.MkdirBuilder.mkdir;
+
@AntProject(Name="example using AntUnit", BaseDir="../../..",
DefaultTarget="antunit")
public class AntUnitTest extends BuildFileBase {
+ private static final String FILE = "build.xml";
+ private static final String OUTPUT = "${output}";
+
public AntUnitTest(Project p) {
super(p);
+ build().property().withName("output").andLocation("build/testoutput")
+ .execute();
}
@AntTarget(Description="describes this build file")
public void describe() {
- build().newTag("echo")
- .withAttribute("message", "${ant.version}").execute();
- build().newTag("echo")
- .withNestedText("Demonstrates running an AntUnit test.").execute();
+ echoMessage(getProject(), "${ant.version}");
+ echoMessage(getProject(), "Demonstrates running an AntUnit test.");
}
@AntTarget
public void setUp() {
- build().newTag("mkdir")
- .withAttribute("dir", "build/testoutput").execute();
+ mkdir(getProject(), OUTPUT);
}
@AntTarget
public void tearDown() {
- build().newTag("delete")
- .withAttribute("dir", "build/testoutput").execute();
+ deleteDir(getProject(), OUTPUT);
}
@AntTarget
public void testCopy() {
- build().newCopy().withAttribute("verbose", "true")
- .file("build.xml").toDir("build/testoutput")
+ build().copy().withAttribute("verbose", "true")
+ .file(FILE).toDir(OUTPUT)
.execute();
- build().newTag("assertFileExists", "antlib:org.apache.ant.antunit")
- .withAttribute("file", "build/testoutput/build.xml")
+ build().tagWithNs("assertFileExists", "antlib:org.apache.ant.antunit")
+ .withAttribute("file", OUTPUT + "/" + FILE)
.execute();
}
@AntTarget(Description="runs the test")
public void antunit() {
- build().newTag("antunit", "antlib:org.apache.ant.antunit")
- .withChild(build().newTag("plainlistener",
- "antlib:org.apache.ant.antunit"))
- .withChild(build().newTag("file").withAttribute("file",
- "${ant.file}"))
+ build().tagWithNs("antunit", "antlib:org.apache.ant.antunit")
+ .withChild(build().tagWithNs("plainlistener",
+ "antlib:org.apache.ant.antunit"))
+ .withChild(build().tag("file").withAttribute("file",
+ "${ant.file}"))
.execute();
}
}
\ No newline at end of file
Modified: ant/sandbox/javafront/src/etc/examples/Simple3.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/src/etc/examples/Simple3.java?rev=709376&r1=709375&r2=709376&view=diff
==============================================================================
--- ant/sandbox/javafront/src/etc/examples/Simple3.java (original)
+++ ant/sandbox/javafront/src/etc/examples/Simple3.java Fri Oct 31 03:31:40 2008
@@ -22,7 +22,7 @@
import org.apache.tools.ant.Project;
import org.apache.ant.javafront.builder.TagBuilder;
[EMAIL PROTECTED](Name="simple3", BaseDir="..", DefaultTarget="hello")
[EMAIL PROTECTED](Name="simple3", DefaultTarget="hello")
public class Simple3 {
private Project p;
@@ -33,14 +33,11 @@
@AntTarget(Name="-setup")
public void setup() {
TagBuilder.forProject(p)
- .newProperty().withName("world").andValue("world").execute();
+ .property().withName("world").andValue("world").execute();
}
@AntTarget(Depends="-setup")
public void hello() {
- TagBuilder.forProject(p)
- .newTag("echo")
- .withAttribute("message", "Hello, ${world}!")
- .execute();
+ TagBuilder.forProject(p).echo().message("Hello, ${world}!").execute();
}
}
Added:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/DeleteBuilder.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/DeleteBuilder.java?rev=709376&view=auto
==============================================================================
---
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/DeleteBuilder.java
(added)
+++
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/DeleteBuilder.java
Fri Oct 31 03:31:40 2008
@@ -0,0 +1,35 @@
+/*
+ * 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 DeleteBuilder extends Tag<DeleteBuilder> {
+ DeleteBuilder(Project p) {
+ super(p, "delete");
+ }
+
+ public DeleteBuilder dir(String name) {
+ withAttribute("dir", name);
+ return this;
+ }
+
+ public static void deleteDir(Project project, String name) {
+ new DeleteBuilder(project).dir(name).execute();
+ }
+}
\ No newline at end of file
Propchange:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/DeleteBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/EchoBuilder.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/EchoBuilder.java?rev=709376&view=auto
==============================================================================
---
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/EchoBuilder.java
(added)
+++
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/EchoBuilder.java
Fri Oct 31 03:31:40 2008
@@ -0,0 +1,35 @@
+/*
+ * 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 EchoBuilder extends Tag<EchoBuilder> {
+ EchoBuilder(Project p) {
+ super(p, "echo");
+ }
+
+ public EchoBuilder message(String msg) {
+ withAttribute("message", msg);
+ return this;
+ }
+
+ public static void echoMessage(Project project, String msg) {
+ new EchoBuilder(project).message(msg).execute();
+ }
+}
\ No newline at end of file
Propchange:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/EchoBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/MkdirBuilder.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/MkdirBuilder.java?rev=709376&view=auto
==============================================================================
---
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/MkdirBuilder.java
(added)
+++
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/MkdirBuilder.java
Fri Oct 31 03:31:40 2008
@@ -0,0 +1,35 @@
+/*
+ * 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 MkdirBuilder extends Tag<MkdirBuilder> {
+ MkdirBuilder(Project p) {
+ super(p, "mkdir");
+ }
+
+ public MkdirBuilder dir(String name) {
+ withAttribute("dir", name);
+ return this;
+ }
+
+ public static void mkdir(Project project, String name) {
+ new MkdirBuilder(project).dir(name).execute();
+ }
+}
\ No newline at end of file
Propchange:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/MkdirBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/Tag.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/Tag.java?rev=709376&r1=709375&r2=709376&view=diff
==============================================================================
--- ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/Tag.java
(original)
+++ ant/sandbox/javafront/src/main/org/apache/ant/javafront/builder/Tag.java
Fri Oct 31 03:31:40 2008
@@ -25,7 +25,10 @@
public class Tag<T extends Tag<T>> {
+ // is there a cleaner way to do it?
+ @SuppressWarnings("unchecked")
private final T self = (T) this;
+
private final UnknownElement ue;
private final RuntimeConfigurable rc;
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=709376&r1=709375&r2=709376&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
Fri Oct 31 03:31:40 2008
@@ -37,25 +37,49 @@
/**
* Collects information for a given task/type.
*/
- public Tag newTag(String name) {
- return newTag(name, "");
+ public Tag tag(String name) {
+ return tagWithNs(name, "");
}
/**
* Collects information for a given task/type.
*/
- public Tag newTag(String name, String namespaceUri) {
+ public Tag tagWithNs(String name, String namespaceUri) {
return new Tag(project, name, namespaceUri);
}
/**
* Specialized for the property task.
*/
- public PropertyBuilder newProperty() {
+ public PropertyBuilder property() {
return new PropertyBuilder(project);
}
- public CopyBuilder newCopy() {
+ /**
+ * Specialized for the copy task.
+ */
+ public CopyBuilder copy() {
return new CopyBuilder(project);
}
+
+ /**
+ * Specialized for the echo task.
+ */
+ public DeleteBuilder delete() {
+ return new DeleteBuilder(project);
+ }
+
+ /**
+ * Specialized for the mkdir task.
+ */
+ public MkdirBuilder mkdir() {
+ return new MkdirBuilder(project);
+ }
+
+ /**
+ * Specialized for the mkdir task.
+ */
+ public EchoBuilder echo() {
+ return new EchoBuilder(project);
+ }
}
\ No newline at end of file