<commit_before><!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
-->
<!--
   This build script expects two properties:
- version.qualifier : defines which version append to the version defined in the manifests.
                      It will probably be "alpha1", "beta4", "RC1" or even "patch-4".
- baseLocation      : the full path to the SDK version of Eclipse in order to build the binary jars.

   Properties could be set in the two files :
- build.properties       : properties shared between developers, so under version control.
                           The version.qualifier property should be set there.
- local.build.properties : properties handled by developers, ignored by subversion.
                           The baseLocation property should be set there.
-->
<project name="ivyde" basedir="." default="build" xmlns:ivy="antlib:org.apache.ivy.ant"
        xmlns:asciidoctor="antlib:org.asciidoctor.ant">

    <property file="local.build.properties"/>
    <property file="build.properties"/>
    <property environment="env"/>

    <property name="work.dir" value="${basedir}/work"/>
    <property name="ivy.work.dir" value="${work.dir}/ivy"/>
    <property name="doc.dir" value="${basedir}/doc"/>
    <property name="src.doc.dir" value="${doc.dir}/src"/>
    <property name="dist.dir" value="${basedir}/dist"/>
    <property name="dist.work.dir" value="${work.dir}/dist"/>
    <property name="dist.work.doc.dir" value="${dist.work.dir}/doc"/>
    <property name="eclipse.work.dir" value="${work.dir}/eclipse"/>
    <property name="eclipse-doc.dir" value="${basedir}/org.apache.ivyde.eclipse/doc"/>
    <property name="checkstyle.src.dir" value="${basedir}/org.apache.ivyde.eclipse/src/etc/checkstyle"/>
    <property name="checkstyle.report.dir" value="${basedir}/checkstyle/report"/>
    <property name="checkstyle.lib" value="${basedir}/checkstyle/lib"/>
    <property name="rat.dir" value="${work.dir}/rat"/>

    <target name="download-ivy" unless="ivy.jar.file">
        <property name="ivy.jar.url"  value="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"/>
        <property name="ivy.jar.dir"  value="${work.dir}"/>
        <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar"/>
        <mkdir dir="${ivy.jar.dir}"/>
        <get src="${ivy.jar.url}" dest="${ivy.jar.file}" usetimestamp="true"/>
    </target>

    <target name="init-ivy" depends="download-ivy">
        <path id="ivy.lib.path">
            <pathelement location="${ivy.jar.file}"/>
        </path>
        <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
    </target>

    <target name="init-asciidoctor-extensions" depends="init-ivy" unless="skip.doc">
        <ivy:cachepath pathid="asciidoctorj.path" organisation="org.asciidoctor" module="asciidoctorj" revision="1.5.6" inline="true"/>
        <mkdir dir="${work.dir}/asciidoc-extensions/classes"/>
        <javac srcdir="${doc.dir}/extensions/src" destdir="${work.dir}/asciidoc-extensions/classes"
               debug="true" includeantruntime="no" classpathref="asciidoctorj.path"/>
        <copy todir="${work.dir}/asciidoc-extensions/classes">
            <fileset dir="${doc.dir}/extensions/src">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>

    <target name="init-asciidoctor" depends="init-asciidoctor-extensions">
        <mkdir dir="${work.dir}/asciidoc-lib/jars" />
        <mkdir dir="${work.dir}/asciidoc-lib/classes" />
        <ivy:retrieve organisation="org.asciidoctor" module="asciidoctor-ant" revision="1.5.4" inline="true" pattern="${work.dir}/asciidoc-lib/jars/[artifact].[ext]" conf="default" />
        <unzip src="${work.dir}/asciidoc-lib/jars/asciidoctor-ant.jar" dest="${work.dir}/asciidoc-lib/classes" />
        <taskdef uri="antlib:org.asciidoctor.ant" resource="org/asciidoctor/ant/antlib.xml">
            <classpath>
                <pathelement location="${work.dir}/asciidoc-extensions/classes"/>
                <pathelement location="${work.dir}/asciidoc-lib/classes" />
            </classpath>
        </taskdef>
    </target>

    <target name="/release" description="Make the build artifacts tagged with the release version">
        <tstamp/>
        <condition property="forceContextQualifier" value="${DSTAMP}${TSTAMP}-RELEASE">
            <length string="${version.qualifier}" trim="true" length="0"/>
        </condition>
        <property name="forceContextQualifier" value="${version.qualifier}-${DSTAMP}${TSTAMP}-RELEASE"/>
    </target>

    <target name="dist" depends="generate-eclipse-doc,build,package-binaries,package-sources,checksum" description="Build every artifacts for distribution"/>

    <target name="clean" description="Remove every build artifacts">
        <delete dir="${work.dir}"/>
        <delete dir="${dist.dir}"/>
    </target>

    <target name="check-baseLocation">
        <property name="baseLocation" location="${basedir}/dependencies/${eclipse.download.sdk.name}"/>
        <fail message="An Eclipse install is needed to run the build. Set your Eclipse install dir in the 'baseLocation' property. Or run 'ant download-eclipse'">
            <condition>
                <not>
                    <available file="${baseLocation}"/>
                </not>
            </condition>
        </fail>
    </target>

    <target name="eclipse-startup-check" depends="check-baseLocation">
        <condition property="eclipse.startup">
            <available file="${baseLocation}/startup.jar"/>
        </condition>
    </target>

    <target name="eclipse-startup-classpath" depends="eclipse-startup-check" if="eclipse.startup">
        <property name="eclipse.classpath" value="${baseLocation}/startup.jar"/>
    </target>

    <target name="eclipse-launcher-classpath" depends="eclipse-startup-check" unless="eclipse.startup">
        <!-- store path to newest launcher JAR in path id 'newest.equinox.launcher.path.id' -->
        <path id="newest.equinox.launcher.path.id">
            <first count="1">
                <sort>
                    <fileset dir="${baseLocation}/plugins" includes="**/org.eclipse.equinox.launcher_*.jar"/>
                    <!-- Seems the default order is oldest > newest so we must reverse it.
                       The 'reverse' and 'date' comparators are in the internal antlib
                       org.apache.tools.ant.types.resources.comparators.
                    -->
                    <reverse xmlns="antlib:org.apache.tools.ant.types.resources.comparators">
                        <!-- 'date' inherits 'reverse's namespace -->
                        <date/>
                    </reverse>
                </sort>
            </first>
        </path>

        <!-- turn the path into a property -->
        <property name="eclipse.classpath" refid="newest.equinox.launcher.path.id"/>
    </target>

    <target name="eclipse-classpath" depends="eclipse-startup-classpath,eclipse-launcher-classpath">
        <echo message="Using equinox launcher jar: ${eclipse.classpath}"/>
    </target>

    <target name="compute-version">
        <tstamp/>
        <condition property="forceContextQualifier" value="${DSTAMP}${TSTAMP}-dev">
            <length string="${version.qualifier}" trim="true" length="0"/>
        </condition>
        <property name="forceContextQualifier" value="${version.qualifier}-${DSTAMP}${TSTAMP}-dev"/>
        <loadfile srcfile="org.apache.ivyde.eclipse/META-INF/MANIFEST.MF" property="build.version">
            <filterchain>
                <linecontainsregexp>
                    <regexp pattern="Bundle-Version:.*"/>
                </linecontainsregexp>
                <replaceregex pattern="Bundle-Version: (.*)qualifier" replace="\1${forceContextQualifier}"/>
                <striplinebreaks/>
            </filterchain>
        </loadfile>
        <echo message="Building version ${build.version}"/>
    </target>

    <!--
        ======================================================================================
        Build targets
        ======================================================================================
     -->

    <target name="build" depends="check-ivy-installed,eclipse-classpath,compute-version" description="Build the plugin distribution binaries">
        <java classpath="${eclipse.classpath}" classname="org.eclipse.core.launcher.Main" fork="true" failonerror="true" taskname="pde-build">
            <arg value="-clean"/>
            <arg line="-application org.eclipse.pde.build.Build"/>
            <sysproperty key="eclipse.consoleLog" value="${eclipse.consoleLog}"/>
            <sysproperty key="baseLocation" value="${baseLocation}"/>
            <sysproperty key="builder" path="${basedir}/builder/component"/>
            <sysproperty key="mapsPath" path="${basedir}/builder/maps"/>
            <sysproperty key="buildDirectory" path="${eclipse.work.dir}"/>
            <sysproperty key="DSTAMP" value="${DSTAMP}"/>
            <sysproperty key="TSTAMP" value="${TSTAMP}"/>
            <sysproperty key="forceContextQualifier" value="${forceContextQualifier}"/>
            <sysproperty key="outputUpdateJars" value="true"/>
            <sysproperty key="build.version" value="${build.version}"/>
            <sysproperty key="javacDebugInfo" value="true"/>
        </java>
    </target>

    <target name="generate-dist-doc-files" depends="compute-version">
        <property name="checkUpToDate" value="true"/>
        <condition property="overwrite">
            <isfalse value="${checkUpToDate}"/>
        </condition>
        <mkdir dir="${dist.work.dir}/apache-ivyde-${build.version}/doc"/>
        <copy todir="${dist.work.dir}/apache-ivyde-${build.version}/doc" overwrite="${overwrite}">
            <fileset dir="${src.doc.dir}">
                <include name="style/**"/>
                <include name="js/**"/>
                <include name="images/**"/>
            </fileset>
        </copy>
    </target>

    <target name="generate-dist-doc-book-adoc" depends="generate-dist-doc-files">
        <scriptdef name="generate-book-adoc" language="javascript">
            <attribute name="jsontocfile"/>
            <attribute name="destFile"/>
            <![CDATA[
                var tocfile = self.getProject().resolveFile(attributes.get("jsontocfile"))
                r = new java.io.BufferedReader(new java.io.FileReader(tocfile));
                var val = "";
                while((s = r.readLine()) != null) {
                    val += s;
                }
                r.close();
                var toc = eval("("+val+")")

                var writeToc = function(o, children, level) {
                    for(var c in children) {
                        if (children[c].id) {
                            o.write(level + ' link:#' + children[c].id.replace(/\//g, '_') + '[' + children[c].title + ']\n');
                            if (children[c].children && children[c].children.length && children[c].children.length != 0) {
                                writeToc(o, children[c].children, level+'*');
                            }
                        }
                    }
                };

                var writeInclude = function(o, children) {
                    for(var c in children) {
                        if (children[c].id) {
                            o.write('= [[' + children[c].id.replace(/\//g, '_') + ']]' + children[c].title + '\n\n');
                            o.write('include::../doc/src/' + children[c].id + '.adoc[]\n\n');
                            if (children[c].children && children[c].children.length && children[c].children.length != 0) {
                                writeInclude(o, children[c].children);
                            }
                        }
                    }
                };

                out = new java.io.FileWriter(self.getProject().resolveFile(attributes.get("destfile")));
                out.write('= Table of Contents\n\n');
                writeToc(out, toc.children[0].children, '*');
                out.write('\n\n');
                writeInclude(out, toc.children[0].children, '*');
                out.close();
            ]]>
        </scriptdef>
        <mkdir dir="${work.dir}/book"/>
        <generate-book-adoc jsontocfile="${src.doc.dir}/toc.json" destFile="${work.dir}/book/book.adoc"/>
    </target>

    <target name="generate-dist-doc-book" depends="compute-version,init-asciidoctor,generate-dist-doc-book-adoc">
        <asciidoctor:convert sourceDirectory="${work.dir}/book" outputDirectory="${dist.work.dir}/apache-ivyde-${build.version}/doc" backend="xhtml5"
                             templateDir="${doc.dir}/templates/book" sourceHighlighter="highlightjs" doctype="book">
            <attribute key="imagesdir" value=""/>
            <attribute key="version" value="${build.version}"/>
            <inlineMacroProcessor blockName="jira" className="org.apache.ivy.asciidoc.JiraMacro"/>
        </asciidoctor:convert>
    </target>

    <target name="generate-dist-doc-articles" depends="compute-version,init-asciidoctor">
        <asciidoctor:convert sourceDirectory="${src.doc.dir}" outputDirectory="${dist.work.dir}/apache-ivyde-${build.version}/doc" backend="xhtml5"
                             templateDir="${doc.dir}/templates/articles" sourceHighlighter="highlightjs" preserveDirectories="true">
            <attribute key="basedir" value="${src.doc.dir}"/>
            <attribute key="imagesdir" value=""/>
            <attribute key="version" value="${build.version}"/>
            <inlineMacroProcessor blockName="jira" className="org.apache.ivy.asciidoc.JiraMacro"/>
        </asciidoctor:convert>
    </target>

    <target name="generate-dist-doc-html" depends="generate-dist-doc-articles,generate-dist-doc-book"/>

    <target name="package-binaries" depends="build,generate-p2-category,generate-dist-doc-files,generate-dist-doc-html">
        <mkdir dir="${dist.work.dir}/apache-ivyde-${build.version}"/>
        <unzip src="${eclipse.work.dir}/${build.version}/org.apache.ivyde.feature-${build.version}.zip" dest="${dist.work.dir}/apache-ivyde-${build.version}"/>
        <unzip src="${eclipse.work.dir}/${build.version}/org.apache.ivyde.eclipse.resolvevisualizer.feature-${build.version}.zip" dest="${dist.work.dir}/apache-ivyde-${build.version}"/>
        <!-- packaging the zip as a p2 repository -->
        <copy todir="${dist.work.dir}/apache-ivyde-${build.version}">
            <fileset dir="${eclipse.work.dir}/p2repo"/>
        </copy>
        <copy todir="${dist.work.dir}/apache-ivyde-${build.version}">
            <fileset dir="${basedir}">
                <include name="LICENSE"/>
                <include name="NOTICE"/>
                <include name="CHANGES.txt"/>
                <include name="README.txt"/>
            </fileset>
        </copy>
        <mkdir dir="${dist.dir}"/>
        <zip destfile="${dist.dir}/apache-ivyde-${build.version}.zip" basedir="${dist.work.dir}"/>
        <tar destfile="${dist.dir}/apache-ivyde-${build.version}.tar.gz" basedir="${dist.work.dir}" compression="gzip"/>
        <!-- put the version in a file so it will be easier in the build of the
             updatesite on jenkins to find out which version it is -->
        <echo file="${dist.dir}/version.properties">
ivyde.build.version=${build.version}
        </echo>
    </target>

    <target name="package-sources" depends="compute-version" description="Create source archive files">
        <delete dir="${work.dir}/sources"/>
        <mkdir dir="${work.dir}/sources"/>
        <exec executable="git" dir="${basedir}" >
            <arg value="archive"/>
            <arg value="HEAD"/>
            <arg value="-o"/>
            <arg value="${dist.dir}/apache-ivyde-sources-${build.version}.tar.gz"/>
        </exec>
        <exec executable="git" dir="${basedir}" >
            <arg value="archive"/>
            <arg value="HEAD"/>
            <arg value="-o"/>
            <arg value="${dist.dir}/apache-ivyde-sources-${build.version}.zip"/>
        </exec>
    </target>


    <target name="generate-p2-category" depends="compute-version,eclipse-classpath">
        <loadfile property="ASL2-header" srcFile="${basedir}/builder/ASL2-header.xml"/>
        <echo file="${work.dir}/category.xml"><![CDATA[<?xml version='1.0' encoding='UTF-8'?>
<site>
    <category-def name="org.apache.ivyde.category" label="Apache IvyDE Eclipse plugins"/>
    <feature url="features/org.apache.ivyde.feature_${build.version}.jar" id="org.apache.ivyde.feature" version="${build.version}">
        <category name="org.apache.ivyde.category"/>
    </feature>
    <feature url="features/org.apache.ivyde.eclipse.resolvevisualizer.feature_${build.version}.jar" id="org.apache.ivyde.eclipse.resolvevisualizer.feature" version="${build.version}">
        <category name="org.apache.ivyde.category"/>
    </feature>
</site>
]]></echo><commit_msg>Package the sources within a version specific root directory<commit_after><!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
-->
<!--
   This build script expects two properties:
- version.qualifier : defines which version append to the version defined in the manifests.
                      It will probably be "alpha1", "beta4", "RC1" or even "patch-4".
- baseLocation      : the full path to the SDK version of Eclipse in order to build the binary jars.

   Properties could be set in the two files :
- build.properties       : properties shared between developers, so under version control.
                           The version.qualifier property should be set there.
- local.build.properties : properties handled by developers, ignored by subversion.
                           The baseLocation property should be set there.
-->
<project name="ivyde" basedir="." default="build" xmlns:ivy="antlib:org.apache.ivy.ant"
        xmlns:asciidoctor="antlib:org.asciidoctor.ant">

    <property file="local.build.properties"/>
    <property file="build.properties"/>
    <property environment="env"/>

    <property name="work.dir" value="${basedir}/work"/>
    <property name="ivy.work.dir" value="${work.dir}/ivy"/>
    <property name="doc.dir" value="${basedir}/doc"/>
    <property name="src.doc.dir" value="${doc.dir}/src"/>
    <property name="dist.dir" value="${basedir}/dist"/>
    <property name="dist.work.dir" value="${work.dir}/dist"/>
    <property name="dist.work.doc.dir" value="${dist.work.dir}/doc"/>
    <property name="eclipse.work.dir" value="${work.dir}/eclipse"/>
    <property name="eclipse-doc.dir" value="${basedir}/org.apache.ivyde.eclipse/doc"/>
    <property name="checkstyle.src.dir" value="${basedir}/org.apache.ivyde.eclipse/src/etc/checkstyle"/>
    <property name="checkstyle.report.dir" value="${basedir}/checkstyle/report"/>
    <property name="checkstyle.lib" value="${basedir}/checkstyle/lib"/>
    <property name="rat.dir" value="${work.dir}/rat"/>

    <target name="download-ivy" unless="ivy.jar.file">
        <property name="ivy.jar.url"  value="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"/>
        <property name="ivy.jar.dir"  value="${work.dir}"/>
        <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar"/>
        <mkdir dir="${ivy.jar.dir}"/>
        <get src="${ivy.jar.url}" dest="${ivy.jar.file}" usetimestamp="true"/>
    </target>

    <target name="init-ivy" depends="download-ivy">
        <path id="ivy.lib.path">
            <pathelement location="${ivy.jar.file}"/>
        </path>
        <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
    </target>

    <target name="init-asciidoctor-extensions" depends="init-ivy" unless="skip.doc">
        <ivy:cachepath pathid="asciidoctorj.path" organisation="org.asciidoctor" module="asciidoctorj" revision="1.5.6" inline="true"/>
        <mkdir dir="${work.dir}/asciidoc-extensions/classes"/>
        <javac srcdir="${doc.dir}/extensions/src" destdir="${work.dir}/asciidoc-extensions/classes"
               debug="true" includeantruntime="no" classpathref="asciidoctorj.path"/>
        <copy todir="${work.dir}/asciidoc-extensions/classes">
            <fileset dir="${doc.dir}/extensions/src">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>

    <target name="init-asciidoctor" depends="init-asciidoctor-extensions">
        <mkdir dir="${work.dir}/asciidoc-lib/jars" />
        <mkdir dir="${work.dir}/asciidoc-lib/classes" />
        <ivy:retrieve organisation="org.asciidoctor" module="asciidoctor-ant" revision="1.5.4" inline="true" pattern="${work.dir}/asciidoc-lib/jars/[artifact].[ext]" conf="default" />
        <unzip src="${work.dir}/asciidoc-lib/jars/asciidoctor-ant.jar" dest="${work.dir}/asciidoc-lib/classes" />
        <taskdef uri="antlib:org.asciidoctor.ant" resource="org/asciidoctor/ant/antlib.xml">
            <classpath>
                <pathelement location="${work.dir}/asciidoc-extensions/classes"/>
                <pathelement location="${work.dir}/asciidoc-lib/classes" />
            </classpath>
        </taskdef>
    </target>

    <target name="/release" description="Make the build artifacts tagged with the release version">
        <tstamp/>
        <condition property="forceContextQualifier" value="${DSTAMP}${TSTAMP}-RELEASE">
            <length string="${version.qualifier}" trim="true" length="0"/>
        </condition>
        <property name="forceContextQualifier" value="${version.qualifier}-${DSTAMP}${TSTAMP}-RELEASE"/>
    </target>

    <target name="dist" depends="generate-eclipse-doc,build,package-binaries,package-sources,checksum" description="Build every artifacts for distribution"/>

    <target name="clean" description="Remove every build artifacts">
        <delete dir="${work.dir}"/>
        <delete dir="${dist.dir}"/>
    </target>

    <target name="check-baseLocation">
        <property name="baseLocation" location="${basedir}/dependencies/${eclipse.download.sdk.name}"/>
        <fail message="An Eclipse install is needed to run the build. Set your Eclipse install dir in the 'baseLocation' property. Or run 'ant download-eclipse'">
            <condition>
                <not>
                    <available file="${baseLocation}"/>
                </not>
            </condition>
        </fail>
    </target>

    <target name="eclipse-startup-check" depends="check-baseLocation">
        <condition property="eclipse.startup">
            <available file="${baseLocation}/startup.jar"/>
        </condition>
    </target>

    <target name="eclipse-startup-classpath" depends="eclipse-startup-check" if="eclipse.startup">
        <property name="eclipse.classpath" value="${baseLocation}/startup.jar"/>
    </target>

    <target name="eclipse-launcher-classpath" depends="eclipse-startup-check" unless="eclipse.startup">
        <!-- store path to newest launcher JAR in path id 'newest.equinox.launcher.path.id' -->
        <path id="newest.equinox.launcher.path.id">
            <first count="1">
                <sort>
                    <fileset dir="${baseLocation}/plugins" includes="**/org.eclipse.equinox.launcher_*.jar"/>
                    <!-- Seems the default order is oldest > newest so we must reverse it.
                       The 'reverse' and 'date' comparators are in the internal antlib
                       org.apache.tools.ant.types.resources.comparators.
                    -->
                    <reverse xmlns="antlib:org.apache.tools.ant.types.resources.comparators">
                        <!-- 'date' inherits 'reverse's namespace -->
                        <date/>
                    </reverse>
                </sort>
            </first>
        </path>

        <!-- turn the path into a property -->
        <property name="eclipse.classpath" refid="newest.equinox.launcher.path.id"/>
    </target>

    <target name="eclipse-classpath" depends="eclipse-startup-classpath,eclipse-launcher-classpath">
        <echo message="Using equinox launcher jar: ${eclipse.classpath}"/>
    </target>

    <target name="compute-version">
        <tstamp/>
        <condition property="forceContextQualifier" value="${DSTAMP}${TSTAMP}-dev">
            <length string="${version.qualifier}" trim="true" length="0"/>
        </condition>
        <property name="forceContextQualifier" value="${version.qualifier}-${DSTAMP}${TSTAMP}-dev"/>
        <loadfile srcfile="org.apache.ivyde.eclipse/META-INF/MANIFEST.MF" property="build.version">
            <filterchain>
                <linecontainsregexp>
                    <regexp pattern="Bundle-Version:.*"/>
                </linecontainsregexp>
                <replaceregex pattern="Bundle-Version: (.*)qualifier" replace="\1${forceContextQualifier}"/>
                <striplinebreaks/>
            </filterchain>
        </loadfile>
        <echo message="Building version ${build.version}"/>
    </target>

    <!--
        ======================================================================================
        Build targets
        ======================================================================================
     -->

    <target name="build" depends="check-ivy-installed,eclipse-classpath,compute-version" description="Build the plugin distribution binaries">
        <java classpath="${eclipse.classpath}" classname="org.eclipse.core.launcher.Main" fork="true" failonerror="true" taskname="pde-build">
            <arg value="-clean"/>
            <arg line="-application org.eclipse.pde.build.Build"/>
            <sysproperty key="eclipse.consoleLog" value="${eclipse.consoleLog}"/>
            <sysproperty key="baseLocation" value="${baseLocation}"/>
            <sysproperty key="builder" path="${basedir}/builder/component"/>
            <sysproperty key="mapsPath" path="${basedir}/builder/maps"/>
            <sysproperty key="buildDirectory" path="${eclipse.work.dir}"/>
            <sysproperty key="DSTAMP" value="${DSTAMP}"/>
            <sysproperty key="TSTAMP" value="${TSTAMP}"/>
            <sysproperty key="forceContextQualifier" value="${forceContextQualifier}"/>
            <sysproperty key="outputUpdateJars" value="true"/>
            <sysproperty key="build.version" value="${build.version}"/>
            <sysproperty key="javacDebugInfo" value="true"/>
        </java>
    </target>

    <target name="generate-dist-doc-files" depends="compute-version">
        <property name="checkUpToDate" value="true"/>
        <condition property="overwrite">
            <isfalse value="${checkUpToDate}"/>
        </condition>
        <mkdir dir="${dist.work.dir}/apache-ivyde-${build.version}/doc"/>
        <copy todir="${dist.work.dir}/apache-ivyde-${build.version}/doc" overwrite="${overwrite}">
            <fileset dir="${src.doc.dir}">
                <include name="style/**"/>
                <include name="js/**"/>
                <include name="images/**"/>
            </fileset>
        </copy>
    </target>

    <target name="generate-dist-doc-book-adoc" depends="generate-dist-doc-files">
        <scriptdef name="generate-book-adoc" language="javascript">
            <attribute name="jsontocfile"/>
            <attribute name="destFile"/>
            <![CDATA[
                var tocfile = self.getProject().resolveFile(attributes.get("jsontocfile"))
                r = new java.io.BufferedReader(new java.io.FileReader(tocfile));
                var val = "";
                while((s = r.readLine()) != null) {
                    val += s;
                }
                r.close();
                var toc = eval("("+val+")")

                var writeToc = function(o, children, level) {
                    for(var c in children) {
                        if (children[c].id) {
                            o.write(level + ' link:#' + children[c].id.replace(/\//g, '_') + '[' + children[c].title + ']\n');
                            if (children[c].children && children[c].children.length && children[c].children.length != 0) {
                                writeToc(o, children[c].children, level+'*');
                            }
                        }
                    }
                };

                var writeInclude = function(o, children) {
                    for(var c in children) {
                        if (children[c].id) {
                            o.write('= [[' + children[c].id.replace(/\//g, '_') + ']]' + children[c].title + '\n\n');
                            o.write('include::../doc/src/' + children[c].id + '.adoc[]\n\n');
                            if (children[c].children && children[c].children.length && children[c].children.length != 0) {
                                writeInclude(o, children[c].children);
                            }
                        }
                    }
                };

                out = new java.io.FileWriter(self.getProject().resolveFile(attributes.get("destfile")));
                out.write('= Table of Contents\n\n');
                writeToc(out, toc.children[0].children, '*');
                out.write('\n\n');
                writeInclude(out, toc.children[0].children, '*');
                out.close();
            ]]>
        </scriptdef>
        <mkdir dir="${work.dir}/book"/>
        <generate-book-adoc jsontocfile="${src.doc.dir}/toc.json" destFile="${work.dir}/book/book.adoc"/>
    </target>

    <target name="generate-dist-doc-book" depends="compute-version,init-asciidoctor,generate-dist-doc-book-adoc">
        <asciidoctor:convert sourceDirectory="${work.dir}/book" outputDirectory="${dist.work.dir}/apache-ivyde-${build.version}/doc" backend="xhtml5"
                             templateDir="${doc.dir}/templates/book" sourceHighlighter="highlightjs" doctype="book">
            <attribute key="imagesdir" value=""/>
            <attribute key="version" value="${build.version}"/>
            <inlineMacroProcessor blockName="jira" className="org.apache.ivy.asciidoc.JiraMacro"/>
        </asciidoctor:convert>
    </target>

    <target name="generate-dist-doc-articles" depends="compute-version,init-asciidoctor">
        <asciidoctor:convert sourceDirectory="${src.doc.dir}" outputDirectory="${dist.work.dir}/apache-ivyde-${build.version}/doc" backend="xhtml5"
                             templateDir="${doc.dir}/templates/articles" sourceHighlighter="highlightjs" preserveDirectories="true">
            <attribute key="basedir" value="${src.doc.dir}"/>
            <attribute key="imagesdir" value=""/>
            <attribute key="version" value="${build.version}"/>
            <inlineMacroProcessor blockName="jira" className="org.apache.ivy.asciidoc.JiraMacro"/>
        </asciidoctor:convert>
    </target>

    <target name="generate-dist-doc-html" depends="generate-dist-doc-articles,generate-dist-doc-book"/>

    <target name="package-binaries" depends="build,generate-p2-category,generate-dist-doc-files,generate-dist-doc-html">
        <mkdir dir="${dist.work.dir}/apache-ivyde-${build.version}"/>
        <unzip src="${eclipse.work.dir}/${build.version}/org.apache.ivyde.feature-${build.version}.zip" dest="${dist.work.dir}/apache-ivyde-${build.version}"/>
        <unzip src="${eclipse.work.dir}/${build.version}/org.apache.ivyde.eclipse.resolvevisualizer.feature-${build.version}.zip" dest="${dist.work.dir}/apache-ivyde-${build.version}"/>
        <!-- packaging the zip as a p2 repository -->
        <copy todir="${dist.work.dir}/apache-ivyde-${build.version}">
            <fileset dir="${eclipse.work.dir}/p2repo"/>
        </copy>
        <copy todir="${dist.work.dir}/apache-ivyde-${build.version}">
            <fileset dir="${basedir}">
                <include name="LICENSE"/>
                <include name="NOTICE"/>
                <include name="CHANGES.txt"/>
                <include name="README.txt"/>
            </fileset>
        </copy>
        <mkdir dir="${dist.dir}"/>
        <zip destfile="${dist.dir}/apache-ivyde-${build.version}.zip" basedir="${dist.work.dir}"/>
        <tar destfile="${dist.dir}/apache-ivyde-${build.version}.tar.gz" basedir="${dist.work.dir}" compression="gzip"/>
        <!-- put the version in a file so it will be easier in the build of the
             updatesite on jenkins to find out which version it is -->
        <echo file="${dist.dir}/version.properties">
ivyde.build.version=${build.version}
        </echo>
    </target>

    <target name="package-sources" depends="compute-version" description="Create source archive files">
        <mkdir dir="${dist.dir}"/>
        <exec executable="git" dir="${basedir}" >
            <arg value="archive"/>
            <arg value="HEAD"/>
            <arg value="--prefix=apache-ivyde-sources-${build.version}/"/>
            <arg value="-o"/>
            <arg value="${dist.dir}/apache-ivyde-sources-${build.version}.tar.gz"/>
        </exec>
        <exec executable="git" dir="${basedir}" >
            <arg value="archive"/>
            <arg value="HEAD"/>
            <arg value="--prefix=apache-ivyde-sources-${build.version}/"/>
            <arg value="-o"/>
            <arg value="${dist.dir}/apache-ivyde-sources-${build.version}.zip"/>
        </exec>
    </target>


    <target name="generate-p2-category" depends="compute-version,eclipse-classpath">
        <loadfile property="ASL2-header" srcFile="${basedir}/builder/ASL2-header.xml"/>
        <echo file="${work.dir}/category.xml"><![CDATA[<?xml version='1.0' encoding='UTF-8'?>
<site>
    <category-def name="org.apache.ivyde.category" label="Apache IvyDE Eclipse plugins"/>
    <feature url="features/org.apache.ivyde.feature_${build.version}.jar" id="org.apache.ivyde.feature" version="${build.version}">
        <category name="org.apache.ivyde.category"/>
    </feature>
    <feature url="features/org.apache.ivyde.eclipse.resolvevisualizer.feature_${build.version}.jar" id="org.apache.ivyde.eclipse.resolvevisualizer.feature" version="${build.version}">
        <category name="org.apache.ivyde.category"/>
    </feature>
</site>
]]></echo>
{'fraction_non_alphanumeric': 0.1757040773434216, 'fraction_numerical': 0.001961608518985568, 'mean_word_length': 2.5682431756824315, 'pattern_counts': {'":': 0, '<': 468, '<?xml version=': 2, '>': 470, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 16}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1906729', 'n_tokens_mistral': 10215, 'n_tokens_neox': 9926, 'n_words': 1839}