我正在 Eclipse 的 Flash Builder 版本中编写构建脚本。此构建脚本需要将启动配置 .launch 文件导入用户的工作区。但是,似乎没有可用的 ANT 变量来确定工作区位置。在使用 intellisense 遍历可用变量时,我注意到 ${osgi.instance.area} 确实指向我当前的工作区,但是当我试图在运行的 ant 脚本中回显它时,它只是吐出 "${osgi.instance.area }"而不是路径。
如有任何帮助,我们将不胜感激。谢谢!!!
最佳答案
如果有人好奇我是如何做到这一点的,但是这是专门为 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>
关于apache-flex - 使用 ANT 查找工作区位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2828271/