从 SVN 获取目录列表以用于 ANT 下拉列表 [英] Getting directory listing from SVN for use in ANT dropdown

查看:26
本文介绍了从 SVN 获取目录列表以用于 ANT 下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经对此进行了一些谷歌搜索,但似乎找不到符合我需要的任何内容.

I've done some Googling on this but I can't seem to find anything along the lines of what I'm needing.

我在我们的部署中使用 ANTForms 作为 GUI.开发人员可以从动态填充的下拉列表中选择构建,点击确定即可.

I'm using ANTForms for the GUI on our deployment. Developers can choose the build from the dynamically populated dropdown, hit ok and away it goes.

目前动态填充下拉列表的方式是 ANT 向我们的 ColdFusion 服务器发出 HTTP 网络服务调用,并提供所需的 SVN 目录列表.CF然后使用一点下划线Java调用SVNKit并返回查询结果供CF处理.它将其转换为逗号分隔的列表,为 ANT 输出它,然后构建这些下拉选项.

The way the dropdown is dynamically populated at the moment is by ANT making an HTTP webservice call to our ColdFusion server giving it a list of needed SVN directories. CF then uses a bit of underlining Java to call SVNKit and return a query result for CF to process. It converts this to a comma-separated list, outputs it for ANT and it then builds these dropdowns options.

我使用 CF 是因为这是我们的主要语言.我真的不知道任何 Java,但这里让我有点烦恼的是,如果我知道我可以让 ANT 直接与 Java/SVNKit 对话,从而完全切掉 CF 的图片.它还可能消除对 HTTP 调用的需要,因为 SVN 设置是本地的,因此速度有所提高 + 消除了对外部源的依赖.

I'm using CF because that's our main language. I don't really know any Java but what's bugging me a bit here is if I did I know I could get ANT to talk to Java / SVNKit directly and therefore cut CF out the picture completely. It would probably also remove the need for the HTTP call as the SVN setup is local so a speed increase is there + it takes out the reliance on a external source.

有没有人做过这件事,或者你知道我能看到的任何工作示例表明 ANT 直接与 SVNKit 对话来做这种事情?

Has anyone done this or do you know any working examples I could see that show ANT talking to SVNKit directly to do this kind of thing?

我在 Subclipse 上查看了通常的 SVN ANT 任务,但他们没有任何方法可以做到这一点.

I had a look at the usual SVN ANT tasks over at Subclipse but they don't have any way of doing this.

任何帮助表示赞赏,詹姆斯

Any help appreciated, James

推荐答案

与其尝试用 Java 构建某些东西,不如根据标准 Subversion 客户端生成的 XML 输出,使用 XLST 生成您的 ANTForm 配置文件:

Rather than trying to build something in Java why not generate your ANTForm configuration file using XLST, based on the XML output produced by the standard subversion client:

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

生成以下 releases.xml 文件(为了清晰起见,我对其进行了编辑):

Produces the following releases.xml file (I've edited it for clarity):

<?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

Example is comprised of two files

  • genGUI.xml
  • genGUI.xsl

运行如下:

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>

这篇关于从 SVN 获取目录列表以用于 ANT 下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