Skip to content

Commit

Permalink
fix: [MASTER-DEV] Port fix 1.10.0.1 (#2165)
Browse files Browse the repository at this point in the history
  • Loading branch information
vgarciabnz authored Jun 17, 2024
2 parents cb56633 + d7f9ea6 commit 286734c
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 116 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
workflow_dispatch

jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: 'gradle'
- name: Change wrapper permission
run: chmod +x ./gradlew

- name: Publish Maven
run: ./.github/workflows/scripts/publish-maven.sh
env:
NEXUS_USERNAME: ${{ secrets.SONATYPE_OSSRH_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.SONATYPE_OSSRH_PASSWORD }}
SIGNING_PRIVATE_KEY: ${{ secrets.PGP_PRIVATE_KEY }}
SIGNING_PASSWORD: ${{ secrets.PGP_PASSPHRASE }}
9 changes: 9 additions & 0 deletions .github/workflows/scripts/publish-maven.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set -x

branch=$(git rev-parse --abbrev-ref HEAD)

if [ "$branch" = "main" ] || [ "$branch" = "master" ]; then
./gradlew :core:publishToSonatype closeAndReleaseSonatypeStagingRepository -PremoveSnapshotSuffix
else
./gradlew :core:publishToSonatype
fi
6 changes: 1 addition & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ pipeline {
// Do not deploy on PR builds
expression { env.CHANGE_ID == null }
anyOf {
expression { env.GIT_BRANCH == "master" }
expression { env.GIT_BRANCH == "develop" }
expression { env.GIT_BRANCH ==~ /[0-9]+\.[0-9]+\.[0-9]+-rc/ }
}
Expand All @@ -85,13 +84,10 @@ pipeline {
environment {
NEXUS_USERNAME = credentials('android-sonatype-nexus-username')
NEXUS_PASSWORD = credentials('android-sonatype-nexus-password')
GPG_KEY_ID = credentials('android-sdk-signing-public-key-id')
GPG_PASSPHRASE = credentials('android-sdk-signing-private-key-password')
GPG_KEY_LOCATION = credentials('android-sdk-signing-private-key-ring-file')
}
steps {
echo 'Deploy to Sonatype nexus'
sh './gradlew :core:publish'
sh './gradlew :core:publishToSonatype'
}
}
}
Expand Down
27 changes: 24 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType

group = "org.hisp.dhis"
version = libs.versions.dhis2AndroidSdkVersion.get()

/**
* Property from the Gradle command line. To remove the snapshot suffix from the version.
*/
if (project.hasProperty("removeSnapshotSuffix")) {
val mainVersion = (version as String).split("-SNAPSHOT")[0]
version = mainVersion
}

buildscript {
repositories {
google()
Expand All @@ -18,6 +29,7 @@ buildscript {
plugins {
alias(libs.plugins.sonarqube)
alias(libs.plugins.dokka)
alias(libs.plugins.nexus.publish)
}

sonarqube {
Expand Down Expand Up @@ -58,9 +70,6 @@ subprojects {
apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "org.jetbrains.dokka")

//group = GROUP
//version = VERSION_NAME

configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
version.set("0.50.0")
android.set(true)
Expand All @@ -70,4 +79,16 @@ subprojects {
reporter(ReporterType.CHECKSTYLE)
}
}
}

val nexusUsername: String? = System.getenv("NEXUS_USERNAME")
val nexusPassword: String? = System.getenv("NEXUS_PASSWORD")

nexusPublishing {
this.repositories {
sonatype {
username.set(nexusUsername)
password.set(nexusPassword)
}
}
}
27 changes: 13 additions & 14 deletions buildSrc/src/main/kotlin/Props.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@
*/

object Props {
val GROUP = "org.hisp.dhis"
val POM_NAME = "Core"
val POM_ARTIFACT_ID = "android-core"
val POM_PACKAGING = "aar"
val POM_DESCRIPTION = "Android SDK for DHIS 2."
val POM_URL = "https://github.com/dhis2/dhis2-android-sdk"
val POM_SCM_URL = "https://github.com/dhis2/dhis2-android-sdk"
val POM_SCM_CONNECTION = "scm:git:git://github.com/dhis2/dhis2-android-sdk.git"
val POM_SCM_DEV_CONNECTION = "scm:git:ssh://[email protected]/dhis2/dhis2-android-sdk.git"
val POM_LICENCE_NAME = "BSD"
val POM_LICENCE_URL = "https://opensource.org/licenses/BSD-3-Clause"
val POM_LICENCE_DIST = "repo"
val POM_DEVELOPER_ID = "DHIS 2"
val POM_DEVELOPER_NAME = "DHIS 2"
const val POM_NAME = "Core"
const val POM_ARTIFACT_ID = "android-core"
const val POM_PACKAGING = "aar"
const val POM_DESCRIPTION = "Android SDK for DHIS 2."
const val POM_URL = "https://github.com/dhis2/dhis2-android-sdk"
const val POM_SCM_URL = "https://github.com/dhis2/dhis2-android-sdk"
const val POM_SCM_CONNECTION = "scm:git:git://github.com/dhis2/dhis2-android-sdk.git"
const val POM_SCM_DEV_CONNECTION = "scm:git:ssh://[email protected]/dhis2/dhis2-android-sdk.git"
const val POM_LICENCE_NAME = "BSD"
const val POM_LICENCE_URL = "https://opensource.org/licenses/BSD-3-Clause"
const val POM_LICENCE_DIST = "repo"
const val POM_DEVELOPER_ID = "DHIS 2"
const val POM_DEVELOPER_NAME = "DHIS 2"
}
63 changes: 9 additions & 54 deletions buildSrc/src/main/kotlin/maven-publish-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,50 +26,17 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import java.net.URI

plugins {
`maven-publish`
signing
}

val VERSION_NAME: String by project

fun isReleaseBuild(): Boolean {
return !VERSION_NAME.contains("SNAPSHOT")
}

val releaseRepositoryUrl: String = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"

val snapshotRepositoryUrl: String = "https://oss.sonatype.org/content/repositories/snapshots/"

fun getRepositoryUsername(): String? {
return System.getenv("NEXUS_USERNAME")
return !version.toString().endsWith("-SNAPSHOT")
}

fun getRepositoryPassword(): String? {
return System.getenv("NEXUS_PASSWORD")
}

fun gpgKeyId(): String? {
return System.getenv("GPG_KEY_ID")
}

fun gpgKeyLocation(): String? {
return System.getenv("GPG_KEY_LOCATION")
}

fun gpgPassphrase(): String? {
return System.getenv("GPG_PASSPHRASE")
}

gradle.taskGraph.whenReady(closureOf<TaskExecutionGraph> {
if (gradle.taskGraph.allTasks.any { it is Sign }) {
allprojects { ext["signing.keyId"] = gpgKeyId() }
allprojects { ext["signing.secretKeyRingFile"] = gpgKeyLocation() }
allprojects { ext["signing.password"] = gpgPassphrase() }
}
})
val signingPrivateKey: String? = System.getenv("SIGNING_PRIVATE_KEY")
val signingPassword: String? = System.getenv("SIGNING_PASSWORD")

val androidJavadocsJar = tasks.register("androidJavadocsJar", Jar::class) {
archiveClassifier.set("javadoc")
Expand All @@ -85,9 +52,7 @@ afterEvaluate {
from(components["release"])
artifact(androidJavadocsJar)

groupId = Props.GROUP
artifactId = Props.POM_ARTIFACT_ID
version = VERSION_NAME

pom {
name = Props.POM_NAME
Expand All @@ -114,22 +79,12 @@ afterEvaluate {
}
}
}

repositories {
maven {
url = if (isReleaseBuild()) URI(releaseRepositoryUrl) else URI(snapshotRepositoryUrl)

credentials {
username = getRepositoryUsername()
password = getRepositoryPassword()
}
}
}
}
}

signing {
setRequired({ isReleaseBuild() && gradle.taskGraph.hasTask("publishing") })
sign(publishing.publications)
}
signing {
setRequired({ isReleaseBuild() && gradle.taskGraph.hasTask("publishing") })
useInMemoryPgpKeys(signingPrivateKey, signingPassword)
sign(publishing.publications)
}
}
}
8 changes: 4 additions & 4 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ repositories {
maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
}

