Skip to content

Commit

Permalink
Update Java to 17 and add sample benchmark, cleanup (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Varsha-Kulkarni authored May 22, 2023
1 parent 3ef034b commit 2f3aa6e
Show file tree
Hide file tree
Showing 23 changed files with 217 additions and 289 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17

- name: Build project
run: ./gradlew spotlessCheck assembleDebug lintDebug --stacktrace
Expand Down
16 changes: 16 additions & 0 deletions .idea/androidTestResultsUserPreferences.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/build
/build
*.keystore
!debug.keystore
47 changes: 29 additions & 18 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@ android {

buildTypes {
release {
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
benchmark {
signingConfig signingConfigs.debug
matchingFallbacks = ['release']
debuggable false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '17'
}
buildFeatures {
compose true
Expand All @@ -56,27 +61,33 @@ dependencies {
api project(":repository")

implementation "androidx.core:core-ktx:$coreKtxVersion"
implementation "androidx.activity:activity-compose:$activityVersion"
implementation "androidx.compose.material:material:$composeMaterialVersion"
implementation "androidx.compose.ui:ui:$composeUiVersion"
implementation "androidx.compose.ui:ui-tooling-preview:$composeUiVersion"

debugImplementation "androidx.compose.ui:ui-tooling:$composeUiVersion"
debugImplementation "androidx.compose.ui:ui-test-manifest:$composeUiVersion"

androidTestImplementation "androidx.test:runner:$testRunnerVersion"
testImplementation "junit:junit:$jUnitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidJUnitVersion"
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$composeUiVersion"
androidTestImplementation("com.google.dagger:hilt-android-testing:$daggerHiltVersion")
kaptAndroidTest "com.google.dagger:hilt-android-compiler:$daggerHiltVersion"

// Lifecycle
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-runtime-compose:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-service:$lifecycleVersion"

// Dagger + Hilt
implementation "com.google.dagger:hilt-android:$daggerHiltVersion"
kapt "com.google.dagger:hilt-android-compiler:$daggerHiltVersion"

// Compose
implementation platform("androidx.compose:compose-bom:$composeBomVersion")
implementation "androidx.compose.ui:ui"
implementation "androidx.compose.ui:ui-graphics"
implementation "androidx.compose.ui:ui-tooling-preview"
implementation "androidx.compose.material3:material3"
implementation "androidx.activity:activity-compose:$activityVersion"

implementation "androidx.compose.material:material:$materialVersion"

//testing
testImplementation "junit:junit:$jUnitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidJUnitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoCoreVersion"
androidTestImplementation platform("androidx.compose:compose-bom:$composeBomVersion")
androidTestImplementation "androidx.compose.ui:ui-test-junit4"
debugImplementation "androidx.compose.ui:ui-tooling"
debugImplementation "androidx.compose.ui:ui-test-manifest"
}
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
android:supportsRtl="true"
android:theme="@style/Theme.MovieHangman"
tools:targetApi="31">
<profileable
android:shell="true"
tools:targetApi="29" />

<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.MovieHangman">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
1 change: 1 addition & 0 deletions benchmark/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
52 changes: 52 additions & 0 deletions benchmark/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
plugins {
id 'com.android.test'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'dev.varshakulkarni.benchmark'
compileSdk 33

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = "17"
}

defaultConfig {
minSdk 24
targetSdk 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
// This benchmark buildType is used for benchmarking, and should function like your
// release build (for example, with minification on). It's signed with a debug key
// for easy local/CI testing.
benchmark {
debuggable = true
signingConfig = debug.signingConfig
matchingFallbacks = ["release"]
}
}

targetProjectPath = ":app"
experimentalProperties["android.experimental.self-instrumenting"] = true
}

dependencies {
implementation 'androidx.test.ext:junit:1.1.5'
implementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'androidx.test.uiautomator:uiautomator:2.2.0'
implementation 'androidx.benchmark:benchmark-macro-junit4:1.1.0-beta05'
}

androidComponents {
beforeVariants(selector().all()) {
enabled = buildType == "benchmark"
}
}
7 changes: 7 additions & 0 deletions benchmark/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<queries>
<package android:name="dev.varshakulkarni.moviehangman" />
</queries>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2023 Varsha Kulkarni
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.varshakulkarni.benchmark

import androidx.benchmark.macro.StartupMode
import androidx.benchmark.macro.StartupTimingMetric
import androidx.benchmark.macro.junit4.MacrobenchmarkRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

/**
* This is an example startup benchmark.
*
* It navigates to the device's home screen, and launches the default activity.
*
* Before running this benchmark:
* 1) switch your app's active build variant in the Studio (affects Studio runs only)
* 2) add `<profileable android:shell="true" />` to your app's manifest, within the `<application>` tag
*
* Run this benchmark from Studio to see startup measurements, and captured system traces
* for investigating your app's performance.
*/
@RunWith(AndroidJUnit4::class)
class ExampleStartupBenchmark {
@get:Rule
val benchmarkRule = MacrobenchmarkRule()

@Test
fun startup() = benchmarkRule.measureRepeated(
packageName = "dev.varshakulkarni.moviehangman",
metrics = listOf(StartupTimingMetric()),
iterations = 5,
startupMode = StartupMode.COLD
) {
pressHome()
startActivityAndWait()
}
}
33 changes: 19 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
buildscript {
ext {
composeUiVersion = '1.4.1'
coreKtxVersion = '1.10.0'
appcompatVersion = '1.6.1'
lifecycleVersion = '2.5.1'
activityVersion = '1.7.0'
materialDesignVersion = '1.8.0'
agpVersion = "8.0.0"
composeBomVersion = "2023.01.00"
coreKtxVersion = "1.10.1"
appcompatVersion = "1.6.1"
lifecycleVersion = "2.5.1"
activityVersion = "1.7.1"
materialDesignVersion = "1.9.0"
materialVersion = "1.4.3"
roomVersion = "2.5.1"
legacySupportVersion = "1.0.0"
daggerHiltVersion = "2.43.2"
javaxInjectVersion = "1"
kotlinVersion = "1.8.10"
coroutinesVersion = "1.6.4"
ktlintVersion = "11.2.0"
composeMaterialVersion = "1.4.1"
composeMaterialVersion = "1.4.3"
jUnitVersion = "4.13.2"
androidJUnitVersion = '1.1.5'
androidJUnitVersion = "1.1.5"
testRunnerVersion = "1.5.2"
espressoCoreVersion = "3.5.1"
spotlessVersion = "5.7.0"
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version "$kotlinVersion" apply false
id 'com.google.dagger.hilt.android' version "$daggerHiltVersion" apply false
id 'org.jetbrains.kotlin.jvm' version '1.6.10' apply false
id 'com.diffplug.spotless' version '5.7.0'
id "com.android.application" version "$agpVersion" apply false
id "com.android.library" version "$agpVersion" apply false
id "org.jetbrains.kotlin.android" version "$kotlinVersion" apply false
id "com.google.dagger.hilt.android" version "$daggerHiltVersion" apply false
id "org.jetbrains.kotlin.jvm" version "$kotlinVersion" apply false
id "com.diffplug.spotless" version "$spotlessVersion"
id "org.jlleitschuh.gradle.ktlint" version "$ktlintVersion"
id "com.android.test" version "$agpVersion" apply false
}

subprojects {
Expand Down
4 changes: 2 additions & 2 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ dependencies {
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
6 changes: 3 additions & 3 deletions data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '17'
}
}

Expand Down
Binary file removed data/src/main/assets/database/.hangman.sql.swp
Binary file not shown.
Binary file removed data/src/main/assets/database/MovieHangman.db
Binary file not shown.
Loading

0 comments on commit 2f3aa6e

Please sign in to comment.