NOTE: 1.2.0 is the last version published using
addSbtPlugin("com.hanhuy.sbt" % "android-gradle-build" % "1.2.0")
,
all future updates can be accessed by using
addSbtPlugin("org.scala-android" % "sbt-android-gradle" % VERSION)
Automatically import all settings from an Android project's build.gradle
into
a generated 00-gradle-generated.sbt
file. Dependencies, flavors, build
types and all Android-related configurations are retained. Any changes to
build.gradle
are automatically reflected in 00-gradle-generated.sbt
whenever changes occur.
- Download & install SBT 0.13.6+ (google it)
- From your Android project root, wherever the base
build.gradle
is located, loadsbt-android-gradle
:mkdir project
echo 'addSbtPlugin("org.scala-android" % "sbt-android-gradle" % "1.3.2")' > project/plugins.sbt
- Run
sbt
- The initial load will be slow as gradle will run to extract all project settings and export them into sbt
- Once fully loaded, the full power of
sbt-android
is available - Typical android projects created by Android Studio have an
app
project, so in order to run any any build tasks, they must generally be prefixed byapp/
, e.g.app/android:package
- Build types and flavors can be loaded using the
variant
command (variant[/PROJECT] [BUILD-TYPE] [FLAVOR]
)- Build variants can be auto-loaded by adding a line into
build.sbt
such asandroid.Plugin.withVariant("PROJECT-NAME (e.g. app)", Some("BUILD-TYPE"), Some("FLAVOR"))
replaceSome(...)
withNone
if only a build-type or flavor is desired. - By default, the first found build type and flavor will be loaded.
- To select an alternative flavor/buildType at sbt file generation,
set
build.flavor
and/orbuild.type
properties in a properties file of your choosing. - Gradle command line options can be passed by setting
gradle.options
in any properties file of your choosing
- Build variants can be auto-loaded by adding a line into
- Load other SBT plugins such as sbt-android-protify to further enhance the build experience
- Custom tasks defined in gradle will not be executed; they will need to be re-implemented in SBT if required.
- Inline function calls to populate android settings in gradle will be detected
and loaded, but will not be updated in SBT until
build.gradle
itself is modified - Only settings defined by the gradle android plugin proper will be imported.
Certain settings, such as
dexOptions
are not exported to tooling and will be unavailable.proguardFiles
is similarly unavailable due to bug 195881. Settings from plugins such asretrolambda
,android-apt
, etc. will not be imported. - Only Android projects will be imported, any non-android gradle projects will be ignored