1 <?xml version="1.0" encoding="UTF-8"?>
3 Copyright (c) 2017 Politecnico di Torino and others.
5 All rights reserved. This program and the accompanying materials
6 are made available under the terms of the Apache License, Version 2.0
7 which accompanies this distribution, and is available at
8 http://www.apache.org/licenses/LICENSE-2.0
10 <project name="Verigraph" default="generate-war" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
15 <property name="root.location" location="." />
16 <!-- The location to be used for class files -->
17 <property name="src.dir" location="${root.location}/src" />
18 <property name="gen.dir" location="${root.location}/gen-src" />
19 <property name="war.dir" location="${root.location}/war" />
20 <property name="grpc.dir" value="${src.dir}/it/polito/verigraph/grpc" />
21 <property name="path.prefix" value="it/polito" />
22 <property name="build.dir" location="${root.location}/build" />
23 <property name="lib.dir" location="${root.location}/lib" />
24 <property name="schemadir" location="${root.location}/schema" />
25 <property name="schemafile" value="xml_components.xsd" />
26 <property name="testfile" value="test.py" />
27 <property name="target" value="1.8" />
28 <property name="source" value="1.8" />
29 <property name="gen-tomcat-service.dir" location="${root.location}/target" />
30 <property name="resources.dir" location="${root.location}/webapp" />
31 <property name="gen-war.dir" location="${root.location}/war" />
32 <property name="jsonschemafolder.dir" location="${root.location}/jsonschema" />
33 <property name="test.dir" location="${root.location}/tester" />
34 <property name="iteration" value="1" />
36 <path id="z3.classpath">
37 <pathelement location="${lib.dir}/com.microsoft.z3.jar" />
41 <import file="tomcat-build.xml" />
43 <target name="mvn-init" unless="compile.classpath" xmlns:artifact="urn:maven-artifact-ant">
44 <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant" classpath="lib/maven-ant-tasks-2.1.3.jar" />
45 <condition property="maven.repo.local" value="${maven.repo.local}" else="${user.home}/.m2/repository">
46 <isset property="maven.repo.local" />
48 <echo>maven.repo.local=${maven.repo.local}</echo>
49 <artifact:localRepository id="local.repository" path="${maven.repo.local}" />
50 <artifact:pom file="pom.xml" id="maven.project" />
51 <artifact:dependencies pathId="compile.classpath" filesetId="compile.fileset" useScope="compile">
52 <pom refid="maven.project" />
53 <localRepository refid="local.repository" />
54 </artifact:dependencies>
55 <artifact:dependencies pathId="test.classpath" filesetId="test.fileset" useScope="test">
56 <pom refid="maven.project" />
57 <localRepository refid="local.repository" />
58 </artifact:dependencies>
59 <artifact:dependencies pathId="runtime.classpath" filesetId="runtime.fileset" useScope="runtime">
60 <pom refid="maven.project" />
61 <localRepository refid="local.repository" />
62 </artifact:dependencies>
63 <artifact:dependencies pathId="build.classpath" filesetId="build.fileset">
64 <pom refid="maven.project" />
65 <localRepository refid="local.repository" />
66 </artifact:dependencies>
71 <mkdir dir="${build.dir}" />
72 <mkdir dir="${gen-tomcat-service.dir}" />
73 <mkdir dir="${gen-war.dir}" />
74 <mkdir dir="${gen.dir}" />
75 <mkdir dir="${lib.dir}" />
76 <get dest="${lib.dir}">
77 <url url="https://github.com/Z3Prover/z3/releases/download/z3-4.5.0/z3-4.5.0-x86-win.zip" />
78 <url url="http://central.maven.org/maven2/org/apache/maven/maven-ant-tasks/2.1.3/maven-ant-tasks-2.1.3.jar" />
80 <unzip src="${lib.dir}/z3-4.5.0-x86-win.zip" dest="${lib.dir}" overwrite="true">
82 <include name="**/**/com.microsoft.z3.jar" />
84 <mapper type="flatten" />
86 <delete file="${lib.dir}/z3-4.5.0-x86-win.zip" />
90 <target name="-chk-bindings">
91 <uptodate property="generate-bindings.notRequired" targetfile="${src.dir}/.flagfile">
92 <srcfiles dir="${schemadir}" includes="${schemafile}" />
97 <target name="generate-bindings" unless="generate-bindings.notRequired" depends="init" description="Create the value classes">
98 <exec executable="xjc" failonerror="true">
99 <arg line="-d ${gen.dir} -p it.polito.neo4j.jaxb ${schemadir}/${schemafile}" />
101 <touch file="${src.dir}/.flagfile" />
105 <!-- The target for compiling the Verigraph application -->
106 <target name="build-service" depends="init, generate-bindings, mvn-init">
107 <echo>Building verigraph (if needed)...</echo>
108 <javac destdir="${build.dir}" debug="${debug}" debuglevel="${debuglevel}" source="${source}" target="${target}" includeantruntime="false">
110 <path id="compile.classpath" />
111 <path id="z3.classpath" />
113 <src path="${src.dir}" />
114 <src path="${gen.dir}" />
115 <src path="${basedir}/gen-protobuf" />
116 <include name="${path.prefix}/**/*.java" />
117 <exclude name="main/proto/" />
123 <macrodef name="war-exploded">
125 <copy toDir="${gen-tomcat-service.dir}" overwrite="true">
126 <fileset dir="${resources.dir}" />
128 <copy toDir="${gen-tomcat-service.dir}" overwrite="true">
130 <include name="server.properties" />
133 <!-- copy class files to WEB-INF/classes directory -->
134 <copy toDir="${gen-tomcat-service.dir}/WEB-INF/classes" overwrite="true">
135 <fileset dir="${build.dir}">
136 <exclude name="verigraph.proto" />
137 <exclude name="src/main/proto" />
140 <!-- copy jsonschema folder to WEB-INF/classes directory -->
141 <copy toDir="${gen-tomcat-service.dir}/jsonschema" overwrite="true">
142 <fileset dir="${jsonschemafolder.dir}" />
144 <!-- copy lib files to WEB-INF/lib directory -->
145 <copy toDir="${gen-tomcat-service.dir}/maven-lib" overwrite="true">
146 <fileset refid="runtime.fileset">
149 <copy toDir="${gen-tomcat-service.dir}/WEB-INF/lib" overwrite="true" flatten="true">
150 <fileset dir="${gen-tomcat-service.dir}/maven-lib">
151 <include name="**/**/*.jar" />
154 <delete dir="${gen-tomcat-service.dir}/maven-lib" />
156 <!-- Make the jar that includes only the classes needed for verigraph models -->
157 <jar destfile="${gen-tomcat-service.dir}/WEB-INF/lib/mcnet.jar">
158 <fileset dir="${build.dir}">
159 <include name="it/polito/verigraph/mcnet/**/*.class" />
162 <!-- Copy the z3 library -->
163 <copy toDir="${gen-tomcat-service.dir}/WEB-INF/lib" overwrite="true" flatten="true">
164 <file name="${lib.dir}/com.microsoft.z3.jar" />
170 <target name="war-exploded" depends="build-service">
175 <target name="generate-war" depends="war-exploded">
176 <war destfile="${gen-war.dir}/${serviceName}.war" basedir="${gen-tomcat-service.dir}">
177 <exclude name="protoc-dependencies/" />
178 <exclude name="protoc-plugins/" />
179 <exclude name="classes/" />
185 <!-- launch test python test -->
186 <target name="run-test">
187 <exec dir="${test.dir}" executable="python">
188 <arg value="${testfile}" />
189 <arg value="-iteration " />
190 <arg value="${iteration}" />
196 <!-- target for cleaning -->
197 <target name="clean">
198 <delete dir="${build.dir}" />
199 <delete dir="${gen.dir}" />
200 <delete dir="${gen-tomcat-service.dir}" />
201 <delete dir="${war.dir}" />
202 <delete dir="${lib.dir}" />