Ant打包jar,程序的混淆
cmd命令下:
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.
C:\Documents and Settings\new>d:
D:\>cd D:\NetBeansProjects\testtest
D:\NetBeansProjects\testtest>ant
Buildfile: build.xml
init:
[mkdir] Created dir: D:\NetBeansProjects\testtest\dist
[mkdir] Created dir: D:\NetBeansProjects\testtest\build
copy:
[copy] Copying 90 files to D:\NetBeansProjects\testtest\build
compile:
[jocky] Jocky enabled
[javac] Compiling 107 source files to D:\NetBeansProjects\testtest\build
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
jar:
[jar] Building jar: D:\NetBeansProjects\testtest\dist\test.jar
archive:
BUILD SUCCESSFUL
Total time: 16 seconds
D:\NetBeansProjects\testtest>
build.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<!--
=======================================================================
Apache Ant own build file
Copyright (c) 2000-2004 The Apache Software Foundation. All rights
reserved.
ant.java.version the JVM version Ant detected; currently it can hold
the values "1.2", "1.3", "1.4" and "1.5".
=======================================================================
-->
<project name="testtest" default="archive" basedir=".">
<description>
gui
</description>
<property environment="env"/>
<property name="java.home" value="${env.JAVA_HOME}"/>
<property name="ant.home" value="${env.ANT_HOME}"/>
<property name="app.copyright" value=" Copyright (c) 2002 The Neusoft Software Foundation. All rights reserved."/>
<!--app src -->
<property name="src" value="src"/>
<!--app lib-->
<property name="lib.dir" value="lib"/>
<property name="main-class" value="com.cjun.login.view.UserLoginView" />
<!-- Creates the output directories -->
<taskdef resource="jockytasks"> </taskdef>
<!-- outer jar lib -->
<path id="lib_class_path">
<fileset dir="${lib.dir}" includes="**/*.jar"></fileset>
<!-- <pathelement path="${java.home}/lib/tools.jar"/> -->
</path>
<target name="init">
<!-- Create the build directory structure used by compile -->
<mkdir dir="dist" />
<mkdir dir="build" />
</target>
<!-- Compiles into the output directories -->
<target name="compile" depends="copy" >
<jocky jar="D:\ant-1.7.1\lib\jocky.jar" enable="true" level="private"> </jocky>
<!-- Compile the java co
<javac encoding="utf-8" destdir="build" debug="on" source="1.5" target="1.5">
<src path="src"></src>
<classpath refid="lib_class_path" />
</javac>
</target>
<target name="copy" depends="init" >
<copy todir="build">
<fileset dir="src" includes="**/*.properties"/>
<fileset dir="src" includes="**/*.png"/>
<fileset dir="src" includes="images/**"/>
<fileset dir="src" includes="**/*.xml"/>
<fileset dir="src" includes="META-INF/**"/>
</copy>
</target>
<!-- Creates the archive -->
<!--
<target name="archive" depends="compile" >
<jar destfile="dist/testjiami.jar" basedir="bin2" />
</target>
-->
<target name="jar" depends="compile">
<jar destfile="dist/test.jar" basedir="build" >
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
<attribute name="Class-Path" value=" lib/appframework-1.0.3.jar lib/swing-worker-1.1.jar lib/hibernate3.jar lib/jdom.jar lib/jtds-1.2.jar lib/log4j-1.2.9.jar lib/commons-dbcp.jar lib/appframework-1.0.3.jar lib/commons-collections-3.0.jar lib/swing-worker-1.1.jar lib/dom4j-1.6.jar lib/commons-logging.jar lib/ehcache-1.1.jar lib/jta.jar lib/cglib-2.1.jar lib/asm.jar"/>
<attribute name="X-COMMENT" value=" Main-Class will be added automatically by build"/>
</manifest>
<!-- <fileset dir="lib" includes="*.jar" /> -->
</jar>
</target>
<target name="archive" depends="jar">
</target>
<!-- Cleans the output directories -->
<target name="clean" depends="init">
<delete dir="build" />
<delete dir="dist" />
</target>
</project>