val VERSION_CODE: String by project
val VERSION_NAME: String by project
group = rootProject.group
version = rootProject.version

android {
compileSdk = libs.versions.targetSdkVersion.get().toInt()
Expand All @@ -57,8 +57,8 @@ android {
multiDexEnabled = true
vectorDrawables.useSupportLibrary = true

buildConfigField("long", "VERSION_CODE", VERSION_CODE)
buildConfigField("String", "VERSION_NAME", "\"${VERSION_NAME}\"")
buildConfigField("long", "VERSION_CODE", libs.versions.dhis2AndroidSdkCode.get())
buildConfigField("String", "VERSION_NAME", "\"$version\"")
}

compileOptions {
Expand Down
33 changes: 0 additions & 33 deletions core/gradle.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ internal abstract class IdentifiableDataHandlerImpl<O>(
relatives: RelationshipItemRelatives?,
)

protected fun beforeCollectionHandled(
protected open fun beforeCollectionHandled(
oCollection: Collection<O>,
params: IdentifiableDataHandlerParams,
): Collection<O> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import org.hisp.dhis.android.core.note.Note
import org.hisp.dhis.android.core.note.internal.NoteDHISVersionManager
import org.hisp.dhis.android.core.note.internal.NoteHandler
import org.hisp.dhis.android.core.note.internal.NoteUniquenessManager
import org.hisp.dhis.android.core.program.ProgramType
import org.hisp.dhis.android.core.program.internal.ProgramStore
import org.hisp.dhis.android.core.relationship.internal.EventRelationshipOrphanCleaner
import org.hisp.dhis.android.core.relationship.internal.RelationshipDHISVersionManager
import org.hisp.dhis.android.core.relationship.internal.RelationshipHandler
Expand All @@ -53,18 +55,33 @@ internal class EventHandler(
relationshipVersionManager: RelationshipDHISVersionManager,
relationshipHandler: RelationshipHandler,
eventStore: EventStore,
private val programStore: ProgramStore,
private val trackedEntityDataValueHandler: TrackedEntityDataValueHandler,
private val noteHandler: NoteHandler,
private val noteVersionManager: NoteDHISVersionManager,
private val noteUniquenessManager: NoteUniquenessManager,
private val relationshipOrphanCleaner: EventRelationshipOrphanCleaner,
) : IdentifiableDataHandlerImpl<Event>(eventStore, relationshipVersionManager, relationshipHandler) {

override fun beforeCollectionHandled(
oCollection: Collection<Event>,
params: IdentifiableDataHandlerParams,
): Collection<Event> {
val programTypes = programStore.selectAll().associate { it.uid() to it.programType() }

val updatedEvents = oCollection.map {
it.takeUnless { programTypes[it.program()] == ProgramType.WITHOUT_REGISTRATION }
?: it.toBuilder().enrollment(null).build()
}

return super.beforeCollectionHandled(updatedEvents, params)
}

override fun beforeObjectHandled(o: Event, params: IdentifiableDataHandlerParams): Event {
return if (GeometryHelper.isValid(o.geometry())) {
o
} else {
Log.i(this.javaClass.simpleName, "Event " + o.uid() + " has invalid geometry value")
Log.i(this::class.simpleName, "Event ${o.uid()} has an invalid geometry value")
o.toBuilder().geometry(null).build()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"program": "lxAQ7Zs9VYR",
"event": "single1",
"status": "COMPLETED",
"enrollment": "u9mt5Z8assp",
"occurredAt": "2018-02-27T00:00:00.000",
"createdAt": "2017-08-07T15:47:25.959",
"completedAt": "2016-02-27T00:00:00.000",
Expand Down Expand Up @@ -112,6 +113,7 @@
"program": "lxAQ7Zs9VYR",
"event": "single2",
"status": "ACTIVE",
"enrollment": "u9mt5Z8assp",
"occurredAt": "2017-02-27T00:00:00.000",
"createdAt": "2018-08-07T15:47:25.959",
"completedAt": "2018-02-27T00:00:00.000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.hisp.dhis.android.core.note.Note
import org.hisp.dhis.android.core.note.internal.NoteDHISVersionManager
import org.hisp.dhis.android.core.note.internal.NoteHandler
import org.hisp.dhis.android.core.note.internal.NoteUniquenessManager
import org.hisp.dhis.android.core.program.internal.ProgramStore
import org.hisp.dhis.android.core.relationship.internal.EventRelationshipOrphanCleaner
import org.hisp.dhis.android.core.relationship.internal.RelationshipDHISVersionManager
import org.hisp.dhis.android.core.relationship.internal.RelationshipHandler
Expand All @@ -51,6 +52,7 @@ import org.junit.runners.JUnit4
@RunWith(JUnit4::class)
class EventHandlerShould {
private val eventStore: EventStore = mock()
private val programStore: ProgramStore = mock()
private val trackedEntityDataValueHandler: TrackedEntityDataValueHandler = mock()
private val trackedEntityDataValue: TrackedEntityDataValue = mock()
private val noteHandler: NoteHandler = mock()
Expand Down Expand Up @@ -84,6 +86,7 @@ class EventHandlerShould {
relationshipVersionManager,
relationshipHandler,
eventStore,
programStore,
trackedEntityDataValueHandler,
noteHandler,
noteVersionManager,
Expand Down
2 changes: 1 addition & 1 deletion docs/content/developer/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Include dependency in build.gradle.

```gradle
dependencies {
implementation "org.hisp.dhis:android-core:1.10.0"
implementation "org.hisp.dhis:android-core:1.10.0.1"
...
}
```
Expand Down
Loading

0 comments on commit 286734c

Please sign in to comment.