Skip to content

Commit

Permalink
Merge pull request #131 from chikoski/main
Browse files Browse the repository at this point in the history
Apply best practices on build scripts.
  • Loading branch information
chikoski authored Oct 13, 2023
2 parents 897fa4c + f8e4068 commit d473df0
Show file tree
Hide file tree
Showing 51 changed files with 342 additions and 91 deletions.
8 changes: 0 additions & 8 deletions JetStreamCompose/.gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
/.idea/
local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
* limitations under the License.
*/

@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
alias(libs.plugins.android.test)
alias(libs.plugins.kotlin.android)
}

android {
namespace 'com.google.jetstream.benchmark'
compileSdk 34
namespace = "com.google.jetstream.benchmark"
compileSdk = 34

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
Expand All @@ -33,19 +34,19 @@ android {
}

defaultConfig {
minSdk 28
minSdk = 28

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
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"]
create("benchmark") {
isDebuggable = true
signingConfig = signingConfigs.getByName("debug")
matchingFallbacks += listOf("release")
}
}

Expand All @@ -63,7 +64,7 @@ dependencies {
}

androidComponents {
beforeVariants(selector().all()) {
enable = buildType == "benchmark"
beforeVariants(selector().withBuildType("benchmark").all()) {
it.enable = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

// Top-level build file where you can add configuration options common to all sub-projects/modules.
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
alias(libs.plugins.android.application) apply(false)
alias(libs.plugins.kotlin.android) apply(false)
Expand Down
2 changes: 1 addition & 1 deletion JetStreamCompose/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ kotlinx-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-

[plugins]
android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }
android-test = { id = "com.android.test", version.ref = "android-test-plugin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin-android" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin-android" }
android-test = { id = "com.android.test", version.ref = "android-test-plugin" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt-android" }
Original file line number Diff line number Diff line change
Expand Up @@ -14,91 +14,83 @@
* limitations under the License.
*/

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.serialization)
id 'kotlin-kapt'
kotlin("kapt")
alias(libs.plugins.hilt)
}

kotlin {
jvmToolchain(17)
}

android {
namespace "com.google.jetstream"
namespace = "com.google.jetstream"
// Needed for latest androidx snapshot build
compileSdk 34
compileSdk = 34

defaultConfig {
applicationId "com.google.jetstream"
minSdk 28
targetSdk 34
versionCode 1
versionName "1.0"
applicationId = "com.google.jetstream"
minSdk = 28
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
useSupportLibrary = true
}
}

buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
getByName("release") {
isMinifyEnabled = false
signingConfig = signingConfigs.getByName("debug")
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
benchmark {
initWith release
signingConfig signingConfigs.debug
matchingFallbacks = ['release']
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-benchmark-rules.pro'
debuggable false
create("benchmark") {
initWith(getByName("release"))
signingConfig = signingConfigs.getByName("debug")
matchingFallbacks += listOf("release")
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-benchmark-rules.pro"
)
isDebuggable = false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
buildFeatures {
compose true
buildConfig true
compose = true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion "1.4.3"
kotlinCompilerExtensionVersion = "1.4.3"
}
packagingOptions {
packaging {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
freeCompilerArgs += "-Xopt-in=androidx.tv.tvMaterial3.ExperimentalTvMaterial3Api"
freeCompilerArgs += "-Xopt-in=androidx.tv.material3.ExperimentalTvMaterial3Api"
freeCompilerArgs += "-Xopt-in=androidx.tv.foundation.ExperimentalTvFoundationApi"
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

kapt {
correctErrorTypes true
correctErrorTypes = true
}

dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation libs.androidx.lifecycle.runtime.compose
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))

// Compose UI libs (Using snapshot build for focus restoring APIs)
//implementation(libs.androidx.)
implementation(libs.androidx.compose.ui.base)
implementation(libs.androidx.compose.ui.tooling.preview)

Expand Down
2 changes: 1 addition & 1 deletion JetStreamCompose/jetstream/proguard-benchmark-rules.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
Expand Down
2 changes: 1 addition & 1 deletion JetStreamCompose/jetstream/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2023 Google LLC
*
* 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
*
* http://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 com.google.jetstream

import android.app.Application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.LocalContentColor
import androidx.tv.material3.MaterialTheme
import com.google.jetstream.presentation.screens.Screens
Expand All @@ -41,6 +42,7 @@ class MainActivity : ComponentActivity() {
}
}

@OptIn(ExperimentalTvMaterial3Api::class)
@Composable
private fun MainActivity.App() {
JetStreamTheme {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package com.google.jetstream.presentation.common
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.focusGroup
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand Down Expand Up @@ -83,9 +82,7 @@ enum class ItemDirection(val aspectRatio: Float) {
Horizontal(16f / 9f);
}

@OptIn(
ExperimentalFoundationApi::class
)
@OptIn(ExperimentalTvMaterial3Api::class)
@Composable
fun MoviesRow(
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -155,10 +152,7 @@ fun MoviesRow(
}
}

@OptIn(
ExperimentalFoundationApi::class,
ExperimentalComposeUiApi::class
)
@OptIn(ExperimentalComposeUiApi::class, ExperimentalTvMaterial3Api::class)
@Composable
fun ImmersiveListScope.ImmersiveListMoviesRow(
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -291,6 +285,7 @@ private fun MoviesRowItem(
)
}

@OptIn(ExperimentalTvMaterial3Api::class)
@Composable
private fun MoviesRowItemImage(
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -337,6 +332,7 @@ private fun MoviesRowItemImage(
}
}

@OptIn(ExperimentalTvMaterial3Api::class)
@Composable
private fun MoviesRowItemText(
showItemTitle: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import androidx.tv.foundation.lazy.grid.rememberTvLazyGridState
import androidx.tv.material3.Border
import androidx.tv.material3.CardDefaults
import androidx.tv.material3.CardLayoutDefaults
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.StandardCardLayout
import androidx.tv.material3.Text
Expand Down Expand Up @@ -84,7 +85,7 @@ fun CategoriesScreen(

}

@OptIn(ExperimentalComposeUiApi::class)
@OptIn(ExperimentalComposeUiApi::class, ExperimentalTvMaterial3Api::class)
@Composable
private fun Catalog(
movieCategories: MovieCategoryList,
Expand Down Expand Up @@ -181,6 +182,7 @@ private fun Catalog(
}
}

@OptIn(ExperimentalTvMaterial3Api::class)
@Composable
private fun Loading(modifier: Modifier = Modifier) {
Text(text = "Loading...", modifier = modifier)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import androidx.tv.foundation.lazy.grid.TvLazyVerticalGrid
import androidx.tv.material3.Border
import androidx.tv.material3.CardDefaults
import androidx.tv.material3.CardLayoutDefaults
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.StandardCardLayout
import androidx.tv.material3.Text
Expand Down Expand Up @@ -87,6 +88,7 @@ fun CategoryMovieListScreen(

}

@OptIn(ExperimentalTvMaterial3Api::class)
@Composable
private fun CategoryDetails(
categoryDetails: MovieCategoryDetails,
Expand Down Expand Up @@ -176,11 +178,13 @@ private fun CategoryDetails(
}
}

@OptIn(ExperimentalTvMaterial3Api::class)
@Composable
private fun Loading(modifier: Modifier = Modifier) {
Text(text = "Loading...", modifier = modifier)
}

@OptIn(ExperimentalTvMaterial3Api::class)
@Composable
private fun Error(modifier: Modifier = Modifier) {
Text(text = "Wops, something went wrong...", modifier = modifier)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.tv.material3.ExperimentalTvMaterial3Api
import androidx.tv.material3.Icon
import androidx.tv.material3.LocalContentColor
import androidx.tv.material3.MaterialTheme
Expand All @@ -68,7 +69,7 @@ val TopBarFocusRequesters = List(size = TopBarTabs.size + 1) { FocusRequester()

private const val ProfileScreenIndex = -1

@OptIn(ExperimentalComposeUiApi::class)
@OptIn(ExperimentalComposeUiApi::class, ExperimentalTvMaterial3Api::class)
@Composable
fun DashboardTopBar(
modifier: Modifier = Modifier,
Expand Down
Loading

0 comments on commit d473df0

Please sign in to comment.