Build file to fetch optional libraries for Apache Ant : Big Project Ant Script « Ant « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JDK 6
25.JNDI LDAP
26.JPA
27.JSP
28.JSTL
29.Language Basics
30.Network Protocol
31.PDF RTF
32.Reflection
33.Regular Expressions
34.Scripting
35.Security
36.Servlets
37.Spring
38.Swing Components
39.Swing JFC
40.SWT JFace Eclipse
41.Threads
42.Tiny Application
43.Velocity
44.Web Services SOA
45.XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
SCJP
Java » Ant » Big Project Ant ScriptScreenshots 
Build file to fetch optional libraries for Apache Ant


<?xml version="1.0"?>

<!--
   Licensed to the Apache Software Foundation (ASFunder 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.
-->
<!--
    Build file to fetch optional libraries for Apache Ant
-->
<project name="fetch" default="all" basedir=".">

<description>
  This build file downloads JAR files that optional Ant tasks use,
  and installs them in a location that is accessible the next time Ant runs.

  You can choose three locations, by going -Ddest=LOCATION on the command line
  -Ddest=user     user lib dir  ${user.home}/.ant/lib
  -Ddest=system   ant lib dir   ${ant.home}/lib
  -Ddest=optional optional dir  $${basedir}/lib/optional  (for Ant developers)

  You may also need to set proxy settings. On Java1.5, Ant tries to get
  this from the OS, unless you use the -noproxy option.

  Proxies can be configured manually setting the JVM proxy values in the
  ANT_OPTS environment variable.

  For example, to set the proxy up in the tcsh shell, the command would be
  something like:

  For csh/tcsh:
    setenv ANT_OPTS "-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080"
  For bash:
    export ANT_OPTS="-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080"
  For Windows, set the environment variable in the appropriate dialog box
  and open a new console. or, by hand
    set ANT_OPTS = -Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080
</description>

  <!-- Give user a chance to override without editing this file
       (and without typing -D each time it compiles it-->
  <property file="${user.home}/.ant/ant.properties"/>
  <property name="lib.dir" location="lib" />
  <property name="optional.dir" location="${lib.dir}/optional" />
  <property name="userlib.dir" location="${user.home}/.ant/lib" />

  <!-- load in our properties table -->
  <property file="${lib.dir}/libraries.properties"/>

  <import file="get-m2.xml" />

  <target name="pick-dest">
    <fail>
      <condition>
        <not>
          <isset property="dest"/>
        </not>
      </condition>ERROR
Set -Ddest=LOCATION on the command line
  -Ddest=user     user lib dir  ${user.home}/.ant/lib
  -Ddest=system   ant lib dir   ${ant.home}/lib
  -Ddest=optional optional dir  $${basedir}/lib/optional  (for Ant developers)
    </fail>

    <condition property="dest.dir"
      value="${lib.dir}">
      <equals arg1="${dest}" arg2="system" />
    </condition>
    <condition property="dest.dir"
      value="${optional.dir}">
      <equals arg1="${dest}" arg2="optional" />
    </condition>
    <condition property="dest.dir"
      value="${userlib.dir}">
      <equals arg1="${dest}" arg2="user" />
    </condition>
    <fail unless="dest.dir">Unknown destination : ${dest}</fail>
    <echo>Downloading to ${dest.dir}</echo>
    <property name="m2.dest.dir" value="${dest.dir}" />
  </target>


  <target name="macros" depends="pick-dest,get-m2"
    xmlns:artifact="antlib:org.apache.maven.artifact.ant">

    <macrodef name="f2">
      <attribute name="project" />
      <attribute name="archive" default="@{project}"/>
      <sequential>
        <fail>
        Unknown archive @{archive-no property @{archive}.version defined.
          <condition>
            <not>
            <isset property="@{archive}.version"/>
            </not>
          </condition>
        </fail>
        <artifact:dependencies pathID="@{archive}.path">
          <dependency groupID="@{project}"
            artifactID="@{archive}"
            version="${@{archive}.version}"/>
        </artifact:dependencies>
        <!-- now we are left with the problem of getting the files
             into our directory -->
        <copy todir="${dest.dir}">
          <path refid="@{archive}.path" />
          <flattenmapper/>
        </copy>
      </sequential>
    </macrodef>
  </target>



  <!-- any init stuff -->
  <target name="init" depends="macros" />


  <target name="diag" depends="init">
    <echoproperties />
  </target>

  <target name="logging"
    description="load logging libraries"
    depends="init">
    <f2 project="log4j" />
    <f2 project="commons-logging" archive="commons-logging-api" />
  </target>

  <target name="junit"
    description="load junit libraries"
    depends="init">
    <f2 project="junit" />
  </target>

  <target name="xml"
    description="load full XML libraries (xalan, resolver)"
    depends="init">
    <f2 project="xalan" />
    <f2 project="xml-resolver" />
  </target>

  <!--
   This is not used as
   we like to get the more recent artifacts than are in the repo at the time of writing (2006-12-21)
   -->

  <target name="xerces"
      description="load an updated version of Xerces"
      depends="init">
    <f2 project="xerces" archive="xercesImpl"/>
    <f2 project="xerces" archive="xml-apis" />
  </target>

  <target name="networking"
    description="load networking libraries (commons-net; jsch)"
    depends="init">
    <f2 project="commons-net" />
    <f2 project="com.jcraft" archive="jsch"/>
  </target>

  <target name="regexp"
    description="load regexp libraries"
    depends="init">
    <f2 project="regexp" />
    <f2 project="oro" />
  </target>

  <target name="antlr"
    description="load antlr libraries"
    depends="init">
    <f2 project="antlr" />
  </target>

  <target name="bcel"
    description="load bcel libraries"
    depends="init">
    <f2 project="bcel" />
  </target>

  <target name="jdepend"
    description="load jdepend libraries"
    depends="init">
    <f2 project="jdepend" />
  </target>

  <target name="bsf"
    description="load bsf libraries"
    depends="init">
    <f2 project="bsf" />
  </target>

  <target name="jruby"
          description="load jruby"
          depends="bsf">
    <f2 project="org.jruby" archive="jruby"/>
  </target>

  <target name="beanshell"
          description="load beanshell support"
          depends="bsf">
    <f2 project="org.beanshell" archive="bsh"/>
    <f2 project="org.beanshell" archive="bsh-core"/>
  </target>

  <target name="jython"
          description="load jython"
          depends="bsf">
    <f2 project="jython" archive="jython"/>
  </target>

  <target name="rhino"
          description="load rhino"
          depends="bsf">
    <f2 project="rhino" archive="js"/>
  </target>

  <target name="script"
          description="load script languages (except jython)"
          depends="bsf,jruby,beanshell,rhino"/>

  <target name="debugging"
    description="internal ant debugging"
    depends="init">
    <f2 project="which" />
  </target>

  <target name="javamail" depends="init"
          description="load javamail">
    <f2 project="javax.mail" archive="mail"/>
  </target>

  <target name="jspc" depends="init" description="loads Jasper">
    <f2 project="tomcat" archive="jasper-compiler"/>
    <f2 project="tomcat" archive="jasper-runtime"/>
    <f2 project="javax.servlet" archive="servlet-api"/>
  </target>

  <target name="all"
    description="load all the libraries (except jython)"
    depends="logging,junit,xml,networking,regexp,antlr,bcel,jdepend,bsf,debugging,script,javamail,jspc" />

</project>

 
Related examples in the same category
1.Ant script for xmlgraphics-commons
2.nutch ant script
3.rhino ant build script
4.apache solr ant script
5.Tomcat ant build script
6.OFBiz ant build script
7.Apache Lenya Build System
8.Apache pivot ant build script
9.XmlSchema ant script
10.xml security
11.velocity tools ant script
12.weka build script
13.xml bean ant script
14.xml graphics common ant script
15.uPortal ant script
16.SmartGWT ant script
17.Build file to fetch maven2 tasks; extracted from (Ant's) fetch.xml
18.Ant build script
19.Build script for apache-cassandra-0.5.1-src
20.apache-log4j-site\build.xml
21.apache-roller-src-4.0.1
22.Build script from apache dbutils
23.Fop build script
24.Google guice ant script
25.GWT ant script
26.hadoop ant build script
27.jakarta jmeter ant script
28.jakarta oro ant script
29.jakarta regexp ant script
30.jedit build script
31.jibx ant build script
32.lucene ant build script
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.