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

推荐订阅源

N
News and Events Feed by Topic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
C
Cisco Blogs
博客园 - 叶小钗
P
Privacy International News Feed
Jina AI
Jina AI
Apple Machine Learning Research
Apple Machine Learning Research
T
Threatpost
IT之家
IT之家
博客园 - 聂微东
Know Your Adversary
Know Your Adversary
Help Net Security
Help Net Security
罗磊的独立博客
I
Intezer
S
Schneier on Security
博客园_首页
C
CERT Recently Published Vulnerability Notes
雷峰网
雷峰网
Cisco Talos Blog
Cisco Talos Blog
宝玉的分享
宝玉的分享
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Webroot Blog
Webroot Blog
TaoSecurity Blog
TaoSecurity Blog
MyScale Blog
MyScale Blog
P
Privacy & Cybersecurity Law Blog
T
The Exploit Database - CXSecurity.com
PCI Perspectives
PCI Perspectives
Security Latest
Security Latest
H
Heimdal Security Blog
S
Secure Thoughts
Hacker News: Ask HN
Hacker News: Ask HN
Y
Y Combinator Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Microsoft Security Blog
Microsoft Security Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
SecWiki News
SecWiki News
The GitHub Blog
The GitHub Blog
A
Arctic Wolf
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
T
Threat Research - Cisco Blogs
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

jobcher on 打工人日志

2023-12-21 打工人日报 2023-12-20 打工人日报 2023-12-19 打工人日报 2023-12-18 打工人日报 2023-12-17 打工人日报 2023-12-16 打工人日报 2023-12-15 打工人日报 2023-12-14 打工人日报 2023-12-13 打工人日报 2023-12-12 打工人日报 2023-12-11 打工人日报 2023-12-10 打工人日报 2023-12-09 打工人日报 2023-12-08 打工人日报 2023-12-07 打工人日报 2023-12-06 打工人日报 2023-12-05 打工人日报 2023-12-04 打工人日报 2023-12-03 打工人日报 2023-12-02 打工人日报 2023-12-01 打工人日报 2023-11-30 打工人日报 2023-11-29 打工人日报 2023-11-28 打工人日报 2023-11-27 打工人日报 2023-11-26 打工人日报 2023-11-25 打工人日报 2023-11-24 打工人日报 2023-11-23 打工人日报 2023-11-22 打工人日报 2023-11-21 打工人日报 2023-11-20 打工人日报 2023-11-19 打工人日报 2023-11-17 打工人日报 2023-11-16 打工人日报 2023-11-15 打工人日报 2023-11-14 打工人日报 2023-11-13 打工人日报 2023-11-12 打工人日报 2023-11-11 打工人日报 2023-11-10 打工人日报 2023-11-09 打工人日报 2023-11-08 打工人日报 2023-11-07 打工人日报 2023-11-06 打工人日报 2023-11-05 打工人日报 2023-11-04 打工人日报 2023-11-03 打工人日报 2023-11-02 打工人日报 2023-11-01 打工人日报 2023-10-31 打工人日报 2023-10-30 打工人日报 2023-10-29 打工人日报 2023-10-28 打工人日报 2023-10-27 打工人日报 2023-10-26 打工人日报 2023-10-25 打工人日报 2023-10-24 打工人日报 2023-10-23 打工人日报 2023-10-22 打工人日报 2023-10-21 打工人日报 2023-10-20 打工人日报 2023-10-19 打工人日报 2023-10-18 打工人日报 2023-10-17 打工人日报 2023-10-16 打工人日报 2023-10-15 打工人日报 2023-10-14 打工人日报 2023-10-13 打工人日报 2023-10-12 打工人日报 2023-10-11 打工人日报 2023-10-10 打工人日报 2023-10-09 打工人日报 2023-10-07 打工人日报 2023-10-06 打工人日报 2023-10-05 打工人日报 2023-10-04 打工人日报 2023-10-03 打工人日报 2023-10-02 打工人日报 2023-10-01 打工人日报 2023-09-30 打工人日报 2023-09-29 打工人日报 2023-09-28 打工人日报 2023-09-27 打工人日报 2023-09-26 打工人日报 2023-09-25 打工人日报 2023-09-24 打工人日报 2023-09-23 打工人日报 2023-09-22 打工人日报 2023-09-21 打工人日报 2023-09-20 打工人日报 2023-09-19 打工人日报 2023-09-18 打工人日报 2023-09-17 打工人日报 2023-09-16 打工人日报 2023-09-15 打工人日报 2023-09-14 打工人日报 2023-09-13 打工人日报 2023-09-12 打工人日报 2023-09-11 打工人日报
Ant中如何添加第三方jar包依赖
2022-04-14 · via jobcher 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