aboutsummaryrefslogtreecommitdiff
path: root/common.xml
blob: 6c62660fb8afe4e7a78e22559db992c80ba48883 (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
<?xml version="1.0"?>

<project name="common">

  <property file="build.properties"/>

  <!-- can be overridden at the command line with -Dversion=
       or in IDEA, in the ant properties dialog -->
  <property name="version" value="snapshot"/>
  <property name="bundle.version" value="0.0.0.snapshot"/>
  <tstamp prefix="datestamp">
    <format property="dateAndTime" pattern="yyyy-MM-dd H:mm"/>
  </tstamp>

  <target name="compile" description="Compile Java source.">
    <mkdir dir="${build.dir}/classes"/>
    <javac srcdir="${src.dir}"
         debug="on"
         destdir="${build.dir}/classes">
      <classpath refid="compile.classpath"/>
    </javac>
    <copy toDir="${build.dir}/classes">
      <fileset dir="${src.dir}" excludes="**/*.java"/>
    </copy>
  </target>

  <target name="manifest"
      description="Build a jar manifest so Guice can be used as an OSGi bundle">
    <dirname property="guice_home" file="${ant.file.common}" />
    <taskdef name="osgiBundleInfo" classname="org.knopflerfish.ant.taskdefs.bundle.BundleInfoTask"
        classpath="${guice_home}/lib/build/OSGiBundleInfo.jar"/>

    <!-- extracts the packagelist for OSGi -->
    <osgiBundleInfo exports="exports" imports="imports" defaultimports="com.google.inject"
        stdimports="java.,net.sf.cglib,org.objectweb.asm,com.google.inject.InjectorImpl,com.google.inject.BindCommandProcessor">
      <fileset dir="${basedir}">
        <include name="src/**/*.java"/>
        <!--<exclude name="src/com/google/inject/internal/**/*.java"/>-->
      </fileset>
    </osgiBundleInfo>

    <mkdir dir="${build.dir}/META-INF"/>
    <manifest file="${build.dir}/META-INF/MANIFEST.MF">
      <attribute name="Manifest-Version" value="1.0"/>
      <attribute name="Built-By" value="${user.name}"/>
      <attribute name="Built-At" value="${datestamp.dateAndTime}"/>

      <attribute name="Bundle-License" value="http://www.apache.org/licenses/LICENSE-2.0"/>
      <attribute name="Import-Package" value="${imports}"/>
      <attribute name="Export-Package" value="${exports}"/>
      <attribute name="Bundle-Version" value="${bundle.version}"/>
      <attribute name="Bundle-Copyright" value="Google Inc. (C) 2006"/>
      <attribute name="Bundle-Name" value="${ant.project.name}"/>
      <attribute name="Bundle-Description" value="Guice is a lightweight dependency injection framework for Java 5 and above"/>
      <attribute name="Bundle-DocURL" value="http://code.google.com/p/google-guice/"/>
      <attribute name="Bundle-Vendor" value="Google Inc."/>
      <attribute name="Bundle-ManifestVersion" value="2"/>
      <attribute name="Bundle-SymbolicName" value="${ant.project.name}"/>
    </manifest>
  </target>

  <target name="test.compile"
      depends="compile"
      description="Compile test source.">
    <mkdir dir="${build.dir}/test"/>
    <javac srcdir="${test.dir}"
         debug="on"
         destdir="${build.dir}/test">
      <classpath path="${build.dir}/classes"/>
      <classpath refid="compile.classpath"/>
    </javac>
    <copy toDir="${build.dir}/test">
      <fileset dir="${test.dir}" excludes="**/*.java"/>
    </copy>
  </target>

  <target name="test"
      depends="test.compile"
      description="Execute JUnit tests.">
    <java fork="true"
        classname="junit.textui.TestRunner"
        failonerror="true"
        taskname="junit">
      <classpath>
        <pathelement location="${build.dir}/test"/>
        <pathelement location="${build.dir}/classes"/>
        <path refid="compile.classpath"/>
      </classpath>
      <arg value="${test.class}"/>
    </java>
  </target>

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

  <target name="source.jar"
      description="Create a .jar file with sources">
    <mkdir dir="${build.dir}"/>
    <zip destfile="${build.dir}/${ant.project.name}-${version}-src.jar">
      <fileset dir="src"/>
    </zip>
  </target>

  <target name="distjars"
      depends="source.jar, jar"
      description="Build jar files"/>

</project>