Skip to content

Commit

Permalink
Merge pull request #340 from s1204IT/main
Browse files Browse the repository at this point in the history
Tidying up Gradle
  • Loading branch information
simondankelmann authored Jan 22, 2025
2 parents 459d858 + 8c9a1bd commit 7c1c165
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 85 deletions.
28 changes: 7 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ name: Build

on:
push:
paths:
- '.github/workflows/build.yml'
- 'app/**'
- 'gradle/**'
- '*.gradle.*'
- '*.properties'
pull_request:
workflow_dispatch:

Expand All @@ -24,10 +18,10 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
java-version: 21

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
uses: gradle/actions/setup-gradle@v4

- name: Set environments
run: |
Expand All @@ -37,26 +31,18 @@ jobs:
echo "repo=$(echo ${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/})"
} >> $GITHUB_ENV
- name: Build with Gradle
- name: Build
run: |
if [ "${{ secrets.STORE_FILE }}" == "" ]; then
echo -e "\nERROR!\nTo release, you need to set up a signing key!\n"
echo "STORE_FILE: A Base64 encoded string of the signing key in JKS format"
echo "STORE_PASSWORD: Key store password"
echo "KEY_ALIAS: Key alias"
echo "KEY_PASSWORD: Key password"
echo ""
exit 1
else
if [ "${{ secrets.STORE_FILE }}" != "" ]; then
echo "${{ secrets.STORE_FILE }}" | base64 -d > app/release.jks
export STORE_PASSWORD="${{ secrets.STORE_PASSWORD }}"
export KEY_ALIAS="${{ secrets.KEY_ALIAS }}"
export KEY_PASSWORD="${{ secrets.KEY_PASSWORD }}"
fi
./gradlew assemble --no-daemon --stacktrace
./gradlew assemble --no-daemon --stacktrace --warning-mode=all
- name: Upload APK
- name: Upload
uses: actions/upload-artifact@v4
with:
name: Bluetooth-LE-Spam(${{ env.version }}@${{ env.commit }})
name: ${{ env.repo }}(${{ env.version }}@${{ env.commit }})
path: app/build/outputs/apk/**/app-*.apk
78 changes: 38 additions & 40 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("androidx.navigation.safeargs")
alias(libs.plugins.agp.app)
alias(libs.plugins.kotlin)
alias(libs.plugins.safeargs)
id("kotlin-kapt")
}

val app_name = "Bluetooth LE Spam"

