我正在使用Flash Builder版本的Eclipse中的構建腳本。該構建腳本需要將啓動配置.launch文件導入用戶的工作區。但是,似乎沒有可用的ANT var來確定工作區位置。在使用intellisense瀏覽可用的變量時,我注意到$ {osgi.instance.area}確實指向了我當前的工作區,但是當我嘗試在運行的ant腳本中回顯它時,它只是吐出「$ {osgi.instance.area }「而不是路徑。使用ANT查找工作區位置
任何幫助將不勝感激。謝謝!!!
我正在使用Flash Builder版本的Eclipse中的構建腳本。該構建腳本需要將啓動配置.launch文件導入用戶的工作區。但是,似乎沒有可用的ANT var來確定工作區位置。在使用intellisense瀏覽可用的變量時,我注意到$ {osgi.instance.area}確實指向了我當前的工作區,但是當我嘗試在運行的ant腳本中回顯它時,它只是吐出「$ {osgi.instance.area }「而不是路徑。使用ANT查找工作區位置
任何幫助將不勝感激。謝謝!!!
如果有人在這裏好奇,我是如何實現這一點的,但是這是專門爲Flash Builder/Flex Builder(因爲這是我們團隊使用的)而定製的,不幸的是我永遠無法使$ {eclipse.home}屬性工作在螞蟻,所以我只好用$ {} eclipse.pdebuild.scripts拿到的安裝目錄:
<property name="install_loc" value=""/>
<!-- find the eclipse install location -->
<script language="javascript">
<![CDATA[
// Because ${eclipse.home} is not available, determine the install
// location using the pdebuild.scripts location
self.log("Looking for Eclipse installation...");
var base = project.getProperty("eclipse.pdebuild.scripts");
var path_pieces = base.split("/");
var path = "";
outterLoop: for(var i = path_pieces.length; i >= 0; --i)
{
if(path_pieces[i] == "Adobe Flash Builder 4" || path_pieces[i] == "Adobe Flex Builder 3")
{
// After determining which array item refers to the Adobe Flash Builder or Flex Builder
// installation, start at the beginning of the array and count up to that point, adding
// paths as you go.
var k = 0;
while(k <= i)
{
path += path_pieces[k] + "/";
++k;
}
break outterLoop;
}
}
// TODO: MAKE SURE THE PATH IS NOT EMPTY
self.log("Install path found at: " + path);
project.setProperty("install_loc", path);
]]>
</script>
<loadfile
property="workspace_prefs"
srcFile="${install_loc}configuration/.settings/org.eclipse.ui.ide.prefs">
</loadfile>
<property name="workspace_loc" value=""/>
<scriptdef name="find-workspace" language="javascript">
<attribute name="workspace_data"/>
<![CDATA[
// Find and return the workspace location
self.log("Looking for Eclipse workspace...");
var defs = attributes.get("workspace_data").split("=");
var loc = defs[defs.length - 1];
self.log("Workspace found: " + loc);
project.setProperty("workspace_loc", loc);
]]>
</scriptdef>
<find-workspace workspace_data="${workspace_prefs}" />
</target>
FWIW,我覺得這可能會給你類似的功能的JavaScript部分中的解。正則表達式對於真實世界的使用可能過於簡單。
<pathconvert property="install_loc" dirsep="/">
<path location="${eclipse.pdebuild.scripts}"/>
<regexpmapper from="(^.*/Adobe [^/]*)" to="\1/"/>
</pathconvert>
參考:螞蟻pathconvert和mapper文檔。
這個工作對我一個普通的Eclipse安裝,提供腳本在Eclipse自己的JVM上運行:
<eclipse.convertPath resourcepath="workspace_loc:/" property="eclipse.workspace.home"/>
爲了表示Ant腳本應該在Eclipse自己的JVM上運行,打開「外部工具配置...「對話框,從左側面板中選擇腳本,轉到」JRE「選項卡,然後選擇明顯的單選按鈕。
Amnon Grossman
我沒有看到eclipse.workspace.home作爲選項。 – prolink007 2012-01-05 16:28:56
當我進入辦公室時,我會給它一個鏡頭。謝謝馬丁! – 2010-05-14 15:40:37