Skip to content

Commit 681f2ac

Browse files
committed
feat(build): Build env. specific xars, with and/or without triggers
* default ant task `ant`: create 1 default xar without (replication) triggers * ant task `ant xar-dev` will create 2 xar files, one with and one without triggers, the triggers will contain the dev environment variables * ant task `ant xar-prod` will create 2 xar files, one with and one without triggers, the triggers will contain the prod environment variables * extract configuration from expath-pgk.xml to build.properties.xml * update readme with build documentation
1 parent 17de838 commit 681f2ac

File tree

7 files changed

+204
-34
lines changed

7 files changed

+204
-34
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,20 @@ A collection of utilities for preparing releases:
99
## Dependencies
1010

1111
- Assumes [HistoryAtState/hsg-project](https://github.com/HistoryAtState/hsg-project) is installed
12+
13+
## Build
14+
15+
1. Single `xar` file: The `collection.xconf` will only contain the index, not any triggers!
16+
~~~shell
17+
ant
18+
~~~
19+
20+
2. DEV environment: The replication triggers for the producer server are enabled in `collection.xconf` and point to the dev server's replication service IP.
21+
~~~shell
22+
ant xar-dev
23+
~~~
24+
25+
3. PROD environment: Same as in 2. but for PROD destination
26+
~~~shell
27+
ant xar-prod
28+
~~~

build.properties.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<root>
3+
<app>
4+
<name>release</name>
5+
<url>http://history.state.gov/ns/apps/release</url>
6+
<title>Release</title>
7+
<version>0.3</version>
8+
</app>
9+
<trigger>
10+
<provider-url>
11+
<dev>failover:tcp://10.0.1.114:61616</dev>
12+
<prod>failover:tcp://10.0.1.131:61616</prod>
13+
</provider-url>
14+
<destination>
15+
<dev>dynamicTopics/hsg-replication</dev>
16+
<prod>dynamicTopics/hsg-replication</prod>
17+
</destination>
18+
</trigger>
19+
</root>

build.xml

Lines changed: 136 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,144 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project default="xar" name="people">
3-
<xmlproperty file="expath-pkg.xml"/>
4-
<property name="project.version" value="${package(version)}"/>
5-
<property name="project.app" value="${package(abbrev)}"/>
3+
<xmlproperty file="build.properties.xml" semanticAttributes="true" keepRoot="false"/>
64
<property name="build.dir" value="build"/>
7-
<target name="xar">
5+
6+
<target name="clean">
7+
<echo message="Deleting xar files..."/>
8+
<delete dir="${build.dir}"/>
89
<mkdir dir="${build.dir}"/>
9-
<zip basedir="." destfile="${build.dir}/${project.app}-${project.version}.xar">
10-
<exclude name="${build.dir}/*"/>
11-
<exclude name=".existdb.json"/>
12-
</zip>
1310
</target>
14-
<target name="clean">
15-
<delete quiet="true">
16-
<fileset dir="${build.dir}">
17-
<include name="*.xar"/>
11+
12+
<target name="copy">
13+
<echo message="Copying the files to the build folder..."/>
14+
<copy todir="${build.dir}/${app.name}-${app.version}">
15+
<fileset dir="${basedir}">
16+
<exclude name="${build.dir}/**"/>
17+
</fileset>
18+
</copy>
19+
</target>
20+
21+
<target name="copy-with-replication-trigger">
22+
<echo message="Copying the files to the build folder..."/>
23+
<copy todir="${build.dir}/${app.name}-${app.version}">
24+
<fileset dir="${basedir}">
25+
<exclude name="${build.dir}/**"/>
26+
<exclude name="collection.xconf"/>
1827
</fileset>
19-
</delete>
28+
</copy>
29+
</target>
30+
31+
<target name="apply-filters">
32+
<echo message="Apply values to expath-pgk.xml..."/>
33+
<copy todir="${build.dir}/${app.name}-${app.version}" overwrite="true" verbose="true">
34+
<fileset file="expath-pkg.xml.tmpl"/>
35+
<filterset>
36+
<filter token="name" value="${app.name}"/>
37+
<filter token="version" value="${app.version}"/>
38+
<filter token="url" value="${app.url}"/>
39+
<filter token="title" value="${app.title}"/>
40+
</filterset>
41+
<globmapper from="*.tmpl" to="*"/>
42+
</copy>
43+
</target>
44+
45+
<target name="apply-filters-to-producer-dev">
46+
<echo message="Apply DEV values to collection.xconf..."/>
47+
<copy todir="${build.dir}/${app.name}-${app.version}" overwrite="true" verbose="true">
48+
<fileset file="collection.xconf.tmpl"/>
49+
<fileset file="expath-pkg.xml.tmpl"/>
50+
<filterset>
51+
<filter token="provider-url" value="${trigger.provider-url.dev}"/>
52+
<filter token="destination" value="${trigger.destination.dev}"/>
53+
<filter token="name" value="${app.name}"/>
54+
<filter token="version" value="${app.version}"/>
55+
<filter token="url" value="${app.url}"/>
56+
<filter token="title" value="${app.title}"/>
57+
</filterset>
58+
<globmapper from="*.tmpl" to="*"/>
59+
</copy>
60+
</target>
61+
62+
<target name="apply-filters-to-producer-prod">
63+
<echo message="Apply PROD values to collection.xconf..."/>
64+
<copy todir="${build.dir}/${app.name}-${app.version}" overwrite="true" verbose="true">
65+
<fileset file="collection.xconf.tmpl"/>
66+
<fileset file="expath-pkg.xml.tmpl"/>
67+
<filterset>
68+
<filter token="provider-url" value="${trigger.provider-url.prod}"/>
69+
<filter token="destination" value="${trigger.destination.prod}"/>
70+
<filter token="name" value="${app.name}"/>
71+
<filter token="version" value="${app.version}"/>
72+
<filter token="url" value="${app.url}"/>
73+
<filter token="title" value="${app.title}"/>
74+
</filterset>
75+
<globmapper from="*.tmpl" to="*"/>
76+
</copy>
77+
</target>
78+
79+
<target name="xar-dev" depends="clean" description="target to create application XAR files for DEV environment">
80+
<antcall target="copy"/>
81+
<antcall target="apply-filters"/>
82+
<echo message="------------------------------------------------------------"/>
83+
<echo message="Creating DEV 'consumer' xar package..."/>
84+
<echo message="------------------------------------------------------------"/>
85+
86+
<zip basedir="${build.dir}/${app.name}-${app.version}" destfile="${build.dir}/${app.name}-${app.version}-consumer.xar">
87+
<exclude name="${build.dir}/**"/>
88+
<exclude name="**/*.tmpl"/>
89+
</zip>
90+
91+
<antcall target="copy-with-replication-trigger"/>
92+
<antcall target="apply-filters-to-producer-dev"/>
93+
94+
<echo message="------------------------------------------------------------"/>
95+
<echo message="Creating DEV 'producer' xar package containing triggers..."/>
96+
<echo message="------------------------------------------------------------"/>
97+
98+
<zip basedir="${build.dir}/${app.name}-${app.version}" destfile="${build.dir}/${app.name}-${app.version}-producer.xar">
99+
<exclude name="**/*.tmpl"/>
100+
</zip>
101+
<delete dir="${build.dir}/${app.name}-${app.version}"/>
102+
</target>
103+
104+
<target name="xar-prod" depends="clean" description="target to create application XAR files for PROD environment">
105+
<antcall target="copy"/>
106+
<antcall target="apply-filters"/>
107+
108+
<echo message="------------------------------------------------------------"/>
109+
<echo message="Creating PROD 'consumer' xar package..."/>
110+
<echo message="------------------------------------------------------------"/>
111+
112+
<zip basedir="${build.dir}/${app.name}-${app.version}" destfile="${build.dir}/${app.name}-${app.version}-consumer.xar">
113+
<exclude name="${build.dir}/**"/>
114+
<exclude name="**/*.tmpl"/>
115+
</zip>
116+
117+
<antcall target="copy-with-replication-trigger"/>
118+
<antcall target="apply-filters-to-producer-prod"/>
119+
120+
<echo message="------------------------------------------------------------"/>
121+
<echo message="Creating PROD 'producer' xar package containing triggers..."/>
122+
<echo message="------------------------------------------------------------"/>
123+
124+
<zip basedir="${build.dir}/${app.name}-${app.version}" destfile="${build.dir}/${app.name}-${app.version}-producer.xar">
125+
<exclude name="${build.dir}/**"/>
126+
<exclude name="**/*.tmpl"/>
127+
</zip>
128+
<delete dir="${build.dir}/${app.name}-${app.version}"/>
129+
</target>
130+
131+
<target name="xar" depends="clean" description="main target to create application XAR files">
132+
<antcall target="copy"/>
133+
<antcall target="apply-filters"/>
134+
<echo message="------------------------------------------------------------"/>
135+
<echo message="Creating xar package..."/>
136+
<echo message="------------------------------------------------------------"/>
137+
138+
<zip basedir="${build.dir}/${app.name}-${app.version}" destfile="${build.dir}/${app.name}-${app.version}.xar">
139+
<exclude name="${build.dir}/**"/>
140+
<exclude name="**/*.tmpl"/>
141+
</zip>
142+
<delete dir="${build.dir}/${app.name}-${app.version}"/>
20143
</target>
21144
</project>

collection.xconf

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,4 @@
1111
<create qname="name" type="xs:string"/>
1212
</range>
1313
</index>
14-
<!-- Replication -->
15-
<!--
16-
<triggers>
17-
<trigger class="org.exist.jms.replication.publish.ReplicationTrigger">
18-
19-
<parameter name="java.naming.factory.initial" value="org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
20-
21-
<parameter name="java.naming.provider.url" value="failover:(tcp://10.0.1.131:61616,tcp://10.0.2.236:61616)"/>
22-
23-
<parameter name="connection-factory" value="ConnectionFactory"/>
24-
25-
<parameter name="destination" value="dynamicTopics/hsg-replication"/>
26-
</trigger>
27-
</triggers>
28-
-->
29-
</collection>
14+
</collection>

collection.xconf.tmpl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<collection xmlns="http://exist-db.org/collection-config/1.0">
3+
<index xmlns:xs="http://www.w3.org/2001/XMLSchema">
4+
<lucene>
5+
<!-- The standard analyzer will ignore stopwords like 'the', 'and' -->
6+
<analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
7+
<analyzer id="ws" class="org.apache.lucene.analysis.core.WhitespaceAnalyzer"/>
8+
<text qname="name"/>
9+
</lucene>
10+
<range>
11+
<create qname="name" type="xs:string"/>
12+
</range>
13+
</index>
14+
<!-- Replication -->
15+
<triggers>
16+
<trigger class="org.exist.jms.replication.publish.ReplicationTrigger">
17+
18+
<parameter name="java.naming.factory.initial" value="org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
19+
20+
<parameter name="java.naming.provider.url" value="@provider-url@"/>
21+
22+
<parameter name="connection-factory" value="ConnectionFactory"/>
23+
24+
<parameter name="destination" value="@destination@"/>
25+
</trigger>
26+
</triggers>
27+
</collection>

expath-pkg.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

expath-pkg.xml.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<package xmlns="http://expath.org/ns/pkg" name="@url@" abbrev="@name@" version="@version@" spec="1.0">
3+
<title>"@title@"</title>
4+
</package>

0 commit comments

Comments
 (0)