当前位置:网站首页>Apache ant extension tutorial
Apache ant extension tutorial
2022-07-03 15:05:00 【trium_ KW】
Apache Ant We are committed to becoming a flexible and convenient construction tool , Though right Java Support more , Some third-party libraries can also be used to support the construction of other languages , Even some routine maintenance tasks . Whereas Apache Ant Use XML As a configuration language , Be good at description , And cannot deal with overly complex process logic , So there is the famous Ant-Contrib Expansion pack, ( Home page see here ) Where it comes in handy .Ant-Contrib Of course, the use of has increased Apache Ant The programmability of , But from the author's point of view , Contrary to Apache Ant Design intention of , meanwhile XML Even if it has programming ability , The logical expressiveness of traditional programming languages is by no means XML Comparable . in fact , Through its official API Expand Apache Ant Make it complete the user customization function , In the long run , It has better simplicity 、 Robustness, 、 Maintainability and stability , It's just relatively friendly XML, read API The arduous task of concealing expansion Apache Ant Just the advantage of .
Apache Ant The build file consists of two elements , Namely Task( Mission ) and DataType( data type ). generally , Type represents a collection of resources , Such as Fileset( File set ); Tasks are used to perform certain operations . Although there are many differences between tasks and types , But both from Java There are many similarities in class structure . for example :
package packagePath;
import org.apache.tools.ant.Task; // Tasks are inherited from here
import org.apache.tools.ant.BuildException;
/* * Use Java Bean Specification definition XML attribute , Attribute name from getter/setter Guess from the name . * To add child elements , Need to use addXXX(YYYY e) Method .XXX For the child element XML Element name * ( stay XML Regardless of case , But in Java The naming in should conform to Java Bean standard ); * YYYY For its practical Java Class name . */
public class MyTask extends Task {
private String myStringAttribute;
private int myIntAttribute;
private File myFileAttribute;
private ArrayList<SelfDefinedSubElement> l;
public MyTask() {
l = new ArrayList<SelfDefinedSubElement>();
}
public String getMyStringAttribute() {
return myStringAttribute;
}
// The other two getters ...
public void setMyStringAttribute(String myStringAttribute) {
this.myStringAttribute = myStringAttribute;
}
// The other two setters ...
public void addSelfDefinedElement(SelfDefinedSubElement e) {
l.add(e);
}
/* * Start the task here .DataType There is no such method ; but DataType Get references * Methods , That is, use attributes in one place id Mark the data type and then use it in another place refid * Get its reference . Detailed inquiry Apache Ant API */
@Override
public void execute() {
if (myStringAttribute == null) {
throw new BuildException("myStringAttribute not set");
}
// Other input checks ...
// What to do ...
}
} This is a task , One Java file .
# Defined here MyTask stay XML Element name in
nameUsedByMyTaskInBuildfile=packagePath.MyTask
selfDefinedElement= Its fully qualified classpath This is the mission statement , One propertes file .
<target name="XXX">
<!-- some other tasks -->
<nameUsedByMyTaskInBuildfile myStringAttribute="stringValue" myFileAttribute="C:\Users" myIntAttribute="5">
<selfDefinedElement someAttributes="" />
</nameUsedByMyTaskInBuildfile>
<!-- some other tasks -->
</target>This is a possible corresponding to the task XML Example .
package anotherPackagePath;
import org.apache.tools.ant.types.DataType; // The data type inherits from here
import org.apache.tools.ant.BuildException;
/* * The description is the same as the task description */
public class MyType extends DataType {
private String myStringAttribute;
private int myIntAttribute;
private File myFileAttribute;
private ArrayList<AnotherSelfDefinedSubElement> l;
public MyTask() {
l = new ArrayList<AnotherSelfDefinedSubElement>();
}
public String getMyStringAttribute() {
return myStringAttribute;
}
// The other two getters ...
public void setMyStringAttribute(String myStringAttribute) {
this.myStringAttribute = myStringAttribute;
}
// The other two setters ...
public void addAnotherSelfDefinedElement(AnotherSelfDefinedSubElement e) {
l.add(e);
}
} This is a data type , One Java file .
nameUsedByMyTypeInBuildfile=anotherPackagePath.MyType
anotherSelfDefinedElement= Its fully qualified classpath This is the data type declaration , One propertes file .
<nameUsedByMyTypeInBuildfile myStringAttribute="stringValue" myFileAttribute="C:\Users" myIntAttribute="5" id="my.id">
<anotherSelfDefinedElement someAttributes="" />
</nameUsedByMyTypeInBuildfile>This is a possible corresponding to this data type XML Example .
- Related reading :
- Apache Ant API The basic use method
- Apache Ant API( This is a download address ,Apache Ant No official online API)
边栏推荐
- Global and Chinese markets for flexible chips 2022-2028: Research Report on technology, participants, trends, market size and share
- [combinatorics] permutation and combination (set permutation, step-by-step processing example)
- 5.4-5.5
- cpu飙升排查方法
- 远程服务器后台挂起 nohup
- Finally, someone explained the financial risk management clearly
- Global and Chinese markets of AC electromechanical relays 2022-2028: Research Report on technology, participants, trends, market size and share
- ASTC texture compression (adaptive scalable texture compression)
- 【Transformer】入门篇-哈佛Harvard NLP的原作者在2018年初以逐行实现的形式呈现了论文The Annotated Transformer
- Yolov5系列(一)——網絡可視化工具netron
猜你喜欢

Besides lying flat, what else can a 27 year old do in life?

Zero copy underlying analysis

5.2-5.3

How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03

什么是embedding(把物体编码为一个低维稠密向量),pytorch中nn.Embedding原理及使用
![[ue4] geometry drawing pipeline](/img/30/9fcf83a665043fe57389d44c2e16a8.jpg)
[ue4] geometry drawing pipeline

B2020 分糖果
![[ue4] HISM large scale vegetation rendering solution](/img/a2/2ff2462207e3c3e8364a092765040c.jpg)
[ue4] HISM large scale vegetation rendering solution

Vs+qt application development, set software icon icon
![[graphics] hair simulation in tressfx](/img/41/cef55811463d3a25a29ddab5278af0.jpg)
[graphics] hair simulation in tressfx
随机推荐
C language memory function
Global and Chinese markets for ionization equipment 2022-2028: Research Report on technology, participants, trends, market size and share
5.2-5.3
Joomla! CMS 3.0~3.4.6 RCE
Déformation de la chaîne bm83 de niuke (conversion de cas, inversion de chaîne, remplacement de chaîne)
2022/02/14
Zzuli:1056 lucky numbers
Global and Chinese market of solder bars 2022-2028: Research Report on technology, participants, trends, market size and share
How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
There are links in the linked list. Can you walk three steps faster or slower
【Transform】【实践】使用Pytorch的torch.nn.MultiheadAttention来实现self-attention
使用Tengine解决负载均衡的Session问题
406. Reconstruct the queue according to height
Global and Chinese markets for flexible chips 2022-2028: Research Report on technology, participants, trends, market size and share
Solve the problem that PR cannot be installed on win10 system. Pr2021 version -premiere Pro 2021 official Chinese version installation tutorial
C # realizes the login interface, and the password asterisk is displayed (hide the input password)
[pytorch learning notes] transforms
Global and Chinese markets for sterile packaging 2022-2028: Research Report on technology, participants, trends, market size and share
[wechat applet] wxss template style
牛客 BM83 字符串变形(大小写转换,字符串反转,字符串替换)