Skip to content

Commit

Permalink
Merge pull request #2 from windauer/feature/add-git-information
Browse files Browse the repository at this point in the history
added git info to repo.xml
  • Loading branch information
joewiz authored Nov 25, 2020
2 parents 8e4e913 + 86b0b09 commit 9635227
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 166 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
build/*
.existdb.json
.DS_Store
expath-pkg.xml
repo.xml
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ The data and app are very preliminary and subject to reorganization.
```shell
ant
```

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.
```shell
ant xar-dev
```
3. PROD environment: Same as in 2. but for PROD destination
```shell
ant xar-prod
```

- Upload build/terms-0.1.xar to eXist-db's Dashboard > Package Manager
- Open http://localhost:8080/exist/apps/terms
10 changes: 0 additions & 10 deletions build.properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,4 @@
<title>Terms</title>
<version>0.4</version>
</app>
<trigger>
<provider-url>
<dev>failover:tcp://10.0.1.114:61616</dev>
<prod>failover:tcp://10.0.1.131:61616</prod>
</provider-url>
<destination>
<dev>dynamicTopics/hsg-replication</dev>
<prod>dynamicTopics/hsg-replication</prod>
</destination>
</trigger>
</root>
172 changes: 54 additions & 118 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,136 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<project default="xar" name="terms">
<project default="xar" name="terms" basedir=".">
<xmlproperty file="build.properties.xml" semanticAttributes="true" keepRoot="false"/>
<property name="build.dir" value="build"/>

<property name="git.repo.path" value="${basedir}/.git"/>
<available file="${git.repo.path}" type="dir" property="git.present"/>

<target name="clean">
<echo message="Deleting xar files..."/>
<delete dir="${build.dir}"/>
<delete dir="${build.dir}" failonerror="false"/>
<delete file="${basedir}/expath-pkg.xml" failonerror="false"/>
<delete file="${basedir}/repo.xml" failonerror="false"/>
</target>

<target name="prepare">
<target name="xar" depends="clean,git.revision" description="create xar file">
<echo message="Creating build folder..."/>
<mkdir dir="${build.dir}"/>
</target>

<target name="copy">
<echo message="Copying the files to the build folder..."/>
<copy todir="${build.dir}/${app.name}-${app.version}">
<fileset dir="${basedir}">
<exclude name="${build.dir}/**"/>
</fileset>
</copy>
</target>

<target name="apply-filters-to-expath-pkg">

<echo message="Apply values to expath-pkg.xml..."/>
<copy todir="${build.dir}/${app.name}-${app.version}" overwrite="true" verbose="true">
<fileset file="expath-pkg.xml.tmpl"/>
<filterset>
<filter token="name" value="${app.name}"/>
<filter token="version" value="${app.version}"/>
<filter token="url" value="${app.url}"/>
<filter token="title" value="${app.title}"/>
</filterset>
<copy todir="${basedir}" overwrite="true" verbose="true">
<fileset file="*.xml.tmpl"/>
<filterchain>
<replacetokens>
<token key="name" value="${app.name}"/>
<token key="version" value="${app.version}"/>
<token key="url" value="${app.url}"/>
<token key="title" value="${app.title}"/>
<token key="commit-id" value="${git.revision}"/>
<token key="commit-time" value="${git.time}"/>
</replacetokens>
<tokenfilter>
<!-- until we move template processing to XSLT, take care with reserved characters -->
<replacestring from="&amp;" to="&amp;amp;"/>
</tokenfilter>
</filterchain>
<globmapper from="*.tmpl" to="*"/>
</copy>
</target>

<target name="apply-filters-to-producer-dev">
<echo message="Apply DEV values to collection.xconf..."/>
<copy todir="${build.dir}/${app.name}-${app.version}" overwrite="true" verbose="true">
<fileset file="collection.xconf.tmpl"/>
<fileset file="expath-pkg.xml.tmpl"/>
<filterset>
<filter token="provider-url" value="${trigger.provider-url.dev}"/>
<filter token="destination" value="${trigger.destination.dev}"/>
<filter token="name" value="${app.name}"/>
<filter token="version" value="${app.version}"/>
<filter token="url" value="${app.url}"/>
<filter token="title" value="${app.title}"/>
</filterset>
<globmapper from="*.tmpl" to="*"/>
</copy>
</target>

<target name="apply-filters-to-producer-prod">
<echo message="Apply PROD values to collection.xconf..."/>
<copy todir="${build.dir}/${app.name}-${app.version}" overwrite="true" verbose="true">
<fileset file="collection.xconf.tmpl"/>
<fileset file="expath-pkg.xml.tmpl"/>
<filterset>
<filter token="provider-url" value="${trigger.provider-url.prod}"/>
<filter token="destination" value="${trigger.destination.prod}"/>
<filter token="name" value="${app.name}"/>
<filter token="version" value="${app.version}"/>
<filter token="url" value="${app.url}"/>
<filter token="title" value="${app.title}"/>
</filterset>
<globmapper from="*.tmpl" to="*"/>
</copy>
</target>

<target name="xar-dev" depends="clean,prepare" description="create xar files for DEV environment">
<antcall target="copy"/>
<antcall target="apply-filters-to-expath-pkg"/>
<echo message="------------------------------------------------------------"/>
<echo message="Creating DEV 'consumer' xar file..."/>
<echo message="------------------------------------------------------------"/>

<zip basedir="${build.dir}/${app.name}-${app.version}" destfile="${build.dir}/${app.name}-${app.version}-consumer-dev.xar">
<exclude name="${build.dir}/**"/>
<exclude name="**/*.tmpl"/>
</zip>

<antcall target="apply-filters-to-producer-dev"/>

<echo message="------------------------------------------------------------"/>
<echo message="Creating DEV 'producer' xar file containing triggers..."/>
<echo message="------------------------------------------------------------"/>

<zip basedir="${build.dir}/${app.name}-${app.version}" destfile="${build.dir}/${app.name}-${app.version}-producer-dev.xar">
<exclude name="**/*.tmpl"/>
</zip>
<delete dir="${build.dir}/${app.name}-${app.version}"/>
</target>

<target name="xar-prod" depends="clean,prepare" description="create xar files for PROD environment">
<antcall target="copy"/>
<antcall target="apply-filters-to-expath-pkg"/>

<echo message="------------------------------------------------------------"/>
<echo message="Creating PROD 'consumer' xar file..."/>
<echo message="------------------------------------------------------------"/>

<zip basedir="${build.dir}/${app.name}-${app.version}" destfile="${build.dir}/${app.name}-${app.version}-consumer.xar">
<exclude name="${build.dir}/**"/>
<exclude name="**/*.tmpl"/>
</zip>

<antcall target="apply-filters-to-producer-prod"/>

<echo message="------------------------------------------------------------"/>
<echo message="Creating PROD 'producer' xar file containing triggers..."/>
<echo message="------------------------------------------------------------"/>

<zip basedir="${build.dir}/${app.name}-${app.version}" destfile="${build.dir}/${app.name}-${app.version}-producer.xar">
<exclude name="${build.dir}/**"/>
<exclude name="**/*.tmpl"/>
</zip>
<delete dir="${build.dir}/${app.name}-${app.version}"/>
</target>

<target name="xar" depends="clean,prepare" description="create xar file">
<antcall target="copy"/>
<antcall target="apply-filters-to-expath-pkg"/>

<echo message="------------------------------------------------------------"/>
<echo message="Creating xar file..."/>
<echo message="------------------------------------------------------------"/>

<zip basedir="${build.dir}/${app.name}-${app.version}" destfile="${build.dir}/${app.name}-${app.version}.xar">
<zip basedir="${basedir}" destfile="${build.dir}/${app.name}-${app.version}.xar">
<exclude name="${build.dir}/**"/>
<exclude name="**/*.tmpl"/>
</zip>
<delete dir="${build.dir}/${app.name}-${app.version}"/>
<exclude name="*.tmpl"/>
</zip>
</target>
</project>

<target name="git.revision" description="Store git revision in ${repository.version}" if="git.present">
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<arg value="--git-dir=${git.repo.path}"/>
<arg value="rev-parse"/>
<arg value="HEAD"/>
</exec>
<condition property="repository.version" value="${git.revision}" else="unknown">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<echo>Git repo: ${repository.version}</echo>

<exec executable="git" outputproperty="git.time" failifexecutionfails="false" errorproperty="">
<arg value="--git-dir=${git.repo.path}"/>
<arg value="show"/>
<arg value="-s"/>
<arg value="--format=%ct"/>
<arg value="${git.revision}"/>
</exec>
<echo>Git time: ${git.time}</echo>
</target>
</project>
26 changes: 0 additions & 26 deletions collection.xconf.tmpl

This file was deleted.

2 changes: 1 addition & 1 deletion repo.xml → repo.xml.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<meta xmlns="http://exist-db.org/xquery/repo">
<meta xmlns="http://exist-db.org/xquery/repo" commit-id="@commit-id@" commit-time="@commit-time@">
<description>Terms</description>
<author>Office of the Historian</author>
<website>https://history.state.gov</website>
Expand Down

0 comments on commit 9635227

Please sign in to comment.