This branch has been modified to work with the prototype of the Declarative Gradle DSL. This build relies on nightly versions of Gradle, Android Studio and Declarative Gradle prototype plugins.
The NowInAndroid project is a "hybrid" build now where there's a mix of declarative and non-declarative (Kotlin DSL) build files. The build can be imported and builds.
The settings file applies a new "Android ecosystem plugin", which exposes androidLibrary
and androidApplication
software types that can be used in subprojects. The current prototype is limited to a single androidLibrary
software type convention, so only a few subprojects have been converted.
Converted subprojects:
:core:common
:core:data
:core:data-test
:core:database
:core:datastore
:core:datastore-proto
:core:domain
:feature:bookmarks
The androidLibrary
software type exposes several configuration options and dependencies. Test related configuration mimics the existing Android extension for now.
The settings file contains several shared model defaults that are applied to all subprojects with an androidLibrary
software type.
Syntax highlighting, code completion and content assist are limited to the latest nightly for Android Studio that understands Gradle DCL files.
There are several capabilities of the androidLibrary
or androidApplication
software types that are optional, such as hilt
, compose
, libraryDesugaring
, feature
and kotlinSerialization
. These capabilities are only enabled by configuring them in the software type model. For instance, an androidLibrary
software type will not use hilt unless its hilt { }
block is configured. This block can be configured with or without setting any properties of hilt. In other words, an empty hilt { }
block will enable the hilt capability, but will use its defaults.
NOTE: The build logic and conventions used by declarative and non-declarative projects is currently duplicated. Subsequent milestones/feedback points will bring these back together.
git clone https://github.com/gradle/nowinandroid.git
cd nowinandroid
git checkout main-declarative
git clone https://github.com/gradle/declarative-gradle.git
This should checkout the main
branch of the Declarative Gradle prototype plugins inside the root of Gradle's NowInAndroid fork.
You should have this project structure:
nowinandroid/
declarative-gradle/
You can assemble the project with the following command:
./gradlew buildDemoDebug
Note: See the note in Screenshot tests about setting up Roborazzi for non-Linux test runs. You may need to run recordRoborazziDemoDebug
to regenerate screenshots that will work on your machine.
./gradlew testDemoDebug :lint:test
./gradlew testDemoDebugUnitTest -Proborazzi.test.verify=false
After starting a local Android emulator in Android Studio:
./gradlew connectedDemoDebugAndroidTest --daemon
Syntax highlighting, code completion and content assist should work in the latest Android Studio nightlies that understand Gradle DCL files.
The settings file contains several shared defaults that are applied to all subprojects with an androidLibrary
software type.
The default values configured here are applied to the androidLibrary
model whenever this software type is added to a subproject.
Editing these defaults will affect all subprojects.
Similarly, changing one of these values in a subproject will override the shared default.
NOTE: In order to avoid applying all configuration from nested blocks such as
kotlinSerialization
orroom
to subprojects where this functionality is unnecessary and perhaps build-breaking, we are using anenabled=false
flag to SIMULATE defining a model default without automatically applying it. This is TEMPORARY WORKAROUND which will ba addressed soon and should not be seen as a pattern to copy.