Skip to content

Commit

Permalink
fix f-droid build for realz
Browse files Browse the repository at this point in the history
seems like dynamic version code or version name is a big no-no for
f-droid, so instead we'll make do with checking proper version updates
during build
  • Loading branch information
ostrya committed Nov 13, 2019
1 parent 85ea385 commit 878bd12
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
31 changes: 12 additions & 19 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
import org.apache.tools.ant.taskdefs.condition.Os

plugins {
id 'com.github.triplet.play' version '2.4.2'
id 'com.jaredsburrows.license' version '0.8.42'
id 'org.ajoberstar.grgit' version '4.0.0-rc.1'
id 'pl.allegro.tech.build.axion-release' version '1.10.2'
}

apply plugin: 'com.android.application'

scmVersion {
tag {
prefix = 'v'
versionSeparator = ''
}
branchVersionIncrementer = [
'feature/.*' : 'incrementMinor',
'master' : 'incrementMinor',
]
}

def getBuildVersionCode() {
def tagCount = grgit.tag.list().findAll{ it.getName().matches('v[1-9].*') }.size()
return isTagged() ? tagCount : tagCount + 1
Expand All @@ -29,8 +15,12 @@ def getBuildApplicationId() {
return isTagged() ? 'org.ostrya.presencepublisher' : 'org.ostrya.presencepublisher.snapshot'
}

def getBuildVersionName() {
return grgit.describe(tags: true, match: ['v[1-9]*']).substring(1)
}

def isTagged() {
return grgit.describe(tags: true, match: ['v[1-9]*']) == "v${scmVersion.version}"
return getBuildVersionName().matches('[0-9]+\\.[0-9]+\\.[0-9]+')
}

def getSigningConfig() {
Expand All @@ -52,8 +42,8 @@ android {
applicationId getBuildApplicationId()
minSdkVersion 14
targetSdkVersion 28
versionCode 19
versionName scmVersion.version
versionCode 20
versionName '1.6.4'
}
signingConfigs {
release getSigningConfig()
Expand All @@ -77,14 +67,17 @@ android {
}

afterEvaluate {
preBuild.dependsOn(checkVersionCode)
preBuild.dependsOn(checkParameters)
}

task checkVersionCode {
task checkParameters {
doLast {
if (android.defaultConfig.versionCode != getBuildVersionCode()) {
throw new InvalidUserDataException("Version code should be ${getBuildVersionCode()}")
}
if (isTagged() && getBuildVersionName() != android.defaultConfig.versionName) {
throw new InvalidUserDataException("Version name should be ${getBuildVersionName()}")
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/play/release-notes/en-US/default.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v1.6.4
• Next attempt to fix F-Droid build.

v1.6.3:
• More minor build script changes to fix F-Droid build.

Expand Down

0 comments on commit 878bd12

Please sign in to comment.