Skip to content

Commit

Permalink
Merge pull request #16 from gradle/tt/declarative-no-conventions
Browse files Browse the repository at this point in the history
Declarativize NiA without custom software types
  • Loading branch information
big-guy committed Apr 25, 2024
2 parents 8290a9c + 0061157 commit 1ccdee9
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 129 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
# Declarative Gradle DSL

This branch has been modified to work with the prototype of the Declarative Gradle DSL.

## Running

First, checkout the `declarative-no-conventions-nia` branch of the [declarative-gradle](https://github.com/gradle/declarative-gradle) project into a **sibling directory** of this project:

```
declarative-gradle/
nowinandroid/
```

then run the following command in the `nowinandroid` directory to build the project:

```shell
./gradlew buildDemoDebug
```

### Running tests
**Note:** See the note in [Screenshot tests](#screenshot-tests) about setting up Roborazzi for non-Linux test runs.

```shell
./gradlew testDemoDebug :lint:test
```

```shell
./gradlew testDemoDebugUnitTest -Proborazzi.test.verify=false
```

After starting a local Android emulator in Android Studio:
```shell
./gradlew connectedDemoDebugAndroidTest --daemon
````

![Now in Android](docs/images/nia-splash.jpg "Now in Android")

<a href="https://play.google.com/store/apps/details?id=com.google.samples.apps.nowinandroid"><img src="https://play.google.com/intl/en_us/badges/static/images/badges/en_badge_web_generic.png" height="70"></a>
Expand Down
9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ buildscript {
dependencies {
classpath(libs.google.oss.licenses.plugin) {
exclude(group = "com.google.protobuf")

constraints {
add("classpath", "com.android.tools.build:gradle:8.3.0") {
because("Aligns the resolved versions of the com.android plugins, prevents: \n" +
"Script compilation errors:\n" +
" Line 62: packaging {\n" +
" ^ Unresolved reference: packaging\n")
}
}
}
}

Expand Down
16 changes: 16 additions & 0 deletions core/common/build.gradle.dcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
androidLibrary {
namespace = "com.google.samples.apps.nowinandroid.core.common"

dependencies {
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
testImplementation("app.cash.turbine:turbine:1.0.0")
}

buildTypes {
buildTypes {
// Need the empty closure to avoid "dangling pure expression" error
debug {}
release {}
}
}
}
29 changes: 0 additions & 29 deletions core/common/build.gradle.kts

This file was deleted.

32 changes: 32 additions & 0 deletions core/data/build.gradle.dcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
androidLibrary {
namespace = "com.google.samples.apps.nowinandroid.core.data"

includeKotlinSerialization = true
configureJacoco = true

dependencies {
api(projects.core.common)
api(projects.core.database)
api(projects.core.datastore)
api(projects.core.network)

implementation(projects.core.analytics)
implementation(projects.core.notifications)

testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
testImplementation(projects.core.datastoreTest)
testImplementation(projects.core.testing)
testImplementation(projects.core.network)
}

testOptions {
includeAndroidResources = true
returnDefaultValues = true
}

buildTypes {
// Need the empty closure to avoid "dangling pure expression" error
debug {}
release {}
}
}
46 changes: 0 additions & 46 deletions core/data/build.gradle.kts

This file was deleted.

20 changes: 20 additions & 0 deletions core/domain/build.gradle.dcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
androidLibrary {
namespace = "com.google.samples.apps.nowinandroid.core.domain"

configureJacoco = true

dependencies {
implementation("javax.inject:javax.inject:1")

api(projects.core.data)
api(projects.core.model)

testImplementation(projects.core.testing)
}

buildTypes {
// Need the empty closure to avoid "dangling pure expression" error
debug {}
release {}
}
}
33 changes: 0 additions & 33 deletions core/domain/build.gradle.kts

This file was deleted.

18 changes: 9 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ androidxActivity = "1.8.0"
androidxAppCompat = "1.6.1"
androidxBrowser = "1.8.0"
androidxComposeBom = "2024.02.02"
androidxComposeCompiler = "1.5.8"
androidxComposeCompiler = "1.5.12"
androidxComposeUiTest = "1.7.0-alpha06"
androidxComposeMaterial3Adaptive = "1.0.0-alpha10"
androidxComposeRuntimeTracing = "1.0.0-beta01"
Expand Down Expand Up @@ -42,7 +42,7 @@ hilt = "2.51"
hiltExt = "1.1.0"
jacoco = "0.8.7"
junit4 = "4.13.2"
kotlin = "1.9.22"
kotlin = "1.9.23"
kotlinxCoroutines = "1.8.0"
kotlinxDatetime = "0.5.0"
kotlinxSerializationJson = "1.6.3"
Expand Down Expand Up @@ -152,18 +152,18 @@ room-gradlePlugin = { group = "androidx.room", name = "room-gradle-plugin", vers
work-testing = { group = "androidx.work", name = "work-testing", version = "2.9.0" }

[plugins]
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
android-test = { id = "com.android.test", version.ref = "androidGradlePlugin" }
android-application = { id = "com.android.application" }
android-library = { id = "com.android.library" }
android-test = { id = "com.android.test" }
baselineprofile = { id = "androidx.baselineprofile", version.ref = "androidxMacroBenchmark"}
dependencyGuard = { id = "com.dropbox.dependency-guard", version.ref = "dependencyGuard" }
firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebaseCrashlyticsPlugin" }
firebase-perf = { id = "com.google.firebase.firebase-perf", version.ref = "firebasePerfPlugin" }
gms = { id = "com.google.gms.google-services", version.ref = "gmsPlugin" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
hilt = { id = "com.google.dagger.hilt.android" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
ksp = { id = "com.google.devtools.ksp" }
module-graph = { id = "com.jraska.module.graph.assertion", version.ref = "moduleGraph" }
protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" }
roborazzi = { id = "io.github.takahirom.roborazzi", version.ref = "roborazzi" }
Expand All @@ -184,4 +184,4 @@ nowinandroid-android-library-jacoco = { id = "nowinandroid.android.library.jacoc
nowinandroid-android-lint = { id = "nowinandroid.android.lint", version = "unspecified" }
nowinandroid-android-room = { id = "nowinandroid.android.room", version = "unspecified" }
nowinandroid-android-test = { id = "nowinandroid.android.test", version = "unspecified" }
nowinandroid-jvm-library = { id = "nowinandroid.jvm.library", version = "unspecified" }
nowinandroid-jvm-library = { id = "nowinandroid.jvm.library", version = "unspecified" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-8.9-20240424122219+0000-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
4 changes: 3 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
5 changes: 5 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@

pluginManagement {
includeBuild("build-logic")
includeBuild("../declarative-gradle/unified-prototype/unified-plugin")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

plugins {
id("org.gradle.experimental.android-ecosystem")
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
Expand Down

0 comments on commit 1ccdee9

Please sign in to comment.