我怎样才能在蚂蚁中编辑一个罐子的路径

时间:2011-04-26 16:26:23

标签: ant

我想基于操作系统替换现有jar的路径。

如下所示:
在windows中:C:/apps/workspace/libs/rpm.jar
在unix中:/user-id/projectname/libs/rpm.jar

有没有办法从C:/apps/workspace/libs/rpm.jar中删除C:/ apps / workspace / libs。

将我的问题编辑为:

谢谢Liv,但我有很多像这样的图书馆。现在我正在维护一个名为“build.start.properties”的文本文件,其中所有库都像这样。 /gwt/X/2.1.0/gwt-servlet.jar
/gwt/X/2.1.0/gwt-user.jar /gwt/X/2.1.0/gwt-dev.jar
/gwt/X/2.1.0/gwt-soyc-vis.jar /log4j/X/1.2.15/log4j-1.2.15.jar /GWT_LOG/X/3.0.3/gwt-log-3.0.3.jar /GWT_MATH/X/2.1/gwt-math-2.1.jar /GWT_MATH/X/2.1/gwt-math-server-2.1.jar /GWT_Commons_Logging/X/0.3/GWT-commons-logging/gwt-commons-logging-0.3.jar
/GWT_Commons_Logging/X/0.3/GWT-commons-logging/gwt-commons-logging-service-0.3.jar

使用低于目标

将它们加载到classptah

    <loadfile property="jars.list.property" srcfile="mybuild/build.start.properties">
        <filterchain>
            <expandproperties />
            <striplinecomments>
                <comment value="#" />
            </striplinecomments>
            <tokenfilter>
                <ignoreblank />
            </tokenfilter>
            <prefixlines prefix="," />
            <striplinebreaks />
        </filterchain>
    </loadfile>
    <filelist id="build.libs" dir="" files="${jars.list.property}" />

    <pathconvert targetos="unix" property="build_unix.libs" refid="build.libs">

        <map from="C:" to="${unix.xenv}" />
        <map from="" to="${unix.xenv}" />
    </pathconvert>
    <pathconvert targetos="windows" property="build_windows.libs" refid="build.libs">
        <map from="C:" to="${windows.xenv}" />
        <map from="" to="${windows.xenv}" />
    </pathconvert>
    <path id="build.classpath.id">
        <pathelement path="${build_windows.libs}" />
        <pathelement path="${build_unix.libs}" />
    </path>
    <echo message="Build Libraries classpath: ${toString:build.classpath.id}" />
</target>

从上面的目标build.classpath.id看起来像 /gwt/X/2.1.0/gwt-servlet.jar:/gwt/X/2.1.0/gwt-user.jar:/gwt/X/2.1.0/gwt-dev.jar:/gwt/X/ 2.1.0 / GWT-SOYC-vis.jar:/log4j/X/1.2.15/log4j-1.2.15.jar:/GWT_LOG/X/3.0.3/gwt-log-3.0.3.jar:GWT_MATH / X / 2.1 / GWT-数学2.1.jar:/GWT_MATH/X/2.1/gwt-math-server-2.1.jar:/GWT_Commons_Logging/X/0.3/GWT-commons-logging/gwt-commons-logging-0.3。罐子:/GWT_Commons_Logging/X/0.3/GWT-commons-logging/gwt-commons-logging-service-0.3.jar

当我在unix上工作时,我必须从文件“build.start.properties”中仅记录jar名称并更新这样的路径

/WebContent/WEB_INF/lib/gwt-servlet.jar:/WebContent/WEB_INF/lib/gwt-user.jar:/WebContent/WEB_INF/lib/gwt-dev.jar:/WebContent/WEB_INF/lib/gwt -soyc-vis.jar:/WebContent/WEB_INF/lib/log4j-1.2.15.jar:/WebContent/WEB_INF/lib/gwt-log-3.0.3.jar:/的WebContent / WEB_INF / LIB / GWT-MAT​​H- 2.1.jar:/WebContent/WEB_INF/lib/gwt-math-server-2.1.jar:/WebContent/WEB_INF/lib/gwt-commons-logging-0.3.jar:/的WebContent / WEB_INF / LIB / GWT-共享记录-service-0.3.jar

2 个答案:

答案 0 :(得分:0)

始终使用相对路径,这样您就不会依赖库位于给定位置和底层操作系统。

虽然这不符合您的要求,但从长远来看,这个建议会对您有所帮助。此外,如果可能,使用Ivy + Ant(或Maven)来管理依赖。

答案 1 :(得分:0)

您可以使用ant任务 - 文档(http://ant.apache.org/manual/Tasks/condition.html)中提供了以下内容:

<condition property="isMacOsButNotMacOsX">
    <and>
      <os family="mac"/>

      <not>
        <os family="unix"/>

      </not>
    </and>
</condition>
相关问题