-
Notifications
You must be signed in to change notification settings - Fork 37
Inherit the SDK path from the android plugin #70
Conversation
…ch logic. The android grade plugin already determines the SDK path and exposes it. Unfortunately it is done in different ways in different versions. The unit test about androidHome is now useless, so it has been removed.
This has been triggered because when the plugin fails to find the SDK in |
@@ -11,7 +11,16 @@ public class AndroidCommandPlugin implements Plugin<Project> { | |||
if (!project.plugins.hasPlugin('android')) { | |||
throw new StopExecutionException("The 'android' plugin is required.") | |||
} | |||
def extension = project.android.extensions.create("command", AndroidCommandPluginExtension, project) | |||
|
|||
def android = project.android |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the name confusing.
Also infer the type of androidHome manually.
throw new IllegalStateException("Couldn't read the SDK directory. If you're running the tests, " + | ||
"make sure you set the ANDROID_HOME env. variable and it points to your Android SDK home. Otherwise, " + | ||
"make sure there's a local.properties in the root of your project with the property sdk.dir pointing to the Android SDK") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to keep some checking here, in case the android plugin API changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I introduced a check in the SDK detection in order to fail even earlier in case the android plugin changes API again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Looks good, thanks for contributing! |
Also reintroduce the androidHome unit test
👍 |
} else if(androidExtension.hasProperty('sdkDirectory')) { | ||
androidHome = "${androidExtension.sdkDirectory}" | ||
} else { | ||
throw new IllegalStateException('The android plugin is not exposing the SDK folder in an expected way.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Inherit the SDK path from the android plugin
Thanks for contributing, @emanuelez ! |
My pleasure! Are you guys planning a release by any chance? :) |
The android grade plugin already determines the SDK path and exposes it so it is not needed to duplicate such logic. Unfortunately it is done in different ways in different versions of the android plugin.
The unit test about androidHome is now useless, so it has been removed.