Find workspace location with ANT

I am working on a script construct in the Flash Builder version of Eclipse. This build script should import the .launch startup configuration files into the user's workspace. However, there is no ANT var available to determine the location of the workspace. Going through the available vars with intellisense, I noticed that $ {osgi.instance.area} points to my current workspace, but when I tried to repeat it back in the running ANT script, it just spat out "$ {osgi.instance.area} ", not the way.

Any help would be greatly appreciated. Thank!!!

+3
source share
3 answers

If anyone is interested, this is how I achieved it, however it is specially adapted for Flash Builder / Flex Builder (as our team does), and, unfortunately, I was never able to get the $ {eclipse.home} property to work in Ant, so I had to use $ {eclipse.pdebuild.scripts} to get into the installation directory:

  

    <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
source

FWIW, I think it can give you similar functionality for the JavaScript part of your solution. Regular expression may be too simplified for real use.

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

For reference: Ant pathconvert and mapper .

0
source

Eclipse, script JVM Eclipse:

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

To denote an Ant script, it should run in its own Eclipse JVM, open the "External Instrument Configurations ..." dialog box, select a script from the left pane, go to the "JRE" tab, and select the obvious switch.

Amnon Grossman

0
source

Source: https://habr.com/ru/post/1745307/


All Articles