You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by gi...@apache.org on 2018/03/12 18:31:41 UTC
ant git commit: Add sources for Hello World tutorial
Repository: ant
Updated Branches:
refs/heads/master 59d2888ac -> 3d72fd9a5
Add sources for Hello World tutorial
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/3d72fd9a
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/3d72fd9a
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/3d72fd9a
Branch: refs/heads/master
Commit: 3d72fd9a506f1ff8297fb001454b3b44c3de5257
Parents: 59d2888
Author: Gintas Grigelionis <gi...@apache.org>
Authored: Mon Mar 12 19:31:45 2018 +0100
Committer: Gintas Grigelionis <gi...@apache.org>
Committed: Mon Mar 12 19:31:45 2018 +0100
----------------------------------------------------------------------
manual/tutorial-HelloWorldWithAnt.html | 2 +-
src/tutorial/hello-world/01-simple/build.xml | 37 ++++++++++
.../01-simple/src/oata/HelloWorld.java | 7 ++
src/tutorial/hello-world/02-logging/build.xml | 47 ++++++++++++
.../02-logging/src/oata/HelloWorld.java | 13 ++++
src/tutorial/hello-world/03-testing/build.xml | 64 +++++++++++++++++
.../hello-world/03-testing/src/log4j.properties | 6 ++
.../03-testing/src/oata/HelloWorld.java | 11 +++
.../03-testing/src/oata/HelloWorldTest.java | 18 +++++
src/tutorial/hello-world/final/build.xml | 75 ++++++++++++++++++++
.../hello-world/final/src/log4j.properties | 6 ++
.../hello-world/final/src/oata/HelloWorld.java | 11 +++
.../final/src/oata/HelloWorldTest.java | 18 +++++
13 files changed, 314 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/3d72fd9a/manual/tutorial-HelloWorldWithAnt.html
----------------------------------------------------------------------
diff --git a/manual/tutorial-HelloWorldWithAnt.html b/manual/tutorial-HelloWorldWithAnt.html
index b349bab..5b02d6a 100644
--- a/manual/tutorial-HelloWorldWithAnt.html
+++ b/manual/tutorial-HelloWorldWithAnt.html
@@ -409,7 +409,7 @@ junit instruction to our buildfile:</p>
</classpath>
<batchtest fork="yes">
- <fileset dir="${src.dir}" includes="*Test.java"/>
+ <fileset dir="${src.dir}" includes="**/*Test.java"/>
</batchtest>
</junit>
</target></b>
http://git-wip-us.apache.org/repos/asf/ant/blob/3d72fd9a/src/tutorial/hello-world/01-simple/build.xml
----------------------------------------------------------------------
diff --git a/src/tutorial/hello-world/01-simple/build.xml b/src/tutorial/hello-world/01-simple/build.xml
new file mode 100644
index 0000000..2da99b0
--- /dev/null
+++ b/src/tutorial/hello-world/01-simple/build.xml
@@ -0,0 +1,37 @@
+<project name="HelloWorld" basedir="." default="main">
+
+ <property name="src.dir" value="src"/>
+
+ <property name="build.dir" value="build"/>
+ <property name="classes.dir" value="${build.dir}/classes"/>
+ <property name="jar.dir" value="${build.dir}/jar"/>
+
+ <property name="main-class" value="oata.HelloWorld"/>
+
+ <target name="clean">
+ <delete dir="${build.dir}"/>
+ </target>
+
+ <target name="compile">
+ <mkdir dir="${classes.dir}"/>
+ <javac includeantruntime="false" srcdir="${src.dir}" destdir="${classes.dir}"/>
+ </target>
+
+ <target name="jar" depends="compile">
+ <mkdir dir="${jar.dir}"/>
+ <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
+ <manifest>
+ <attribute name="Main-Class" value="${main-class}"/>
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="run" depends="jar">
+ <java jar="${jar.dir}/${ant.project.name}.jar" fork="true"/>
+ </target>
+
+ <target name="clean-build" depends="clean,jar"/>
+
+ <target name="main" depends="clean,run"/>
+
+</project>
http://git-wip-us.apache.org/repos/asf/ant/blob/3d72fd9a/src/tutorial/hello-world/01-simple/src/oata/HelloWorld.java
----------------------------------------------------------------------
diff --git a/src/tutorial/hello-world/01-simple/src/oata/HelloWorld.java b/src/tutorial/hello-world/01-simple/src/oata/HelloWorld.java
new file mode 100644
index 0000000..b2e7230
--- /dev/null
+++ b/src/tutorial/hello-world/01-simple/src/oata/HelloWorld.java
@@ -0,0 +1,7 @@
+package oata;
+
+public class HelloWorld {
+ public static void main(String[] args) {
+ System.out.println("Hello World");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ant/blob/3d72fd9a/src/tutorial/hello-world/02-logging/build.xml
----------------------------------------------------------------------
diff --git a/src/tutorial/hello-world/02-logging/build.xml b/src/tutorial/hello-world/02-logging/build.xml
new file mode 100644
index 0000000..8206cc8
--- /dev/null
+++ b/src/tutorial/hello-world/02-logging/build.xml
@@ -0,0 +1,47 @@
+<project name="HelloWorld" basedir="." default="main">
+
+ <property name="src.dir" value="src"/>
+
+ <property name="build.dir" value="build"/>
+ <property name="classes.dir" value="${build.dir}/classes"/>
+ <property name="jar.dir" value="${build.dir}/jar"/>
+ <property name="lib.dir" value="lib"/>
+
+ <path id="classpath">
+ <fileset dir="${lib.dir}" includes="**/*.jar"/>
+ </path>
+
+ <property name="main-class" value="oata.HelloWorld"/>
+
+ <target name="clean">
+ <delete dir="${build.dir}"/>
+ </target>
+
+ <target name="compile">
+ <mkdir dir="${classes.dir}"/>
+ <javac includeantruntime="false" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
+ </target>
+
+ <target name="jar" depends="compile">
+ <mkdir dir="${jar.dir}"/>
+ <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
+ <manifest>
+ <attribute name="Main-Class" value="${main-class}"/>
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="run" depends="jar">
+ <java classname="${main-class}" fork="true">
+ <classpath>
+ <path refid="classpath"/>
+ <path location="${jar.dir}/${ant.project.name}.jar"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="clean-build" depends="clean,jar"/>
+
+ <target name="main" depends="clean,run"/>
+
+</project>
http://git-wip-us.apache.org/repos/asf/ant/blob/3d72fd9a/src/tutorial/hello-world/02-logging/src/oata/HelloWorld.java
----------------------------------------------------------------------
diff --git a/src/tutorial/hello-world/02-logging/src/oata/HelloWorld.java b/src/tutorial/hello-world/02-logging/src/oata/HelloWorld.java
new file mode 100644
index 0000000..751dcc9
--- /dev/null
+++ b/src/tutorial/hello-world/02-logging/src/oata/HelloWorld.java
@@ -0,0 +1,13 @@
+package oata;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.BasicConfigurator;
+
+public class HelloWorld {
+ static Logger logger = Logger.getLogger(HelloWorld.class);
+
+ public static void main(String[] args) {
+ BasicConfigurator.configure();
+ logger.info("Hello World"); // the old System.out-statement
+ }
+}
http://git-wip-us.apache.org/repos/asf/ant/blob/3d72fd9a/src/tutorial/hello-world/03-testing/build.xml
----------------------------------------------------------------------
diff --git a/src/tutorial/hello-world/03-testing/build.xml b/src/tutorial/hello-world/03-testing/build.xml
new file mode 100644
index 0000000..9ebe9ba
--- /dev/null
+++ b/src/tutorial/hello-world/03-testing/build.xml
@@ -0,0 +1,64 @@
+<project name="HelloWorld" basedir="." default="main">
+
+ <property name="src.dir" value="src"/>
+
+ <property name="build.dir" value="build"/>
+ <property name="classes.dir" value="${build.dir}/classes"/>
+ <property name="jar.dir" value="${build.dir}/jar"/>
+ <property name="lib.dir" value="lib"/>
+
+ <path id="application" location="${jar.dir}/${ant.project.name}.jar"/>
+ <path id="classpath">
+ <fileset dir="${lib.dir}" includes="**/*.jar"/>
+ </path>
+
+ <property name="main-class" value="oata.HelloWorld"/>
+
+ <target name="clean">
+ <delete dir="${build.dir}"/>
+ </target>
+
+ <target name="compile">
+ <mkdir dir="${classes.dir}"/>
+ <javac includeantruntime="false" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
+ <copy todir="${classes.dir}">
+ <fileset dir="${src.dir}" excludes="**/*.java"/>
+ </copy>
+ </target>
+
+ <target name="jar" depends="compile">
+ <mkdir dir="${jar.dir}"/>
+ <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
+ <manifest>
+ <attribute name="Main-Class" value="${main-class}"/>
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="run" depends="jar">
+ <java classname="${main-class}" fork="true">
+ <classpath>
+ <path refid="classpath"/>
+ <path refid="application"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="junit" depends="jar">
+ <junit printsummary="yes">
+ <classpath>
+ <path refid="classpath"/>
+ <path refid="application"/>
+ </classpath>
+
+ <batchtest fork="yes">
+ <fileset dir="${src.dir}" includes="**/*Test.java"/>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="clean-build" depends="clean,jar"/>
+
+ <target name="main" depends="clean,run"/>
+
+</project>
http://git-wip-us.apache.org/repos/asf/ant/blob/3d72fd9a/src/tutorial/hello-world/03-testing/src/log4j.properties
----------------------------------------------------------------------
diff --git a/src/tutorial/hello-world/03-testing/src/log4j.properties b/src/tutorial/hello-world/03-testing/src/log4j.properties
new file mode 100644
index 0000000..111e080
--- /dev/null
+++ b/src/tutorial/hello-world/03-testing/src/log4j.properties
@@ -0,0 +1,6 @@
+log4j.rootLogger=DEBUG, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%m%n
http://git-wip-us.apache.org/repos/asf/ant/blob/3d72fd9a/src/tutorial/hello-world/03-testing/src/oata/HelloWorld.java
----------------------------------------------------------------------
diff --git a/src/tutorial/hello-world/03-testing/src/oata/HelloWorld.java b/src/tutorial/hello-world/03-testing/src/oata/HelloWorld.java
new file mode 100644
index 0000000..73c3229
--- /dev/null
+++ b/src/tutorial/hello-world/03-testing/src/oata/HelloWorld.java
@@ -0,0 +1,11 @@
+package oata;
+
+import org.apache.log4j.Logger;
+
+public class HelloWorld {
+ static Logger logger = Logger.getLogger(HelloWorld.class);
+
+ public static void main(String[] args) {
+ logger.info("Hello World"); // the old System.out-statement
+ }
+}
http://git-wip-us.apache.org/repos/asf/ant/blob/3d72fd9a/src/tutorial/hello-world/03-testing/src/oata/HelloWorldTest.java
----------------------------------------------------------------------
diff --git a/src/tutorial/hello-world/03-testing/src/oata/HelloWorldTest.java b/src/tutorial/hello-world/03-testing/src/oata/HelloWorldTest.java
new file mode 100644
index 0000000..d08244f
--- /dev/null
+++ b/src/tutorial/hello-world/03-testing/src/oata/HelloWorldTest.java
@@ -0,0 +1,18 @@
+package oata;
+
+import org.junit.Test;
+
+import static org.junit.Assert.fail;
+
+public class HelloWorldTest {
+
+ @Test
+ public void testNothing() {
+ }
+
+ @Test
+ public void testWillAlwaysFail() {
+ fail("An error message");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ant/blob/3d72fd9a/src/tutorial/hello-world/final/build.xml
----------------------------------------------------------------------
diff --git a/src/tutorial/hello-world/final/build.xml b/src/tutorial/hello-world/final/build.xml
new file mode 100644
index 0000000..d2f25fb
--- /dev/null
+++ b/src/tutorial/hello-world/final/build.xml
@@ -0,0 +1,75 @@
+<project name="HelloWorld" basedir="." default="main">
+
+ <property name="src.dir" value="src"/>
+
+ <property name="build.dir" value="build"/>
+ <property name="classes.dir" value="${build.dir}/classes"/>
+ <property name="jar.dir" value="${build.dir}/jar"/>
+ <property name="lib.dir" value="lib"/>
+ <property name="report.dir" value="${build.dir}/junitreport"/>
+
+ <path id="application" location="${jar.dir}/${ant.project.name}.jar"/>
+ <path id="classpath">
+ <fileset dir="${lib.dir}" includes="**/*.jar"/>
+ </path>
+
+ <property name="main-class" value="oata.HelloWorld"/>
+
+ <target name="clean">
+ <delete dir="${build.dir}"/>
+ </target>
+
+ <target name="compile">
+ <mkdir dir="${classes.dir}"/>
+ <javac includeantruntime="false" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
+ <copy todir="${classes.dir}">
+ <fileset dir="${src.dir}" excludes="**/*.java"/>
+ </copy>
+ </target>
+
+ <target name="jar" depends="compile">
+ <mkdir dir="${jar.dir}"/>
+ <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
+ <manifest>
+ <attribute name="Main-Class" value="${main-class}"/>
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="run" depends="jar">
+ <java classname="${main-class}" fork="true">
+ <classpath>
+ <path refid="classpath"/>
+ <path refid="application"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="junit" depends="jar">
+ <mkdir dir="${report.dir}"/>
+ <junit printsummary="yes" tempdir="${build.dir}">
+ <classpath>
+ <path refid="classpath"/>
+ <path refid="application"/>
+ </classpath>
+
+ <formatter type="xml"/>
+
+ <batchtest fork="yes" todir="${report.dir}">
+ <fileset dir="${src.dir}" includes="**/*Test.java"/>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="junitreport">
+ <junitreport todir="${report.dir}">
+ <fileset dir="${report.dir}" includes="TEST-*.xml"/>
+ <report todir="${report.dir}"/>
+ </junitreport>
+ </target>
+
+ <target name="clean-build" depends="clean,jar"/>
+
+ <target name="main" depends="clean,run"/>
+
+</project>
http://git-wip-us.apache.org/repos/asf/ant/blob/3d72fd9a/src/tutorial/hello-world/final/src/log4j.properties
----------------------------------------------------------------------
diff --git a/src/tutorial/hello-world/final/src/log4j.properties b/src/tutorial/hello-world/final/src/log4j.properties
new file mode 100644
index 0000000..111e080
--- /dev/null
+++ b/src/tutorial/hello-world/final/src/log4j.properties
@@ -0,0 +1,6 @@
+log4j.rootLogger=DEBUG, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%m%n
http://git-wip-us.apache.org/repos/asf/ant/blob/3d72fd9a/src/tutorial/hello-world/final/src/oata/HelloWorld.java
----------------------------------------------------------------------
diff --git a/src/tutorial/hello-world/final/src/oata/HelloWorld.java b/src/tutorial/hello-world/final/src/oata/HelloWorld.java
new file mode 100644
index 0000000..73c3229
--- /dev/null
+++ b/src/tutorial/hello-world/final/src/oata/HelloWorld.java
@@ -0,0 +1,11 @@
+package oata;
+
+import org.apache.log4j.Logger;
+
+public class HelloWorld {
+ static Logger logger = Logger.getLogger(HelloWorld.class);
+
+ public static void main(String[] args) {
+ logger.info("Hello World"); // the old System.out-statement
+ }
+}
http://git-wip-us.apache.org/repos/asf/ant/blob/3d72fd9a/src/tutorial/hello-world/final/src/oata/HelloWorldTest.java
----------------------------------------------------------------------
diff --git a/src/tutorial/hello-world/final/src/oata/HelloWorldTest.java b/src/tutorial/hello-world/final/src/oata/HelloWorldTest.java
new file mode 100644
index 0000000..d08244f
--- /dev/null
+++ b/src/tutorial/hello-world/final/src/oata/HelloWorldTest.java
@@ -0,0 +1,18 @@
+package oata;
+
+import org.junit.Test;
+
+import static org.junit.Assert.fail;
+
+public class HelloWorldTest {
+
+ @Test
+ public void testNothing() {
+ }
+
+ @Test
+ public void testWillAlwaysFail() {
+ fail("An error message");
+ }
+
+}