summaryrefslogtreecommitdiffstats
path: root/verigraph/build.xml
blob: dae4678c9a5d96f8c229a1fcf6b1987919b38d33 (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
<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright (c) 2017 Politecnico di Torino and others.

 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Apache License, Version 2.0
 which accompanies this distribution, and is available at
 http://www.apache.org/licenses/LICENSE-2.0
-->
<project name="Verigraph" default="generate-war" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
  <description>
      Script for Verigraph
  </description>

  <property name="root.location" location="." />
  <!-- The location to be used for class files -->
  <property name="src.dir" location="${root.location}/src" />
  <property name="gen.dir" location="${root.location}/gen-src" />
  <property name="war.dir" location="${root.location}/war" />
  <property name="grpc.dir" value="${src.dir}/it/polito/verigraph/grpc" />
  <property name="path.prefix" value="it/polito" />
  <property name="build.dir" location="${root.location}/build" />
  <property name="lib.dir" location="${root.location}/lib" />
  <property name="schemadir" location="${root.location}/schema" />
  <property name="schemafile" value="xml_components.xsd" />
  <property name="testfile" value="test.py" />
  <property name="target" value="1.8" />
  <property name="source" value="1.8" />
  <property name="gen-tomcat-service.dir" location="${root.location}/target" />
  <property name="resources.dir" location="${root.location}/webapp" />
  <property name="gen-war.dir" location="${root.location}/war" />
  <property name="jsonschemafolder.dir" location="${root.location}/jsonschema" />
  <property name="test.dir" location="${root.location}/tester" />
  <property name="iteration" value="1" />

  <path id="z3.classpath">
    <pathelement location="${lib.dir}/com.microsoft.z3.jar" />
  </path>


  <import file="tomcat-build.xml" />

  <target name="mvn-init" unless="compile.classpath" xmlns:artifact="urn:maven-artifact-ant">
    <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" classpath="lib/maven-ant-tasks-2.1.3.jar" />
    <condition property="maven.repo.local" value="${maven.repo.local}" else="${user.home}/.m2/repository">
      <isset property="maven.repo.local" />
    </condition>
    <echo>maven.repo.local=${maven.repo.local}</echo>
    <artifact:localRepository id="local.repository" path="${maven.repo.local}" />
    <artifact:pom file="pom.xml" id="maven.project" />
    <artifact:dependencies pathId="compile.classpath" filesetId="compile.fileset" useScope="compile">
      <pom refid="maven.project" />
      <localRepository refid="local.repository" />
    </artifact:dependencies>
    <artifact:dependencies pathId="test.classpath" filesetId="test.fileset" useScope="test">
      <pom refid="maven.project" />
      <localRepository refid="local.repository" />
    </artifact:dependencies>
    <artifact:dependencies pathId="runtime.classpath" filesetId="runtime.fileset" useScope="runtime">
      <pom refid="maven.project" />
      <localRepository refid="local.repository" />
    </artifact:dependencies>
    <artifact:dependencies pathId="build.classpath" filesetId="build.fileset">
      <pom refid="maven.project" />
      <localRepository refid="local.repository" />
    </artifact:dependencies>
  </target>


  <target name="init">
    <mkdir dir="${build.dir}" />
    <mkdir dir="${gen-tomcat-service.dir}" />
    <mkdir dir="${gen-war.dir}" />
    <mkdir dir="${gen.dir}" />
    <mkdir dir="${lib.dir}" />
    <get dest="${lib.dir}">
      <url url="https://github.com/Z3Prover/z3/releases/download/z3-4.5.0/z3-4.5.0-x86-win.zip" />
      <url url="http://central.maven.org/maven2/org/apache/maven/maven-ant-tasks/2.1.3/maven-ant-tasks-2.1.3.jar" />
    </get>
    <unzip src="${lib.dir}/z3-4.5.0-x86-win.zip" dest="${lib.dir}" overwrite="true">
      <patternset>
        <include name="**/**/com.microsoft.z3.jar" />
      </patternset>
      <mapper type="flatten" />
    </unzip>
    <delete file="${lib.dir}/z3-4.5.0-x86-win.zip" />
  </target>

	
  <target name="-chk-bindings">
    <uptodate property="generate-bindings.notRequired" targetfile="${src.dir}/.flagfile">
      <srcfiles dir="${schemadir}" includes="${schemafile}" />
    </uptodate>
  </target>

	
  <target name="generate-bindings" unless="generate-bindings.notRequired" depends="init" description="Create the value classes">
    <exec executable="xjc" failonerror="true">
      <arg line="-d ${gen.dir} -p it.polito.neo4j.jaxb ${schemadir}/${schemafile}" />
    </exec>
    <touch file="${src.dir}/.flagfile" />
  </target>

  	
  <!-- The target for compiling the Verigraph application -->
  <target name="build-service" depends="init, generate-bindings, mvn-init">
    <echo>Building verigraph (if needed)...</echo>
    <javac destdir="${build.dir}" debug="${debug}" debuglevel="${debuglevel}" source="${source}" target="${target}" includeantruntime="false">
      <classpath>
        <path id="compile.classpath" />
        <path id="z3.classpath" />
      </classpath>
      <src path="${src.dir}" />
      <src path="${gen.dir}" />
      <src path="${basedir}/gen-protobuf" />
      <include name="${path.prefix}/**/*.java" />
      <exclude name="main/proto/" />
    </javac>
    <echo>Done.</echo>
  </target>


  <macrodef name="war-exploded">
    <sequential>
      <copy toDir="${gen-tomcat-service.dir}" overwrite="true">
        <fileset dir="${resources.dir}" />
      </copy>
      <copy toDir="${gen-tomcat-service.dir}" overwrite="true">
        <fileset dir=".">
          <include name="server.properties" />
        </fileset>
      </copy>
      <!-- copy class files to WEB-INF/classes directory -->
      <copy toDir="${gen-tomcat-service.dir}/WEB-INF/classes" overwrite="true">
        <fileset dir="${build.dir}">
          <exclude name="verigraph.proto" />
          <exclude name="src/main/proto" />
        </fileset>
      </copy>
      <!-- copy jsonschema folder to WEB-INF/classes directory -->
      <copy toDir="${gen-tomcat-service.dir}/jsonschema" overwrite="true">
        <fileset dir="${jsonschemafolder.dir}" />
      </copy>
      <!-- copy lib files to WEB-INF/lib directory -->
      <copy toDir="${gen-tomcat-service.dir}/maven-lib" overwrite="true">
        <fileset refid="runtime.fileset">
        </fileset>
      </copy>
      <copy toDir="${gen-tomcat-service.dir}/WEB-INF/lib" overwrite="true" flatten="true">
        <fileset dir="${gen-tomcat-service.dir}/maven-lib">
          <include name="**/**/*.jar" />
        </fileset>
      </copy>
      <delete dir="${gen-tomcat-service.dir}/maven-lib" />

      <!-- Make the jar that includes only the classes needed for verigraph models -->
      <jar destfile="${gen-tomcat-service.dir}/WEB-INF/lib/mcnet.jar">
        <fileset dir="${build.dir}">
          <include name="it/polito/verigraph/mcnet/**/*.class" />
        </fileset>
      </jar>
      <!-- Copy the z3 library -->
      <copy toDir="${gen-tomcat-service.dir}/WEB-INF/lib" overwrite="true" flatten="true">
        <file name="${lib.dir}/com.microsoft.z3.jar" />
      </copy>
    </sequential>
  </macrodef>

	
  <target name="war-exploded" depends="build-service">
    <war-exploded />
  </target>

	
  <target name="generate-war" depends="war-exploded">
    <war destfile="${gen-war.dir}/${serviceName}.war" basedir="${gen-tomcat-service.dir}">
      <exclude name="protoc-dependencies/" />
      <exclude name="protoc-plugins/" />
      <exclude name="classes/" />
      <exclude />
    </war>
  </target>

	
  <!-- launch test python test -->
  <target name="run-test">
    <exec dir="${test.dir}" executable="python">
      <arg value="${testfile}" />
      <arg value="-iteration " />
      <arg value="${iteration}" />
    </exec>
  </target>



  <!-- target for cleaning -->
  <target name="clean">
    <delete dir="${build.dir}" />
    <delete dir="${gen.dir}" />
    <delete dir="${gen-tomcat-service.dir}" />
    <delete dir="${war.dir}" />
    <delete dir="${lib.dir}" />
  </target>


</project>