2010-05-13 86 views
3

我正在使用Flash Builder版本的Eclipse中的构建脚本。该构建脚本需要将启动配置.launch文件导入用户的工作区。但是,似乎没有可用的ANT var来确定工作区位置。在使用intellisense浏览可用的变量时,我注意到$ {osgi.instance.area}确实指向了我当前的工作区,但是当我尝试在运行的ant脚本中回显它时,它只是吐出“$ {osgi.instance.area }“而不是路径。使用ANT查找工作区位置

任何帮助将不胜感激。谢谢!!!

回答

0

如果有人在这里好奇,我是如何实现这一点的,但是这是专门为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> 
0

FWIW,我觉得这可能会给你类似的功能的JavaScript部分中的解。正则表达式对于真实世界的使用可能过于简单。

<pathconvert property="install_loc" dirsep="/"> 
    <path location="${eclipse.pdebuild.scripts}"/> 
    <regexpmapper from="(^.*/Adobe [^/]*)" to="\1/"/> 
</pathconvert> 

参考:蚂蚁pathconvertmapper文档。

+0

当我进入办公室时,我会给它一个镜头。谢谢马丁! – 2010-05-14 15:40:37

0

这个工作对我一个普通的Eclipse安装,提供脚本在Eclipse自己的JVM上运行:

<eclipse.convertPath resourcepath="workspace_loc:/" property="eclipse.workspace.home"/> 

为了表示Ant脚本应该在Eclipse自己的JVM上运行,打开“外部工具配置...“对话框,从左侧面板中选择脚本,转到”JRE“选项卡,然后选择明显的单选按钮。

Amnon Grossman

+0

我没有看到eclipse.workspace.home作为选项。 – prolink007 2012-01-05 16:28:56