Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
build.xml Required by Apache Ant
What is the build.xml Required by Apache Ant?
✍: FYIcenter.com
The build.xml file required by Apache Ant
is XML file that contains instructions to build final
targets using system commands and source files.
Here is a tutorial on how to create a build.xml file and use "ant" to build a simple Java project.
1. Create a build.xml as shown below:
> type build.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Set the project name, basedir and default target to be executed-->
<project name="Ant-Build-Project-Test" default="mainTarget" basedir=".">
<!-- Sets the properties here-->
<property name="src.dir" location="src" />
<property name="build.dir" location="bin" />
<!-- Target for deleting the existing directories-->
<target name="clean">
<delete dir="${build.dir}" />
</target>
<!-- Target for creating the new directories-->
<target name="makedir">
<mkdir dir="${build.dir}" />
</target>
<!-- Target for compiling the java code-->
<target name="compile" depends="clean, makedir">
<javac srcdir="${src.dir}" destdir="${build.dir}">
</javac>
</target>
<!-- Defualt target to run all targets-->
<target name="mainTarget" depends="compile">
<description>Main target</description>
</target>
</project>
2. Verify your Apache Ant installation:
> \local\ant\bin\ant.bat -version Apache Ant(TM) version 1.10.10 compiled on April 12 2021
3. Run the default target defined in the build.xml. The build process will fail, because there is no "src" sub-directory and Java source code to compile.
> \local\ant\bin\ant.bat
Buildfile: \Users\fyicenter\build.xml
clean:
makedir:
[mkdir] Created dir: \Users\fyicenter\bin
compile:
[javac] build.xml:21: warning: 'includeantruntime' was not set,
defaulting to build.sysclasspath=last; set to false for repeatable builds
BUILD FAILED
build.xml:21: srcdir "\Users\fyicenter\src" does not exist!
Total time: 0 seconds
4. Run the default target again with a sample Java source code.
> mkdire src
> edit src\Hello.java
public class Hello {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
> \local\ant\bin\ant.bat
Buildfile: build.xml
clean:
[delete] Deleting directory bin
makedir:
[mkdir] Created dir: bin
compile:
[javac] Compiling 1 source file to bin
mainTarget:
BUILD SUCCESSFUL
Total time: 0 seconds
5. Verify the build result:
> dir bin 336 Hello.class > java -cp bin Hello Hello world!
⇒ Download Apache Ant Source Package
⇐ Run Apache Ant on Windows, Mac and Linux
2021-07-10, ∼1781🔥, 0💬
Popular Posts:
JDK 11 jdk.charsets.jmod is the JMOD file for JDK 11 Charsets module. JDK 11 Charsets module compile...
What Is activation.jar? I heard it's related to JAF (JavaBeans Activation Framework) 1.0.2? The if y...
maven-compat-3.8.6.jar is the JAR file for Apache Maven 3.8.6 Compact module. The JAR file name may ...
Xalan-Java, Version 2.7.1, is an XSLT processor for transforming XML documents into HTML, text, or o...
The JMX technology provides the tools for building distributed, Web-based, modular and dynamic solut...