diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml index 7faddae6d..af177ffba 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: @@ -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/build.gradle b/build.gradle deleted file mode 100644 index 5030d5f40..000000000 --- a/build.gradle +++ /dev/null @@ -1,126 +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.3' -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 'javax.annotation', 'shadow.javax.annotation' - relocate 'org.apache', 'shadow.org.apache' - relocate 'org.jvnet', 'shadow.org.jvnet' - relocate 'org.codehaus', 'shadow.org.codehaus' - relocate 'org.threeten', 'shadow.org.threeten' - relocate 'org.checkerframework', 'shadow.org.checkerframework' - relocate 'okhttp3', 'shadow.okhttp3' - relocate 'okio', 'shadow.okio' - relocate 'kotlin', 'shadow.kotlin' - relocate 'org.intellij', 'shadow.org.intellij' - relocate 'org.jetbrains', 'shadow.org.jetbrains' -} - -repositories { - mavenCentral() -} - -dependencies { - implementation "com.squareup.okhttp3:okhttp:${okhttpclientVersion}" - implementation "com.squareup.okhttp3:okhttp-sse:${okhttpclientVersion}" - implementation 'com.moandjiezana.toml:toml4j:0.7.2' - // use the android version because we don't want java 8 stuff - // TODO: Do we really need to introduce guava? - implementation 'com.google.guava:guava:32.1.2-android' - implementation 'com.google.code.gson:gson:2.10.1' - implementation 'net.i2p.crypto:eddsa:0.3.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..25e3e1a00 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,149 @@ +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.3" + +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" + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + } + + val uberJar by creating(Jar::class) { + 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" +