Skip to content

Commit 38b7d01

Browse files
Merge pull request #27 from getyoti/YM-26133_V2
[YM-26133] Update publication scripts
2 parents 69b2ff3 + 426cb64 commit 38b7d01

File tree

5 files changed

+67
-42
lines changed

5 files changed

+67
-42
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
sonatypePassword: ${{ secrets.sonatypePassword }}
7575
signingKey: ${{ secrets.signingPrivateKey }}
7676
signingPassword: ${{ secrets.signingPrivateKeyPassword }}
77-
run: ./gradlew publishAarReleasePublicationToMavenCentralRepository closeAndReleaseRepository -PsonatypeUsername="$sonatypeUsername" -PsonatypePassword="$sonatypePassword" -PinMemorySigningKey="$signingKey" -PinMemoryKeyPassword="$signingPassword" --no-daemon
77+
run: ./gradlew publishAarReleasePublicationToSonatype closeAndReleaseRepository -PsonatypeUsername="$sonatypeUsername" -PsonatypePassword="$sonatypePassword" -PinMemorySigningKey="$signingKey" -PinMemoryKeyPassword="$signingPassword" --no-daemon
7878

7979
tag:
8080
runs-on: ubuntu-latest

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ buildscript {
66
jcenter()
77
google()
88
mavenCentral()
9+
maven { url "https://plugins.gradle.org/m2/" }
910
}
1011
dependencies {
1112
classpath 'com.android.tools.build:gradle:3.5.4'
13+
classpath "de.marcphilipp.gradle:nexus-publish-plugin:0.4.0"
1214
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.20.0"
1315
}
1416
}
15-
1617
apply plugin: 'io.codearte.nexus-staging'
1718

1819

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ pomId=yoti-button-sdk
5757
pomGroup=com.yoti.mobile.android.sdk
5858
pomPackaging=aar
5959
pomVersion=1.3.3
60+
pomName=Yoti Button SDK
6061
pomDescription=Button SDK that allows 3rd party to trigger Yoti as support app
6162
currentVersionCode=000013
6263

