Skip to content

Commit

Permalink
Update dependencies and cleanup VersioningPlugin.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonMarquis committed May 1, 2020
1 parent 97eac47 commit afd469d
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 74 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ versioning {

android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
buildToolsVersion '29.0.3'
defaultConfig {
applicationId "fr.smarquis.ar_toolbox"
minSdkVersion 24
Expand Down Expand Up @@ -55,12 +55,12 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.browser:browser:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.core:core-ktx:1.3.0-alpha01'
implementation 'androidx.core:core-ktx:1.3.0-rc01'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
implementation 'androidx.preference:preference-ktx:1.1.0'
implementation 'androidx.preference:preference-ktx:1.1.1'

implementation 'com.google.android.material:material:1.2.0-alpha04'
implementation 'com.google.android.material:material:1.2.0-alpha06'

implementation 'com.google.ar:core:1.16.0'
implementation 'com.google.ar.sceneform:core:1.15.0'
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/bottom_sheet_face.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
app:behavior_hideable="true"
app:behavior_peekHeight="@dimen/bottom_sheet_peek_height"
app:behavior_skipCollapsed="false"
app:gestureInsetBottomIgnored="true"
app:layout_behavior="@string/bottom_sheet_behavior"
tools:showIn="@layout/activity_face">

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/bottom_sheet_node.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
android:theme="@style/ThemeOverlay.MaterialComponents.Light"
app:behavior_hideable="true"
app:behavior_peekHeight="0dp"
app:gestureInsetBottomIgnored="true"
app:layout_behavior="@string/bottom_sheet_behavior"
tools:showIn="@layout/activity_scene">

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/bottom_sheet_scene.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
app:behavior_hideable="true"
app:behavior_peekHeight="@dimen/bottom_sheet_peek_height"
app:behavior_skipCollapsed="false"
app:gestureInsetBottomIgnored="true"
app:layout_behavior="@string/bottom_sheet_behavior"
tools:showIn="@layout/activity_scene">

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
buildscript {
ext.kotlin_version = '1.3.61'
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0-alpha09'
classpath 'com.android.tools.build:gradle:4.1.0-alpha08'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.ar.sceneform:plugin:1.15.0'
}
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'kotlin'

buildscript {
ext.kotlin_version = '1.3.61'
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
Expand All @@ -17,5 +17,5 @@ repositories {
}

dependencies {
implementation 'com.android.tools.build:gradle:4.0.0-alpha09'
implementation 'com.android.tools.build:gradle:4.1.0-alpha08'
}
65 changes: 0 additions & 65 deletions buildSrc/src/main/java/VersioningPlugin.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import com.android.build.gradle.AppExtension
import com.android.build.gradle.BaseExtension
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.internal.api.ApkVariantOutputImpl
import com.android.build.gradle.internal.api.LibraryVariantOutputImpl
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand All @@ -20,13 +16,6 @@ import org.gradle.api.Project
class VersioningPlugin : Plugin<Project> {

companion object {
private val ABI_CODES = mapOf(
"universal" to 0,
"armeabi-v7a" to 1,
"arm64-v8a" to 2,
"x86" to 3,
"x86_64" to 4
)
private const val EXTENSION_KEY = "versioning"
}

Expand All @@ -35,10 +24,6 @@ class VersioningPlugin : Plugin<Project> {
project.afterEvaluate {
validateExtension(version)
validateDefaultConfig(project, version)
when {
project.plugins.hasPlugin("com.android.application") -> renameApplication(project, version)
project.plugins.hasPlugin("com.android.library") -> renameLibrary(project, version)
}
}
}

Expand Down Expand Up @@ -81,56 +66,6 @@ class VersioningPlugin : Plugin<Project> {
}
}

private val BaseExtension.app: AppExtension
get() = this as AppExtension

@SuppressWarnings("DefaultLocale")
private fun renameApplication(project: Project, version: Version) {
project.android.app.applicationVariants.all { variant ->
// Rename APKs
variant.outputs.all { output ->
@Suppress("LABEL_NAME_CLASH")
val apk = output as? ApkVariantOutputImpl ?: return@all
if (project.android.splits.abi.isEnable) {
val abi = apk.getFilter("ABI") ?: "universal"
apk.versionCodeOverride = variant.versionCode * 10 + ABI_CODES.getValue(abi)
apk.outputFileName = "${variant.applicationId}-${version.name()}-$abi-${variant.baseName}.apk"
} else {
apk.outputFileName = "${variant.applicationId}-${version.name()}-${variant.baseName}.apk"
}
project.logger.lifecycle(apk.outputFileName)
}

// Rename AABs
val bundleTask = project.tasks.getByName("bundle${variant.name.capitalize()}")
val renamingTask = project.tasks.register("${bundleTask.name}Renaming") { task ->
task.doLast {
val directory = "${project.buildDir}/outputs/bundle/${variant.name}"
val aab = project.fileTree(directory) { it.include("*.aab") }.firstOrNull() ?: return@doLast
val filename = "${variant.applicationId}-${version.name()}-${variant.baseName}.aab"
aab.renameTo(project.file("$directory/$filename"))
project.logger.lifecycle(filename)
}
}
bundleTask.finalizedBy(renamingTask)
}
}

private val BaseExtension.lib: LibraryExtension
get() = this as LibraryExtension

private fun renameLibrary(project: Project, version: Version) {
project.android.lib.libraryVariants.all { variant ->
variant.outputs.all { output ->
@Suppress("LABEL_NAME_CLASH")
val aar = (output as? LibraryVariantOutputImpl) ?: return@all
val archivesBaseName = project.property("archivesBaseName")
aar.outputFileName = "$archivesBaseName-${version.name()}-${variant.baseName}.aar"
project.logger.lifecycle(aar.outputFileName)
}
}
}

}

open class Version(
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip

0 comments on commit afd469d

Please sign in to comment.