Skip to content

Commit a723638

Browse files
authored
Merge pull request #186 from rees46/bugfix/DEV-3859-fix-jitpack-publish
DEV-3859: fix android build for jitpack
2 parents 2c4e907 + 15673e3 commit a723638

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ plugins {
1919
}
2020

2121
def versionFile = file("version.properties")
22-
def projectVersion = versionFile.text.split("VERSION_NAME=")[1].trim()
22+
def fileVersion = versionFile.text.split("VERSION_NAME=")[1].trim()
23+
// Use version passed by JitPack (-Pversion=vX.Y.Z), stripping the 'v' prefix if present.
24+
// Falls back to version.properties for local builds.
25+
def jitpackVersion = (project.hasProperty('version') && project.version != 'unspecified')
26+
? project.version.toString().replaceAll('^v', '')
27+
: fileVersion
2328

2429
project(':personalization-sdk') {
25-
version=projectVersion
30+
version = jitpackVersion
2631
}
2732

2833
allprojects {

gradle/publishing/publications.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ publishing {
1111
return
1212
}
1313

14-
if (variant.flavorName != variantName) {
14+
// When variantName is empty (e.g. JitPack builds), publish all release variants.
15+
// When variantName is set (CI/CD), publish only the matching flavor.
16+
if (variantName && variant.flavorName != variantName) {
1517
println "Skipping variant due to flavor mismatch: ${variant.flavorName} != ${variantName}"
1618
return
1719
}

personalization-sdk/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ tasks.register('sourcesJar', Jar) {
124124
}
125125

126126
tasks.register('javadoc', Javadoc) {
127-
source = fileTree(dir: 'src/main/kotlin', include: '**/*.kt')
127+
// Javadoc tool cannot process .kt files — only include generated .java stubs
128+
source = fileTree(dir: 'src/main/kotlin', include: '**/*.java')
128129
classpath += files("${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
129130
failOnError false
130131
options.encoding = 'UTF-8'

0 commit comments

Comments
 (0)