publish-aar.gradle

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Version 2.1.1
1+
//Version 2.2.2
22
buildscript {
33
repositories {
44
mavenCentral()
@@ -57,17 +57,24 @@ project.afterEvaluate {
5757

5858
def allTaskNames
5959

60+
def includeDebug = project.hasProperty('publishReleaseOnly') ?
61+
!Boolean.valueOf(publishReleaseOnly) : true
62+
6063
if (project.hasProperty('productFlavors')) {
6164
def parts = productFlavors.split(",")
6265
allTaskNames = new ArrayList<?>(parts.length * 2)
6366
for (part in parts) {
64-
allTaskNames.add(tasksContainer.getByName("bundle${part.capitalize()}DebugAar"))
67+
if (includeDebug) {
68+
allTaskNames.add(tasksContainer.getByName("bundle${part.capitalize()}DebugAar"))
69+
}
6570
allTaskNames.add(tasksContainer.getByName("bundle${part.capitalize()}ReleaseAar"))
6671
}
6772
} else {
6873
allTaskNames = new ArrayList<?>(2)
6974
allTaskNames.add(tasksContainer.getByName("bundleReleaseAar"))
70-
allTaskNames.add(tasksContainer.getByName("bundleDebugAar"))
75+
if (includeDebug) {
76+
allTaskNames.add(tasksContainer.getByName("bundleDebugAar"))
77+
}
7178
}
7279

7380

@@ -252,24 +259,21 @@ project.afterEvaluate {
252259

253260
def scopes = ["compile", "api", "implementation"]
254261
for (scope in scopes) {
255-
for (conf in configurations) {
256-
def confName = conf.name.toLowerCase()
257-
258-
if (confName.endsWith(scope) &&
259-
!confName.contains("test") &&
260-
!confName.contains("metadata") &&
261-
!confName.contains("android") &&
262-
!confName.contains("dependencies") && (
263-
264-
// Only consider the debug dependencies for debug publication
265-
// equally release for release or normal (neither debug,
266-
// nor release)
267-
(buildTypeLower == "debug" && confName.contains('debug')) ||
268-
(buildTypeLower == "release" && confName.contains('release')) ||
269-
(!confName.contains('debug') && !confName.contains('release'))
270-
)
271-
) {
272-
conf.getDependencies().each { dep ->
262+
def scopeConfigurations = new ArrayList<String>(4)
263+
//api
264+
scopeConfigurations.add(scope)
265+
//debugApi
266+
scopeConfigurations.add(buildTypeLower + scope.capitalize())
267+
if (!productFlavorLower.empty) {
268+
//stagingApi
269+
scopeConfigurations.add(productFlavorLower + scope.capitalize())
270+
//stagingDebugApi
271+
scopeConfigurations.add(productFlavorLower + buildTypeLower.capitalize() + scope.capitalize())
272+
}
273+
274+
for (confName in scopeConfigurations) {
275+
configurations.getByName(confName) {
276+
getDependencies().each { dep ->
273277
//Ignore kotlin transitive dependencies as they will be applied
274278
// by the kotlin plugin
275279
if (!(dep.group == "org.jetbrains.kotlin" &&
@@ -398,8 +402,11 @@ class ArtefactFlavorConf {
398402

399403
// Allow the definition to be only artefact name-based
400404
boolean isArtefact(PropertyDependency dependency) {
401-
return (artefact == dependency || (artefact.isNameOnly() && artefact.name == dependency.name)) ||
402-
isForAllArtefacts()
405+
return (artefact == dependency || isNamedArtefact(dependency.name))
406+
}
407+
408+
boolean isNamedArtefact(String name) {
409+
return (artefact.isNameOnly() && artefact.name == name) || iusForAllArtefacts()
403410
}
404411

405412
boolean hasFlavor(String flavorName) {
@@ -435,6 +442,21 @@ class ArtefactFlavorProperties {
435442
configuration = []
436443
}
437444

445+
boolean ignoreFlavorFor(ProjectDependency dependency, String flavor) {
446+
if (flavor.empty) {
447+
//No flavours in project, treat this as ignored
448+
return true
449+
}
450+
451+
for (ArtefactFlavorConf conf : configuration) {
452+
if (conf.isNamedArtefact(dependency.name) && conf.hasFlavor(flavor)){
453+
return true
454+
}
455+
}
456+
457+
return false
458+
}
459+
438460
boolean ignoreFlavorFor(PropertyDependency dependency, String flavor){
439461
if (flavor.empty) {
440462
//No flavours in project, treat this as ignored

publish-maven.gradle

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
1-
//Version 2.1.0
2-
apply from: "$rootDir/publish-aar.gradle"
1+
//Version 3.0.1
2+
if (project.hasProperty('publicationGradleFileUrl')) {
3+
apply from: publicationGradleFileUrl
4+
} else {
5+
apply from: "$rootDir/publish-aar.gradle"
6+
}
37

48
apply plugin: 'maven-publish'
59
apply plugin: 'signing'
10+
apply plugin: 'de.marcphilipp.nexus-publish'
611

712
nexusStaging {
813
// this package group has to be this one so that all yoti publication there are under the same group
914
packageGroup = "com.yoti"
1015

1116
username = sonatypeUsername
1217
password = sonatypePassword
18+
19+
delayBetweenRetriesInMillis = 15000
1320
}
1421

15-
project.afterEvaluate {
16-
publishing {
17-
repositories {
18-
maven {
19-
def repoUrl = project.hasProperty('ossrhRepository') ?
20-
ossrhRepository : "https://oss.sonatype.org/service/local/staging/deploy/maven2"
21-
22-
name = "mavenCentral"
23-
url = repoUrl
24-
credentials {
25-
username = sonatypeUsername
26-
password = sonatypePassword
27-
}
28-
}
29-
}
22+
import java.time.Duration
23+
24+
nexusPublishing {
25+
repositories {
26+
sonatype()
3027
}
28+
connectTimeout = Duration.ofMinutes(5)
29+
clientTimeout = Duration.ofMinutes(10)
30+
}
3131

32+
project.afterEvaluate {
3233
signing {
3334
def performSigning = !(project.hasProperty('disableSigning') ?
3435
Boolean.valueOf(disableSigning) : false)

0 commit comments

Comments
 (0)