blob: 7dddfb5a40b9a7205b77440b34d18671bb3d9e0f [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<project name="prepare-update-site" basedir="." default="process-repository" xmlns:comp="antlib:org.apache.ant.compress">
<property name="repository" value="${basedir}/target/repository" />
<property name="contentxml" value="${repository}/content.xml" />
<property name="p2contentxml" value="${basedir}/target/p2content.xml" />
<property name="stylesheet" value="${basedir}/p2content.xslt" />
<macrodef name="transform">
<attribute name="file"/>
<attribute name="stylesheet"/>
<sequential>
<copy file="@{file}" tofile="@{file}.orig"/>
<xslt style="@{stylesheet}" in="@{file}" out="@{file}.tmp"/>
<move file="@{file}.tmp" tofile="@{file}"/>
<delete file="@{file}.orig"/>
</sequential>
</macrodef>
<target name="transform-repository-xml">
<transform file="${contentxml}" stylesheet="${stylesheet}"/>
<transform file="${p2contentxml}" stylesheet="${stylesheet}"/>
</target>
<target name="compress-repository-files">
<jar basedir="${repository}" destfile="${repository}/content.jar" includes="content.xml" filesonly="true" compress="true" level="9"/>
<jar basedir="${repository}" destfile="${repository}/artifacts.jar" includes="artifacts.xml" filesonly="true" compress="true" level="9"/>
<comp:xz src="${repository}/content.xml" destfile="${repository}/content.xml.xz"/>
<comp:xz src="${repository}/artifacts.xml" destfile="${repository}/artifacts.xml.xz"/>
<replace file="${repository}/p2.index">
<replacefilter token="metadata.repository.factory.order=content.xml" value="metadata.repository.factory.order=content.xml.xz,content.xml"/>
<replacefilter token="artifact.repository.factory.order=artifacts.xml" value="artifact.repository.factory.order=artifacts.xml.xz,artifacts.xml"/>
</replace>
<move todir="${repository}/..">
<fileset dir="${repository}" includes="content.xml,artifacts.xml"/>
</move>
</target>
<condition property="repository.archive.exists">
<and>
<isset property="repository.archive"/>
<available file="${repository.archive}"/>
</and>
</condition>
<target name="update-repository-archive" if="repository.archive.exists">
<move file="${repository.archive}" tofile="${repository.archive}.tmp"/>
<zip destfile="${repository.archive}" update="true" keepcompression="true">
<fileset dir="${repository}" includes="content.jar,content.xml.xz,artifacts.jar,artifacts.xml.xz,p2.index"/>
<zipfileset src="${repository.archive}.tmp" excludes="content.xml,artifacts.xml,p2.index"/>
</zip>
<delete file="${repository.archive}.tmp"/>
</target>
<target name="process-repository" depends="transform-repository-xml,compress-repository-files,update-repository-archive"/>
</project>