Skip to content

Commit

Permalink
Merge pull request #191 from opensrp/issue189-2
Browse files Browse the repository at this point in the history
Migrate core dependencies
  • Loading branch information
ndegwamartin authored Dec 20, 2022
2 parents 7df7c50 + a135e72 commit ce201bb
Show file tree
Hide file tree
Showing 57 changed files with 1,004 additions and 781 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run unit tests with Gradle
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Snapshot Release

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+-SNAPSHOT
- v[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+-SNAPSHOT
- v[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+-[0-9a-zA-Z]+-SNAPSHOT
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Cancel previous workflow runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout 🛎️
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Run unit tests with Gradle
run: ./gradlew :opensrp-immunization:clean :opensrp-immunization:testDebugUnitTest --stacktrace

- name: Generate & upload library snapshot artifact AAR (Android Archive) file
run: ./gradlew :opensrp-immunization:uploadArchives -PmavenLocal=false --stacktrace -PsonatypeUsername=${{ secrets.NEXUS_USERNAME }} -PsonatypePassword=${{ secrets.NEXUS_PASSWORD }}

- name: Github Release
uses: softprops/action-gh-release@v1
with:
prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') }}
25 changes: 11 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven {
url "https://maven.google.com"
}
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url "https://repo.maven.apache.org/maven2" }
maven{ url "https://plugins.gradle.org/m2/" }
maven { url "https://plugins.gradle.org/m2/" }
}

dependencies {
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.11.0"
classpath 'gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.10.2'
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"
classpath 'gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.12.0'
classpath 'org.smartregister:gradle-jarjar-plugin:1.0.0-SNAPSHOT'
classpath 'gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.10.2'
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.android.tools.build:gradle:4.2.2'
}
}

Expand All @@ -30,7 +28,7 @@ configure(allprojects) { project ->
jcenter()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven{ url "https://plugins.gradle.org/m2/" }
maven { url "https://plugins.gradle.org/m2/" }
mavenLocal()
}
}
Expand All @@ -42,11 +40,11 @@ subprojects {

group = 'org.smartregister'

ext.androidToolsBuildGradle = '4.1.3'
ext.androidBuildToolsVersion = '29.0.2'
ext.androidMinSdkVersion = 18
ext.androidCompileSdkVersion = 29
ext.androidTargetSdkVersion = 29
ext.androidToolsBuildGradle = '4.2.2'
ext.androidBuildToolsVersion = '30.0.2'
ext.androidMinSdkVersion = 18
ext.androidCompileSdkVersion = 31
ext.androidTargetSdkVersion = 31

ext.androidAnnotationsVersion = '3.0.1'
ext.androidAnnotationsAPIVersion = '3.0.1'
Expand All @@ -56,9 +54,8 @@ subprojects {
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url "http://acra.googlecode.com/svn/repository/releases" }
maven { url "https://acra.googlecode.com/svn/repository/releases" }
maven { url "https://repo.maven.apache.org/maven2" }
maven { url "http://cloudant.github.io/cloudant-sync-eap/repository" }
mavenLocal()
}

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=4.0.7-SNAPSHOT
VERSION_NAME=5.0.0-SNAPSHOT
VERSION_CODE=3
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Immunization
Expand All @@ -13,5 +13,5 @@ POM_SETTING_DEVELOPER_ID=opensrp
POM_SETTING_DEVELOPER_NAME=OpenSRP Onadev
android.useAndroidX=true
android.enableJetifier=true
android.jetifier.blacklist=shadows
android.jetifier.ignorelist=shadows,bcprov-jdk15on
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ zipStorePath=wrapper/dists
org.gradle.parallel=true
zipStoreBase=GRADLE_USER_HOME
org.gradle.jvmargs=-Xmx2048m -XX\:MaxPermSize\=512m -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
org.gradle.configureondemand=true
distributionPath=wrapper/dists
distributionBase=GRADLE_USER_HOME
30 changes: 17 additions & 13 deletions opensrp-immunization/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ description = 'OpenSRP immunization client library'
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:$androidToolsBuildGradle"
classpath 'org.apache.commons:commons-lang3:3.10'
classpath 'org.apache.commons:commons-lang3:3.12.0'
}
}

Expand All @@ -16,7 +16,7 @@ apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'

jacoco {
toolVersion = "0.8.6"
toolVersion = "0.8.8"
}

