<?xml version="1.0" encoding="UTF-8"?>
<!--
编译src目录下的源文件,然后放在compile文件夹下,接着把compile下的class文件打包,放在dist文件夹下,并设置清单
src有源文件Test3,图像化程序
-->
<project name="myAntProject" default="myCompile" basedir="..\">
<property name="compile" value="compile" description="文件夹compile,存放编译好的文件"></property>
<property name="dist" value="dist" description="文件夹dist,存放打包好的文件"></property>
<target name="preprocess">
<mkdir dir="${compile}" description="创建文件夹compile"/>
<mkdir dir="${dist}" description="创建文件夹dist"/>
</target>
<target name="myCompile" depends="preprocess">
<javac srcdir="src" destdir="${compile}" description="把src文件夹下的所有源文件编译后放在compile文件夹中"></javac>
</target>
<target name="package" depends="myCompile">
<jar destfile="${dist}\package.jar" basedir="${compile}"
description="把compile下的class文件打包package.jar,放在dist文件夹下">
<!-- 设置清单 -->
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Main-Class" value="com.bjpowernode.test.Test3"/>
</manifest>
</jar>
</target>
</project>
package com.bjpowernode.test;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Test3 {
/**
* @param args
*/
public static void main(String[] args) {
JFrame jFrame = new JFrame("Hello Ant");
jFrame.setSize(new Dimension(200, 300));
jFrame.setBackground(new Color(200, 200, 200));
jFrame.setAlwaysOnTop(true);
jFrame.getContentPane().add(new JButton("Ant"));
jFrame.setVisible(true);
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}