Re: wolips preferences file

From: Kieran Kelleher (kieran_list..ac.com)
Date: Tue Dec 22 2009 - 10:28:43 EST

  • Next message: David Avendasora: "Re: wolips preferences file"

    FYI, Just to followup on this.........

    Well, it works, but the biggest PITA was the jumping thru hoops to
    assign a filepath-containing-spaces to a variable and then to feed it
    into awk. What a bunch of garbage. All because the "Application
    Support" dir has a stupid space in it. Also the trick is to convert
    the property names by replacing .'s, etc with underscores, otherwise
    bash balks. The result is that I get a bunch of shell variables
    defined as follows (when run in Linux for example) as a result of the
    WOLips properties workspace preference:

    org_objectstyle_wolips_preference_AutoEOGenerateOnBuild=true
    org_objectstyle_wolips_preference_CapureAntOutput=true
    org_objectstyle_wolips_wolipsPropertiesFile=wolips.533.properties
    wo_apps_root=/var/wo533/Library/WebObjects/Applications
    wo_bootstrapjar=/var/wo533/Library/WebObjects/JavaApplications/
    wotaskd.woa/WOBootstrap.jar
    wo_extensions=/Library/WebObjects/NoExtensions
    wo_local_frameworks=/var/wo533//Library/Frameworks
    wo_local_root=/
    wo_network_frameworks=/Network/Library/Frameworks
    wo_network_root=/Network
    wo_system_frameworks=/var/wo533/Library/Frameworks
    wo_system_root=/var/wo533/System
    wo_user_frameworks=/home/admin/Library/Frameworks
    wo_user_root=/home/admin

    Here is a little snippet from preflight portion of the script in case
    some other poor soul wants to incorporate such unstructured antiquated
    obscure twiddling with custom wolips props in workspace bash
    scripts! :-)

    <snip>
    ############# Begin Utility Functions #############

    ## Works for scripts executed like this:
    # ./doscript.sh
    # /opt/scripts/doscript.sh
    # ./mydir/scripts/anotherdir/doscript.sh
    function script_dir {
         CUR_WORKING_DIR=`pwd`
         SCRIPT_EXEC_CMD=$0
         SCRIPT_EXEC_DIR=`dirname $0`
         cd $SCRIPT_EXEC_DIR
         SCRIPT_DIR=`pwd`
         ## go back to working dir
         cd $CUR_WORKING_DIR
         echo "$SCRIPT_DIR"
    }

    ## Get parent dir of a file or dir
    # the arg can have a trailing / and it still works
    function parent_dir {
         FILE_TO_CHECK=$1
         # Remove trailing / if exists
         FILE_NO_SLASH="${FILE_TO_CHECK%/}"
         # Get parent dir
         PARENT_DIR="${FILE_NO_SLASH%/*}"
         echo "$PARENT_DIR"
    }

    ## Gets eclipse workspace dir
    ## looks for presence of a dir named ".metadata/.plugins/
    org.eclipse.core.runtime"
    function eclipse_workspace {

         # Get the script dir
         WKSPACE_DIR=`script_dir`

         while [ -z ${ECLIPSE_WORKSPACE} ]; do
                 # get parent dir
                 WKSPACE_DIR=`parent_dir $WKSPACE_DIR`
                 if [ -d "${WKSPACE_DIR}/.metadata/.plugins/
    org.eclipse.core.runtime" ]; then
                         ECLIPSE_WORKSPACE=$WKSPACE_DIR
                 fi
         done

         echo "$ECLIPSE_WORKSPACE"
    }

    ## reads in a java-style properties file, replacing non-alpha-digit-
    underscore characters in the property names with underscore
    function read_properties_file {
            # For both linux/osx compatability we need to use mktemp -t form and
    pick a reasonably unique name
            TEMPFILE=$(mktemp -t "wolips.tmp."`date +"%Y%m%d_%H%M%S"`)
            cat ${1} | \
            awk 'BEGIN { FS="="; } \
            /^\#/ { print; } \
            !/^\#/ { if (NF == 2) { n = $1; gsub(/[^A-Za-z0-9_]/,"_",n); print n
    "=\"" $2 "\""; } else { print; } }' \
    >$TEMPFILE
            source $TEMPFILE
            rm $TEMPFILE
    }

    ############# End Utility Functions #############

    # Read in the eclipse workspace wolips preferences file. It complains
    on two properties that we don't care about, but it successfully
    # reads and sets the other properties
    read_properties_file `eclipse_workspace`/.metadata/.plugins/
    org.eclipse.core.runtime/.settings/
    org.objectstyle.wolips.preferences.prefs

    # Stupidity because bash scripts cannot handle spaces in filenames in
    an efficient and effective way
    # Google for 'bash filenames with spaces' and you will find this
    solution appears to be the only one
    # This step is slow as molasses in OS X Tiger, but instantly fast in
    Linux - go figure
    find "${HOME}/Library" -path "*/Application Support/WOLips*" -name "$
    {org_objectstyle_wolips_wolipsPropertiesFile}" | while read
    WOLIPS_PROPERTIES_FILE; do
            echo "processing $WOLIPS_PROPERTIES_FILE"
            if [ -e "$WOLIPS_PROPERTIES_FILE" ]; then
                    # And because the awk function pukes if we quote the variable, we
    just ln this path-with-spaces
                    # to a temporary file path with no spaces and then proceed in the
    usual care-free scripting way
                    ln -sfF "$WOLIPS_PROPERTIES_FILE" /tmp/$
    {org_objectstyle_wolips_wolipsPropertiesFile}
            fi
    done

    read_properties_file /tmp/${org_objectstyle_wolips_wolipsPropertiesFile}

    # Check if it worked
    echo "wo_local_frameworks is ${wo_local_frameworks}"
    </snip>

    On Dec 21, 2009, at 1:49 PM, Kieran Kelleher wrote:

    > Good idea Jeremy. Made two clean workspaces with this property
    > different in both and used diff tool.
    >
    > Turns out the value is in a plain Properties formatted file at:
    >
    > workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/
    > org.objectstyle.wolips.preferences.prefs
    >
    > and the property is:
    > org
    > .objectstyle.wolips.wolipsPropertiesFile=<wolips_properties_file_name>
    >
    > Great ...... I can just grab the property from there and stuff it
    > into ant build files and bash scripts. .... much better than David
    > Avendasora's complex workaround on the wiki ;-)
    >
    > Regards, Kieran
    >
    > PS. Just kidding with ya David A. :-)
    >
    >
    > On Dec 21, 2009, at 1:14 PM, Jeremy Matthews wrote:
    >
    >> Diffing tool?
    >>
    >> -j
    >>
    >> On Dec 21, 2009, at 11:56 AM, Kieran Kelleher wrote:
    >>
    >>> I have a bash script that runs relative to the workspace and I
    >>> need to include the current wolips properties file by accessing
    >>> the value as specified in Eclipse/Preferences/WOLips/Build/WOLips
    >>> Properties File setting. I was expecting that this pref might be
    >>> stored somewhere in the workspace's .metadata dir, but if it is I
    >>> cannot find it..... any hints?
    >>>
    >>> -Kieran
    >>
    >



    This archive was generated by hypermail 2.0.0 : Tue Dec 22 2009 - 10:29:35 EST