Retrieving a Directory List from SVN for Use in the ANT Drop-Down List

I have done something for Google, but I cannot find anything similar to what I need.

I am using ANTForms for the GUI for our deployment. Developers can select an assembly from a dynamically populated drop-down list , click OK and off.

The way to dynamically populate the drop-down list is currently carried out using ANT, calling the HTTP web service on our ColdFusion server, providing it with a list of the necessary SVN directories. Then CF uses a bit of Java underscore to invoke SVNKit and returns the query result for CF processing. It converts this to a comma separated list, outputs it to ANT, and then creates these dropdown lists.

I use CF because it is our main language. I don’t know any Java, but what annoys me a bit, if I know, I could get ANT to talk directly to Java / SVNKit and therefore completely disable CF. Probably, this will also eliminate the need for an HTTP call, since the SVN setting is local, so the speed increase there is +, this eliminates the dependence on an external source.

Has anyone done this or do you know any working examples that I could see that show ANT is talking to SVNKit directly to do such things?

I looked at the usual SVN ANT tasks in Subclipse, but they have no way to do this.

Any help appreciated James

+3
source share
1 answer

Instead of trying to create something in Java, why not generate an ANTForm configuration file using XLST based on the XML result generated by the standard subversion client:

svn list --xml http://svn.apache.org/repos/asf/ant/ivy/core/tags > releases.xml

The following release.xml file produces (for this I edited it):

<?xml version="1.0"?>
<lists>
  <list path="http://svn.apache.org/repos/asf/ant/ivy/core/tags">
    <entry ..>
      <name>1.4.1</name>
      ..
    </entry>
    <entry ..>
      <name>2.0.0</name>
      ..
    </entry>
  </list>
</lists>

Example

The example consists of two files.

  • genGUI.xml
  • genGUI.xsl

Follow these steps:

ant -f genGUI.xml

genGUI.xml

<project name="genGUI" default="run">

    <property name="repo.url"  value="http://svn.apache.org/repos/asf/ant/ivy/core/tags"/>
    <property name="build.dir" location="build"/>
    <property name="xsl.file"  location="genGUI.xsl"/>
    <property name="data.file" location="${build.dir}/data.xml"/>
    <property name="run.file"  location="${build.dir}/run.xml"/>

    <target name="init">
        <mkdir dir="${build.dir}"/>
    </target>

    <target name="get-data" depends="init">
        <exec executable="svn" failonerror="true" output="${data.file}">
            <arg line="list --xml ${repo.url}"/>
        </exec>
    </target>

    <target name="generate" depends="get-data">
        <xslt style="${xsl.file}" in="${data.file}" out="${run.file}"/>
    </target>

    <target name="run" depends="generate">
        <ant antfile="${run.file}"/>
    </target>

    <target name="clean">
        <delete dir="${build.dir}"/>
    </target>

</project>

genGUI.xsl

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="xml" indent="yes"/>

    <xsl:variable name="antform-home">${env.ANTFORM_HOME}</xsl:variable>

    <xsl:template match="/">
        <project name="genForm" default="menu">

            <property environment="env"/>

            <path id="runtime.cp">
                <pathelement location="{$antform-home}/lib/antform.jar"/>
            </path>

            <target name="menu">
                <taskdef name="antmenu" classname="com.sardak.antform.AntMenu" classpathref="runtime.cp"/>

                <antmenu image="{$antform-home}/doc/images/logo-small.jpg" title="My simple form" stylesheet="{$antform-home}/style.test">
                    <label>Form is generated from subversion</label>
                    <xsl:apply-templates select="lists/list/entry"/>
                </antmenu>
            </target>

        </project>
    </xsl:template>

    <xsl:template match="entry">
        <button label="{name}" target="{name}"/>
    </xsl:template>

</xsl:stylesheet>
+2

Source: https://habr.com/ru/post/1760720/


All Articles