Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ant 在不同操作系统上工作时更新jar的相对路径_Ant - Fatal编程技术网

Ant 在不同操作系统上工作时更新jar的相对路径

Ant 在不同操作系统上工作时更新jar的相对路径,ant,Ant,我想替换基于OS的现有jar的路径。 现在,我正在维护一个名为“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.ja

我想替换基于OS的现有jar的路径。 现在,我正在维护一个名为“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看起来像 /1.1.1.0/gwt/2.1/2.1.0/2.1/2.1/2.1.0/gwt-1.1.0/gwt-1.1.0/gwt-dev-1.1.1/2.1/2.1/2.1/2.0/gwt/2.1/2.1/gwt/2.1/2.1/2.1/1/2.1/1/2.1/2.1/2.1/2.1/2.1/2.1/2.1/2.1/2.1/2.1.1.1.1.1.1.1.1.1/1/1/1/1/1/1/1/1/1/1/2.1.1.1.1.1.1.1.1.1.1.1.1/1/1/1/2.1.1.1/1/1/1.1/1/Logging/gwt-Commons-Logging-0.3.jar:/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-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-math-2.1.jar:/WebContent/lib/gwt/lib/gwt-commons-logging-0.3.jar:/WebContent/WEB_-INF/lib/gwt-commons-logging-service-0.3.jar使用条件

<condition property="isWindows">
<os family="windows" />
</condition>
<condition property="isUnix">
    <os family="unix" />
</condition>

On the targets then u can use

<target name="path_if_unix" if="isUnix">
    <map from="C:" to="${unix.xenv}" />
    <map from="" to="${unix.xenv}" />
</target>

在目标上,然后你可以使用

这对我不起作用,因为在UNix上,相对路径可能会根据用户的不同而变化。您需要重新表述您的问题,然后。。。既然你不仅想知道操作系统,还想知道用户,你怎么知道你想要哪个用户?