2011-04-26 63 views
0

我想根据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在不同操作系统上工作时更新jar的相对路径

和装载他们用低于目标

<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到classptah看起来像 /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-数学服务器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

当我在UNIX上工作,我不得不从PIC文件“build.start.properties”只罐子名和更新路径这样

/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-math-2.1.jar:/WebContent/WEB_INF/lib/gwt-math-server-2.1。罐子:/WebContent/WEB_INF/lib/gwt-commons-logging-0.3.jar:/WebContent/WEB_INF/lib/gwt-commons-logging-service-0.3.jar

回答

0

使用条件

<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> 
+0

这不适用于我,因为在UNIX相对路径可能会根据用户更改。 – Jagan 2011-04-26 18:07:36

+0

因为你不仅要知道操作系统,还需要知道用户 – 2011-04-26 20:04:22

+0

你怎么知道你想要哪个用户? – 2011-04-26 20:04:56

相关问题