• [ANT]apache ant 安装说明


    准备工作

    下载地址: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
    
    • 1

    在这里插入图片描述

    编译打包

    #默认使用build.xml
    ant 
    #使用非默认build.xml 文件通过-f指定
    ant -f mybuild.xml
    
    
    • 1
    • 2
    • 3
    • 4
    • 5

    示例

    基于官方提供的build修改示例

    增加classpath的设置说明(四种方式)

    <project name="MyProject" default="dist" basedir=".">
      <description>
        simple example build file
      description>
      
      <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">
        
        <tstamp/>
        
        <mkdir dir="${build}"/>
      target>
    
      <target name="compile" depends="init"
            description="compile the source">
        
        
        
        <javac srcdir="${src}" destdir="${build}">
          
          
          
          
          
          
        javac>
      target>
    
      <target name="dist" depends="compile"
            description="generate the distribution">
        
        <mkdir dir="${dist}/lib"/>
        <copy todir="${dist}/lib">
           <fileset dir="lib" erroronmissingdir=""/>
        copy>
        
        <jar jarfile="${dist}/MyProject-${DSTAMP}.jar" basedir="${build}"/>
      target>
    
      <target name="clean"
            description="clean up">
        
        <delete dir="${build}"/>
        <delete dir="${dist}"/>
      target>
    project>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59

    编写测试代码

    src下编写java代码
    示例

    //src/A.java
    public class A{
    	private String var1;
    	private String demo(String args){
    		System.out.println(args);
    		return "OK";
    	}
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    目录结构示例
    在这里插入图片描述

    编译打包

    ant
    
    • 1

    编译完成目录结构示例:
    在这里插入图片描述

    文档

    https://ant.apache.org/manual/using.html#buildfile
    完整源码: https://gitcode.net/master336/ant-demo

  • 相关阅读:
    Python+大数据-hadoop(七)-Apache Hive SQL DQL、参数配置与函数
    线性回归模型与分析r语言
    QT学习管理系统
    请求数据时,后端返回的状态码
    开发工具 - Ubuntu版本VS code离线安装
    Spring Cloud Alibaba-Sentinel规则
    Nginx概念
    【研发日记】,Matlab/Simulink开箱报告(十)——Requirements Toolbox
    Python快速刷题网站——牛客网 数据分析篇(十五)
    【软件工程_设计模式Designer Method】三类?23种常用设计模式?-简介-作业一
  • 原文地址:https://blog.csdn.net/master336/article/details/126146270