summaryrefslogtreecommitdiff
path: root/Tools/Java/Source/SurfaceArea/build.xml
blob: 6dd98cd9d104f13c6de2c1170e5adce40b70dd0c (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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution.  The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-->
<project default="all" basedir="." name="SurfaceArea">
  <taskdef resource="net/sf/antcontrib/antlib.xml"/>
  <property environment="env" />
  <property name="WORKSPACE" value="${env.WORKSPACE}"/>
  <taskdef resource="net/sf/antcontrib/antlib.xml"/>

  <path id="classpath">
    <fileset dir="${WORKSPACE}/Tools/Jars">
      <include name="*.jar"/>
    </fileset>
    <fileset dir="${env.XMLBEANS_HOME}/lib">
      <include name="*.jar"/>
    </fileset>
    <pathelement path = "${env.CLASSPATH}"/>
  </path>

  <target name="init">
    <uptodate targetfile="${WORKSPACE}/Tools/Jars/SurfaceArea.jar" property="jar.newer">
      <srcfiles dir="${WORKSPACE}/Tools/XMLSchema" includes="*.xsd"/>
    </uptodate>
  </target>

  <!--
    Generate SurfaceArea.jar and source code 
    -->
  <target name="SurfaceArea.jar" depends="init">
    <java classname="org.apache.xmlbeans.impl.tool.SchemaCompiler">
      <classpath refid="classpath"/>
      <arg value="-javasource"/>
      <arg value="1.5"/>
      <arg value="-dl"/>
      <arg value="-out"/>
      <arg value="${WORKSPACE}/Tools/Jars/SurfaceArea.jar"/>
      <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsd"/>
      <arg value="${WORKSPACE}/Tools/XMLSchema/FarManifest.xsd"/>
      <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsdconfig"/>
    </java>
  </target>
  
  <target name="SurfaceArea.java" depends="init">
    <antcall target="SurfaceArea.java.clean"/>
    <java classname="org.apache.xmlbeans.impl.tool.SchemaCompiler">
      <classpath refid="classpath"/>
      <arg value="-javasource"/>
      <arg value="1.5"/>
      <arg value="-dl"/>
      <arg value="-srconly"/>
      <arg value="-src"/>
      <arg value="${WORKSPACE}/Tools/Java/Source/SurfaceArea"/>
      <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsd"/>
      <arg value="${WORKSPACE}/Tools/XMLSchema/FarManifest.xsd"/>
      <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsdconfig"/>
    </java>
  </target>
  
  <target name="SurfaceArea" depends="init" unless="jar.newer">
    <antcall target="SurfaceArea.java.clean"/>
    <java classname="org.apache.xmlbeans.impl.tool.SchemaCompiler" fork="true">
      <classpath refid="classpath"/>
      <arg value="-javasource"/>
      <arg value="1.5"/>
      <arg value="-dl"/>
      <arg value="-src"/>
      <arg value="${WORKSPACE}/Tools/Java/Source/SurfaceArea"/>
      <arg value="-out"/>
      <arg value="${WORKSPACE}/Tools/Jars/SurfaceArea.jar"/>
      <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsd"/>
      <arg value="${WORKSPACE}/Tools/XMLSchema/FarManifest.xsd"/>
      <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsdconfig"/>
    </java>
  </target>
  
  <target name="SurfaceArea.java.clean">
    <delete includeemptydirs="true" failonerror="false">
      <fileset dir="${WORKSPACE}/Tools/Java/Source/SurfaceArea" includes="org"/>
    </delete>
  </target>

  <target name="SurfaceArea.jar.clean">
  </target>
  
  <!--
    Surface Area Description file validation
    -->
  <target name="validate">
    <echo message="Validating ... ${SURFACE_AREA_FILE}"/>
    <!--
      java -classpath %cp% org.apache.xmlbeans.impl.tool.InstanceValidator %*
    -->
    <copy file="${SURFACE_AREA_FILE}" tofile="${SURFACE_AREA_FILE}.xml"/>
    <java classname="org.apache.xmlbeans.impl.tool.InstanceValidator" 
          outputproperty="XMLBEANS_OUTPUT"
          errorproperty="XMLBEANS_ERROR">
          
      <classpath refid="classpath"/>
      <arg value="-dl"/>
      <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsd"/>
      <arg value="${SURFACE_AREA_FILE}.xml"/>
      
    </java>   

    <delete file="${SURFACE_AREA_FILE}.xml" quiet="true"/>
    <if>
      <or>
        <contains string="${XMLBEANS_OUTPUT}" substring="NOT valid"/>
        <contains string="${XMLBEANS_OUTPUT}" substring=": error:"/>
        <contains string="${XMLBEANS_ERROR}" substring="XmlException"/>
        <contains string="${XMLBEANS_ERROR}" substring=": error:"/>
      </or>
      <then>
        <echo message="Result ... ${XMLBEANS_OUTPUT}&#x0d;&#x0a;${XMLBEANS_ERROR}"/>
        <fail message="${SURFACE_AREA_FILE} is invalid!"/>
      </then>
      <else>
        <echo message="Result ... ${SURFACE_AREA_FILE} is valid"/>
      </else>
    </if>
  </target>
  
  <!--
    beautify xml file
    -->
  <target name="pretty">
    <echo message="Beautify ... ${SURFACE_AREA_FILE}"/>
    <!--
      java -classpath %cp% org.apache.xmlbeans.impl.tool.PrettyPrinter %*
    -->
    <java classname="org.apache.xmlbeans.impl.tool.PrettyPrinter" 
      errorproperty="XMLBEANS_OUTPUT"
      output="${SURFACE_AREA_FILE}">
          
      <classpath refid="classpath"/>
      <arg value="-indent"/>
      <arg value="2"/>
      <arg value="${SURFACE_AREA_FILE}"/>
      
    </java>

    <if>
      <equals arg1="${XMLBEANS_OUTPUT}" arg2=""/>
      <then>
        <echo message="Result ... DONE"/>
      </then>
      <else>
        <echo message="Result ... ${XMLBEANS_OUTPUT}"/>
      </else>
    </if>
  </target>

  <!--
    generate Surface Area template file from schema
    -->
  <target name="generate">
    <echo message="Generating ... ${SURFACE_AREA_FILE}"/>
    <!--
      java -classpath %cp% org.apache.xmlbeans.impl.xsd2inst.SchemaInstanceGenerator %*
    -->
    <java classname="org.apache.xmlbeans.impl.xsd2inst.SchemaInstanceGenerator" fork="true"
      errorproperty="XMLBEANS_OUTPUT" 
      output="${SURFACE_AREA_FILE}.tmp">
          
      <classpath refid="classpath"/>
      <arg value="-dl"/>
      <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsd"/>
      <arg value="-name"/>
      <arg value="${SURFACE_AREA_ELEMENT}"/>
      
    </java>

    <concat destfile="${SURFACE_AREA_FILE}">
      <header trimleading="yes" filtering="no"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>]]>
      </header>
      <fileset file="${SURFACE_AREA_FILE}.tmp"/>
    </concat>
    
    <delete file="${SURFACE_AREA_FILE}.tmp" deleteonexit="true" quiet="true"/>
    <if>
      <equals arg1="${XMLBEANS_OUTPUT}" arg2=""/>
      <then>
        <echo message="Result ... DONE"/>
      </then>
      <else>
        <echo message="Result ... ${XMLBEANS_OUTPUT}"/>
      </else>
    </if>
  </target>

  <target name="clean" depends="SurfaceArea.java.clean">
  </target>

  <target name="cleanall" depends="SurfaceArea.jar.clean">
    <echo message="Removing Class Files and the Java Archive: SurfaceArea.jar"/>
    <delete file="${WORKSPACE}/Tools/Jars/SurfaceArea.jar"/>
    <if>
      <available file="${WORKSPACE}/Tools/Jars/SurfaceArea.jar"/>
      <then>
        <echo message="You must manually remove the file: ${WORKSPACE}/Tools/Jars/SurfaceArea.jar"/>
        <echo message="Java has already loaded the file, and cannot remove it within ANT!"/>
      </then>
    </if>
  </target>

  <target name="all" depends="SurfaceArea">
  </target>

  <target name="install" depends="SurfaceArea.jar">
  </target>

</project>