This repository was archived by the owner on Mar 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
178 lines (162 loc) · 7.68 KB
/
build.xml
File metadata and controls
178 lines (162 loc) · 7.68 KB
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
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for additional
information regarding copyright ownership. The ASF licenses this file to
you under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License. -->
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="TestJPA" default="execute">
<!-- this build file is a self contained project: it doesn't require anything
else that ant 1.6.2 or greater and java 1.4 or greater properly installed.
It is used to showcase how easy and straightforward it can be to use Ivy.
This is not an example of the best pratice to use in a project, especially
for the java source code "generation" :-) (see generate-src target) To run
copy this file in an empty directory, open a shell or a command window in
this directory and run "ant". It will download ivy and then use it to resolve
the dependency of the class which is itself "contained" in this build script.
After a successful build run "ant" again and you will see the build will
be much faster. More information can be found at http://ant.apache.org/ivy/ -->
<!-- here is the version of ivy we will use. change this property to try
a newer version if you want -->
<property name="ivy.install.version" value="2.4.0" />
<property name="ivy.jar.dir" value="${basedir}/ivy" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<property name="ivy.pattern" value="${ivy.jar.dir}/[artifact]-[revision].[ext]" />
<property name="libs.dir" value="${basedir}/libs" />
<property name="libs.pattern" value="${libs.dir}/[artifact]-[revision].[ext]" />
<property name="build.dir" value="${basedir}/build" />
<property name="src.dir" value="${basedir}/src" />
<property name="target.dir" value="${basedir}/target" />
<property name="modules.dir" value="${basedir}/mlib" />
<property name="java_home" value="/usr/lib/jvm/java-9-oracle" />
<property name="JAVA_BIN" value="${java_home}/bin" />
<property name="iris.version" value="1.0" />
<property name="hibernate.version" value="5.2.1.Final" />
<property name="sqlite.version" value="3.8.11.2" />
<property name="module.name" value="iris" />
<property name="main.class" value="br.unb.cic.iris.MainApp" />
<!-- ================================= CLEAN ================================= -->
<target name="clean" description="Basic cleaning">
<delete includeemptydirs="true" quiet="true">
<fileset dir="${build.dir}" />
<fileset dir="${target.dir}" />
<fileset dir="${modules.dir}" />
<!--<fileset dir="${libs.dir}" />-->
</delete>
<mkdir dir="${build.dir}" />
<mkdir dir="${modules.dir}" />
<!--<mkdir dir="${libs.dir}" />-->
</target>
<target name="clean-ivy">
<delete dir="${ivy.jar.dir}" />
</target>
<target name="clean-cache" depends="install-ivy">
<ivy:cleancache />
</target>
<target name="clean_full" depends="clean, clean-ivy, clean-cache" description="Full cleaning">
<delete includeemptydirs="true" quiet="true">
<fileset dir="${libs.dir}" />
</delete>
</target>
<!-- ================================= TEST ================================= -->
<target name="execute" depends="clean,download-dependencies">
<antcall target="create_module" />
<antcall target="run" />
<antcall target="run_info" />
</target>
<target name="create_module">
<echo>Creating Module: ${module.name}</echo>
<antcall target="compile_module" />
<antcall target="create_main_jar" />
</target>
<target name="compile_module">
<fileset dir="${src.dir}" id="fileset" casesensitive="yes">
<include name="**/*.java" />
</fileset>
<pathconvert refid="fileset" property="converted" pathsep=" " />
<exec executable="${JAVA_BIN}/javac" failonerror="true">
<arg value="-mp" />
<arg value="${libs.dir}" />
<arg value="-d" />
<arg value="${build.dir}" />
<arg value="-modulesourcepath" />
<arg value="${src.dir}" />
<arg line="${converted}" />
</exec>
</target>
<target name="create_main_jar">
<mkdir dir="${build.dir}/${module.name}/META-INF" />
<copy todir="${build.dir}/${module.name}/META-INF">
<fileset dir="${src.dir}/${module.name}/META-INF" />
</copy>
<exec executable="${JAVA_BIN}/jar" failonerror="true">
<arg value="--create" />
<arg value="--file" />
<arg value="${modules.dir}/${module.name}@${iris.version}.jar" />
<arg value="--module-version" />
<arg value="${iris.version}" />
<arg value="--main-class" />
<arg value="${main.class}" />
<arg value="-C" />
<arg line="${build.dir}/${module.name}" />
<arg line="." />
</exec>
</target>
<target name="run">
<echo>Running app ...</echo>
<fileset dir="${libs.dir}" id="fileset" casesensitive="yes">
<include name="**/*.jar" />
</fileset>
<pathconvert refid="fileset" property="classpath" pathsep=":" />
<exec executable="${JAVA_BIN}/java" failonerror="true">
<arg value="-cp" />
<arg value="${classpath}" />
<arg value="-mp" />
<arg value="${modules.dir}:${libs.dir}" />
<arg value="-m" />
<arg value="${module.name}" />
</exec>
</target>
<target name="run_info">
<echo>Module was successfully generated!</echo>
<echo>To run the application:</echo>
<echo>export JAVA_HOME=${java_home}</echo>
<echo>export JAVA_BIN=$JAVA_HOME/bin</echo>
<echo>$JAVA_BIN/java -mp mlib:libs -m ${module.name}</echo>
</target>
<target name="download-dependencies" depends="install-ivy" unless="skip.download">
<get src="https://repo1.maven.org/maven2/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar" dest="${libs.dir}/dom4j-1.6.1.jar" usetimestamp="true" />
<ivy:retrieve pattern="${libs.pattern}">
<dependency org="org.hibernate" name="hibernate-core" rev="${hibernate.version}" />
<dependency org="org.xerial" name="sqlite-jdbc" rev="${sqlite.version}" />
<exclude org="junit" module="junit" />
<exclude org="*" ext="*" type="source" />
<exclude org="*" ext="*" type="javadoc" />
</ivy:retrieve>
</target>
<!-- ================================= IVY ================================= -->
<target name="download-ivy" unless="skip.download">
<mkdir dir="${ivy.jar.dir}" />
<!-- download Ivy from web site so that it can be used even without any
special installation -->
<echo message="installing ivy..." />
<get src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" dest="${ivy.jar.file}" usetimestamp="true" />
</target>
<!-- ================================= target: install-ivy this target is
not necessary if you put ivy.jar in your ant lib directory if you already
have ivy in your ant lib, you can simply remove this target and the dependency
the 'go' target has on it ================================= -->
<target name="install-ivy" depends="download-ivy">
<!-- try to load ivy here from local ivy dir, in case the user has not
already dropped it into ant's lib dir (note that the latter copy will always
take precedence). We will not fail as long as local lib dir exists (it may
be empty) and ivy is in at least one of ant's lib dir or the local lib dir. -->
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar" />
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path" />
</target>
</project>