Skip to content

Commit 047dce8

Browse files
authored
DRYD-2080: Support Ant scripts (#523)
* Add ant module to download js libs * Update build scripts to include ant classpath * Rework scriptdefs to run with prepare-ant-libs as a dependency
1 parent 50c71f2 commit 047dce8

7 files changed

Lines changed: 98 additions & 50 deletions

File tree

3rdparty/ant/build.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<project name="ant-libs" default="prepare-ant" basedir=".">
2+
<description>Collectionspace Services - Ant Libs</description>
3+
4+
<target name="prepare-ant-libs">
5+
<exec executable="mvn" failonerror="true">
6+
<arg value="dependency:copy-dependencies"/>
7+
</exec>
8+
</target>
9+
10+
<target name="test-classpath" depends="prepare-ant-libs">
11+
<path id="javax.classpath">
12+
<fileset dir="./target/dependency">
13+
<include name="*.jar" />
14+
</fileset>
15+
</path>
16+
17+
<scriptdef name="testscript" language="javascript" manager="javax" classpathref="javax.classpath">
18+
<![CDATA[self.log('script ran successfully')]]>
19+
</scriptdef>
20+
21+
<testscript/>
22+
</target>
23+
</project>

3rdparty/ant/pom.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
<parent>
5+
<groupId>org.collectionspace.services</groupId>
6+
<artifactId>org.collectionspace.services.3rdparty</artifactId>
7+
<version>${revision}</version>
8+
</parent>
9+
10+
<modelVersion>4.0.0</modelVersion>
11+
<artifactId>org.collectionspace.services.3rdparty.ant-lib</artifactId>
12+
<name>collectionspace.3rdparty.ant-lib</name>
13+
<packaging>pom</packaging>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>org.openjdk.nashorn</groupId>
18+
<artifactId>nashorn-core</artifactId>
19+
<version>15.7</version>
20+
</dependency>
21+
</dependencies>
22+
</project>

3rdparty/pom.xml

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,7 @@
1212
<packaging>pom</packaging>
1313

1414
<modules>
15+
<module>ant</module>
1516
<module>nuxeo</module>
1617
</modules>
17-
18-
<dependencyManagement>
19-
<dependencies>
20-
</dependencies>
21-
</dependencyManagement>
22-
23-
<build>
24-
<!--
25-
<pluginManagement>
26-
<plugins>
27-
<plugin>
28-
<groupId>org.apache.maven.plugins</groupId>
29-
<artifactId>maven-compiler-plugin</artifactId>
30-
<configuration>
31-
<source>1.5</source>
32-
<target>1.5</target>
33-
</configuration>
34-
</plugin>
35-
</plugins>
36-
</pluginManagement>
37-
-->
38-
</build>
39-
4018
</project>

build.xml

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<!-- environment should be declared before reading build.properties -->
44
<property environment="env" />
55
<!-- set global properties for this build -->
6+
<property name="services.trunk" value="." />
67
<property file="build.properties" />
78
<property name="mvn.opts" value="-V" />
89
<property name="src" location="src" />
@@ -14,14 +15,28 @@
1415
<os family="windows" />
1516
</condition>
1617

17-
<scriptdef name="urlencode" language="javascript">
18-
<attribute name="property"/>
19-
<![CDATA[
20-
var value = self.project.getProperty(attributes.get("property"));
21-
var encoded = encodeURIComponent(value);
22-
self.project.setProperty(attributes.get("property") + ".encoded", encoded)
23-
]]>
24-
</scriptdef>
18+
<target name="prepare-ant-libs">
19+
<ant antfile="3rdparty/ant/build.xml" target="prepare-ant-libs" inheritAll="false" />
20+
</target>
21+
22+
<target name="encode-jdbc-options" depends="prepare-ant-libs">
23+
<path id="javax.classpath">
24+
<fileset dir="${services.trunk}/3rdparty/ant/target/dependency">
25+
<include name="*.jar" />
26+
</fileset>
27+
</path>
28+
29+
<scriptdef name="encode" language="javascript" manager="javax" classpathref="javax.classpath">
30+
<attribute name="property"/>
31+
<![CDATA[
32+
var value = self.project.getProperty(attributes.get("property"));
33+
var encoded = encodeURIComponent(value);
34+
self.project.setProperty(attributes.get("property") + ".encoded", encoded)
35+
]]>
36+
</scriptdef>
37+
38+
<encode property="db.jdbc.urloptions" />
39+
</target>
2540

2641
<target name="init">
2742
<!-- Create the time stamp -->
@@ -226,8 +241,7 @@
226241
<!--
227242
This target calls the 'create_nuxeo_db' and 'create_cspace_db' targets and creates some database utility functions
228243
-->
229-
<target name="-create_db" depends="-validate_create_db_unix, -validate_create_db_windows">
230-
<urlencode property="db.jdbc.urloptions" />
244+
<target name="-create_db" depends="-validate_create_db_unix, -validate_create_db_windows, encode-jdbc-options">
231245
<antcall target="create_nuxeo_db" />
232246
<antcall target="create_cspace_db" />
233247
<antcall target="create_update_userid_db_function" />
@@ -311,19 +325,22 @@
311325
<ant antfile="services/build.xml" target="create_cspace_db" inheritAll="false" />
312326
</target>
313327

314-
<target name="import" description="import default configuration">
315-
<urlencode property="db.jdbc.urloptions" />
316-
<ant antfile="services/build.xml" target="import" inheritAll="false" />
328+
<target name="import" depends="encode-jdbc-options" description="import default configuration">
329+
<ant antfile="services/build.xml" target="import" inheritAll="false">
330+
<property name="db.jdbc.urloptions.encoded" value="${db.jdbc.urloptions.encoded}" />
331+
</ant>
317332
</target>
318333

319-
<target name="deploy" depends="install, setup_initdb.sql" description="deploy services in ${jee.server.cspace}">
334+
<target name="deploy" depends="install, setup_initdb.sql, encode-jdbc-options" description="deploy services in ${jee.server.cspace}">
320335
<!-- copy db scripts, etc. -->
321336
<copy todir="${jee.server.cspace}/cspace/services/scripts">
322337
<fileset dir="${src}/main/resources/scripts/" />
323338
</copy>
324339
<ant antfile="3rdparty/build.xml" target="deploy" inheritAll="false" />
325340
<ant antfile="common-lib/build.xml" target="deploy" inheritAll="false" />
326-
<ant antfile="services/build.xml" target="deploy" inheritAll="false" />
341+
<ant antfile="services/build.xml" target="deploy" inheritAll="false">
342+
<property name="db.jdbc.urloptions.encoded" value="${db.jdbc.urloptions.encoded}" />
343+
</ant>
327344
<ant antfile="cspace-ui/build.xml" target="deploy" inheritAll="false" />
328345
</target>
329346

cspace-ui/build.xml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@
1111
</sequential>
1212
</macrodef>
1313

14-
<scriptdef name="uppercase" language="javascript">
15-
<attribute name="property" />
16-
<attribute name="string" />
17-
18-
project.setProperty(attributes.get("property"), attributes.get("string").toUpperCase());
19-
</scriptdef>
20-
2114
<!-- set global properties for this build -->
2215
<property name="services.trunk" value=".." />
2316
<property name="build.dir.name" value="build" />
@@ -142,6 +135,19 @@
142135

143136
<target name="deploy_tenant">
144137
<basename property="tenant.shortname" file="${basedir}" />
138+
<path id="javax.classpath">
139+
<!-- The subant calls in this file make it so we're required to traverse based off the tenant directory -->
140+
<fileset dir="../../3rdparty/ant">
141+
<include name="**/*.jar" />
142+
</fileset>
143+
</path>
144+
145+
<scriptdef name="uppercase" language="javascript" manager="javax" classpathref="javax.classpath">
146+
<attribute name="property" />
147+
<attribute name="string" />
148+
project.setProperty(attributes.get("property"), attributes.get("string").toUpperCase());
149+
</scriptdef>
150+
145151
<uppercase property="tenant.shortname.upper" string="${tenant.shortname}" />
146152
<propertycopy name="tenant.create.disabled" from="env.CSPACE_${tenant.shortname.upper}_CREATE_DISABLED_OPT" />
147153

services/JaxRsServiceProvider/build.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353

5454
<target name="package" depends="package-unix,package-windows"
5555
description="Package CollectionSpace Services" />
56-
<urlencode property="db.jdbc.urloptions" />
5756
<target name="package-unix" if="osfamily-unix">
5857
<exec executable="mvn" failonerror="true">
5958
<arg value="package" />
@@ -78,7 +77,6 @@
7877
</exec>
7978
</target>
8079

81-
8280
<target name="clean" depends="clean-unix,clean-windows"
8381
description="Delete target directories" >
8482
<delete dir="${build}"/>

services/build.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@
145145

146146
<target name="import"
147147
description="import default configuration">
148-
<ant antfile="authorization-mgt/build.xml" target="import" inheritAll="false"/>
148+
<ant antfile="authorization-mgt/build.xml" target="import" inheritAll="false">
149+
<property name="db.jdbc.urloptions.encoded" value="${db.jdbc.urloptions.encoded}" />
150+
</ant>
149151
</target>
150152

151153
<!-- this target is called in order based on the dependencies between the services -->
@@ -200,8 +202,10 @@
200202
<ant antfile="publicitem/build.xml" target="deploy" inheritAll="false"/>
201203
<ant antfile="uoc/build.xml" target="deploy" inheritAll="false"/>
202204
<ant antfile="transport/build.xml" target="deploy" inheritAll="false"/>
203-
<ant antfile="advancedsearch/build.xml" target="deploy" inheritAll="false"/>
204-
<ant antfile="JaxRsServiceProvider/build.xml" target="deploy" inheritAll="false"/>
205+
<ant antfile="advancedsearch/build.xml" target="deploy" inheritAll="false"/>
206+
<ant antfile="JaxRsServiceProvider/build.xml" target="deploy" inheritAll="false">
207+
<property name="db.jdbc.urloptions.encoded" value="${db.jdbc.urloptions.encoded}" />
208+
</ant>
205209
</target>
206210

207211
<!-- this target is called in reverse order of deploy targets -->

0 commit comments

Comments
 (0)