Ant build tutorial pdf




















It allows developers to adopt agile principles and test-driven development to automate the repetitive development tasks like generating documentation, etc. Ant is an acronym for Another Neat Tool. Follow the below steps for installing Ant:. Step 1 Download the binaries. Step 2 Unzip Files. Step 3 Create an environment variable. Step 4 Go to system settings. Step 6 Find out environment variables. Step 7 Create new user. Skip to content. What is Apache Ant? Report a Bug. Previous Prev. Somebody told us not to use System -statements.

We use Log4J for that, because. We store our external libraries in a new directory lib. Log4J can be downloaded [1] from Logging's Homepage. Create the lib directory and extract the log4j After that we have to modify our Java source file to use that library and our buildfile so that this library could be accessed during compilation and run.

Working with Log4J is documented inside its manual. Here we use the MyApp -example from the Short Manual [2]. First we have to modify the java source to use the logging framework:. Most of the modifications are "framework overhead" which has to be done once.

The blue line is our "old System-out" statement. Don't try to run ant —you will only get lot of compiler errors. Log4J is not on the classpath so we have to do a little work here. This is only for this project and maybe you would break other environments this is one of the most famous mistakes when working with Ant. We introduce Log4J or to be more precise: all libraries jar-files which are somewhere under. In this example we start our application not via its Main-Class manifest-attribute, because we could not provide a jar-name and a classpath.

So add our class in the red line to the already defined path and start as usual. Running ant would give after the usual compile stuff :. For another layout Why we have used Log4J? No—all is hardcoded! But that is not the fault of Log4J—it's ours. We had coded BasicConfigurator.

More comfortable would be using a property file. In the Java source file, delete the BasicConfiguration line from the main method and the related import statement.

Log4J will search then for a configuration as described in its manual. That's the default name for Log4J's configuration and using that name would make life easier—not only the framework knows what is inside, you too! We should deliver the configuration file, too. So we change the buildfile:. This copies all resources as long as they haven't the suffix. In this step we will introduce the usage of the JUnit [3] test framework in combination with Ant.

Because Ant has a built-in JUnit 4.



0コメント

  • 1000 / 1000