android {
namespace = "de.simon.dankelmann.bluetoothlespam"
compileSdk = 34
compileSdk = 35

defaultConfig {
applicationId = "de.simon.dankelmann.bluetoothlespam"
minSdk = 26
targetSdk = 34
targetSdk = 35
versionCode = 2
versionName = "1.0.8"

//testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
create("release") {
storeFile = file("release.jks")
Expand All @@ -31,7 +31,8 @@ android {

buildTypes {
configureEach {
signingConfig = signingConfigs["release"]
val variant = if (File("release.jks").exists()) "release" else "debug"
signingConfig = signingConfigs[variant]
}
release {
resValue("string", "app_name", app_name)
Expand All @@ -46,64 +47,61 @@ android {
applicationIdSuffix = ".debug"
}
}

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

kotlinOptions {
jvmTarget = "17"
jvmTarget = "21"
}

buildFeatures {
viewBinding = true
}
}


dependencies {
implementation("com.airbnb.android:lottie:6.3.0")
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.8.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.1")
implementation("androidx.navigation:navigation-fragment-ktx:2.7.7")
implementation("androidx.navigation:navigation-ui-ktx:2.7.7")
implementation("androidx.preference:preference-ktx:1.2.1")
implementation("androidx.legacy:legacy-support-v4:1.0.0")
//testImplementation("junit:junit:4.13.2")
//androidTestImplementation("androidx.test.ext:junit:1.1.5")
//androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
implementation("androidx.preference:preference-ktx:1.2.1")

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")

val room_version = "2.6.1"
implementation("androidx.room:room-runtime:$room_version")
annotationProcessor("androidx.room:room-compiler:$room_version")
implementation(libs.airbnb.lottie)

implementation(libs.core.ktx)
implementation(libs.preference.ktx)
implementation(libs.kotlinx.coroutines)
implementation(libs.androidx.appcompat)
implementation(libs.navigation.fragment.ktx)
implementation(libs.navigation.ui.ktx)
implementation(libs.lifecycle.livedata.ktx)
implementation(libs.lifecycle.viewmodel.ktx)
implementation(libs.legacy.support)
implementation(libs.android.constraintlayout)
implementation(libs.google.material)

implementation(libs.room.runtime)
annotationProcessor(libs.room.compiler)

// To use Kotlin annotation processing tool (kapt)
kapt("androidx.room:room-compiler:$room_version")
kapt(libs.room.compiler)

// To use Kotlin Symbol Processing (KSP)
//ksp("androidx.room:room-compiler:$room_version")
//ksp(libs.room.compiler)

// optional - Kotlin Extensions and Coroutines support for Room
//implementation("androidx.room:room-ktx:$room_version")
//implementation(libs.room.ktx)

// optional - RxJava2 support for Room
//implementation("androidx.room:room-rxjava2:$room_version")
//implementation(libs.room.rxjava2)

// optional - RxJava3 support for Room
implementation("androidx.room:room-rxjava3:$room_version")
implementation(libs.room.rxjava3)

// optional - Guava support for Room, including Optional and ListenableFuture
//implementation("androidx.room:room-guava:$room_version")
//implementation(libs.room.guava)

// optional - Test helpers
//testImplementation("androidx.room:room-testing:$room_version")
//testImplementation(libs.room.testing)

// optional - Paging 3 Integration
//implementation("androidx.room:room-paging:$room_version")

//implementation(libs.room.paging)
}
5 changes: 4 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
-ignorewarnings
-keepattributes LineNumberTable,SourceFile
-renamesourcefileattribute SourceFile
-dontobfuscate
-keepparameternames
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class StartFragment : Fragment() {
_binding = null
}

fun getAppVersion():String{
fun getAppVersion():String?{
val manager = AppContext.getContext()!!.packageManager
val info = manager.getPackageInfo(AppContext.getContext().packageName, 0)
val version = info.versionName
Expand Down Expand Up @@ -397,4 +397,4 @@ class StartFragment : Fragment() {

viewModel.advertisementServiceIsReady.postValue(advertisementServiceIsReady)
}
}
}
16 changes: 3 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.4.0" apply false
id("org.jetbrains.kotlin.android") version "1.9.23" apply false
id("androidx.navigation.safeargs.kotlin") version "2.7.7" apply false
}

buildscript {
repositories {
google()
}
dependencies {
val nav_version = "2.7.7"
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version")
}
alias(libs.plugins.agp.app) apply false
alias(libs.plugins.kotlin) apply false
alias(libs.plugins.safeargs) apply false
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
Expand All @@ -20,4 +20,4 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true
44 changes: 44 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[versions]
agp = "8.8.0"
kotlin = "2.1.0"
core = "1.15.0"
preference = "1.2.1"
coroutines = "1.10.1"
appcompat = "1.7.0"
navigation = "2.8.5"
lifecycle = "2.8.7"
legacy = "1.0.0"
constraintlayout = "2.2.0"
material = "1.12.0"
room = "2.6.1"
lottie = "6.6.2"

[plugins]
agp-app = { id = "com.android.application", version.ref = "agp" }
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
safeargs = { id = "androidx.navigation.safeargs.kotlin", version.ref = "navigation" }

[libraries]
airbnb-lottie = { group = "com.airbnb.android", name = "lottie", version.ref = "lottie" }

core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core" }
preference-ktx = { group = "androidx.preference", name = "preference-ktx", version.ref = "preference" }
kotlinx-coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "coroutines" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
navigation-fragment-ktx = { group = "androidx.navigation", name = "navigation-fragment-ktx", version.ref = "navigation"}
navigation-ui-ktx = { group = "androidx.navigation", name = "navigation-ui-ktx", version.ref = "navigation" }
lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "lifecycle" }
lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
legacy-support = { group = "androidx.legacy", name = "legacy-support-v4", version.ref = "legacy" }

android-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
google-material = { group = "com.google.android.material", name = "material", version.ref = "material" }

room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
room-rxjava2 = { group = "androidx.room", name = "room-rxjava2", version.ref = "room" }
room-rxjava3 = { group = "androidx.room", name = "room-rxjava3", version.ref = "room" }
room-guava = { group = "androidx.room", name = "room-guava", version.ref = "room" }
room-testing = { group = "androidx.room", name = "room-testing", version.ref = "room" }
room-paging = { group = "androidx.room", name = "room-paging", version.ref = "room" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionSha256Sum=7a00d51fb93147819aab76024feece20b6b84e420694101f276be952e08bef03
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
6 changes: 4 additions & 2 deletions 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 Expand Up @@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 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
4 changes: 2 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ dependencyResolutionManagement {
}
}

rootProject.name = "Bluetooth LE Spam"
include(":app")
rootProject.name = "Bluetooth-LE-Spam"
include("app")

0 comments on commit 7c1c165

Please sign in to comment.