`

最全的Ant文件

 
阅读更多
<?xml version="1.0"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<project default="all" basedir="." name="xmlgraphics-commons">

  <!-- See build.properties and build-local.properties for overriding build settings. -->
  <!-- build-local.properties is not stored in SVN and overrides values from build.properties -->
  <property file="${basedir}/build-local.properties"/>
  <property file="${basedir}/build.properties"/>
  <property environment="env"/>

  <property name="Name" value="Apache XML Graphics Commons"/>
  <property name="name" value="xmlgraphics-commons"/>
  <property name="year" value="1999-2009"/>

  <property name="javac.debug" value="on"/>
  <property name="javac.optimize" value="off"/>
  <property name="javac.deprecation" value="on"/>
  <property name="javac.source" value="1.4"/>
  <property name="javac.target" value="1.4"/>
  <property name="javac.fork" value="no"/>

  <property name="junit.fork" value="on"/>

  <property name="javadoc.packages" value="org.apache.xmlgraphics.*"/>
  
  <property name="internal-codecs.disabled" value="false"/>
  
  <property name="src.dir" value="${basedir}/src"/>
  <property name="src.java.dir" value="${src.dir}/java"/>
  <property name="src.res.dir" value="${src.dir}/resources"/>
  <property name="lib.dir" value="${basedir}/lib"/>

  <property name="build.dir" value="${basedir}/build"/>
  <property name="build.classes.dir" value="${build.dir}/classes"/>
  <property name="build.javadocs.dir" value="${build.dir}/javadocs"/>
  
  <property name="dist.bin.dir" value="${basedir}/dist-bin"/>
  <property name="dist.src.dir" value="${basedir}/dist-src"/>
  <property name="dist.bin.result.dir" value="${dist.bin.dir}/${name}-${version}"/>
  <property name="dist.src.result.dir" value="${dist.src.dir}/${name}-${version}"/>

  <!-- .NET support (using IKVM) -->
  <property name="ikvm.dir" value="."/>
  <property name="ikvmc" value="${ikvm.dir}/bin/ikvmc.exe"/>

  <tstamp>
    <format property="ts" pattern="yyyyMMdd-HHmmss-z"/>
  </tstamp>

  <path id="libs-build-classpath">
    <fileset dir="${lib.dir}">
      <include name="*.jar"/>
    </fileset>
  </path>

  <path id="libs-run-classpath">
    <fileset dir="${lib.dir}">
      <include name="*.jar"/>
    </fileset>
    <fileset dir="${build.dir}">
      <include name="${name}.jar"/>
    </fileset>
  </path>

  <fileset dir="${basedir}" id="dist.bin">
    <include name="examples/**"/>
    <include name="LICENSE"/>
    <include name="NOTICE"/>
    <include name="README"/>
    <include name="KEYS"/>
    <include name="status.xml"/>
  </fileset>

  <fileset dir="${basedir}" id="dist.bin.lib">
    <patternset id="dist.lib">
      <include name="lib/commons-io*"/>
      <include name="lib/commons-logging*"/>
      <include name="lib/README*"/>
    </patternset>
  </fileset>

  <fileset dir="${basedir}" id="dist.src">
    <include name="src/**"/>
    <patternset refid="dist.lib"/>
    <include name="test/**"/>
    <include name="examples/**"/>
    <include name="LICENSE"/>
    <include name="NOTICE"/>
    <include name="README"/>
    <include name="KEYS"/>
    <include name="status.xml"/>
    <include name="*.pom"/>
    <include name="build.*"/>
    <include name="forrest.*"/>
  </fileset>

  <!-- ------------------------------------------------------------------- -->
  <!-- Initialization target                                               -->
  <!-- ------------------------------------------------------------------- -->
  <target name="info">
    <echo message="------------------- ${Name} ${version} [${year}] ----------------"/>
    <echo message="See build.properties and build-local.properties for additional build settings"/>
    <echo message="${ant.version}"/>
    <echo message="VM: ${java.vm.version}, ${java.vm.vendor}"/>
    <echo message="JAVA_HOME: ${env.JAVA_HOME}"/>
  </target>
  
  <target name="init" depends="info, init-avail"/>

  <target name="init-avail">
    <available property="jdk14.present" classname="java.lang.CharSequence"/>
    <fail message="${Name} requires at least Java 1.4" unless="jdk14.present"/>
    
    <available property="sun.jpeg.present" classname="com.sun.image.codec.jpeg.JPEGCodec"/>
    <condition property="sun.jpeg.message" value="Sun-private JPEG Support PRESENT">
      <equals arg1="${sun.jpeg.present}" arg2="true"/>
    </condition>
    <condition property="sun.jpeg.message" value="Sun-private JPEG Support NOT Present">
      <not>
        <equals arg1="${sun.jpeg.present}" arg2="true"/>
      </not>
    </condition>
    <echo message="${sun.jpeg.message}"/>
    <condition property="internal-codecs.eff.disabled">
      <or>
        <not>
          <equals arg1="${sun.jpeg.present}" arg2="true"/>
        </not>
        <equals arg1="${internal-codecs.disabled}" arg2="true"/>
      </or>
    </condition>

    <available property="junit.present" classname="junit.framework.TestCase"
        classpathref="libs-build-classpath"/>
    <condition property="junit.message" value="JUnit Support PRESENT">
      <equals arg1="${junit.present}" arg2="true"/>
    </condition>
    <condition property="junit.message" value="JUnit Support NOT Present - Committers are required to have JUnit working">
      <not>
        <equals arg1="${junit.present}" arg2="true"/>
      </not>
    </condition>
    <echo message="${junit.message}"/>

    <condition property="IKVM.present">
      <and>
        <available file="${ikvmc}"/>
        <equals arg1="${internal-codecs.eff.disabled}" arg2="true"/>
      </and>
    </condition>
    <condition property="ikvm.message" value="IKVM Support PRESENT and ENABLED">
      <equals arg1="${IKVM.present}" arg2="true"/>
    </condition>
    <condition property="ikvm.message" value="IKVM Support NOT Present">
      <not>
        <available file="${ikvmc}"/>
      </not>
    </condition>
    <condition property="ikvm.message" value="IKVM Support DISABLED">
      <not>
        <equals arg1="${IKVM.present}" arg2="true"/>
      </not>
    </condition>
    <echo message="${ikvm.message}"/>
  </target>

  <!-- ------------------------------------------------------------------- -->
  <!-- Help on usage                                                       -->
  <!-- ------------------------------------------------------------------- -->
  <target name="usage">
    <echo message="Use the -projecthelp option instead"/>
  </target>

  <!-- ------------------------------------------------------------------- -->
  <!-- Compiles the source directory                                       -->
  <!-- ------------------------------------------------------------------- -->
  <target name="compile" depends="compile-java, compile-copy-resources" description="Compiles the source code"/>

  <target name="compile-copy-resources" description="Copies the resource files into the build directory">
    <mkdir dir="${build.classes.dir}"/>
    <copy todir="${build.classes.dir}">
      <fileset dir="${src.res.dir}"/>
    </copy>
  </target>

  <target name="compile-pattern-with-codecs" depends="init" unless="internal-codecs.eff.disabled">
    <echo message="Internal codecs will be compiled."/>
    <patternset id="compile-pattern">
      <include name="**/*.java"/>
    </patternset>
  </target>
  <target name="compile-pattern-without-codecs" depends="init" if="internal-codecs.eff.disabled">
    <echo message="Internal codecs will be skipped."/>
    <patternset id="compile-pattern">
      <include name="**/*.java"/>
      <exclude name="**/image/codec/tiff/**/*.java"/>
      <exclude name="**/image/writer/internal/JPEGImageWriter*.java"/>
      <exclude name="**/image/writer/internal/TIFFImageWriter*.java"/>
    </patternset>
  </target>
  <target name="compile-java" depends="init, compile-pattern-with-codecs, compile-pattern-without-codecs">
    <!-- create directories -->
    <mkdir dir="${build.classes.dir}"/>
    <javac destdir="${build.classes.dir}" fork="${javac.fork}" debug="${javac.debug}"
           deprecation="${javac.deprecation}" optimize="${javac.optimize}"
           source="${javac.source}" target="${javac.target}">
      <src path="${src.java.dir}"/>
      <patternset refid="compile-pattern"/>
      <classpath refid="libs-build-classpath"/>
    </javac>
  </target>

  <!-- ------------------------------------------------------------------- -->
  <!-- Creates JAR files                                                   -->
  <!-- ------------------------------------------------------------------- -->

  <target name="uptodate-jar-main" depends="compile">
    <uptodate property="jar.main.uptodate" targetfile="${build.dir}/${name}.jar">
      <srcfiles dir= "${build.classes.dir}"/>
    </uptodate>
  </target>

  <target name="jar-main" depends="compile,uptodate-jar-main" description="Generates the main jar file" unless="jar.main.uptodate">
    <jar jarfile="${build.dir}/${name}-${version}.jar" basedir="${build.classes.dir}">
      <manifest>
        <attribute name="Implementation-Title" value="${Name}"/>
        <attribute name="Implementation-Version" value="${version}"/>
        <attribute name="Implementation-Vendor" value="The Apache Software Foundation (http://xmlgraphics.apache.org/)"/>
        <attribute name="Build-Id" value="${ts} (${user.name} [${os.name} ${os.version} ${os.arch}, Java ${java.runtime.version}])"/>
      </manifest>
      <metainf dir="${basedir}" includes="LICENSE,NOTICE"/>
    </jar>
  </target>

  <target name="package.NET" depends="jar-main" if="IKVM.present" description="Generates the .NET DLL using IKVM">
    <property name="commons-io" value="commons-io-1.1"/>
    <exec executable="${ikvmc}">
      <arg value="-reference:${ikvm.dir}/bin/IKVM.GNU.Classpath.dll"/>
      <arg value="-target:library"/>
      <arg value="-out:${build.dir}\${commons-io}.dll"/>
      <arg value="${lib.dir}\${commons-io}.jar"/>
    </exec>
    <exec executable="${ikvmc}">
      <arg value="-reference:${ikvm.dir}/bin/IKVM.GNU.Classpath.dll"/>
      <arg value="-reference:${build.dir}/${commons-io}.dll"/>
      <!--arg value="-reference:${ikvm.dir}/bin/IKVM.AWT.WinForms.dll"/-->
      <arg value="-target:library"/>
      <arg value="-out:${build.dir}\${name}-${version}.dll"/>
      <arg value="${build.dir}\${name}-${version}.jar"/>
    </exec>
  </target>

  <target name="uptodate-jar-sources" depends="init">
    <uptodate property="jar.sources.uptodate" targetfile="${build.dir}/${name}-${version}-sources.jar">
      <srcfiles dir="${src.java.dir}"/>
      <srcfiles dir="${src.java.version.dir}"/>
    </uptodate>
  </target>

  <target name="jar-sources" depends="uptodate-jar-sources" description="Generates a jar file with all the sources" unless="jar.sources.uptodate">
    <patternset id="java-only">
      <include name="**/*.java"/>
    </patternset>
    <jar jarfile="${build.dir}/${name}-${version}-sources.jar">
      <manifest>
        <attribute name="Build-Id" value="${ts} (${user.name} [${os.name} ${os.version} ${os.arch}, Java ${java.runtime.version}])"/>
      </manifest>
      <fileset dir="${src.java.dir}">
        <patternset refid="java-only"/>
      </fileset>
      <metainf dir="${basedir}" includes="LICENSE,NOTICE"/>
    </jar>
  </target>

  <target name="package" depends="jar-main, package.NET" description="Generates the jar files"/>

  <!-- ------------------------------------------------------------------- -->
  <!-- Testing                                                             -->
  <!-- ------------------------------------------------------------------- -->
  <target name="junit-compile" depends="package" if="junit.present">
    <mkdir dir="${build.dir}/test-classes"/>
    <mkdir dir="${build.dir}/test-reports"/>
    <javac destdir="${build.dir}/test-classes" fork="${javac.fork}"
           debug="${javac.debug}" deprecation="${javac.deprecation}"
           optimize="${javac.optimize}" source="${javac.source}"
           target="${javac.target}">
      <src path="${basedir}/test/java"/>
      <patternset refid="compile-pattern"/>
      <classpath>
        <path refid="libs-build-classpath"/>
        <fileset dir="${build.dir}">
          <include name="${name}-${version}.jar"/>
        </fileset>
      </classpath>
    </javac>
    <copy todir="${build.dir}/test-classes" includeEmptyDirs="false">
      <fileset dir="${basedir}/test/resources"/>
      <fileset dir="${basedir}/test/java">
        <exclude name="**/*.java"/>
        <exclude name="**/*.html"/>
      </fileset>
    </copy>
  </target>

  <target name="junit-basic" depends="junit-compile" description="Runs the standard JUnit test suite" if="junit.present">
    <echo message="Running basic functionality tests"/>
    <junit haltonerror="no" fork="${junit.fork}" errorproperty="test.junit.error" failureproperty="test.junit.failure">
      <sysproperty key="basedir" value="${basedir}"/>
      <sysproperty key="jawa.awt.headless" value="true"/>
      <jvmarg value="-enableassertions"/>
      <formatter type="brief" usefile="false"/>
      <formatter type="plain" usefile="true"/>
      <formatter type="xml" usefile="true"/>
      <classpath>
        <pathelement location="${build.dir}/test-classes"/>
        <path refid="libs-build-classpath"/>
        <fileset dir="build">
          <include name="${name}-${version}.jar"/>
        </fileset>
      </classpath>
      <batchtest fork="${junit.fork}" todir="${build.dir}/test-reports">
        <fileset dir="${basedir}/test/java">
          <include name="**/*Test*.java"/>
          <exclude name="**/*TestSuite.java"/>
          <exclude name="**/image/writer/internal/JPEGImageWriter*.java" if="internal-codecs.eff.disabled"/>
          <exclude name="**/image/writer/internal/TIFFImageWriter*.java" if="internal-codecs.eff.disabled"/>
        </fileset>
      </batchtest>
    </junit>
  </target>

  <target name="junit" depends="junit-basic" description="Runs all JUnit tests" if="junit.present">
    <fail>
      <condition>
        <or>
          <isset property="test.junit.error"/>
          <isset property="test.junit.failure"/>
        </or>
      </condition>
NOTE:
**************************************************************************
* One or more of the Junit tests had Failures or Errors or were skipped! *
*         Please check the output above for relevant messages.           *
**************************************************************************
    </fail>
    <echo>All Junit tests passed!</echo>
  </target>

  <!-- ------------------------------------------------------------------- -->
  <!-- Creates the API documentation                                       -->
  <!-- ------------------------------------------------------------------- -->
  <target name="javadocs" depends="init" description="Generates javadocs">
    <property name="javadoc.public"  value="false"/>
    <property name="javadoc.package" value="false"/>
    <property name="javadoc.private" value="false"/>
    <condition property="javadoc.level" value=" (level: private)">
      <equals arg1="${javadoc.private}" arg2="true"/>
    </condition>
    <condition property="javadoc.level" value=" (level: package)">
      <equals arg1="${javadoc.package}" arg2="true"/>
    </condition>
    <condition property="javadoc.level" value=" (level: public)">
      <equals arg1="${javadoc.public}" arg2="true"/>
    </condition>
    <property name="javadoc.level" value=""/>
    <echo message="Producing the javadoc files${javadoc.level}"/>
    <mkdir dir="${build.javadocs.dir}"/>

    <javadoc
        packagenames="${javadoc.packages}"
        destdir="${build.javadocs.dir}"
        author="true"
        version="true"
        windowtitle="${Name} ${version} API"
        doctitle="Apache XML Graphics Commons"
        bottom="Copyright ${year} The Apache Software Foundation. All Rights Reserved."
        overview="${src.dir}/java/org/apache/xmlgraphics/overview.html"
        use="true"
        failonerror="true"
        public="${javadoc.public}"
        package="${javadoc.package}"
        private="${javadoc.private}"
        source="${javac.source}">
      <header>${name} ${version}</header>
      <footer>${name} ${version}</footer>
      <classpath>
        <path refid="libs-build-classpath"/>
        <pathelement path="${java.class.path}"/>
      </classpath>
      <sourcepath>
        <pathelement path="${src.java.dir}"/>
      </sourcepath>
      <tag name="todo" scope="all" description="To do:"/>
      <group title="Images">
        <package name="org.apache.xmlgraphics.image"/>
        <package name="org.apache.xmlgraphics.image.*"/>
      </group>
      <group title="Java2D">
        <package name="org.apache.xmlgraphics.java2d"/>
        <package name="org.apache.xmlgraphics.java2d.*"/>
      </group>
      <group title="PDF, PostScript...">
        <package name="org.apache.xmlgraphics.ps"/>
        <package name="org.apache.xmlgraphics.ps.*"/>
        <package name="org.apache.xmlgraphics.pdf"/>
        <package name="org.apache.xmlgraphics.pdf.*"/>
      </group>
      <group title="Fonts">
        <package name="org.apache.xmlgraphics.fonts"/>
      </group>
      <group title="XMP Metadata">
        <package name="org.apache.xmlgraphics.xmp"/>
        <package name="org.apache.xmlgraphics.xmp.*"/>
      </group>
      <group title="Utility">
        <package name="org.apache.xmlgraphics.util"/>
        <package name="org.apache.xmlgraphics.util.*"/>
      </group>
    </javadoc>
  </target>

  <target name="jar-javadocs" depends="javadocs">
    <jar jarfile="${build.dir}/${name}-${version}-javadoc.jar">
      <manifest>
        <attribute name="Build-Id" value="${ts} (${user.name} [${os.name} ${os.version} ${os.arch}, Java ${java.runtime.version}])"/>
      </manifest>
      <fileset dir="${build.javadocs.dir}"/>
      <metainf dir="${basedir}" includes="LICENSE,NOTICE"/>
    </jar>
  </target>

  <!-- ------------------------------------------------------------------- -->
  <!-- Checkstyle                                                          -->
  <!-- ------------------------------------------------------------------- -->
  <property name="checkstyle.home.dir" value="${optional.lib.dir}"/>
  <property name="checkstyle.noframes.xslt" value="${checkstyle.home.dir}/contrib/checkstyle-noframes.xsl"/>

  <path id="checkstyle-path">
    <fileset dir="${checkstyle.home.dir}">
      <include name="checkstyle-all-*.jar"/>
      <include name="checkstyle-*.jar"/>
      <include name="antlr*.jar"/>
      <include name="commons-beanutils*.jar"/>
      <include name="commons-collections*.jar"/>
      <include name="commons-logging*.jar"/>
      <include name="jakarta-regexp*.jar"/>      
    </fileset>
  </path>

  <path id="checkstyle-runpath">
    <path refid="checkstyle-path"/>
  </path>

  <target name="checkstyle-avail" depends="init">
    <available property="checkstyle.available" classname="com.puppycrawl.tools.checkstyle.CheckStyleTask" classpathref="checkstyle-path"/>
    <available property="checkstyle.4.x" classname="com.puppycrawl.tools.checkstyle.checks.coding.ModifiedControlVariableCheck" classpathref="checkstyle-path"/>
    <available property="checkstyle.noframes.xslt.available" file="${checkstyle.noframes.xslt}"/>
    <condition property="checkstyle.message" value="Checkstyle 4.x Support PRESENT">
      <and>
        <equals arg1="${checkstyle.available}" arg2="true"/>
        <equals arg1="${checkstyle.4.x}" arg2="true"/>
      </and>
    </condition>
    <condition property="checkstyle.message" value="Checkstyle 3.x Support PRESENT">
      <equals arg1="${checkstyle.available}" arg2="true"/>
    </condition>
    <condition property="checkstyle.message" value="Checkstyle Support NOT Present">
      <not>
        <equals arg1="${checkstyle.available}" arg2="true"/>
      </not>
    </condition>
    <echo message="${checkstyle.message}"/>
    <condition property="checkstyle.config" value="checkstyle-4.0.xml">
      <equals arg1="${checkstyle.4.x}" arg2="true"/>
    </condition>
    <condition property="checkstyle.config" value="checkstyle-3.5-fop-head.xml">
      <not>
        <equals arg1="${checkstyle.4.x}" arg2="true"/>
      </not>
    </condition>
    <condition property="checkstyle.noframes.xslt.message" value="Checkstyle HTML style sheet support PRESENT">
      <equals arg1="${checkstyle.noframes.xslt.available}" arg2="true"/>
    </condition>
    <condition property="checkstyle.noframes.xslt.message" value="Checkstyle HTML style sheet support NOT Present">
      <not>
        <equals arg1="${checkstyle.noframes.xslt.available}" arg2="true"/>
      </not>
    </condition>
    <echo message="${checkstyle.noframes.xslt.message}"/>
  </target>

  <target name="checkstyle-check" depends="checkstyle-avail, init" if="checkstyle.available">
    
    <taskdef name="checkstyle" classname="com.puppycrawl.tools.checkstyle.CheckStyleTask" classpathref="checkstyle-runpath"/>
    <checkstyle config="${checkstyle.config}" failonviolation="false"
                classpathref="checkstyle-runpath">
      <fileset dir="${src.java.dir}" includes="**/*.java"/>
      <formatter type="plain" toFile="${build.dir}/checkstyle_report.txt"/>
      <formatter type="xml" toFile="${build.dir}/checkstyle_report.xml"/>
    </checkstyle>
  </target>

  <target name="checkstyle-html" depends="checkstyle-avail, checkstyle-check" if="checkstyle.noframes.xslt.available">
    <style in="${build.dir}/checkstyle_report.xml" out="${build.dir}/checkstyle_report.html" style="${checkstyle.noframes.xslt}"/>
  </target>

  <target name="checkstyle" depends="checkstyle-avail, checkstyle-check, checkstyle-html" description="Runs Checkstyle for a code quality report"/>

  <!-- ------------------------------------------------------------------- -->
  <!-- Creates the documentation                                           -->
  <!-- ------------------------------------------------------------------- -->
  <target name="docs" description="Generates documentation">
    <echo message="Building documentation with Forrest..."/>
    <!--
    <echo message="Make sure that you have installed Apache Forrest and"/>
    <echo message="the FORREST_HOME environment variable is set (see http://forrest.apache.org/)"/>
    <echo message="FORREST_HOME = ${forrest.home}"/>
    -->
    <echo message="Make sure you have a proper Forrest installation (see http://forrest.apache.org/)"/>

    <!--<antcall target="site"/>-->
    
    <condition property="forrest.call" value="forrest.bat" else="forrest">
      <os family="windows"/>
    </condition>
    <exec executable="${forrest.call}"/>
  </target>
  
  <!-- ------------------------------------------------------------------- -->
  <!-- Creates the distribution                                            -->
  <!-- ------------------------------------------------------------------- -->
  <target name="dist" depends="distclean,dist-src,dist-bin,maven-artifacts" description="Generates the distribution package"/>

  <!-- IMPORTANT: .NET binaries must not be included in the distribution. License policy! -->

  <target name="dist-bin" depends="all,javadocs,docs">
    <echo message="Building the binary distribution files (zip,tar)"/>
    <mkdir dir="${dist.bin.result.dir}"/>
    <copy todir="${dist.bin.result.dir}">
      <fileset refid="dist.bin"/>
      <fileset refid="dist.bin.lib"/>
    </copy>
    <copy todir="${dist.bin.result.dir}/docs">
      <fileset dir="${build.dir}/site"/>
    </copy>
    <copy todir="${dist.bin.result.dir}/javadocs">
      <fileset dir="${build.javadocs.dir}"/>
    </copy>
    <mkdir dir="${dist.bin.result.dir}/build"/>
    <copy todir="${dist.bin.result.dir}/build" file="build/${name}-${version}.jar"/>

    <!--property name="bin.suffix" value="bin-jdk${java.specification.version}"/-->
    <property name="bin.suffix" value="bin"/>
    <zip zipfile="${name}-${version}-${bin.suffix}.zip" basedir="${dist.bin.dir}" includes="**"/>
    <tar longfile="gnu"
         destfile="${name}-${version}-${bin.suffix}.tar">
      <tarfileset dir="${dist.bin.dir}">
        <include name="**"/>
      </tarfileset>
    </tar>
    <gzip zipfile="${name}-${version}-${bin.suffix}.tar.gz" src="${name}-${version}-${bin.suffix}.tar"/>
    <delete file="${name}-${version}-${bin.suffix}.tar"/>
  </target>

  <target name="dist-src" depends="all">
    <echo message="Building the source distribution files (zip,tar)"/>
    <mkdir dir="${dist.src.result.dir}"/>
    <copy todir="${dist.src.result.dir}">
      <fileset refid="dist.src"/>
    </copy>

    <zip zipfile="${name}-${version}-src.zip">
      <zipfileset dir="${dist.src.dir}" filemode="644" dirmode="755">
        <include name="**"/>
      </zipfileset>
    </zip>
    <tar longfile="gnu"
         destfile="${name}-${version}-src.tar" >
      <tarfileset dir="${dist.src.dir}" mode="644" dirmode="755">
        <include name="**"/>
      </tarfileset>
    </tar>
    <gzip zipfile="${name}-${version}-src.tar.gz" src="${name}-${version}-src.tar"/>
    <delete file="${name}-${version}-src.tar"/>
  </target>

  <target name="release-dist" depends="dist" description="Generates the distribution package and signs the release">
    <!--property name="bin.suffix" value="bin-jdk${java.specification.version}"/-->
    <property name="bin.suffix" value="bin"/>
    <input message="Passphrase for your default private key (attention: passphrase will be echoed in clear text on the display!)" addproperty="pwd"/>
    <antcall target="md5">
      <param name="sign.archive" value="${name}-${version}-src.zip"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${name}-${version}-src.zip"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>
    <antcall target="md5">
      <param name="sign.archive" value="${name}-${version}-src.tar.gz"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${name}-${version}-src.tar.gz"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>
    <antcall target="md5">
      <param name="sign.archive" value="${name}-${version}-${bin.suffix}.zip"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${name}-${version}-${bin.suffix}.zip"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>
    <antcall target="md5">
      <param name="sign.archive" value="${name}-${version}-${bin.suffix}.tar.gz"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${name}-${version}-${bin.suffix}.tar.gz"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>
  </target>

  <target name="md5">
    <property name="md5.exec" value="md5sum"/>
    <property name="md5.options" value=""/>
    <exec executable="${md5.exec}" output="${sign.archive}.md5">
      <arg line="${md5.options} ${sign.archive}"/>
    </exec>
  </target>

  <target name="sign-file">
    <property name="gpg.exec" value="gpg"/>
    <property name="gpg.options" value="--armor --detach-sign --force-v3-sigs --batch --verbose --passphrase-fd 0"/>
    <delete file="${sign.archive}.asc"/>
    <exec executable="${gpg.exec}" inputstring="${pwd}">
      <arg line="${gpg.options} ${sign.archive}"/>
    </exec>
  </target>
  
  <!-- ------------------------------------------------------------------- -->
  <!-- Maven artifacts                                                     -->
  <!-- ------------------------------------------------------------------- -->
  <target name="maven-artifacts" depends="jar-main, jar-sources, jar-javadocs" description="Builds a Maven artifact that can be uploaded to a Maven repository">
    <filter  token="version" value="${version}"/>
    <mkdir dir="${build.dir}/maven"/>
    <copy file="${basedir}/xmlgraphics-commons-pom-template.pom" tofile="${build.dir}/maven/pom.xml" filtering="true"/>
    <jar jarfile="${build.dir}/${name}-${version}-bundle.jar">
      <manifest>
        <attribute name="Build-Id" value="${ts} (${user.name} [${os.name} ${os.version} ${os.arch}, Java ${java.runtime.version}])"/>
      </manifest>
      <fileset dir="${build.dir}">
        <include name="${name}-${version}.jar"/>
        <include name="${name}-${version}-sources.jar"/>
        <include name="${name}-${version}-javadoc.jar"/>
      </fileset>
      <fileset dir="${build.dir}/maven"/>
      <metainf dir="${basedir}" includes="LICENSE,NOTICE"/>
    </jar>
  </target>
  
  <!-- ------------------------------------------------------------------- -->
  <!-- Clean targets                                                       -->
  <!-- ------------------------------------------------------------------- -->
  <target name="clean" description="Cleans the build directory">
    <delete dir="${build.dir}"/>
  </target>

  <target name="distclean" depends="clean" description="Cleans the distribution target directories">
    <delete dir="${dist.src.dir}"/>
    <delete dir="${dist.bin.dir}"/>
    <delete>
      <fileset dir="${basedir}" includes="${name}-*.tar.gz*"/>
      <fileset dir="${basedir}" includes="${name}-*.zip*"/>
    </delete>
  </target>
  
  <!-- ------------------------------------------------------------------- -->
  <!-- Default Target                                                      -->
  <!-- ------------------------------------------------------------------- -->

  <target name="all" depends="package, junit"/> <!-- "all" target for us Makefile converts ;-) -->

  <!-- ------------------------------------------------------------------- -->
  <!-- Special target for Gump                                             -->
  <!-- ------------------------------------------------------------------- -->

  <target name="gump" depends="all, javadocs"/>

</project>


File: build.properties

## This is a template for settings which are useful to be
## overridden in a developer specific property files.
## Copy this to build-local.properties, uncomment and change
## properties which should be overridden.
## The file buil-local.properties is not stored in the code
## repository and ignored for file adds.

## -------------------------------------------------------------------
## 1. Path settings

## Path to your IKVM installation. Set this if you want to compile
## XML Graphics Commons to a .NET DLL.
## NOTE: If you want to compile the .NET DLL you'll have to
## disable the internal codecs. See below.
#ikvm.dir=C:\\javalib\\ikvm-12-07-2004\\ikvm

## -------------------------------------------------------------------
## 2. Switches for common tasks

## Javac switches
# javac.debug = on
# javac.optimize = off
# javac.deprecation = on
# javac.source = 1.4
# javac.target = 1.4
# javac.fork = on

## JUnit task switches
# junit.fork = on

## Packages to produce javadoc.
# javadoc.packages = org.apache.xmlgraphics.*

## -------------------------------------------------------------------
## 3. Project specific properties

version = 1.4svn

## Allows you to switch off the compilation of the internal image
## codecs which depend on Sun-private classes. Setting this to true
## enabled compatibility with non-Sun Java implementations such as
## Kaffe, IKVM, GCC/GCJ or even Apache Harmony (i.e. system which 
## are based on GNU Classpath, for example).
# internal-codecs.disabled = false

 

不想说了 太全了

0
6
分享到:
评论
2 楼 chenhailong 2013-05-27  
sgq0085 写道
没注释 都不知道自己想要的在里面是哪段。。。


有target注释啊,知道任务即可
1 楼 sgq0085 2013-05-27  
没注释 都不知道自己想要的在里面是哪段。。。

相关推荐

    ant自动获取文件路径

    标题“ant自动获取文件路径”涉及的是Apache Ant这一构建自动化工具在处理文件路径时的技巧。Apache Ant是一个基于Java的构建工具,它被广泛用于Java项目中,类似于Unix的make,但依赖于XML来描述构建过程。在Ant中...

    Ant参考教程,Ant使用指南,Ant全攻略

    任务(task)是Ant中最基本的工作单元,例如`javac`用于编译Java源码,`copy`用于复制文件,`jar`用于创建JAR文件等。 "ant+初步.doc"可能会涵盖Ant的安装、环境配置以及第一个简单的构建文件的创建。一个基本的...

    一个常用的ant的build.xml

    Ant是基于XML的,它的核心在于`build.xml`文件,这个文件是项目的构建脚本,详细定义了构建过程中的各种任务和依赖关系。 标题“一个常用的ant的build.xml”暗示了我们讨论的是一个标准且常见的Ant构建配置文件。...

    ANT1.6+index文档全文件

    "ANT 1.6+index文档全文件"显然是一份包含Ant 1.6完整帮助文档和索引的资源集合,这对于理解和使用这个版本的Ant非常有帮助。 Ant 是基于XML的,它的核心概念是构建文件(build.xml),这是一个描述了构建过程的XML...

    Ant全攻略 教会你如何玩转Ant

    Ant全攻略:掌握Java构建工具Ant Ant是一种基于Java和XML的构建工具,由Apache软件基金会开发,用于自动化Java项目的构建过程,包括编译、测试、打包和部署等任务。它以其灵活性和可扩展性著称,通过XML格式的配置...

    Ant最全的中文ant教程

    ### Ant最全的中文ant教程知识点详解 #### 1. Ant是什么? Apache Ant是一个开源的构建工具,基于Java语言设计,旨在帮助开发者自动化构建过程,包括编译、测试、打包等任务,从而确保每次构建的一致性和高效性。...

    Ant培训全套学习教程

    二、Ant文件编写 Ant的核心在于其构建文件build.xml,这是一个XML格式的文件,定义了构建过程中的任务和目标。在build.xml中,我们可以定义属性(properties)、任务(tasks)、目标(targets)和路径(paths)。...

    ant打包编译全套资料

    Ant以其灵活性和可扩展性,通过XML格式的构建文件(build.xml)来定义任务,使得开发者能够自动化执行各种构建过程。 在Ant中,"标签"是构建文件的核心元素,它们定义了具体的任务和操作。例如,`&lt;project&gt;`标签是...

    Ant 1.9.1 学习笔记

    在配置Ant构建文件时,需要注意属性的命名规范,通常使用全小写字母,并且中间可以用下划线分隔。定义路径时,可以使用通配符和文件集(fileset),这对于管理文件和目录非常有帮助。在定义任务时,可以利用Ant提供...

    Ant_的最完整build.xml解释,Ant入门与进阶

    《Ant的最完整build.xml解释:Ant入门与进阶》 Ant,作为Java世界中的一个构建工具,由Apache软件基金会开发,是项目管理和自动化构建的重要工具。它通过XML定义的build.xml文件,来描述项目的构建过程,包括编译、...

    ant的配置文件build.xml

    总结,`build.xml`是Ant的核心,它通过XML描述了项目构建的全过程,包括源代码的编译、打包、测试和部署等步骤。理解并熟练掌握`build.xml`的编写,对于有效地管理和自动化Java项目的构建至关重要。通过合理配置,...

    ANT全套资料20100322

    "ant教程详解--javac,java,jar,war,delete,copy,mkdir....ziw"这则教程可能详细解析了ANT中与Java开发密切相关的任务,如编译源代码(javac)、运行Java程序(java)、创建JAR和WAR包、删除文件或目录(delete...

    Ant全攻略 学习Ant非常好的资料

    这个“Ant全攻略”很可能是一个详细的指南,旨在帮助用户深入理解和掌握Ant的使用,无论是在操作系统的层面上还是在构建Java项目的过程中。Ant在软件开发中扮演着重要角色,特别是对于Java开发者,它提供了自动化...

    ant 脚本从svn上取代码打包代码全,同时包括相关的jar包

    在给定的场景中,"ant 脚本从svn上取代码打包代码全,同时包括相关的jar包",这意味着我们需要了解如何用Ant配合Subversion(SVN)进行代码管理,并打包项目,同时处理依赖的jar文件。 首先,让我们来看看Ant脚本的...

    ant部署示例代码

    通过Ant,你可以轻松地为`HelloWorld`项目配置一个`build.xml`文件,完成从源代码编译到JAR打包的全过程。例如,`&lt;javac&gt;`任务会编译`src/main/java`目录下的源代码,`&lt;jar&gt;`任务则会将编译后的`HelloWorld.class`...

    jax生成client代码的Ant配置文件模板

    Ant通过XML文件定义任务,这些文件通常称为构建文件,其中包含了编译、打包、测试等步骤的描述。 在提供的Ant配置文件模板中,我们看到以下关键元素: 1. `&lt;project&gt;` 元素:这是Ant构建文件的根元素,定义了项目...

    Ant Design4.20.2版本离线版本文档

    总的来说,Ant Design 4.20.2离线文档提供了一个全方位的本地学习资源,涵盖了框架的所有组件、API、主题定制以及版本更新信息。开发者可以利用这些资源快速上手Ant Design,提高开发效率,并随时查看最新的功能和...

    ant 1.9.4 打包

    Ant是一个XML驱动的工具,其构建文件(build.xml)描述了项目构建的步骤和依赖关系。XML格式使得构建过程可读性强,易于理解和维护。Ant的核心概念包括任务(tasks)、属性(properties)和目标(targets)。任务是...

Global site tag (gtag.js) - Google Analytics