diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..3ad782d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: gradle + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..49054e3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: CI + +on: + pull_request: + branches: [master] + +permissions: + contents: read + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Provide onfleet.properties (placeholder is fine for a build) + run: | + if [ ! -f app/src/main/assets/onfleet.properties ]; then + cp app/src/main/assets/onfleet.properties.example \ + app/src/main/assets/onfleet.properties + fi + + - name: Assemble debug + run: ./gradlew assembleDebug --no-daemon --stacktrace diff --git a/.gitignore b/.gitignore index fa3d373..31570d7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,9 +9,14 @@ **/**/*.apk /app/production /app/debug -/app/google-services.json /fastlane/report.xml /firebase_app_distribution /.idea/deploymentTargetDropDown.xml /bundletool_temp/bundletool.jar /app/jacoco.exec + +# Local SDK config — copy from onfleet.properties.example +/app/src/main/assets/onfleet.properties + +# Local Firebase config — replaces the committed placeholder google-services.json +/app/google-services.json.local diff --git a/CHANGELOG.md b/CHANGELOG.md index 54a44cd..dec06e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,63 @@ # Change Log -Breaking changes and additions to to Onfleet SDK will be documented in this file. +Breaking changes and additions to Onfleet SDK will be documented in this file. -## [0.11.1] - 2023-09-14 +## [0.12.0] + +Breaking changes to API + +### Added Features + +- **Custom fields** ([Custom Fields](https://support.onfleet.com/hc/en-us/articles/21799942217748-Custom-Fields)) +- **Route plans** ([Route Plans](https://support.onfleet.com/hc/en-us/articles/25492148360596-Route-Plans)) +- **Self-assign tasks** ([Self-Assign Tasks & Routes](https://support.onfleet.com/hc/en-us/articles/360041740172-Self-Assign-Tasks-Routes)) +- **End-of-route task types** ([End Route / Return to Hub](https://support.onfleet.com/hc/en-us/articles/34992206461716-End-Route-Return-to-Hub)) +- **Route load & bulk pick-up task types** +- **Hidden requirement state** +- **Custom task completion requirements** ([Proof of Delivery](https://support.onfleet.com/hc/en-us/articles/10348848090644-Proof-of-Delivery)) +- **Custom completion reasons** ([Custom Task Completion Reasons](https://support.onfleet.com/hc/en-us/articles/9382652814228-Custom-Task-Completion-Reasons)) +- **Age attestation** ([Complete a Task](https://support.onfleet.com/hc/en-us/articles/10373142665364-Complete-a-Task#h_01GGAK84GT77TGWRK5GHTH065X)) +- **Order short id** +- **Completed-task PII setting** ([Remove PII from Driver Task History](https://support.onfleet.com/hc/en-us/articles/38159626547348-Remove-Personally-Identifiable-Information-PII-from-Driver-Task-History)) + +### Added + +- CompletedTask has custom field support in the public model (`getCustomFields()`) +- Custom field checklist variant added: `CustomField.CustomFieldChecklist` +- Route model added (`Route`) to support route plans +- TasksManager has new `getRoutes()` method +- TasksManager has new `selfAssignRoutes()` method +- TasksManager has new `getSelfAssignableTasks()` method (task list split) +- Task and CompletedTask now expose `TaskType` in public API +- Requirements model for task completion added (`Requirements`, `RequirementState`) +- Task completion CustomRequirements added +- Package completion reasons exposed (`PackageCompletionReason`) +- Task object has a new field isRecipientNumberActive related to the offline mode +- Task object has a new field attestationAge +- Task object has orderShortId +- Organization object has a new settings completedTaskPIIEnabled +- Organization object has a new settings warnWhenStartTaskOnDifferentRoute + +### Changed + +- CompletedTask attachments are now of type `CompletedTaskAttachment` (previous attachment helper methods moved accordingly) +- Task/CompletedTask signatures expanded with requirements and task-type payloads (`Requirements`, `TaskType`, `CustomRequirements`) +- TasksManager task assignment changed: `selfAssignTask()` renamed/split into `selfAssignTasks()` and `selfAssignRoutes()` +- Sync type enum removed (`SyncType`) and sync payloads now use updated sync status/data semantics +- Account deletion response enum removed (`DeleteAccountResponse`) +- Android minimum supported SDK increased from 24 to 26 (consumer apps must target `minSdk >= 26`) +- CompletedTask isPickupTask has been removed. Use type (TaskType) instead +- CompletedTask metadata type is renamed to Metadata +- Task isPickupTask has been removed. Use type (TaskType) instead +- Task recipientMetadata type is renamed to Metadata +- Task metadata type is renamed to Metadata +- DriverManager getDriver() is now nullable instead of throwing exception +- SessionManager getOrganization() is now nullable instead of throwing exception + +## [0.11.1] No changes. Only a proguard fix to avoid dependency conflicts on the obfuscated classes. -## [0.11.0] - 2023-06-19 +## [0.11.0] Breaking changes to API @@ -29,7 +81,7 @@ Breaking changes to API ### Fixed -## [0.10.5] - 2023-06-01 +## [0.10.5] ### Added diff --git a/README.md b/README.md index cf3f2e7..0b5fde9 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,25 @@ # Android Onfleet SDK example project -- in the assets folder onfleet.properties file enter an application name and SDK key -- add google-services.json that you registered with Onfleet for push messages +A minimal example app showing how to integrate the Onfleet Driver SDK. + +## Setup + +1. Copy the config template and fill in the values Onfleet gave you: + ```bash + cp app/src/main/assets/onfleet.properties.example app/src/main/assets/onfleet.properties + ``` + - `applicationName` — your application name + - `sdkApplicationId` — your Onfleet SDK key + +2. (Push notifications) Replace the placeholder `app/google-services.json` with the + `google-services.json` for the Firebase project you registered with Onfleet. The + committed file is a non-functional placeholder so the project builds out of the box; + push delivery requires your own Firebase config. + +## Build + +```bash +./gradlew assembleDebug +``` + +CI builds every pull request and every push to `master`. diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b6a9fad..f69fba4 100755 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,66 +1,55 @@ plugins { id("com.android.application") - id("kotlin-android") - id("kotlin-parcelize") + id("org.jetbrains.kotlin.plugin.parcelize") id("com.google.gms.google-services") + id("org.jetbrains.kotlin.plugin.compose") } android { - compileSdk = 34 - buildToolsVersion = "34.0.0" + compileSdk = 36 + buildToolsVersion = "36.0.0" defaultConfig { applicationId = "com.onfleet.sdk.onfleetclientexample" - minSdk = 24 - targetSdk = 34 + minSdk = 26 + targetSdk = 36 versionCode = 1 - versionName = "0.11.1" - multiDexEnabled = true + versionName = "0.12.0" } buildTypes { release { isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") } debug { } } compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_11.toString() - freeCompilerArgs = freeCompilerArgs + "-Xopt-in=kotlin.RequiresOptIn" + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } buildFeatures { compose = true } - composeOptions { - kotlinCompilerExtensionVersion = "1.4.7" - } namespace = "com.onfleet.sdk.onfleetclientexample" } dependencies { - implementation("com.onfleet:driver:0.11.1") - implementation("androidx.appcompat:appcompat:1.6.1") - implementation("androidx.core:core-ktx:1.10.1") - implementation("org.jetbrains.kotlin:kotlin-stdlib:1.8.22") - implementation("androidx.exifinterface:exifinterface:1.3.6") - implementation("com.google.firebase:firebase-core:21.1.1") - implementation("com.google.firebase:firebase-messaging:23.1.2") - implementation("androidx.multidex:multidex:2.0.1") + implementation("com.onfleet:driver:0.12.0") + implementation("androidx.appcompat:appcompat:1.7.1") + implementation("org.jetbrains.kotlin:kotlin-stdlib:2.1.0") + implementation("androidx.exifinterface:exifinterface:1.4.2") + implementation(platform("com.google.firebase:firebase-bom:34.11.0")) + implementation("com.google.firebase:firebase-messaging") implementation("com.jakewharton.timber:timber:5.0.1") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1") - implementation("androidx.compose.ui:ui:1.5.0-beta02") - implementation("androidx.compose.ui:ui-tooling:1.5.0-beta02") - implementation("androidx.compose.foundation:foundation:1.5.0-beta02") - implementation("androidx.compose.compiler:compiler:1.4.7") - implementation("androidx.activity:activity-compose:1.7.2") - implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1") - implementation("androidx.compose.material3:material3:1.2.0-alpha02") - implementation("com.google.accompanist:accompanist-permissions:0.31.3-beta") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2") + implementation("androidx.compose.ui:ui:1.10.5") + implementation("androidx.compose.ui:ui-tooling:1.10.5") + implementation("androidx.compose.foundation:foundation:1.10.5") + implementation("androidx.activity:activity-compose:1.13.0") + implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.10.0") + implementation("androidx.compose.material3:material3:1.4.0") + implementation("com.google.accompanist:accompanist-permissions:0.37.3") } diff --git a/app/google-services.json b/app/google-services.json new file mode 100755 index 0000000..0743e05 --- /dev/null +++ b/app/google-services.json @@ -0,0 +1,25 @@ +{ + "project_info": { + "project_number": "000000000000", + "project_id": "onfleet-sdk-example-placeholder", + "storage_bucket": "onfleet-sdk-example-placeholder.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:000000000000:android:0000000000000000000000", + "android_client_info": { + "package_name": "com.onfleet.sdk.onfleetclientexample" + } + }, + "oauth_client": [], + "api_key": [ + { "current_key": "AIzaSyPLACEHOLDERPLACEHOLDERPLACEHOLDER00000" } + ], + "services": { + "appinvite_service": { "other_platform_oauth_client": [] } + } + } + ], + "configuration_version": "1" +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index baf361f..53f0aec 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,6 +6,9 @@ + diff --git a/app/src/main/assets/onfleet.properties b/app/src/main/assets/onfleet.properties deleted file mode 100644 index fb323d1..0000000 --- a/app/src/main/assets/onfleet.properties +++ /dev/null @@ -1,4 +0,0 @@ -#TODO: enter application name -applicationName= -#TODO: enter Onfleet SDK key -sdkApplicationId= diff --git a/app/src/main/assets/onfleet.properties.example b/app/src/main/assets/onfleet.properties.example new file mode 100644 index 0000000..200ba34 --- /dev/null +++ b/app/src/main/assets/onfleet.properties.example @@ -0,0 +1,5 @@ +# Copy this file to onfleet.properties and fill in the values. +# cp app/src/main/assets/onfleet.properties.example app/src/main/assets/onfleet.properties +# Both values are provided by Onfleet when you register your app. +applicationName= +sdkApplicationId= diff --git a/app/src/main/java/com/onfleet/sdk/onfleetclientexample/MainActivity.kt b/app/src/main/java/com/onfleet/sdk/onfleetclientexample/MainActivity.kt index 74d202c..a01fe9c 100755 --- a/app/src/main/java/com/onfleet/sdk/onfleetclientexample/MainActivity.kt +++ b/app/src/main/java/com/onfleet/sdk/onfleetclientexample/MainActivity.kt @@ -9,6 +9,7 @@ import android.widget.Toast import androidx.activity.compose.setContent import androidx.appcompat.app.AppCompatActivity import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.material3.* @@ -63,7 +64,7 @@ class MainActivity : AppCompatActivity() { } else if (!state.isAuthenticated) { var phone by remember { mutableStateOf("") } var password by remember { mutableStateOf("") } - Column(modifier = Modifier.fillMaxSize()) { + Column(modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center) { TextField(value = phone, label = { Text("Phone") }, onValueChange = { phone = it }) TextField( value = password, label = { Text("Password") }, onValueChange = { password = it }, @@ -80,7 +81,8 @@ class MainActivity : AppCompatActivity() { } else if (state.isList) { LazyColumn( contentPadding = PaddingValues(horizontal = 16.dp, vertical = 8.dp), - modifier = Modifier.fillMaxSize() + modifier = Modifier.fillMaxSize(), + verticalArrangement = Arrangement.Center ) { item { Switch( @@ -112,7 +114,7 @@ class MainActivity : AppCompatActivity() { } } else if (state.isDetails) { state.selectedTask?.let { - Column(modifier = Modifier.fillMaxSize()) { + Column(modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center) { Text("Details of " + it.shortId) Button( onClick = { diff --git a/app/src/main/java/com/onfleet/sdk/onfleetclientexample/MainViewModel.kt b/app/src/main/java/com/onfleet/sdk/onfleetclientexample/MainViewModel.kt index 77af083..d2e8837 100644 --- a/app/src/main/java/com/onfleet/sdk/onfleetclientexample/MainViewModel.kt +++ b/app/src/main/java/com/onfleet/sdk/onfleetclientexample/MainViewModel.kt @@ -1,6 +1,5 @@ package com.onfleet.sdk.onfleetclientexample -import android.os.Parcelable import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.google.firebase.messaging.FirebaseMessaging @@ -8,7 +7,6 @@ import com.onfleet.sdk.dataModels.* import com.onfleet.sdk.managers.* import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch -import kotlinx.parcelize.Parcelize import timber.log.Timber class MainViewModel : ViewModel() { @@ -17,7 +15,6 @@ class MainViewModel : ViewModel() { private var cachedPhoneNumber = "" // for simplification - don't cache sensitive data private var cachedPassword = "" // for simplification - don't cache sensitive data - @Parcelize data class State( val isLoading: Boolean = false, val isAuthenticated: Boolean = false, @@ -26,7 +23,7 @@ class MainViewModel : ViewModel() { val isDetails: Boolean = false, val tasks: List = emptyList(), val selectedTask: Task? = null, - ) : Parcelable + ) sealed class Event { data class OnDutyClicked(val status: Boolean) : Event() @@ -43,7 +40,7 @@ class MainViewModel : ViewModel() { viewModelScope.launch { SessionManager.getInstance().getAccountsFlow().collect { accounts -> for (account in accounts) { - if (account.isPending()) { + if (account.accountStatus == AccountStatus.INVITED) { SessionManager.getInstance().respondToInvitation(account, true) } } @@ -55,7 +52,7 @@ class MainViewModel : ViewModel() { } } viewModelScope.launch { - TasksManager.getInstance().getTasksFlow().collect { tasks -> + TasksManager.getInstance().getTasks().collect { tasks -> val selectedTask = tasks.find { it.id == _state.value.selectedTask?.id } _state.update { it.copy(tasks = tasks, selectedTask = selectedTask) } } @@ -80,6 +77,11 @@ class MainViewModel : ViewModel() { // resolve in activity } } + SDKErrorType.INTEGRITY_API_NOT_AVAILABLE -> {} + SDKErrorType.INTEGRITY_CANNOT_BIND_TO_SERVICE -> {} + SDKErrorType.PLAY_SERVICES_NOT_FOUND -> {} + SDKErrorType.PLAY_STORE_ACCOUNT_NOT_FOUND -> {} + SDKErrorType.PLAY_STORE_NOT_FOUND -> {} } } } @@ -92,7 +94,7 @@ class MainViewModel : ViewModel() { LoginStatus.SET_NEW_PASSWORD_SUCCESS, LoginStatus.PROVISIONING_COMPLETED_LOG_IN -> { SessionManager.getInstance().login(cachedPhoneNumber, cachedPassword) } - LoginStatus.WAIT_PROVISIONING, LoginStatus.WAIT_ADMIN_VERIFICATION, LoginStatus.WAIT_SMS_VERIFICATION, LoginStatus.RECEIVED_SMS_VERIFICATION -> { + LoginStatus.WAIT_PROVISIONING -> { Timber.d(status.toString()) } LoginStatus.SET_NEW_PASSWORD -> { @@ -142,7 +144,7 @@ class MainViewModel : ViewModel() { private fun onSelfAssignClicked(task: Task) = viewModelScope.launch { _state.update { it.copy(isLoading = true) } - when (val response = TasksManager.getInstance().selfAssignTask(listOf(task.id))) { + when (val response = TasksManager.getInstance().selfAssignTasks(listOf(task.id))) { SelfAssignResponse.SUCCESS -> {} else -> { Timber.e(response.toString()) @@ -166,6 +168,8 @@ class MainViewModel : ViewModel() { successNotes = null, completionStatusReason = null, signatureText = null, + attestationAge = null, + customRequirements = null, ), ) ) { diff --git a/app/src/main/java/com/onfleet/sdk/onfleetclientexample/OnfleetClientExampleApplication.kt b/app/src/main/java/com/onfleet/sdk/onfleetclientexample/OnfleetClientExampleApplication.kt index 4350ca0..20c902e 100755 --- a/app/src/main/java/com/onfleet/sdk/onfleetclientexample/OnfleetClientExampleApplication.kt +++ b/app/src/main/java/com/onfleet/sdk/onfleetclientexample/OnfleetClientExampleApplication.kt @@ -1,6 +1,5 @@ package com.onfleet.sdk.onfleetclientexample -import androidx.multidex.MultiDex import android.os.Build import android.os.Build.VERSION_CODES import android.annotation.TargetApi @@ -17,15 +16,11 @@ import timber.log.Timber.Forest.plant class OnfleetClientExampleApplication : Application() { override fun attachBaseContext(base: Context) { super.attachBaseContext(base) - MultiDex.install(this) } override fun onCreate() { super.onCreate() - if (BuildConfig.DEBUG) { - plant(Timber.DebugTree()) - } - + plant(Timber.DebugTree()) initOnfleetSDK() } diff --git a/build.gradle.kts b/build.gradle.kts index c2be8f4..bf549db 100755 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,25 +1,10 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - repositories { - mavenCentral() - google() - } - dependencies { - classpath("com.android.tools.build:gradle:7.4.2") - classpath("com.google.gms:google-services:4.3.15") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21") - } +plugins { + id("com.android.application") version "9.1.0" apply false + id("com.android.library") version "9.1.0" apply false + id("com.google.gms.google-services") version "4.4.4" apply false + id("org.jetbrains.kotlin.plugin.compose") version "2.1.0" apply false + id("org.jetbrains.kotlin.plugin.parcelize") version "2.1.0" apply false } -allprojects { - repositories { - google() - maven("https://jitpack.io") - mavenCentral() - } -} - -tasks.register("clean", Delete::class) { - delete(rootProject.buildDir) -} diff --git a/gradle.properties b/gradle.properties index dc251f5..96a4eb2 100755 --- a/gradle.properties +++ b/gradle.properties @@ -6,10 +6,9 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx1536m -# 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.jvmargs=-XX:+UseParallelGC -Xmx8g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +org.gradle.parallel=true +org.gradle.caching=true android.useAndroidX=true -android.enableJetifier=true \ No newline at end of file +android.nonTransitiveRClass=true +org.gradle.configureondemand=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..61285a6 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5de896a..a2ea75a 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..61b77d7 --- /dev/null +++ b/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# 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. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# 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/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# 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 -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 + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..bd8a8c0 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,93 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@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 ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +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 + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +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 + +:execute +@rem Setup the command line + + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle index e7b4def..60dbe62 100755 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,22 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.10.0' +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + // mavenLocal() // uncomment for local testing of unreleased SDK builds (./gradlew publishToMavenLocal) + google() + mavenCentral() + maven { url 'https://jitpack.io' } + } +} include ':app'