我想替换基于操作系统的现有jar的路径。
像下面这样:
C:/apps/workspace/libs/rpm.jar
Unix:/user-id/projectname/libs/rpm.jar
有没有办法从C:/apps/workspace/libs/rpm.jar中删除C:/apps/workspace/libs ?
编辑我的问题到:
谢谢丽芙,但是我有很多这样的图书馆。现在我正在维护一个名为"build.start"的文本文件。所有库的属性都是这样的/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
并使用以下target
将它们加载到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-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
当我在unix上工作时,我只能从文件"build.start"中选择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-math-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-commons-logging-service-0.3.jar
始终使用相对路径,这样您就不会依赖于库位于给定位置和底层操作系统。
虽然这没有回答你的确切要求,但从长远来看,这个建议会对你有所帮助。此外,如果可能的话,使用Ivy + Ant(或Maven)来管理依赖关系。
您可以使用ant任务—以下内容摘自文档(http://ant.apache.org/manual/Tasks/condition.html):
)<condition property="isMacOsButNotMacOsX">
<and>
<os family="mac"/>
<not>
<os family="unix"/>
</not>
</and>
</condition>