source: apps/sam/java/build.xml @ e68182a

Last change on this file since e68182a was e68182a, checked in by zzz <zzz@…>, 3 years ago

Build: Provide option to prevent Class-Path in manifests (ticket #2317)

  • Property mode set to 100644
File size: 6.1 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<project basedir="." default="all" name="sam">
3    <target name="all" depends="clean, build" />
4    <target name="build" depends="builddep, jar" />
5    <target name="builddep">
6        <!-- run from top level build.xml to get dependencies built -->
7    </target>
8    <condition property="depend.available">
9        <typefound name="depend" />
10    </condition>
11    <target name="depend" if="depend.available">
12        <depend
13            cache="../../../build"
14            srcdir="./src" 
15            destdir="./build/obj" >
16            <!-- Depend on classes instead of jars where available -->
17            <classpath>
18                <pathelement location="../../../core/java/build/obj" />
19                <pathelement location="../../../core/java/build/gnu-getopt.jar" />
20                <pathelement location="../../ministreaming/java/build/obj" />
21            </classpath>
22        </depend>
23    </target>
24
25    <!-- only used if not set by a higher build.xml -->
26    <property name="javac.compilerargs7" value="" />
27    <property name="javac.version" value="1.7" />
28    <property name="manifest.classpath.name" value="Class-Path" />
29
30    <!-- compile everything including client classes -->
31    <target name="compile" depends="depend">
32        <mkdir dir="./build" />
33        <mkdir dir="./build/obj" />
34        <javac 
35            srcdir="./src" 
36            debug="true" deprecation="on" source="${javac.version}" target="${javac.version}" 
37            includeAntRuntime="false"
38            destdir="./build/obj" 
39            classpath="../../../core/java/build/i2p.jar:../../../core/java/build/gnu-getopt.jar:../../ministreaming/java/build/mstreaming.jar" >
40            <compilerarg line="${javac.compilerargs7}" />
41        </javac>
42    </target>
43
44    <target name="compileTest" depends="compile">
45        <javac 
46            srcdir="./test" 
47            debug="true" deprecation="on" source="1.7" target="1.7" 
48            includeAntRuntime="false"
49            destdir="./build/obj" 
50            classpath="../../../core/java/build/i2p.jar:../../ministreaming/java/build/mstreaming.jar" >
51            <compilerarg line="${javac.compilerargs7}" />
52        </javac>
53    </target>
54
55    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
56        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
57            <arg value="list" />
58            <arg value="changed" />
59            <arg value="." />
60        </exec>
61        <!-- \n in an attribute value generates an invalid manifest -->
62        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
63            <arg value="-s" />
64            <arg value="[:space:]" />
65            <arg value="," />
66        </exec>
67    </target>
68
69    <!-- does not include client classes, moved to samclient.jar -->
70    <target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
71        <!-- set if unset -->
72        <property name="workspace.changes.tr" value="" />
73        <jar destfile="./build/sam.jar" basedir="./build/obj" includes="**/*.class" excludes="net/i2p/sam/client/*">
74            <manifest>
75                <attribute name="Main-Class" value="net.i2p.sam.SAMBridge" />
76                <attribute name="${manifest.classpath.name}" value="i2p.jar mstreaming.jar streaming.jar" />
77                <attribute name="Implementation-Version" value="${full.version}" />
78                <attribute name="Built-By" value="${build.built-by}" />
79                <attribute name="Build-Date" value="${build.timestamp}" />
80                <attribute name="Base-Revision" value="${workspace.version}" />
81                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
82                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
83                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
84            </manifest>
85        </jar>
86    </target>
87
88    <target name="clientjar" depends="compile, listChangedFiles" >
89        <!-- set if unset -->
90        <property name="workspace.changes.tr" value="" />
91        <jar destfile="./build/samclient.jar" basedir="./build/obj" includes="net/i2p/sam/client/*.class">
92            <manifest>
93                <attribute name="Main-Class" value="net.i2p.sam.SAMBridge" />
94                <attribute name="Class-Path" value="i2p.jar mstreaming.jar streaming.jar" />
95                <attribute name="Implementation-Version" value="${full.version}" />
96                <attribute name="Built-By" value="${build.built-by}" />
97                <attribute name="Build-Date" value="${build.timestamp}" />
98                <attribute name="Base-Revision" value="${workspace.version}" />
99                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
100            </manifest>
101        </jar>
102    </target>
103
104    <target name="jarUpToDate">
105        <uptodate property="jar.uptodate" targetfile="build/sam.jar" >
106            <srcfiles dir= "build/obj" includes="**/*.class" />
107        </uptodate>
108        <condition property="shouldListChanges" >
109            <and>
110                <not>
111                    <isset property="jar.uptodate" />
112                </not>
113                <isset property="mtn.available" />
114            </and>
115        </condition>
116    </target>
117
118    <target name="jarTest" depends="jar, compileTest">
119        <jar destfile="./build/sam.jar" basedir="./build/obj" includes="**/*Test*.class" update="true" />
120    </target>
121    <target name="javadoc">
122        <mkdir dir="./build" />
123        <mkdir dir="./build/javadoc" />
124        <javadoc 
125            sourcepath="./src:../../../core/java/src:../../ministreaming/java/src:../../streaming/java/src" destdir="./build/javadoc" 
126            packagenames="*" 
127            use="true" 
128            splitindex="true" 
129            windowtitle="SAMBridge" />
130    </target>
131    <target name="clean">
132        <delete dir="./build" />
133    </target>
134    <target name="cleandep" depends="clean">
135    </target>
136    <target name="distclean" depends="clean">
137    </target>
138</project>
Note: See TracBrowser for help on using the repository browser.