Linki

ant manual, tasks

Snippety

  1. build number
    <target name="buildnumber">
    <!-- this fills build.number with an old build number, so it's better to skip it placing it in another target -->
    <buildnumber/>
    </target>

    <antcall target="buildnumber" />
    <property file="build.number" />
    <property name="plikZip" value="${basedir}/${ant.project.name}_r${build.number}.zip" />
  2. clean
        <delete quiet="true" dir="${basedir}/work/comp" />
    <mkdir dir="${basedir}/work/comp" />
  3. comp
    <javac verbose="no" classpath="${basedir}" srcdir="${basedir}" destdir="${compDir}"
    includes="*.java pbn/*.java" encoding="windows-1250"/>
  4. condition
    <condition property="prog2" value="KP" else="${prog}">
    <equals arg1="${prog}" arg2="KD" casesensitive="false">
    </equals>
    </condition>

    <condition property="src.dir" value="/usr/src/zbar" else="c:\temp\30\zbar"><os family="unix"/></condition>

    <condition property="linux-native">
    <and><isset property="linux"/><not><isset property="cross"/></not></and>
    </condition>

    <target name="cos" if="property.name">
  5. copy
        <copy file="${nbDir1}/DlgProcess.java" todir="${basedir}" overwrite="true" />
    <copy todir="${basedir}"><fileset dir="${nbDir1}" includes="*.java brydz/*.java"/></copy>
    <!-- tofile="..." -->
  6. echo
        <echo file="${katrap}/kop_temp.bat">
    @echo off
    copy ${basedir}\*.sc* ${katrap}
    copy r:\kom\hm\kodhas.sci ${katrap}
    copy ${basedir}\..\imp_wb_z_fk_do_hm ${katrap}
    </echo>
  7. exec
      <target name="run_symf" >
    <exec executable="c:\symfonia\${prog}\${progver}\am${prog}.exe"
    output="out.txt" outputproperty="zmienna.wyjscie" failonerror="true"
    input="wejscie.txt" inputstring="wejscie" >
    <arg line="arg1 arg2" />
    </exec>
    </target>
  8. ftp
      <ftp server="jarek.katowice.pl"
    remotedir="/public_html"
    userid="uuu@host"
    password="pppp"
    passive="yes"
    >
    <fileset dir="www" includes="maglab.htmlp" />
    </ftp>
  9. if
    <target name="prepare-files">
    <available property="jest.pomoc.html" file="pomoc.html" />
    <antcall target="build-help" />
    </target>
    <target name="build-help" if="jest.pomoc.html">
    </target>
  10. include/ ant
    <include file="${basedir}/../build.xml"/> - adds prefix to included targets
    <import file="${basedir}/../build.xml"/> - included file may call parent's targets
    <ant antfile="../build.xml" target="test-rozdaj" />
  11. jar
        <jar destfile="${basedir}/PbnTools.jar" basedir="${basedir}/work/comp" includes="*.class" >
    <fileset dir="${src}/resources" includes="**/*.png" excludes="" />
    <manifest>
    <attribute name="Manifest-Version" value="1.0" />
    <attribute name="Main-Class" value="PbnTools" />
    </manifest>
    </jar>
  12. java
    <java classpath="${compDir}" classname="pbn.PlikPbn" dir="${basedir}" fork="yes" >
    <arg value="wyn.pbn"/>
    <jvmarg value="-Duser.language=pl" />
    </java>
  13. script
    <property name="jythonJar" location="C:\lang\java\jython2.5.2\jython.jar" />
    <property name="bshJar" value="C:\lang\java\bsh-1.3.0.jar:C:\lang\java\bsf.jar:
    C:\lang\java\commons-logging-1.1.1.jar" />
    <script language="jython" classpath="${jythonJar}" ><![CDATA[
    print("test")
    ]]></script>
    <script manager="bsf" language="beanshell" classpath="${bshJar}"><![CDATA[
    java.awt.Desktop.getDesktop().open("info.rtf");
    ]]></script>
  14. zip
    <project name="eksp_kompens" default="zip" >

    <target name="zip">
    <zip destfile="${basedir}/${ant.project.name}.zip">
    <fileset dir="${basedir}" includes="*.sc*" />
    </zip>
    </target>

    </project>
  15. przykładowy build.xml z sqlem i zenity ask
    <project default="sql" >

    <property name="prog" value="hm" />
    <property name="progver" value="111a" />

    <target name="ask">
    <exec executable="zenity.bat" failonerror="true" outputproperty="out">
    <arg line="--entry --title=&quot;Enter target name&quot; --text=&quot;&quot;"/></exec>
    <antcall target="${out}"/>
    </target>

    <target name="mssql">
    <sql driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
    url="jdbc:sqlserver://bonsoftpc\expr:1065;databasename=prophix"
    userid="sa" password="sa"
    print="true" csvColumnSeparator=" " delimiter="go" strictDelimiterMatching="false" >
    <![CDATA[
    select * from prophix.dbo.integracja_kontrakty
    go
    ]]>
    </sql>
    </target>

    <target name="psql">
    <sql driver="com.pervasive.jdbc.v2.Driver" url="jdbc:pervasive://bonsoftpc/kddemo101a" userid="admin"
    password=""
    print="true" csvColumnSeparator=" " delimiter="go" strictDelimiterMatching="false" >
    <![CDATA[
    select * from pracownicy
    go
    ]]>
    </sql>
    </target>

    <target name="postgresql">
    <sql driver="org.postgresql.Driver" url="jdbc:postgresql://localhost/metz_dk" userid="postgres"
    password="postgres"
    print="true" csvColumnSeparator=" " delimiter="go" strictDelimiterMatching="false" >
    <![CDATA[
    select * from dane_we limit 1
    go
    ]]>
    </sql>
    </target>

    </project>