java构建与管理(1) - Apache Ant Short History

#1. Install Apache Ant

<!--

    1. Make sure you have a Java environment installed, See System Requirements for details.
    2. Download Ant. http://ant.apache.org/
    3. Uncompress the downloaded file into a directory.
    4. Set environmental variables JAVA_HOME to your Java environment, ANT_HOME to the directory you uncompressed Ant to,       and add ${ANT_HOME}/bin (Unix) or %ANT_HOME%/bin (Windows) to your PATH.
    5. Optionally, from the ANT_HOME directory run ant -f fetch.xml -Ddest=system to get the library dependencies of most of       the Ant tasks that require them. If you don‘t do this, many of the dependent Ant tasks will not be available.
    6. Optionally, add any desired Antlibs.

-->

#2. Using Apache Ant

<project name="MyProject" default="dist" basedir=".">
    <description>simple example build file</description>

    <!-- set global properties for this build -->
    <property name="src" location="src"/>
    <property name="build" location="build"/>
    <property name="dist" location="dist"/>

    <target name="init">
        <!-- Create the time stamp -->
        <tstamp/>

        <!-- Create the build directory structure used by compile -->
        <mkdir dir="${build}"/>
    </target>

    <target name="compile" depends="init" description="compile the source">
        <!-- Compile the java code from ${src} into ${build} -->
        <javac srcdir="${src}" destdir="${build}"/>
    </target>

    <target name="dist" depends="compile" description="generate the distribution">
        <!-- Create the distribution directory -->
        <mkdir dir="${dist}/lib"/>

        <!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
        <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>
    </target>

    <target name="clean" description="clean up">
        <!-- Delete the ${build} and ${dist} directory trees -->
        <delete dir="${build}"/>
        <delete dir="${dist}"/>
    </target>
</project>

#3. Running Apache Ant

<!--
ant [options] [target1 [target2 [target3]]]
Options:
    -help, -h                     print this message and exit
    -projecthelp, -p              print project help information and exit
    -version                      print the version information and exit
    -diagnostics                  print information that might be helpful to diagnose or report problems and exit
    -quiet, -q                    be extra quiet
    -silent, -S                   print nothing but task outputs and build failure
    -verbose, -v                  be extra verbose
    -debug, -d                    print debugging information
    -emacs, -e                    produce logging information without adornments
    -lib <path>                   specifies a path to search for jars and classes
    -logfile <file>, -l <file>    use given file for log
    -logger <classname>           the class which is to perform logging
    -listener <classname>         add an instance of class as a project listener
    -noinput                      do not allow interactive input
    -buildfile <file>,
    -file <file>, -f <file>       use given build file
    -D<property>=<value>          use value for given property
    -keep-going, -k               execute all targets that do not depend on failed target(s)
    -propertyfile <name>          load all properties from file with -D properties taking precedence
    -inputhandler <class>         the class which will handle input requests
    -find <file>, -s <file>       (s)earch for buildfile towards the root of the filesystem and use it
    -nice number                  A niceness value for the main thread: 1 (lowest) to 10 (highest); 5 is the default
    -nouserlib                    Run ant without using the jar files from ${user.home}/.ant/lib
    -noclasspath                  Run ant without using CLASSPATH
    -autoproxy                    Java 1.5+ : use the OS proxies
    -main <class>                 override Ant‘s normal entry point
-->
时间: 2024-08-01 23:32:42

java构建与管理(1) - Apache Ant Short History的相关文章

Apache Ant学习笔记(2):Apache Ant命令行

Apache Ant的命令行是Apache Ant构建的基础.虽然我们通常在IDE中集成Apache Ant并使用它进行构建,但是了解Apache Ant的命令行对我们在IDE中使用Apache Ant还是很有好处的,如对IDE中Apache Ant的默认设置进行修改以符合自己的要求.此外,还是有用到命令行的场景,虽然很少. 进入命令行,输入ant -help,显示如下(括弧中的文字是选项的注释): ant [options] [target [target2 [target3] ...]] O

Apache Ant学习笔记(1):了解Ant

