我正在使用Flash Builder版本的Eclipse中的构建脚本。此构建脚本需要将启动配置.launch文件导入用户的工作区。但是,似乎没有可用的ANT var来确定工作空间位置。在使用intellisense逐步通过可用变量时,我注意到$ {osgi.instance.area}确实指向我当前的工作区,但是当我尝试在运行的ant脚本中回显它时,它只是吐出“$ {osgi.instance.area “而不是路径。
非常感谢任何帮助。谢谢!!!
答案 0 :(得分:0)
如果有人好奇,我是如何实现这一目标的,但这是专门为Flash Builder / Flex Builder量身定制的(因为这是我们团队使用的),不幸的是我永远无法让$ {eclipse.home}属性工作Ant所以我不得不使用$ {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>
答案 1 :(得分:0)
FWIW,我认为这可能会为您提供与解决方案的javascript部分类似的功能。对于实际使用,正则表达式可能过于简单。
<pathconvert property="install_loc" dirsep="/">
<path location="${eclipse.pdebuild.scripts}"/>
<regexpmapper from="(^.*/Adobe [^/]*)" to="\1/"/>
</pathconvert>
供参考:Ant pathconvert和mapper文档。
答案 2 :(得分:0)
这对我来说是一个常规的Eclipse安装,只要脚本在Eclipse自己的JVM中运行:
<eclipse.convertPath resourcepath="workspace_loc:/" property="eclipse.workspace.home"/>
为了表示Ant脚本应该在Eclipse自己的JVM中运行,打开“External Tools Configurations ...”对话框,从左侧面板中选择脚本,转到“JRE”选项卡,然后选择明显的无线电按钮。
Amnon Grossman