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

推荐订阅源

C
Cisco Blogs
爱范儿
爱范儿
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
Jina AI
Jina AI
Project Zero
Project Zero
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
WordPress大学
WordPress大学
Simon Willison's Weblog
Simon Willison's Weblog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tenable Blog
F
Fortinet All Blogs
大猫的无限游戏
大猫的无限游戏
Last Week in AI
Last Week in AI
月光博客
月光博客
雷峰网
雷峰网
G
Google Developers Blog
V
V2EX
T
Tor Project blog
罗磊的独立博客
Schneier on Security
Schneier on Security
Know Your Adversary
Know Your Adversary
W
WeLiveSecurity
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Privacy International News Feed
S
Securelist
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
小众软件
小众软件
Scott Helme
Scott Helme
I
Intezer
T
Threat Research - Cisco Blogs
The GitHub Blog
The GitHub Blog
N
Netflix TechBlog - Medium
C
CERT Recently Published Vulnerability Notes
Security Archives - TechRepublic
Security Archives - TechRepublic
酷 壳 – CoolShell
酷 壳 – CoolShell
L
LINUX DO - 最新话题
N
News | PayPal Newsroom
L
Lohrmann on Cybersecurity
T
Troy Hunt's Blog
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
人人都是产品经理
人人都是产品经理
Latest news
Latest news
AWS News Blog
AWS News Blog
Apple Machine Learning Research
Apple Machine Learning Research

日常 on 打工人日志

Proxmox VE(PVE) 更新到最新版本 iStoreOS(旁路由)使用openclash实现dns劫持 异常流量分析:图片库服务黑客入侵 openwrt 硬盘扩容 搭建ip地址检索服务 通知:《打工人日报》迁移到独立板块 黑群晖最新安装教程 推荐一下 容器云资源 2010年的天涯神贴聊房价 如何礼貌回绝不合理的需求 github 国内代理访问下载 逆境和成长-2022年终总结 优雅的使用Conda管理python环境 shell功能脚本集合 Cloudflare Zero Trust 内网穿透 headscale 部署使用 羊了个羊小程序 破解通关 RocketMQ k8s部署 4主4从集群 linux服务器 删除空间却未释放 VSCode插件推荐=> Code Runner ant build.xml 编写 记录一次上门打散工 linux 网络测速 网心云挂机教程 | 轻松实现睡后收入~ Proxmox VE 在线扩容磁盘分区 centos7.9 网络配置 RocketMQ 安装和启动 安装 minIO Azure S3网关 logrotate 日志滚动的使用 安装配置 Terraform rsync 文件同步 获取用户浏览器默认语言设置,自动判断跳转不同网站 linux系统开启root权限 163企业邮箱设置教程 2021年第50周记 自建服务器内网穿透 树莓派搭建k3s 优秀英语教材的选择
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