summaryrefslogtreecommitdiffstats
path: root/guava/build.xml
blob: e6a73cbf937a6ac0b2c0ee5c9b753ecab36dea06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?xml version="1.0"?>

<!--

  You must:
   * have JAVA_HOME set to a recent JDK 6 installation
   * have JAVA5_HOME set to a recent JDK 1.5.0 installation, 
     or specify this with -Djava5home=
   * have unzipped $JAVA_HOME/src.zip to $JAVA_HOME/src,
     or specify this with -Djavasrc=
   * specify -Drelease=r09 (for example) on the ant command line

-->

<project name="guava" default="compile">

  <property environment="env"/>

  <!-- these properties can be overridden at the command line with
       -Dname=value, or in IDEA in the ant properties dialog -->

  <property name="release" value="unknown"/>
  <property name="java5home" value="${env.JAVA5_HOME}" />
  <property name="javasrc" value="${env.JAVA_HOME}/src" />

  <target name="compile" description="Compile Java source.">
    <mkdir dir="build/classes"/>

    <property name="java5bootclasspath" value="${java5home}/jre/lib/rt.jar"/>

    <available file="${java5bootclasspath}" property="isJava5HomeSetRight"/>
    <fail unless="isJava5HomeSetRight" 
          message="JAVA5_HOME must be set to a valid JDK 1.5 installation, containing a jre/lib/rt.jar file"/>

    <javac srcdir="src"
         debug="on"
         destdir="build/classes"
         source="1.5"
         target="1.5"
         bootclasspath="${java5bootclasspath}"
         extdirs="">
      <compilerarg value="-Xlint:all"/>
      <classpath>
        <pathelement location="lib/jsr305.jar"/>
      </classpath>
    </javac>
  </target>

  <target name="jar" depends="compile" description="Build jar.">
    <mkdir dir="build/dist/guava-${release}"/>
    <jar jarfile="build/dist/guava-${release}/guava-${release}.jar">
      <fileset dir="build/classes"/>
    </jar>
  </target>

  <target name="javadoc" description="Generate Javadocs">
    <delete dir="build/javadoc"/>
    <mkdir dir="build/javadoc"/>

    <javadoc packagenames="com.google.common.*"
         destdir="build/javadoc"
         encoding="UTF-8"
         docencoding="UTF-8"
         charset="UTF-8"
         use="true"
         author="true"
         protected="true"
         linksource="true"
         windowtitle="Guava: Google Core Libraries for Java - ${release}">
      <sourcepath>
        <pathelement location="src"/>
        <pathelement location="${javasrc}"/>
      </sourcepath>
      <!-- workaround for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6442982 -->
      <classpath>
        <pathelement location="lib/jsr305.jar"/>
      </classpath>
      <link href="http://jsr-305.googlecode.com/svn/trunk/javadoc"/>
      <link href="http://java.sun.com/javase/6/docs/api"/>
    </javadoc>

    <!-- remove dumb comments inserted by javadoc so that we only see svn diffs
         when things actually change. -->
    <replaceregexp 
        match="^.*(META NAME=.date|generated by javadoc ).*$\n"
        replace=""
        flags="gmi">
      <fileset dir="build/javadoc" includes="**/*.html"/>
    </replaceregexp>
  </target>

  <target name="jdiff" description="Generate JDiff report">
    <mkdir dir="build/javadoc/jdiff"/>
    <javadoc doclet="jdiff.JDiff"
         docletpath="lib/jdiff.jar"
         additionalparam="-apiname 'Guava ${release}' -apidir build/javadoc/jdiff"
         packagenames="com.google.common.*"
         destdir="build/javadoc/jdiff">
      <sourcepath>
        <pathelement location="src"/>
      </sourcepath>
      <classpath>
        <pathelement location="lib/jsr305.jar"/>
      </classpath>
    </javadoc>

    <!-- remove dumb comments inserted by jdiff so that we only see svn diffs when things actually change. -->
    <replaceregexp match="^.!--\s+(on|Command line arguments) .* -->$\n" 
        replace="" flags="gm" file="build/javadoc/jdiff/Guava_${release}.xml"/>
  </target>

  <target name="zipsrc" description="Build zip of source.">
    <mkdir dir="build/dist/guava-${release}"/>
    <jar jarfile="build/dist/guava-${release}/guava-src-${release}.zip">
      <fileset dir="src"/>
    </jar>
  </target>

  <target name="dist" depends="jar, zipsrc, javadoc"
       description="Build entire distribution.">
    <copy toDir="build/dist/guava-${release}" file="COPYING"/>
    <copy toDir="build/dist/guava-${release}" file="README"/>
    <copy toDir="build/dist/guava-${release}">
      <fileset dir="build" includes="javadoc/**/*" excludes="javadoc/jdiff/**/*"/>
    </copy>

    <zip destfile="build/guava-${release}.zip"
      basedir="build/dist"/>
  </target>

  <target name="clean"
      description="Remove generated files.">
    <delete dir="build"/>
  </target>

</project>