use Gradle Kotlin DSL

This commit is contained in:
Daniel Micay 2021-11-21 15:10:47 -05:00
parent a68bac16d6
commit a40708ce02
7 changed files with 95 additions and 98 deletions

2
.gitignore vendored
View File

@ -2,7 +2,7 @@
.gradle
local.properties
build/
signing.properties
keystore.properties
*.keystore
/.idea
/releases

View File

@ -1,65 +0,0 @@
plugins {
id "com.android.application"
}
android {
compileSdkVersion 31
buildToolsVersion "31.0.0"
defaultConfig {
applicationId "org.grapheneos.pdfviewer"
minSdkVersion 26
targetSdkVersion 31
versionCode 6
versionName versionCode.toString()
resConfigs "en"
}
signingConfigs {
release
}
buildTypes {
debug {
applicationIdSuffix ".debug"
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}
dependencies {
implementation fileTree(include: ["*.jar"], dir: "libs")
implementation "androidx.appcompat:appcompat:1.4.0"
implementation "com.google.android.material:material:1.4.0"
}
def props = new Properties()
def propFile = new File("signing.properties")
if (propFile.canRead()) {
props.load(new FileInputStream(propFile))
if (props != null &&
props.containsKey("STORE_FILE") &&
props.containsKey("STORE_PASSWORD") &&
props.containsKey("KEY_ALIAS") &&
props.containsKey("KEY_PASSWORD")) {
android.signingConfigs.release.storeFile = rootProject.file(props["STORE_FILE"])
android.signingConfigs.release.storePassword = props["STORE_PASSWORD"]
android.signingConfigs.release.keyAlias = props["KEY_ALIAS"]
android.signingConfigs.release.keyPassword = props["KEY_PASSWORD"]
} else {
println "signing.properties found but some entries are missing"
android.buildTypes.release.signingConfig = null
}
} else {
println "signing.properties not found"
android.buildTypes.release.signingConfig = null
}

63
app/build.gradle.kts Normal file
View File

@ -0,0 +1,63 @@
import java.util.Properties
import java.io.FileInputStream
val keystorePropertiesFile = rootProject.file("keystore.properties")
val useKeystoreProperties = keystorePropertiesFile.canRead()
val keystoreProperties = Properties()
if (useKeystoreProperties) {
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}
plugins {
id("com.android.application")
}
android {
if (useKeystoreProperties) {
signingConfigs {
create("release") {
storeFile = rootProject.file(keystoreProperties["storeFile"]!!)
storePassword = keystoreProperties["storePassword"] as String
keyAlias = keystoreProperties["keyAlias"] as String
keyPassword = keystoreProperties["keyPassword"] as String
}
}
}
compileSdk = 31
buildToolsVersion("31.0.0")
defaultConfig {
applicationId = "org.grapheneos.pdfviewer"
minSdk = 26
targetSdk = 31
versionCode = 6
versionName = versionCode.toString()
resConfigs("en")
}
buildTypes {
getByName("debug") {
applicationIdSuffix = ".debug"
}
getByName("release") {
isShrinkResources = true
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
if (useKeystoreProperties) {
signingConfig = signingConfigs.getByName("release")
}
}
}
compileOptions {
sourceCompatibility(JavaVersion.VERSION_11)
targetCompatibility(JavaVersion.VERSION_11)
}
}
dependencies {
implementation("androidx.appcompat:appcompat:1.4.0")
implementation("com.google.android.material:material:1.4.0")
}

View File

@ -1,31 +0,0 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

22
build.gradle.kts Normal file
View File

@ -0,0 +1,22 @@
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.3")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0")
}
}
allprojects {
tasks.withType<JavaCompile> {
val compilerArgs = options.compilerArgs
compilerArgs.add("-Xlint:unchecked")
compilerArgs.add("-Xlint:deprecation")
}
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}

View File

@ -1 +0,0 @@
include ':app'

9
settings.gradle.kts Normal file
View File

@ -0,0 +1,9 @@
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "PdfViewer"
include(":app")