1.软件构建 软件构建是将程序的源文件转换成可以直接使用的应用程序或应用程序组件的过程.软件构建过程涉及到一些我们很熟悉的操作如文件/文件夹操作.编译.测试.打包.部署.发布等. 以下描述一个简单的软件构建过程:首先会创建一系列文件夹来存放一系列的源文件和资源文件等文件:在源文件编写完成之后,对它进行编译(出错的情况下还会进行调试).测试(单元测试):在程序的所有源文件都编写完成之后,对所有源文件进行测试:测试完成之后,在没有发现错误的情况下,将编译生成的目标文件和相关的资源文件进行打包生成打包

Java构建工具:如何用Maven,Gradle和Ant+Ivy进行依赖管理

原文来自:https://zeroturnaround.com/rebellabs/java-build-tools-how-dependency-management-works-with-maven-gradle-and-ant-ivy/ 编译的时候可以运行,运行时出问题 在当今java项目自动化构建的场景当中,依赖管理已经成为了项目构建自动化工具中的一个主要部分,但是在过去并总是这样. 回想以前那个很爽的时候,你的项目依赖性管理只需要将jar包导入到lib文件夹中,然后将其加入到你的版本控

手动利用Apache Ant构建部署自己的Java项目

虽然Eclipse从3.0开始已经继承了Ant插件,大家的项目可以自动构建 部署,此篇文章看也没多大用处,但是手动去自己使用以下 Ant来构建自己的Java项目也是一件有意义的事情,虽然现在已经没用人用Javac Java命令行的方式 来搞程序.... Ant是Apache基金项目下的一个工具,在Apache官方给出的解释 是      一个帮助我们构建软件的 Java库和命令行工具 . Apache Ant is a Java library and command-line tool tha

[Java] Apache Ant 构建基础教程

环境:Ubuntu 12.04, java 1.7.0, ant 1.8.2. 前言 Apache Ant 是一个软件自动化构建工具,构建过程包括编译.测试和部署等.它和 Make 工具相似,但由 Java 实现,所以要求 Java 运行环境,非常适合构建 Java 程序. Ant 和 Make 明显不同之处在于 Ant 使用 XML 来表述构建过程与依赖关系,而 Make 使用 Makefile 格式文件.Ant 默认的构建文件名为 build.xml.每一个 build.xml 文件包含一个

java代理使用 apache ant实现文件压缩/解压缩

[背景] 近日在研究web邮件下载功能,下载的邮件可以导入foxmail邮件客户端,但是批量下载邮件还需将邮件打成一个压缩包.从网上搜索通过java实现文件压缩.解压缩有很多现成的例子. [参考代码](需要下载apache ant.jar包) import java.io.File; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.an

Apache Ant介绍

Apache Ant,是一个将软件编译.测试.部署等步骤联系在一起加以自动化的一个工具,大多用于Java环境中的软件开发. Ant是纯Java语言编写的,所以具有很好的跨平台性.操作简单.Ant是由一个内置任务和可选任务组成的.Ant运行时需要一个XML文件(构建文件). Ant通过调用target树,就可以执行各种task.每个task实现了特定接口对象.由于Ant构建文件 是XML格式的文件,所以很容易维护和书写,而且结构很清晰. 当开始一个新的项目时,首先应该编写Ant构建文件.Ant构建

Apache Ant学习总结(一):Ant自动化脚本入门以及一些常用命令介绍

一 Ant简介 Apache Ant是一个将软件编译.测试.部署等步骤联系在一起加以自动化的一个工具,大多用于Java环境中的自动化构建.它是Apache软件基金会JAKARTA目录中的一个子项目,它有以下的优点: 跨平台性.Ant是纯Java语言编写的,所以具有很好的跨平台性 操作简单.Ant是由一个内置任务和可选任务组成的.Ant运行时需要一个XML文件(构建文件). Ant通过调用target树,就可以执行各种任务.由于Ant构建文件 是XML格式的文件,所以很容易维护和书写,而且结构清晰

Apache Ant和Apache Maven的区别

Apache Ant和Apache Maven的区别 分类: ANT Maven 2013-12-10 18:47 1477人阅读 评论(26) 收藏 举报 ———摘自<maven权威指南> Apache Ant 1.Ant 是程序化的,你必须明确的告诉 Ant 做什么,什么时候做.你必须告诉它去编译,然后复制,然后压缩. 2.Ant 没有生命周期,你必须定义目标和目标之间的依赖.你必须手工为每个目标附上一个任务序列. Apache Maven 1.Maven 拥有约定,因为你遵循了约定,它已