Using Ant
Inside PageSeeder
Ant scripts can be invoked in PageSeeder through the Upload, Process, Export or Publish action icons or menu items. For information on configuring these see PSML Ant scripts.
Outside PageSeeder
Ant scripts can also be invoked outside PageSeeder, for example from a Windows or Linux command line using the following steps.
Windows
- If not installed already, install Java 11 or higher as follows:
- Go to https://www.oracle.com/java and choose Java for Developers / Java SE.
- Download the JDK or JRE .exe for windows (x64 for 64 bit) and run it.
- Download a .zip binary distribution of Ant 1.10.12 or higher from http://ant.apache.org/bindownload.cgi .
- Unzip Ant to a local folder (e.g.
c:\ant\apache-ant-1.10.12
). - Download the
pageseeder-publish-api-x.jar
for your version of PageSeeder from downloads and save it in a folder (e.g.c:\ant\lib
). - Download any dependencies (see below) and save them in a folder (e.g.
c:\ant\lib
). - Create a build script (for example,
c:\ant\build.xml
) with axmlns:ps="antlib:com.pageseeder.publishapi.ant"
attribute on the<project>
element, see examples. - Enter the following on the Windows command line using the paths for the system (they can also be put into a batch file):
set ANT_HOME=c:\ant\apache-ant-1.10.12 set JAVA_HOME=c:\Program Files\Java\jdk-11.0.14 set PATH=%PATH%;%ANT_HOME%\bin cd c:\ant ant -lib lib
Linux
- If not installed already, install Java 11 or higher, for example, as follows:
- OpenJDK (JDK 11)
http://openjdk.java.net/install/$ su -c "yum install java-11-openjdk"
- Download a binary distribution of Ant 1.10.12 or higher from http://ant.apache.org/bindownload.cgi .
- Decompress Ant to a folder (e.g.
/opt/ant/apache-ant-1.10.12
). - Download the
pageseeder-publish-api-x.jar
for your version of PageSeeder from downloads and save it in a folder (e.g./opt/ant/lib
). - Download any dependencies (see below) and save them in a folder (e.g.
/opt/ant/lib
). - Create a build script (e.g.
/opt/ant/build.xml
) with axmlns:ps="antlib:com.pageseeder.publishapi.ant"
attribute on the<project>
element, see examples. - Enter the following on the Linux command line using the paths for the system (they can also be put into a script file):
export ANT_HOME=/opt/ant/apache-ant-1.10.12 export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-[insert correct path] export PATH=${PATH}:${ANT_HOME}/bin cd /opt/ant ant -lib lib
Dependencies
To use the pageseeder-publish-api-x.jar
, you need to download the following files:
- pso-psml-[latest version].jar
- pso-xmlwriter-1.0.x.jar
- slf4j-api-1.7.x.jar
- slf4j-simple-1.7.x.jar
- pso-diffx-1.0.x (for
diff
task) - Saxon-HE-10.x.jar (for
process
andtransform
tasks)
Examples
Following is an example build.xml
file which could be used outside PageSeeder to upload documents and set their status to In Progress
.
If there is more than one target, it can be specified after the Ant command, for example:
ant -lib lib upload-specs
To display debug messages add the -debug
option, for example:
ant -lib lib -debug
<project name="example" default="upload-specs" xmlns:ps="antlib:com.pageseeder.publishapi.ant"> <target name="upload-specs" description="Upload specs"> <ps:config file="pageseeder.properties" /> <ps:upload group="example-specs" folder="documents" overwriteproperties="true" overwrite="true" unzip="true"> <workflow status="In Progress" /> <fileset dir="zip"> <include name="mydocs.zip"/> </fileset> </ps:upload> </target> </project>
The following file pageseeder.properties
must be in the same folder as build.xml
.
scheme=https host=ps.example.com port=443 servlet.prefix=/ps/servlet site.prefix=/ps username=jsmith password=mypassword
It is more secure to leave the password out of the properties file and add the following after <ps:config file="pageseeder.properties" />
.
<input message="password?" addproperty="ps.config.default.password"> <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> </input>
In PageSeeder v6 or higher it is recommended to use the OAuth client.id
and client.secret
properties instead of username/password
as these are more secure.