Skip to content

Commit c8fbdba

Browse files
authored
Remove the need to update the version in two places (#80)
When doing a version bump, we should keep the values in pubspec.yaml and config.gradle for android the same. This PR uses a gradle Yaml library to parse the pubspec version and use it in the gradle config step. I am also updating the gradle version and have applied some auto generated android studio fixes related to migrating to AndroidX.
1 parent 39e852d commit c8fbdba

File tree

7 files changed

+48
-9
lines changed

7 files changed

+48
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Next Release
2+
3+
- Fixes versioning system to not require a manual update in two places. (#80)
4+
- Updates Gradle version and enable AndroidX for Android plugin and example. (#80)
5+
- Changes open source license to modified BSD instead of Apache. (#79)
6+
17
## [1.10.3] - 11 Jan 2021
28

39
- Updates copyright year to 2021. (#75)

android/config.gradle

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
* UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
77
* This notice may not be removed from this file.
88
*/
9+
10+
buildscript {
11+
repositories {
12+
jcenter()
13+
}
14+
dependencies {
15+
classpath "org.yaml:snakeyaml:1.27"
16+
}
17+
}
18+
19+
import org.yaml.snakeyaml.Yaml
20+
921
def localProperties = new Properties()
1022
def localPropertiesFile = rootProject.file('local.properties')
1123
if (localPropertiesFile.exists()) {
@@ -31,10 +43,17 @@ if (pspdfkitVersion == null || pspdfkitVersion == '') {
3143

3244
ext.pspdfkitMavenModuleName = 'pspdfkit'
3345

34-
ext.pspdfkitFlutterVersion = '1.10.3'
46+
// Get our library version from the top level pubspec.yaml file.
47+
def pubspecFilePath = '../pubspec.yaml'
48+
def pubspecFile = rootProject.file(pubspecFilePath)
49+
if (!pubspecFile.exists()) {
50+
throw new GradleException("'pubspec.yaml' file not found. Expected at the top level of the Flutter repository.")
51+
}
52+
def pubspecYaml = new Yaml().load(pubspecFile.newInputStream())
53+
ext.pspdfkitFlutterVersion = pubspecYaml.version
3554

3655
ext.androidCompileSdkVersion = 29
3756
ext.androidBuildToolsVersion = '29.0.1'
3857
ext.androidMinSdkVersion = 19
3958
ext.androidTargetSdkVersion = 29
40-
ext.androidGradlePluginVersion = '3.6.3'
59+
ext.androidGradlePluginVersion = '4.1.1'

android/gradle.properties

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1+
## For more details on how to configure your build environment visit
2+
# http://www.gradle.org/docs/current/userguide/build_environment.html
3+
#
4+
# Specifies the JVM arguments used for the daemon process.
5+
# The setting is particularly useful for tweaking memory settings.
6+
# Default value: -Xmx1024m -XX:MaxPermSize=256m
7+
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
8+
#
9+
# When configured, Gradle will run in incubating parallel mode.
10+
# This option should only be used with decoupled projects. More details, visit
11+
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
12+
# org.gradle.parallel=true
13+
#Mon Feb 01 09:50:51 GMT 2021
14+
android.enableJetifier=true
15+
android.useAndroidX=true
16+
org.gradle.configureondemand=false
117
org.gradle.jvmargs=-Xmx1536M
2-
org.gradle.configureondemand=false
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Jul 16 16:27:42 CEST 2018
1+
#Mon Feb 01 16:17:50 GMT 2021
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ flutter {
4444
}
4545

4646
dependencies {
47-
compile 'com.android.support:multidex:1.0.3'
47+
implementation 'com.android.support:multidex:1.0.3'
4848
testImplementation 'junit:junit:4.12'
4949
androidTestImplementation 'androidx.test:runner:1.1.1'
5050
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

example/android/gradle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ org.gradle.jvmargs=-Xmx1536M
22
org.gradle.configureondemand=false
33
android.useAndroidX=true
44
android.enableJetifier=true
5-
android.enableR8=true
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Jun 23 08:50:38 CEST 2017
1+
#Tue Feb 02 09:21:10 GMT 2021
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

0 commit comments

Comments
 (0)