allprojects {
Expand Down Expand Up @@ -110,23 +110,24 @@ android {

dependencies {

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9'
testImplementation 'junit:junit:4.13.2'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.0'

implementation('org.smartregister:opensrp-client-core:4.3.26-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-core:6.0.0-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.github.bmelnychuk', module: 'atv'
exclude group: 'jakarta.annotation', module: 'jakarta.annotation-api'
exclude group: 'com.ibm.fhir', module: 'fhir-model'
exclude group: 'com.ibm.fhir', module: 'fhir-path'
}

implementation('org.smartregister:opensrp-client-native-form:1.14.8.5-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-native-form:3.1.1-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'recyclerview-v7'
exclude group: 'com.google.code.gson', module: 'gson'
}
testImplementation 'com.ibm.fhir:fhir-model:4.7.0'
testImplementation 'com.ibm.fhir:fhir-path:4.7.0'
testImplementation 'com.ibm.fhir:fhir-model:4.7.1'
testImplementation 'com.ibm.fhir:fhir-path:4.7.1'

testImplementation 'junit:junit:4.13.2'

Expand All @@ -139,22 +140,25 @@ dependencies {
exclude group: 'com.google.auto.service', module: 'auto-service'
exclude group: 'com.android.support'
}
testImplementation "org.robolectric:shadows-multidex:$robolectricVersion"
testImplementation "org.robolectric:shadows-support-v4:3.3.2"
testImplementation ("org.robolectric:shadows-multidex:$robolectricVersion") {
exclude group: 'com.google.guava', module: 'guava'
}
testImplementation "org.robolectric:shadows-support-v4:3.4-rc2"

androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0') {
androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0') {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'junit', module: 'junit'
}

// PowerMock
def powerMockVersion = '2.0.7'
def powerMockVersion = '2.0.9'
testImplementation "org.powermock:powermock-module-junit4:$powerMockVersion"
testImplementation "org.powermock:powermock-module-junit4-rule:$powerMockVersion"
testImplementation "org.powermock:powermock-api-mockito2:$powerMockVersion"
testImplementation("org.powermock:powermock-classloading-xstream:$powerMockVersion")
testImplementation 'org.apache.maven:maven-ant-tasks:2.1.3'
testImplementation group: 'org.skyscreamer', name: 'jsonassert', version: '1.2.3'
testImplementation group: 'org.skyscreamer', name: 'jsonassert', version: '1.5.1'
testImplementation "org.json:json:20220320"
}

tasks.withType(Test) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@
*/
public class ImmunizationLibrary {

public static List<String> COMBINED_VACCINES = new ArrayList<>();
public static Map<String, String> COMBINED_VACCINES_MAP = new HashMap<>();
private static ImmunizationLibrary instance;
private static boolean allowExpiredVaccineEntry;
private static Map<String, VaccineCache> vaccineCacheMap = new HashMap<>();
private final Repository repository;
private final Context context;
private final Map<String, String> conditionalVaccinesMap = new HashMap<>();
private EventClientRepository eventClientRepository;
private VaccineRepository vaccineRepository;
private RecurringServiceRecordRepository recurringServiceRecordRepository;
Expand All @@ -45,33 +50,29 @@ public class ImmunizationLibrary {
private CommonFtsObject commonFtsObject;
private int applicationVersion;
private int databaseVersion;
private String applicationVersionName;
private Map<String, Object> jsonMap = new HashMap<>();
private static boolean allowExpiredVaccineEntry;
private static Map<String, VaccineCache> vaccineCacheMap = new HashMap<>();

public static List<String> COMBINED_VACCINES = new ArrayList<>();
public static Map<String, String> COMBINED_VACCINES_MAP = new HashMap<>();
private final Map<String, String> conditionalVaccinesMap = new HashMap<>();
private String currentConditionalVaccine;
private boolean allowSyncImmediately = false;
private List<VaccineRepo.Vaccine> skippableVaccines = new ArrayList<>();
private VaccineOverdueCountRepository vaccineOverdueCountRepository;

private long vaccineSyncTime = -1;

private ImmunizationLibrary(Context context, Repository repository, CommonFtsObject commonFtsObject, int applicationVersion, int databaseVersion) {
private ImmunizationLibrary(Context context, Repository repository, CommonFtsObject commonFtsObject, int applicationVersion, String applicationVersionName, int databaseVersion) {
this.repository = repository;
this.context = context;
this.commonFtsObject = commonFtsObject;
this.applicationVersion = applicationVersion;
this.applicationVersionName = applicationVersionName;
this.databaseVersion = databaseVersion;
setCurrentConditionalVaccine(null);
setSkippableVaccines(Arrays.asList(VaccineRepo.Vaccine.bcg2, VaccineRepo.Vaccine.measles1));
}

public static void init(Context context, Repository repository, CommonFtsObject commonFtsObject, int applicationVersion, int databaseVersion) {
public static void init(Context context, Repository repository, CommonFtsObject commonFtsObject, int applicationVersion, String applicationVersionName, int databaseVersion) {
if (instance == null) {
instance = new ImmunizationLibrary(context, repository, commonFtsObject, applicationVersion, databaseVersion);
instance = new ImmunizationLibrary(context, repository, commonFtsObject, applicationVersion, applicationVersionName, databaseVersion);

allowExpiredVaccineEntry = instance.getProperties().isTrue(IMConstants.APP_PROPERTIES.VACCINE_EXPIRED_ENTRY_ALLOW);

Expand All @@ -85,6 +86,37 @@ public static void init(Context context, Repository repository, CommonFtsObject
}
}

/**
* This init method is deprecated, use {@link #init(Context context, Repository repository, CommonFtsObject commonFtsObject, int applicationVersion, String applicationVersionName, int databaseVersion.
*/
@Deprecated
public static void init(Context context, Repository repository, CommonFtsObject commonFtsObject, int applicationVersion, int databaseVersion) {
init(context, repository, commonFtsObject, applicationVersion, null, databaseVersion);
}

public static <T> T assetJsonToJava(Map<String, Object> jsonMap, android.content.Context context, String fileName, Class<T> clazz, Type type) {
return AssetHandler.assetJsonToJava(jsonMap, context, fileName, clazz, type);
}

public static ImmunizationLibrary getInstance() {
if (instance == null) {
throw new IllegalStateException(" Instance does not exist!!! Call " + ImmunizationLibrary.class
.getName() + ".init method in the onCreate method of your Application class ");
}
return instance;
}

public static Map<String, VaccineCache> getVaccineCacheMap() {
return vaccineCacheMap;
}

/**
* Public method to clear the instance/destroy useful for testing
*/
public static void destroy() {
instance = null;
}

public Map<String, String> getConditionalVaccinesMap() {
return conditionalVaccinesMap;
}
Expand All @@ -93,10 +125,6 @@ public <T> T assetJsonToJava(String fileName, Class<T> clazz, Type type) {
return AssetHandler.assetJsonToJava(jsonMap, context.applicationContext(), fileName, clazz, type);
}

public static <T> T assetJsonToJava(Map<String, Object> jsonMap, android.content.Context context, String fileName, Class<T> clazz, Type type) {
return AssetHandler.assetJsonToJava(jsonMap, context, fileName, clazz, type);
}

public EventClientRepository eventClientRepository() {
if (eventClientRepository == null) {
eventClientRepository = new EventClientRepository();
Expand Down Expand Up @@ -163,6 +191,10 @@ public int getApplicationVersion() {
return applicationVersion;
}

public String getApplicationVersionName() {
return applicationVersionName;
}

public int getDatabaseVersion() {
return databaseVersion;
}
Expand All @@ -171,14 +203,6 @@ public Locale getLocale() {
return ImmunizationLibrary.getInstance().context().applicationContext().getResources().getConfiguration().locale;
}

public static ImmunizationLibrary getInstance() {
if (instance == null) {
throw new IllegalStateException(" Instance does not exist!!! Call " + ImmunizationLibrary.class
.getName() + ".init method in the onCreate method of your Application class ");
}
return instance;
}

public Map<String, Object> getVaccinesConfigJsonMap() {
return jsonMap;
}
Expand Down Expand Up @@ -208,10 +232,6 @@ public boolean isAllowExpiredVaccineEntry() {
return allowExpiredVaccineEntry;
}

public static Map<String, VaccineCache> getVaccineCacheMap() {
return vaccineCacheMap;
}

public boolean isExpiredVaccineCardRed() {
return getProperties().isTrue(IMConstants.APP_PROPERTIES.EXPIRED_CARD_AS_RED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.json.JSONObject;
import org.json.XML;
import org.smartregister.immunization.db.VaccineRepo;
import org.smartregister.immunization.util.VaccinateActionUtils;

Expand Down Expand Up @@ -70,7 +69,7 @@ public String updateFormSubmission() {
parent = "Woman_TT_Followup_Form";
}

JSONObject formSubmission = XML.toJSONObject(formData);
JSONObject formSubmission = new JSONObject(formData);

JSONObject encounterJson = VaccinateActionUtils.find(formSubmission, parent);

Expand Down Expand Up @@ -136,7 +135,7 @@ public String updateFormSubmission() {
VaccinateActionUtils.updateJson(encounterJson, "phonenumber", "no phonenumber property in enketo");


String data = XML.toString(formSubmission);
String data = formSubmission.toString();
return data;
} catch (Exception e) {
Timber.e(e);
Expand Down
Loading

0 comments on commit ce201bb

Please sign in to comment.