diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..1e6237d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,24 @@ +name: Java-SDK +on: + workflow_dispatch: + push: + branches: + - main + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup Java 8 + uses: actions/setup-java@v3 + with: + distribution: "adopt" + java-version: "8" + cache: "gradle" + + - name: Build Java SDK + run: | + ./gradlew clean build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..d4ca82f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,39 @@ +name: Publish Java-SDK + +on: + push: + branches: + - "main" + tags: + - v* +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup Java 8 + uses: actions/setup-java@v3 + with: + distribution: "adopt" + java-version: "8" + cache: "gradle" + + - name: Publish JavaSDK + env: + ORG_GRADLE_PROJECT_VERSION_NAME: ${{ github.event.inputs.versionName }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSWORD }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + GRADLE_PROPERTIES: ${{ secrets.GRADLE_PROPERTIES }} + SECRET_FILE_DATA: ${{ secrets.SECRET_FILE_DATA }} + run: | + export GPG_TTY=$(tty) + mkdir -p ~/.gradle/ + ln -s /usr/local/bin/gpg /usr/local/bin/gpg2 + echo -n "$SECRET_FILE_DATA" | base64 --decode | gpg --import --passphrase "$ORG_GRADLE_PROJECT_signingInMemoryKeyPassword" --batch + echo "GRADLE_USER_HOME=${HOME}/.gradle" >> $GITHUB_ENV + echo "${GRADLE_PROPERTIES}" > ~/.gradle/gradle.properties + ./gradlew clean build publish closeAndReleaseSonatypeStagingRepository -x test \ No newline at end of file diff --git a/build.gradle b/build.gradle index ac752b9..153bd81 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ plugins { ext { - VERSION = "1.5.3" + VERSION = "1.6.1" GROUP_ID = "com.absmartly.sdk" slf4jVersion = "1.7.30" @@ -123,8 +123,8 @@ configure(rootProject) { nexusUrl = uri("https://s01.oss.sonatype.org/service/local/") snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") - username = findProperty("ossrh.username") - password = findProperty("ossrh.password") + username = System.getenv('ORG_GRADLE_PROJECT_mavenCentralUsername') + password = System.getenv('ORG_GRADLE_PROJECT_mavenCentralPassword') } } } diff --git a/core-api/src/main/java/com/absmartly/sdk/Context.java b/core-api/src/main/java/com/absmartly/sdk/Context.java index 7631360..a3d99b3 100644 --- a/core-api/src/main/java/com/absmartly/sdk/Context.java +++ b/core-api/src/main/java/com/absmartly/sdk/Context.java @@ -181,7 +181,7 @@ public String[] getCustomFieldKeys() { for (final Experiment experiment : data_.experiments) { if (experiment.customFieldValues != null) { for (final CustomFieldValue customFieldValue : experiment.customFieldValues) { - keys.add(customFieldValue.name); + keys.add(customFieldValue.getName()); } } } @@ -997,18 +997,18 @@ public int compare(ContextExperiment a, ContextExperiment b) { if (experiment.customFieldValues != null) { for (final CustomFieldValue customFieldValue : experiment.customFieldValues) { final ContextCustomFieldValue value = new ContextCustomFieldValue(); - contextExperiment.customFieldValues.put(customFieldValue.name, value); - - value.type = customFieldValue.type; - if (customFieldValue.value != null) { - if (customFieldValue.type.startsWith("json")) { - value.value = variableParser_.parse(this, experiment.name, customFieldValue.value); - } else if (customFieldValue.type.equals("boolean")) { - value.value = Boolean.parseBoolean(customFieldValue.value); - } else if (customFieldValue.type.equals("number")) { - value.value = Double.parseDouble(customFieldValue.value); + contextExperiment.customFieldValues.put(customFieldValue.getName(), value); + + value.type = customFieldValue.getType(); + if (customFieldValue.getValue() != null) { + if (customFieldValue.getType().startsWith("json")) { + value.value = variableParser_.parse(this, experiment.name, customFieldValue.getValue()); + } else if (customFieldValue.getType().equals("boolean")) { + value.value = Boolean.parseBoolean(customFieldValue.getValue()); + } else if (customFieldValue.getType().equals("number")) { + value.value = Double.parseDouble(customFieldValue.getValue()); } else { - value.value = customFieldValue.value; + value.value = customFieldValue.getValue(); } } } diff --git a/core-api/src/main/java/com/absmartly/sdk/json/CustomFieldValue.java b/core-api/src/main/java/com/absmartly/sdk/json/CustomFieldValue.java index a640955..aa528f4 100644 --- a/core-api/src/main/java/com/absmartly/sdk/json/CustomFieldValue.java +++ b/core-api/src/main/java/com/absmartly/sdk/json/CustomFieldValue.java @@ -6,9 +6,9 @@ @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) public class CustomFieldValue { - public String name; - public String type; - public String value; + private String name; + private String type; + private String value; public CustomFieldValue() {} @@ -44,4 +44,28 @@ public String toString() { ", value='" + value + '\'' + '}'; } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } }