.


:




:

































 

 

 

 


build-




Build- Ant XML. build - (project) (target). (tasks). , build -, id . . : Project Project :
name
default , , ,
basedir , , ( , , build-)
. , . Ant , () . , .

Targets

. , : . , . Ant . , depends - Ant ,
. Ant , depends ( ).<target name="A"/><target name="B" depends="A"/><target name="C" depends="B"/><target name="D" depends="C,B,A"/> D. depends , C, B , , A. : C B, a B A, , A, B, C, D. , . , (property) ( ) . (, , Java ..). Ant , , . , , . :<target name="build-module-A" if="module-A-present"/><target name="build-own-fake-module-A" unless= "module-A-present"/> if unless , . description projecthelp. Target :
name
depends ,
if , ,
unless , ,
description function
, "", "," . build- :

<?xml version='1.0' encoding='ISO-8859-1'?>

<project name="MyProject" default="dist" basedir=".">

<description>

build

</description>

<!-- -->

<property name="src" location="src"/>

<property name="build" location="build"/>

<property name="dist" location="dist"/>

<target name="init">

<!-- -->

<tstamp/>

<!-- build , -->

<mkdir dir="${build}"/>

</target>

<target name="compile" depends="init"

description="compile the source " >

<!-- java ${src} ${build} -->

<javac srcdir="${src}" destdir="${build}"/>

</target>

<target name="dist" depends="compile"

description=" " >

<!-- -->

<mkdir dir="${dist}/lib"/>

 

<!-- ${build} MyProject-${DSTAMP}.jar -->

<jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>

</target>

<target name="clean"

description=" " >

<!-- Delete the ${build} and ${dist} directory trees -->

<delete dir="${build}"/>

<delete dir="${dist}"/>

</target>

</project>

. , projecthelp ; .

, src package.

:

D:\tmp\1>ant

Buildfile: build.xml

init:

[mkdir] Created dir: D:\tmp\1\build

compile:

[javac] Compiling 1 source file to D:\tmp\1\build

dist:

[mkdir] Created dir: D:\tmp\1\dist\lib

[jar] Building jar: D:\tmp\1\dist\lib\MyProject-20070815.jar

BUILD SUCCESSFUL

Total time: 3 seconds

Property

Ant , . , ,
Ant : .

<property name=path value=./project/>

:

${path}

:

<property name=libpath" value="${path}/lib"/>

Ant property-. property-:

#

# A sample ant.properties file

#

month=30 days

year=2004

 

<?xml version="1.0"?>

<project name=test.properties" default="all" >

<property file=ant.properties"/>

<target name="all" description="Uses properties">

<echo>This month is ${month}</echo>

<echo>This year is ${year}</echo>

</target>

</project>

, , , .java, EJB. :

<copy todir="archive">

<fileset dir="src">

<include name="*.java"/>

<exclude name= "EJB*.java/>

</fileset>

</copy>

Filter

.

<filterset id="copy.filterset">

<filter token="version" value="1.1"/>

</filterset>

<target name=copy>

<copy file="file1.txt" tofile="file2.txt" filtering="true">

<filterset refid="copy.filterset" />

</copy>

</target>

:

# file.txt

Version is @version@

:

# file.txt

Version is 1.1

Path-like

path classpath, ":" (unix-style) ";" (windows-style) . Ant .

, path-like , (nested elements). :

<classpath> <pathelement path="${classpath}"/> <pathelement location="lib/helper.jar"/> </classpath>

location , path locations. path .

< classpath > path location :

<classpath> <pathelement path="${classpath}"/> </classpath>

:

<classpath path="${classpath}"/>

DirSets, FileSets FileLists :

<classpath> <pathelement path="${classpath}"/> <fileset dir="lib"> <include name="**/*.jar"/> </fileset> <pathelement location="classes"/> <dirset dir="${build.dir}"> <include name="apps/**/classes"/> <exclude name="apps/**/*Test*"/> </dirset> <filelist refid="third-party_jars"/> </classpath>

Path-like path-like <path> :

<path id="base.path"> <pathelement path="${classpath}"/> <fileset dir="lib"> <include name="**/*.jar"/> </fileset> <pathelement location="classes"/> </path> <path id="tests.path"> <path refid="base.path"/> <pathelement location="testclasses"/> </path>

Ant :

ant [options] [target [target2 [target3]...]]

Options

-help, -h
-projecthelp, -p
-version
-diagnostics
quiet, -q
-verbose, -v ,
-debug, -d
-lib <path> , jar class
-logfile <file>
-l <file> ''
-logger <classname> ,
-noinput
-buildfile <file> build- ( build.xml)
-file <file> ''
-f <file> ''
-D<property>=<value>
-keep-going, -k ,
-propertyfile <name> D




:


: 2016-04-03; !; : 516 |


:

:

: , .
==> ...

2028 - | 1649 -


© 2015-2024 lektsii.org - -

: 0.022 .