Building AOSP on OS X after upgrading Xcode to 4.4

28 07 2012

I recently upgraded to OS X 10.8 Mountain Lion and Xcode 4.4, and quickly found out that the 10.6 SDK was removed from Xcode.  Unfortunately, Android requires it to build and gives an error like this when running make:

build/core/combo/HOST_darwin-x86.mk:62: *****************************************************
build/core/combo/HOST_darwin-x86.mk:63: * Can not find SDK 10.6 at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk
build/core/combo/HOST_darwin-x86.mk:65: * If you wish to build using higher version of SDK,
build/core/combo/HOST_darwin-x86.mk:66: * try setting BUILD_MAC_SDK_EXPERIMENTAL=1 before
build/core/combo/HOST_darwin-x86.mk:67: * rerunning this command
build/core/combo/HOST_darwin-x86.mk:69: *****************************************************
build/core/combo/HOST_darwin-x86.mk:70: *** Stop.. Stop.

To work around it, run this from Terminal:

export BUILD_MAC_SDK_EXPERIMENTAL=1

Also, I got a compile failure after running ‘make’ under Mountain Lion:

************************************************************
You are attempting to build with the incorrect version
of java.

Your version is: java version “1.7.0_07”.
The correct version is: Java SE 1.6.

Please follow the machine setup instructions at
https://source.android.com/source/download.html
************************************************************
build/core/main.mk:141: *** stop. Stop.

Java 7 became the default JDK after the upgrade.  To switch back to Java 6, run this from Terminal:

export JAVA_HOME=`/usr/libexec/java_home -v 1.6`




Installing Groovy and Grails bundles in TextMate (updated)

2 10 2009

It looks like the Groovy and Grails bundles have moved to GitHub.  Here are the new instructions for installing the bundles.  First, you’ll need to install GitHub.  The easiest way is to use MacPorts:

sudo port selfupdate
sudo port install git-core

You can find other GitHub installation instructions at http://help.github.com/mac-git-installation/

Once you have GitHub installed, open Terminal and run these commands to install the TextMate bundles:

mkdir -p /Library/Application\ Support/TextMate/Bundles
cd /Library/Application\ Support/TextMate/Bundles/
git clone git://github.com/alkemist/groovy.tmbundle.git
git clone git://github.com/alkemist/Groovy-Grails.tmbundle.git

I hope this helps!





Installing Groovy and Grails bundles in TextMate

30 08 2009

These instructions are now outdated.  See https://charliesquires.wordpress.com/2009/10/02/installing-groovy-and-grails-bundles-in-textmate-updated/ for updated instructions. Thanks!

The Groovy website’s instructions for installing the TextMate bundle are very vague.  They point you to the bundle location and link you to the TextMate bundle instructions (which are useful, but long when all you want to know is how to install bundles).  Here’s all you need to do to install the Groovy and Grails bundles.

Open Terminal and run these commands:

mkdir -p /Library/Application\ Support/TextMate/Bundles
cd /Library/Application\ Support/TextMate/Bundles/
svn co http://svn.textmate.org/trunk/Bundles/Groovy.tmbundle
svn co http://svn.textmate.org/trunk/Bundles/Groovy%20Grails.tmbundle





Running Groovy tests in NetBeans 6.7.1

30 08 2009

I’m a long-time Eclipse user, but I heard that NetBeans has better (for the time being) Groovy support.  To see what it was all about I downloaded and installed NetBeans 6.7.1.  While I was attending the No Fluff Just Stuff conference this weekend I tried following along with a Groovy testing session by plugging the examples into NetBeans.  We created a mix of Java and Groovy tests inside a Java project, but when I ran the test suite only the Java tests ran.

I dug through the generated build-impl.xml file to find out why, and found that JUnit is being passed a list of .java files.  The Groovy tests are .groovy, so they won’t run.  JUnit will accept .class files, and since Java and Groovy are compiled to .class files by NetBeans tests in both languages will run this way.  I edited build.xml and overrode three targets from build-impl.xml.  With these changes you can run individual Java and Groovy tests or run them as part of a full test run.  I highlighted the changes I made from the original build-impl.xml targets in red.  If you copy/paste the xmlns attribute and these targets into build.xml you should be able to run all of your Groovy and Java tests in NetBeans.

Note: Be sure to edit build.xml, not build-impl.xml since it can regenerate and overwrite your changes.  Yes, I found this out the hard way 🙂

build.xml:

<?xml version="1.0" encoding="UTF-8"?>

<project name="TestGroovy" default="default" basedir="." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3">
    <description>Builds, tests, and runs the project TestGroovy.</description>
    <import file="nbproject/build-impl.xml"/>

    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
        <j2seproject3:junit testincludes="**/*Test.class"/>
    </target>

    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
        <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpath="${javac.classpath}"/>
        <groovy>
            properties."test.includes.class" = properties."test.includes".split("\\.")[0] + ".class"
        </groovy>
        <j2seproject3:junit excludes="" includes="${test.includes.class}"/>
    </target>

    <target name="-init-macrodef-junit">
        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
            <attribute default="${includes}" name="includes"/>
            <attribute default="${excludes}" name="excludes"/>
            <attribute default="**" name="testincludes"/>
            <sequential>
                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
                    <batchtest todir="${build.test.results.dir}">
                        <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
                            <filename name="@{testincludes}"/>
                        </fileset>
                    </batchtest>
                    <classpath>
                        <path path="${run.test.classpath}"/>
                    </classpath>
                    <syspropertyset>
                        <propertyref prefix="test-sys-prop."/>
                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
                    </syspropertyset>
                    <formatter type="brief" usefile="false"/>
                    <formatter type="xml"/>
                    <jvmarg line="${run.jvmargs}"/>
                </junit>
            </sequential>
        </macrodef>
    </target>
</project>