diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml index 7faddae6d..c7667b5fd 100644 --- a/.github/workflows/test-deploy.yml +++ b/.github/workflows/test-deploy.yml @@ -11,7 +11,7 @@ on: - created env: - JAVA_VERSION: '11' + JAVA_VERSION: '17' JAVA_DISTRIBUTION: 'microsoft' jobs: @@ -28,7 +28,7 @@ jobs: - name: Test run: ./gradlew check - shadow_jar: + build: needs: test runs-on: ubuntu-latest steps: @@ -39,13 +39,13 @@ jobs: with: java-version: ${{ env.JAVA_VERSION }} distribution: ${{ env.JAVA_DISTRIBUTION }} - - name: Build JAR - run: ./gradlew shadowJar - - name: Persist JAR Artifact + - name: Build + run: ./gradlew build + - name: Persist JAR Artifacts uses: actions/upload-artifact@v3 with: - name: jar - path: build/libs/stellar-sdk.jar + name: libs + path: build/libs/*.jar javadoc: needs: test @@ -66,27 +66,8 @@ jobs: name: javadoc path: javadoc - javadoc_jar: - needs: test - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Set up JDK - uses: actions/setup-java@v2 - with: - java-version: ${{ env.JAVA_VERSION }} - distribution: ${{ env.JAVA_DISTRIBUTION }} - - name: Generate javadocJar - run: ./gradlew javadocJar - - name: Persist javadocJar - uses: actions/upload-artifact@v3 - with: - name: javadoc_jar - path: build/libs/stellar-sdk-javadoc.jar - android-test: - needs: shadow_jar + needs: build runs-on: macos-13 name: android-test (api ${{ matrix.emulator.api-level }}) strategy: @@ -96,7 +77,7 @@ jobs: # TODO: Investigate why it is unstable on API 33. emulator: [ { api-level: 26, target: google_apis }, - { api-level: 33, target: playstore } + { api-level: 32, target: playstore } ] steps: - name: checkout @@ -104,11 +85,11 @@ jobs: - name: Download JAR Artifact uses: actions/download-artifact@v2 with: - name: jar + name: libs path: android_test/app/libs/ - uses: actions/setup-java@v3 with: - java-version: 17 # TODO: Android Gradle plugin requires Java 11, consider replacing other parts with Java 17. + java-version: ${{ env.JAVA_VERSION }} distribution: ${{ env.JAVA_DISTRIBUTION }} - name: run tests uses: reactivecircus/android-emulator-runner@v2 @@ -121,7 +102,7 @@ jobs: profile: 'pixel_2' deploy: - needs: [ javadoc, shadow_jar, javadoc_jar ] # TODO: add android-test when it is stable. + needs: [ build, javadoc ] # TODO: add android-test when it is stable. permissions: contents: write if: github.event_name == 'release' && github.event.action == 'created' @@ -132,26 +113,20 @@ jobs: - name: Download JAR Artifact uses: actions/download-artifact@v2 with: - name: jar - path: jar + name: libs + path: libs - name: Download Java Documentation uses: actions/download-artifact@v2 with: name: javadoc path: javadoc - - name: Download javadocJar - uses: actions/download-artifact@v2 - with: - name: javadoc_jar - path: javadoc_jar - name: Archive Documentation run: tar -czf stellar-sdk-javadoc.tar.gz javadoc - name: Upload artifacts to GitHub Release uses: softprops/action-gh-release@v1 with: files: | - jar/stellar-sdk.jar - javadoc_jar/stellar-sdk-javadoc.jar + libs/*.jar stellar-sdk-javadoc.tar.gz - name: Upload Documentation to GitHub Pages uses: JamesIves/github-pages-deploy-action@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bf734eeb..1023b6027 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,15 @@ As this project is pre 1.0, breaking changes may happen for minor version bumps. ## 0.41.0-beta.4 * Add support for Soroban Preview 11. ([#530](https://github.com/stellar/java-stellar-sdk/pull/530)) * Bump dependencies & Remove unnecessary dependencies. ([#523](https://github.com/stellar/java-stellar-sdk/pull/523)) +* No longer provide a shadow jar that has relocated third-party dependencies, but instead default to providing a thin jar. + We also offer an [uber jar](https://docs.gradle.org/current/userguide/working_with_files.html#sec:creating_uber_jar_example) and javadoc jar. + You can import the jar you need in one of the following three ways: ([#528](https://github.com/stellar/java-stellar-sdk/issues/528)) + ```kotlin + implementation("com.github.stellar:java-stellar-sdk:{version}") // thin jar + implementation("com.github.stellar:java-stellar-sdk:{version}:uber") // uber jar + implementation("com.github.stellar:java-stellar-sdk:{version}:javadoc") // javadoc jar + ``` +* Use JDK 17 for CI builds. ([#528](https://github.com/stellar/java-stellar-sdk/issues/528)) ## 0.41.0-beta.3 * Fix the bug in Transaction.isSorobanTransaction to accommodate BumpFootprintExpirationOperation. ([#518](https://github.com/stellar/java-stellar-sdk/pull/518)) diff --git a/android_test/app/build.gradle.kts b/android_test/app/build.gradle.kts index e8ee153b8..e4ef7f80a 100644 --- a/android_test/app/build.gradle.kts +++ b/android_test/app/build.gradle.kts @@ -60,6 +60,14 @@ dependencies { implementation("androidx.compose.ui:ui-tooling-preview") implementation("androidx.compose.material3:material3") implementation(files("libs/stellar-sdk.jar")) + // Since we are adding local jar(libs/stellar-sdk.jar) as dependency, + // gradle cannot automatically download the required third-party dependencies. + implementation("com.squareup.okhttp3:okhttp:4.11.0") + implementation("com.squareup.okhttp3:okhttp-sse:4.11.0") + implementation("com.moandjiezana.toml:toml4j:0.7.2") + implementation("com.google.code.gson:gson:2.10.1") + implementation("net.i2p.crypto:eddsa:0.3.0") + implementation("commons-codec:commons-codec:1.16.0") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.uiautomator:uiautomator:2.3.0-alpha03") androidTestImplementation("androidx.test.ext:junit:1.1.5") diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 40e74d935..000000000 --- a/build.gradle +++ /dev/null @@ -1,119 +0,0 @@ -import org.gradle.internal.os.OperatingSystem - -buildscript { - ext.okhttpclientVersion = '4.11.0' -} - -plugins { - id "io.freefair.lombok" version "6.4.1" - id "com.github.johnrengelman.shadow" version "7.1.2" - id "java" - id "com.github.ben-manes.versions" version "0.42.0" - id "project-report" - id "maven-publish" - id "java-library" - id "com.diffplug.spotless" version "6.19.0" -} - -spotless { - java { - importOrder("java", "javax", "org.stellar") - removeUnusedImports() - googleJavaFormat() - } -} - - -sourceCompatibility = JavaVersion.VERSION_1_8.toString() -version = '0.41.0-beta.4' -group = 'stellar' -jar.enabled = false - -compileJava.options.encoding = 'UTF-8' -compileTestJava.options.encoding = 'UTF-8' -javadoc.options.encoding = 'UTF-8' - - -shadowJar { - manifest { - attributes( - "Implementation-Title": "stellar-sdk", - "Implementation-Version": project.getVersion() - ) - } - duplicatesStrategy DuplicatesStrategy.EXCLUDE - archiveClassifier.set('') - archiveFileName.set('stellar-sdk.jar') - relocate('com.', 'shadow.com.') { - // okhttp hardcodes android platform class loading to this package, shadowing would attempt to rewrite the hardcode - // to be 'shadow.com.android.org.conscrypt' which we don't want to happen. - exclude 'com.android.org.conscrypt' - } - relocate 'net.', 'shadow.net.' - relocate 'okhttp3', 'shadow.okhttp3' - relocate 'okio', 'shadow.okio' - relocate 'kotlin', 'shadow.kotlin' - relocate 'org.intellij', 'shadow.org.intellij' - relocate 'org.jetbrains', 'shadow.org.jetbrains' - relocate 'org.apache', 'shadow.org.apache' -} - -repositories { - mavenCentral() -} - -dependencies { - implementation "com.squareup.okhttp3:okhttp:${okhttpclientVersion}" - implementation "com.squareup.okhttp3:okhttp-sse:${okhttpclientVersion}" - implementation 'com.moandjiezana.toml:toml4j:0.7.2' - implementation 'com.google.code.gson:gson:2.10.1' - implementation 'net.i2p.crypto:eddsa:0.3.0' - implementation 'commons-codec:commons-codec:1.16.0' - - testImplementation 'org.mockito:mockito-core:5.5.0' - testImplementation "com.squareup.okhttp3:mockwebserver:${okhttpclientVersion}" - testImplementation 'junit:junit:4.13.2' - testImplementation 'org.junit.vintage:junit-vintage-engine:5.10.0' -} - -tasks.named('test') { task -> - useJUnitPlatform() -} - -tasks.register('updateGitHook', Copy) { - from 'scripts/pre-commit.sh' - into '.git/hooks' - rename { fileName -> - fileName.endsWith('.sh') ? fileName[0..-4] : fileName - } -} - -tasks.javadoc { - destinationDir = file('javadoc') - failOnError = true - exclude("org/stellar/sdk/xdr/**") - // cast options to StandardJavadocDocletOptions - // https://docs.gradle.org/current/javadoc/org/gradle/external/javadoc/StandardJavadocDocletOptions.html - StandardJavadocDocletOptions options = options as StandardJavadocDocletOptions - options.setSplitIndex(true) - options.setMemberLevel(JavadocMemberLevel.PUBLIC) - options.setEncoding('UTF-8') -} - -tasks.register('javadocJar', Jar) { - dependsOn javadoc - archiveClassifier.set('javadoc') - from javadoc.destinationDir - archiveFileName.set('stellar-sdk-javadoc.jar') -} - -publishing { - publications { - sdkLibrary(MavenPublication) { publication -> - project.shadow.component(publication) - } - javadocPublication(MavenPublication) { publication -> - artifact tasks.javadocJar - } - } -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..01b03db2a --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,148 @@ +plugins { + id("java") + id("java-library") + id("maven-publish") + id("project-report") + id("com.diffplug.spotless") version "6.21.0" + id("com.github.ben-manes.versions") version "0.48.0" + id("io.freefair.lombok") version "8.3" +} + +group = "stellar" +version = "0.41.0-beta.4" + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +spotless { + java { + importOrder("java", "javax", "org.stellar") + removeUnusedImports() + googleJavaFormat() + } +} + +repositories { + mavenCentral() +} + +dependencies { + val okhttpVersion = "4.11.0" + + implementation("com.squareup.okhttp3:okhttp:${okhttpVersion}") + implementation("com.squareup.okhttp3:okhttp-sse:${okhttpVersion}") + implementation("com.moandjiezana.toml:toml4j:0.7.2") + implementation("com.google.code.gson:gson:2.10.1") + implementation("net.i2p.crypto:eddsa:0.3.0") + implementation("commons-codec:commons-codec:1.16.0") + + testImplementation("org.mockito:mockito-core:5.5.0") + testImplementation("com.squareup.okhttp3:mockwebserver:${okhttpVersion}") + testImplementation("junit:junit:4.13.2") + testImplementation("org.junit.vintage:junit-vintage-engine:5.10.0") +} + +tasks { + test { + useJUnitPlatform() + } + + jar { + manifest { + attributes["Implementation-Title"] = "stellar-sdk" + attributes["Implementation-Version"] = version + } + archiveFileName = "stellar-sdk.jar" + } + + val uberJar by creating(Jar::class) { + // https://docs.gradle.org/current/userguide/working_with_files.html#sec:creating_uber_jar_example + manifest { + attributes["Implementation-Title"] = "stellar-sdk" + attributes["Implementation-Version"] = version + } + archiveClassifier = "uber" + archiveFileName = "stellar-sdk-uber.jar" + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + from(sourceSets.main.get().output) + dependsOn(configurations.runtimeClasspath) + from({ + configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) } + }) + } + + val javadocJar by creating(Jar::class) { + manifest { + attributes["Implementation-Title"] = "stellar-sdk" + attributes["Implementation-Version"] = version + } + archiveClassifier = "javadoc" + archiveFileName = "stellar-sdk-javadoc.jar" + dependsOn(javadoc) + from(javadoc.get().destinationDir) + } + + javadoc { + destinationDir = file("javadoc") + isFailOnError = false + exclude("org/stellar/sdk/xdr/**") + options { + // https://docs.gradle.org/current/javadoc/org/gradle/external/javadoc/StandardJavadocDocletOptions.html + this as StandardJavadocDocletOptions + isSplitIndex = true + memberLevel = JavadocMemberLevel.PUBLIC + encoding = "UTF-8" + } + } + + register("updateGitHook") { + from("scripts/pre-commit.sh") { rename { it.removeSuffix(".sh") } } + into(".git/hooks") + doLast { + file(".git/hooks/pre-commit").setExecutable(true) + } + } + + compileJava { + options.encoding = "UTF-8" + } + + compileTestJava { + options.encoding = "UTF-8" + } +} + +artifacts { + archives(tasks.jar) + archives(tasks["uberJar"]) + archives(tasks["javadocJar"]) +} + +publishing { + publications { + create("mavenJava") { + from(components["java"]) + artifact(tasks["uberJar"]) + artifact(tasks["javadocJar"]) + pom { + name.set("java-stellar-sdk") + description.set("The Java Stellar SDK library provides APIs to build transactions and connect to Horizon and Soroban-RPC server.") + url.set("https://github.com/stellar/java-stellar-sdk") + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("https://github.com/stellar/java-stellar-sdk/blob/master/LICENSE") + } + } + developers { + developer { + id.set("stellar") + name.set("Stellar Development Foundation") + } + } + } + } + } +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 41d9927a4..249e5832f 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 00e33edef..296835041 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Thu Sep 14 18:53:02 CST 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/jitpack.yml b/jitpack.yml index f81efc783..5fc872f5b 100644 --- a/jitpack.yml +++ b/jitpack.yml @@ -1,7 +1,4 @@ -jdk: - - openjdk11 - before_install: - - sdk install java 11.0.23-open - - sdk use java 11.0.23-open + - sdk install java 17.0.8.1-ms + - sdk use java 17.0.8.1-ms diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index e68f941fb..000000000 --- a/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = 'java-stellar-sdk' - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 000000000..f60bc99c1 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,2 @@ +rootProject.name = "java-stellar-sdk" + diff --git a/src/main/java/org/stellar/sdk/responses/AccountResponse.java b/src/main/java/org/stellar/sdk/responses/AccountResponse.java index 5d3390a1f..3aa672629 100644 --- a/src/main/java/org/stellar/sdk/responses/AccountResponse.java +++ b/src/main/java/org/stellar/sdk/responses/AccountResponse.java @@ -102,7 +102,7 @@ public void setSequenceNumber(long seqNum) { @Override public Long getIncrementedSequenceNumber() { - return new Long(sequenceNumber + 1); + return sequenceNumber + 1; } @Override diff --git a/src/test/java/org/stellar/sdk/AccountTest.java b/src/test/java/org/stellar/sdk/AccountTest.java index 791356ae6..bc636923d 100644 --- a/src/test/java/org/stellar/sdk/AccountTest.java +++ b/src/test/java/org/stellar/sdk/AccountTest.java @@ -28,11 +28,11 @@ public void testGetIncrementedSequenceNumber() { Account account = new Account(random.getAccountId(), 100L); Long incremented; incremented = account.getIncrementedSequenceNumber(); - assertEquals(new Long(100L), account.getSequenceNumber()); - assertEquals(new Long(101L), incremented); + assertEquals(Long.valueOf(100L), account.getSequenceNumber()); + assertEquals(Long.valueOf(101L), incremented); incremented = account.getIncrementedSequenceNumber(); - assertEquals(new Long(100L), account.getSequenceNumber()); - assertEquals(new Long(101L), incremented); + assertEquals(Long.valueOf(100L), account.getSequenceNumber()); + assertEquals(Long.valueOf(101L), incremented); } @Test @@ -40,7 +40,7 @@ public void testIncrementSequenceNumber() { KeyPair random = KeyPair.random(); Account account = new Account(random.getAccountId(), 100L); account.incrementSequenceNumber(); - assertEquals(account.getSequenceNumber(), new Long(101L)); + assertEquals(account.getSequenceNumber(), Long.valueOf(101L)); } @Test @@ -49,6 +49,6 @@ public void testGetters() { Account account = new Account(keypair.getAccountId(), 100L); assertEquals(account.getKeyPair().getAccountId(), keypair.getAccountId()); assertEquals(account.getAccountId(), keypair.getAccountId()); - assertEquals(account.getSequenceNumber(), new Long(100L)); + assertEquals(account.getSequenceNumber(), Long.valueOf(100L)); } } diff --git a/src/test/java/org/stellar/sdk/ServerTest.java b/src/test/java/org/stellar/sdk/ServerTest.java index cb4486cac..ad839a7a2 100644 --- a/src/test/java/org/stellar/sdk/ServerTest.java +++ b/src/test/java/org/stellar/sdk/ServerTest.java @@ -206,7 +206,7 @@ Transaction buildTransaction(Network network) throws IOException { assertEquals(1, builder.getOperationsCount()); Transaction transaction = builder.build(); assertEquals(2908908335136769L, transaction.getSequenceNumber()); - assertEquals(new Long(2908908335136769L), account.getSequenceNumber()); + assertEquals(Long.valueOf(2908908335136769L), account.getSequenceNumber()); transaction.sign(source); return transaction; } @@ -240,7 +240,7 @@ public void testSubmitTransactionSuccess() throws IOException, AccountRequiresMe SubmitTransactionResponse response = server.submitTransaction(this.buildTransaction(), true); assertTrue(response.isSuccess()); - assertEquals(response.getLedger(), new Long(826150L)); + assertEquals(response.getLedger(), Long.valueOf(826150L)); assertEquals( response.getHash(), "2634d2cf5adcbd3487d1df042166eef53830115844fdde1588828667bf93ff42"); assertEquals( diff --git a/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java index a29352323..d7ba8440d 100644 --- a/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java +++ b/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java @@ -62,7 +62,7 @@ public void testOperationById() throws IOException, InterruptedException { Server server = new Server(mockWebServer.url("").toString()); OperationResponse response = server.operations().operation(438086668289l); assertEquals(response.getType(), "create_account"); - assertEquals(response.getId(), new Long(438086668289l)); + assertEquals(response.getId(), Long.valueOf(438086668289l)); assertEquals( response.getSourceAccount(), "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"); RecordedRequest request = mockWebServer.takeRequest(); diff --git a/src/test/java/org/stellar/sdk/responses/AccountDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/AccountDeserializerTest.java index 570c6e9ef..9aa379d9b 100644 --- a/src/test/java/org/stellar/sdk/responses/AccountDeserializerTest.java +++ b/src/test/java/org/stellar/sdk/responses/AccountDeserializerTest.java @@ -44,8 +44,8 @@ public void testDeserialize() { AccountResponse account = GsonSingleton.getInstance().fromJson(json, AccountResponse.class); assertEquals( account.getAccountId(), "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7"); - assertEquals(account.getSequenceNumber(), new Long(2319149195853854L)); - assertEquals(account.getSubentryCount(), new Integer(0)); + assertEquals(account.getSequenceNumber(), Long.valueOf(2319149195853854L)); + assertEquals(account.getSubentryCount(), Integer.valueOf(0)); assertEquals(account.getSequenceUpdatedAtLedger().longValue(), 1234); assertEquals(account.getSequenceUpdatedAtTime().longValue(), 4567); assertEquals(