当前位置:网站首页>[ANT]apache ant 安装说明
[ANT]apache ant 安装说明
2022-08-09 02:04:00 【master336】
准备工作
下载地址:https://downloads.apache.org/ant/binaries/
JDK: 1.8
官网: https://ant.apache.org/manual/index.html
ANT依赖jdk,所以需要提前配置好JDK
开始安装
下载
目前官网提供的下载版本为1.9.x 1.10.x,ant的安装方式跟jdk的离线安装类似
解压
解压下载的ant包到安装位置
安装
https://ant.apache.org/manual/install.html#installing
ant的安装过程为配置ant命令可执行的过程
需要配置环境变量ANT_HOME 、CLASSPATH
以下摘自官网
ANT_HOME : ant 安装目录
CLASSPATH: ant lib目录所在目录
(注意不要覆盖JAVA lib/tools\rt的设置)
classpath的目录官方的安装文档中标注需要,但实际测试中可能并不需要,尽管如此依然建议进行配置,Linux环境下跳过
使用
版本查询
ant -version
编译打包
#默认使用build.xml
ant
#使用非默认build.xml 文件通过-f指定
ant -f mybuild.xml
示例
基于官方提供的build修改示例
增加classpath的设置说明(四种方式)
<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"/>
<path id="classpath3d">
<fileset dir="lib" erroronmissingdir="false">
<include name="*.jar"/>
</fileset>
</path>
<property name="classpath3d" refid="classpath3d"/>
<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} -->
<!--1. 通过变量设置 -->
<!--<javac srcdir="${src}" destdir="${build}" classpath="${classpath3d}"/>-->
<javac srcdir="${src}" destdir="${build}">
<!--2. 通过引用设置 -->
<!--<classpath refid="classpath3d"/>-->
<!--3. 直接写明 -->
<!--<classpath path="lib/mysql-connector-java-8.0.29.jar"/> <classpath path="lib/ojdbc8.jar"/>-->
<!-- 4. 聚合 -->
<!--<classpath> <fileset dir="lib"> <include name="*.jar"/> </fileset> </classpath>-->
</javac>
</target>
<target name="dist" depends="compile" description="generate the distribution">
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>
<copy todir="${dist}/lib">
<fileset dir="lib" erroronmissingdir=""/>
</copy>
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar jarfile="${dist}/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>
编写测试代码
src下编写java代码
示例
//src/A.java
public class A{
private String var1;
private String demo(String args){
System.out.println(args);
return "OK";
}
}
目录结构示例
编译打包
ant
编译完成目录结构示例:
文档
https://ant.apache.org/manual/using.html#buildfile
完整源码: https://gitcode.net/master336/ant-demo
边栏推荐
猜你喜欢
Summary of Database Design
2022 PMP Project Management Certification Exam Registration Guide (1)
LeetCode每日两题02:第一个错误的版本 (均1200道)方法:二分查找
Use of torchversion.transforms
torchversion.transforms的使用
如何最大限度地减少企业受到供应链攻击的风险
The most fierce "employee" in history, madly complaining about the billionaire boss Xiao Zha: So rich, he always wears the same clothes!
typescript90-使用类型文件声明类型
LeetCode每日两题01:二分查找 (均1200道)
LeetCode每日两题02:轮转数组 (均1200道)
随机推荐
D. Tournament Countdown
力扣刷题记录5.1-----59. 螺旋矩阵 II
How to install ngrok in Synology system (Synology 6.X version)
JDBC technology (1) - a simple JDBC test
Group DETR:分组一对多匹配是加速DETR收敛的关键
Go-10-模块与包
My thoughts on software development
ROS 、SLAM 学习 error整理
使用JS实现数组扁平化的几种方式
数据库设计的总结
ZCMU--5115: Buying Keys(C语言)
帮助安全红队取得成功的11条建议
【Unity】判断鼠标是否点击在UI上
终于有人把灰度发布架构设计讲明白了
企业里Foxmail邮箱问题解决方法汇总
力扣刷题记录6.1-----203. 移除链表元素
嵌入式设备驱动开发
mysql 5.7 入坑
德语翻译-德语在线批量翻译软件
【HNUMSC】C language second lecture