惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
Blog — PlanetScale
Blog — PlanetScale
博客园 - 【当耐特】
博客园_首页
The GitHub Blog
The GitHub Blog
月光博客
月光博客
Hugging Face - Blog
Hugging Face - Blog
有赞技术团队
有赞技术团队
博客园 - 三生石上(FineUI控件)
D
Docker
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
酷 壳 – CoolShell
酷 壳 – CoolShell
雷峰网
雷峰网
小众软件
小众软件
I
InfoQ
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
S
SegmentFault 最新的问题
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky

博客 on 打工人日志

k8s RKE2 cilium L2 + envoy gateway 安装配置 k8s RKE2 vSphere 存储配置 OpenClaw 全能指南:从安装到进阶自动化实战 (2026 最终版) Kubernetes — skywalking + banyanDB APM监控部署 Kubernetes — promtail + loki + grafana 日志系统部署 k8s master 节点 Unauthorized Kubernetes — metalLB + Traefik 部署 Kubernetes — SSL 证书自动更新 Kubernetes — RKE2 + kube-vip + cilium 部署 使用TLSv1.3 升级nginx和openssl Proxmox VE(PVE) 更新到最新版本 kindle 邮件发送失败,错误代码E999 metallb + ingress-nginx + argocd 本地部署 iStoreOS(旁路由)使用openclash实现dns劫持 异常流量分析:图片库服务黑客入侵 openwrt 硬盘扩容 搭建ip地址检索服务 Kubernetes — k8s 手动安装 1.17.9 SELinux 问题:导致端口无法创建,无法访问 【福利】免费!本地部署!去除视频中移动的物体 通知:《打工人日报》迁移到独立板块 KyBook 3 | calibre-web - IOS系统最佳图书伴侣 Tmux 安装和使用教程 DockerHub 加速镜像部署 - 使用cloudflare 代理 docker的零停机部署 SD-webui 批量处理图片 ubuntu 安装 ComfyUI ubuntu 安装 stable-diffusion-webui 测试策略:微服务架构 单元测试:测试单元质量提升
Ant中如何添加第三方jar包依赖
2022-04-14 · via 博客 on 打工人日志

Ant 中如何添加第三方 jar 包依赖

如果使用 ant 进行 java 项目的编译部署,那怎么添加第三方 jar 包的依赖呢?方法如下:

  1. 在项目的根目录下创建 lib 目录,并把所有需要的第三方 jar 包放到此目录下。
  2. 在 build.xml 中依次添加:path、property,并在 javac 中添加 classpath,添加 unjar。完整配置如下:
 1<?xml version="1.0" encoding="UTF-8"?>
 2<project name="MyTool" default="build" basedir=".">
 3  <description>The ant project to build MyTool.</description>
 4  <property name="srcDir" location="src" description="源文件的存放目录" />
 5  <property name="libDir" location="lib" description="第三方jar包的存放目录" />
 6  <property name="antDir" location="ant" description="编译后所有文件存放的根目录" />
 7  <property name="binDir" location="${antDir}/bin" description="编译后class文件的存放目录" />
 8  <property name="jarDir" location="${antDir}/jar" description="打包后jar包的存放目录" />
 9  <property name="jarFile" location="${jarDir}/MyTool.jar" description="打包后jar包存放的完整路径" />
10  <property name="package" value="com.xiboliya.mytool" description="包名" />
11  <property name="mainClass" value="MyTool" description="主类名" />
12  <property name="resFromDir" location="res" description="资源文件的源目录" />
13  <property name="resToDir" location="${binDir}/res" description="资源文件的目标目录" />
14  <path id="libPath" description="编译时依赖的第三方jar包的存放路径">
15    <fileset dir="${libDir}" erroronmissingdir="false">
16      <include name="*.jar" />
17    </fileset>
18  </path>
19  <property name="classpath" refid="libPath" description="编译时依赖的第三方jar包的存放路径" />
20  <target name="init" description="初始化">
21    <delete dir="${binDir}" />
22    <delete dir="${jarDir}" />
23    <mkdir dir="${binDir}" />
24    <mkdir dir="${jarDir}" />
25    <copy todir="${resToDir}" description="复制资源文件">
26      <fileset dir="${resFromDir}" />
27    </copy>
28  </target>
29  <target name="compile" depends="init" description="编译代码">
30    <javac srcdir="${srcDir}" destdir="${binDir}" classpath="${classpath}" includeAntRuntime="false">
31      <compilerarg value="-Xlint:unchecked"/>
32      <compilerarg value="-Xlint:deprecation"/>
33    </javac>
34  </target>
35  <target name="unjarLib" depends="init" description="解压第三方jar包,以便于重新打包入程序jar包中">
36    <unjar dest="${binDir}">
37      <fileset dir="${libDir}">
38        <include name="**/*.jar" />
39      </fileset>
40      <patternset>
41        <exclude name="META-INF"/>
42        <exclude name="META-INF/MANIFEST.MF"/>
43      </patternset>
44    </unjar>
45  </target>
46  <target name="makeJar" depends="init,compile,unjarLib" description="生成jar包">
47    <jar destfile="${jarFile}" basedir="${binDir}" excludes="**/Thumbs.db" description="打包为jar文件,并排除Thumbs.db文件">
48      <manifest>
49        <attribute name="Main-Class" value="${package}.${mainClass}" />
50      </manifest>
51    </jar>
52  </target>
53  <target name="build" depends="init,compile,makeJar" description="编译并打包">
54    <echo message="Ant is building the project." />
55  </target>
56</project>

欢迎关注我的博客www.jobcher.com