HSAdmin Backend Domains, E-Mail, Datenbanken
Michael Hierweck
2014-08-28 d61f6bf9e5411e6cd72529e9dba0912bbdd3a4ee
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?xml version="1.0" encoding="UTF-8"?>
<project name="hsarback" default="war">
 
    <property name="build.home" value="${basedir}/build" />
    <property name="lib.home" value="${basedir}/lib" />
    <property name="conf.home" value="${basedir}/conf" />
    <property name="src.home" value="${basedir}/src" />
    <property name="test.home" value="${basedir}/test" />
    <property name="dist.home" value="${basedir}/dist" />
 
    <property file="${user.home}/.hsar.ant.properties" />
    
    <!-- Optionen  für Java-Compiler-->
    <property name="compile.debug" value="true" />
    <property name="compile.deprecation" value="true" />
    <property name="compile.optimize" value="true" />
 
    <path id="compile.classpath">
        <fileset dir="lib">
            <include name="*.jar" />
        </fileset>
    </path>
 
    <path id="enhance.classpath">
        <fileset dir="lib">
            <include name="*.jar" />
        </fileset>
        <dirset dir="conf"/>
        <dirset dir="${build.home}"/>
    </path>
 
    <target name="clean" description="aufräumen">
        <delete dir="${build.home}" />
        <delete dir="${dist.home}" />
        <delete file="webapp/WEB-INF/web.xml" />
        <delete file="webapp/META-INF/context.xml" />
    </target>
 
    <target name="deploy" depends="war">
        <delete dir="${hsar.deploy.dir}/hsar" />
        <copy file="build/hsar.war" todir="${hsar.deploy.dir}" />
        <!-- <sleep minutes="2"/> -->
    </target>
 
    <target name="jar" depends="enhance">
        <jar destfile="build/hsar.jar">
            <fileset dir="build/cls"/>
            <fileset dir="src">
                <include name="**/*.properties"/>
                <include name="**/*.vm"/>
            </fileset>
            <fileset dir="conf">
                <include name="**/*.xml"/>
            </fileset>
        </jar>
    </target>
    
    <target name="war" depends="enhance">
        <copy file="conf/WEB-INF/${target}-web.xml" tofile="webapp/WEB-INF/web.xml">
            <filterset>
                <filter token="LOGIN_HOST" value="${cas.domain.name}"/>
                <filter token="LOGIN_PORT" value="${cas.https.port}"/>
                <filter token="CONFIG_HOST" value="${hsar.domain.name}"/>
                <filter token="CONFIG_PORT" value="${hsar.https.port}"/>
            </filterset>
        </copy>
        <copy file="conf/META-INF/${target}-context.xml" tofile="webapp/META-INF/context.xml">
        </copy>
        <war destfile="build/hsar.war" basedir="webapp" needxmlfile="false">
            <lib dir="lib">
                <include name="**/*.jar"/>
                <exclude name="**/servlet*.jar"/>
                <exclude name="**/geronimo-jms*.jar"/>
                <exclude name="**/geronimo-j2ee-management*.jar"/>
                <exclude name="**/activemq*.jar"/>
            </lib>
            <classes dir="build/cls" />
            <classes dir="src">
                <include name="**/*.properties"/>
                <include name="**/*.vm"/>
            </classes>
            <classes dir="conf">
                <include name="**/*.xml"/>
            </classes>
        </war>
    </target>
 
    <target name="compile" description="compilieren">
        <mkdir dir="${build.home}" />
        <mkdir dir="${build.home}/cls" />
        <javac srcdir="${src.home}" destdir="${build.home}/cls" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}" encoding="UTF8" includeantruntime="false">
            <classpath refid="compile.classpath" />
        </javac>
    </target>
 
    <target name="compile-test" description="tests compilieren" depends="compile">
        <mkdir dir="${build.home}" />
        <mkdir dir="${build.home}/test" />
        <javac srcdir="${test.home}" destdir="${build.home}/test" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}" encoding="UTF8" includeantruntime="false">
            <classpath refid="compile.classpath" />
            <classpath>
                <pathelement path="${compile.classpath}"/>
                <pathelement location="${build.home}/cls"/>
                <pathelement path="/usr/share/java/junit4.jar"/>
            </classpath>
        </javac>
    </target>
 
    <target name="enhance" description="openjpa enhancer" depends="compile">
        <taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask">
            <classpath refid="enhance.classpath"/>
        </taskdef>
        <taskdef name="mappingtool" classname="org.apache.openjpa.jdbc.ant.MappingToolTask">
            <classpath refid="enhance.classpath"/>
        </taskdef>
        <openjpac>
            <classpath refid="enhance.classpath"/>
        </openjpac>
        <echo message="Enhancing complete."/>
    </target>
 
    <target name="init-db" description="init empty database">
        <sql
            classpath="/usr/share/java/postgresql-jdbc3.jar"
            driver="org.postgresql.Driver" 
            url="jdbc:postgresql://${database.host}:5432/${database.name}"
            userid="${database.user}" password="${database.password}" 
            src="database/schema.sql" />        
        <sql
            classpath="/usr/share/java/postgresql-jdbc3.jar"
            driver="org.postgresql.Driver" 
            url="jdbc:postgresql://${database.host}:5432/${database.name}"
            userid="${database.user}" password="${database.password}" 
            src="database/data.sql" />        
    </target>
    
    <target name="drop-db" description="make empty database">
        <sql
            classpath="/usr/share/java/postgresql-jdbc3.jar"
            driver="org.postgresql.Driver" 
            url="jdbc:postgresql://${database.host}:5432/${database.name}"
            userid="${database.user}" password="${database.password}" 
            src="database/dropschema.sql" />
    </target>
    
    <target name="update-db" description="upgrade existing database">
        <sql
            classpath="/usr/share/java/postgresql-jdbc3.jar"
            driver="org.postgresql.Driver" 
            url="jdbc:postgresql://${database.host}:5432/${database.name}"
            userid="${database.user}" password="${database.password}" 
            src="database/database_update.sql" />
    </target>
    
    <target name="remote-test" description="inspection of xmlrpc-api" depends="compile-test">
        <mkdir dir="${build.home}/junit" />
        <junit printsummary="yes" fork="yes">
            <classpath>
                <fileset dir="lib">
                    <include name="*.jar" />
                </fileset>
                <pathelement location="${build.home}/cls"/>
                <pathelement location="${build.home}/test"/>
                <pathelement path="/usr/share/java/junit4.jar"/>
            </classpath>
            <formatter type="xml"/>
            <test name="de.hsadmin.remote.ContinuousIntegrationTest" todir="${build.home}/junit" />
        </junit>
    </target>
    
</project>