diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 10c5237c..00000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,76 +0,0 @@ -name: tbdex SDK Kotlin CI - -on: - workflow_dispatch: - push: - branches: - - main - pull_request: - branches: - - "*" - -jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - steps: - - name: Checkout source - uses: actions/checkout@v2 - with: - submodules: "true" - # https://cashapp.github.io/hermit/usage/ci/ - - name: Init Hermit - uses: cashapp/activate-hermit@v1 - with: - cache: "true" - - uses: actions/cache@v2 - with: - path: ~/.gradle/caches - key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/versions.properties') }} - - - name: Run Gradle Tasks - run: gradle build koverXmlReport - - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} - verbose: true - flags: ${{ runner.os }} - - - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - name: test-results - path: | - **/build/test-results/test/*TbdexTestVectors*.xml - - - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - name: tests-report-junit - path: | - **/build/test-results/test/*.xml - - - name: Generate an access token to trigger downstream repo - uses: actions/create-github-app-token@2986852ad836768dfea7781f31828eb3e17990fa # v1.6.2 - id: generate_token - if: github.ref == 'refs/heads/main' - with: - app-id: ${{ secrets.CICD_ROBOT_GITHUB_APP_ID }} - private-key: ${{ secrets.CICD_ROBOT_GITHUB_APP_PRIVATE_KEY }} - owner: TBD54566975 - repositories: sdk-report-runner - - - name: Trigger sdk-report-runner report build - if: github.ref == 'refs/heads/main' - run: | - curl -L \ - -H "Authorization: Bearer ${APP_TOKEN}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - -H "Content-Type: application/json" \ - --fail \ - --data '{"ref": "main"}' \ - https://api.github.com/repos/TBD54566975/sdk-report-runner/actions/workflows/build-report.yaml/dispatches - env: - APP_TOKEN: ${{ steps.generate_token.outputs.token }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..1d54c4de --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,177 @@ +# Runs on every commit to main. This is the main CI job; it runs in MacOS and Ubuntu environments which: +# * Build +# * Run tests +# +# In the Ubuntu environment only, to avoid double uploads from MacOS, it also: +# * Uploads Test reports to BuildKite +# * Uploads Coverage reports to CodeCov +# * Uploads Test Vectors reports to the SDK Report Runner +# * Publishes (deploys) to TBD's Artifactory instance as version commit-$shortSHA-SNAPSHOT +# +# If triggered from workflow_dispatch, you may select a branch or tag to +# deploy as an internal "release" (or SNAPSHOT, depending upon the version in the POM) +# to TBD's Artifactory instance by not specifying a version. +name: SDK Kotlin CI + +on: + workflow_dispatch: + inputs: + version: + description: 'Version to publish. For example "1.0.0-SNAPSHOT". If not supplied, will default to version specified in the POM. Must end in "-SNAPSHOT".' + required: false + default: "0.0.0-SNAPSHOT" + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + # On MacOS we only build, test, and verify + build-test-macos: + runs-on: macOS-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + # https://cashapp.github.io/hermit/usage/ci/ + - name: Init Hermit + uses: cashapp/activate-hermit@v1 + with: + cache: true + + - name: hash test inputs + run: | + if ! which sha256sum; then brew install coreutils; fi + sha256sum $(find test-vectors -name '*.json') > test-vector-hashes.txt + + - name: Build, Test, and Verify + run: | + # Maven "verify" lifecycle will build, test, and verify + mvn verify \ + --batch-mode \ + -P sign-artifacts + env: + SIGN_KEY_PASS: ${{ secrets.GPG_SECRET_PASSPHRASE }} + SIGN_KEY: ${{ secrets.GPG_SECRET_KEY }} + + # On Ubuntu we build, test, verify, and deploy: Code Coverage, Test Vectors, and SNAPSHOT artifacts to TBD Artifactory + build-test-deploy-snapshot-ubuntu: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + # https://cashapp.github.io/hermit/usage/ci/ + - name: Init Hermit + uses: cashapp/activate-hermit@v1 + with: + cache: true + + - name: hash test inputs + run: | + if ! which sha256sum; then brew install coreutils; fi + sha256sum $(find test-vectors -name '*.json') > test-vector-hashes.txt + + - name: Resolve Snapshot Version + id: resolve_version + run: | + # Version resolution: use provided + if [ -n "${{ github.event.inputs.version }}" ]; then + resolvedVersion=${{ github.event.inputs.version }} + # Otherwise, construct a version for deployment in form X.Y.Z-commit-$shortSHA-SNAPSHOT + else + longSHA=$(git rev-parse --verify HEAD) + shortSHA=$(echo "${longSHA:0:7}") + resolvedVersion="commit-$shortSHA-SNAPSHOT" + echo "Requesting deployment as version: $resolvedVersion" + fi + + # Postcondition check; only allow this to proceed if we have a version ending in "-SNAPSHOT" + if [[ ! "$resolvedVersion" =~ -SNAPSHOT$ ]]; then + echo "Error: The version does not end with \"-SNAPSHOT\": $resolvedVersion" + exit 1 + fi + + echo "Resolved SNAPSHOT Version: $resolvedVersion" + echo "resolved_version=$resolvedVersion" >> $GITHUB_OUTPUT + + - name: Build, Test, and Deploy to TBD Artifactory + run: | + # Set newly resolved version in POM config + mvn \ + versions:set \ + --batch-mode \ + -DnewVersion=${{ steps.resolve_version.outputs.resolved_version }} + + # Maven deploy lifecycle will build, run tests, verify, sign, and deploy + mvn \ + deploy \ + --batch-mode \ + --settings .maven_settings.xml \ + -P sign-artifacts + env: + ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + SIGN_KEY_PASS: ${{ secrets.GPG_SECRET_PASSPHRASE }} + SIGN_KEY: ${{ secrets.GPG_SECRET_KEY }} + + - name: Upload Vector test results + uses: actions/upload-artifact@v3 + with: + name: test-results + path: | + **/target/surefire-reports/*TestVectors*.xml + test-vector-hashes.txt + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true + flags: ${{ runner.os }} + + - name: Upload JUnit tests report + uses: actions/upload-artifact@v3 + with: + name: tests-report-junit + path: | + **/target/surefire-reports/*.xml + + # Uncomment these before merging upstream again; this Action is custom to TBD and can't be verified in ALRubinger fork + - name: Generate an access token to trigger downstream repo + uses: actions/create-github-app-token@2986852ad836768dfea7781f31828eb3e17990fa # v1.6.2 + id: generate_token + if: github.ref == 'refs/heads/main' + with: + app-id: ${{ secrets.CICD_ROBOT_GITHUB_APP_ID }} + private-key: ${{ secrets.CICD_ROBOT_GITHUB_APP_PRIVATE_KEY }} + owner: TBD54566975 + repositories: sdk-report-runner + + - name: Trigger sdk-report-runner report build + if: github.ref == 'refs/heads/main' + run: | + curl -L \ + -H "Authorization: Bearer ${APP_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -H "Content-Type: application/json" \ + --fail \ + --data '{"ref": "main"}' \ + https://api.github.com/repos/TBD54566975/sdk-report-runner/actions/workflows/build-report.yaml/dispatches + env: + APP_TOKEN: ${{ steps.generate_token.outputs.token }} + + # Ensure both MacOS and Ubuntu build/test jobs succeeded + confirm-successful-build-and-tests: + # Wait on both jobs to succeed + needs: [build-test-macos, build-test-deploy-snapshot-ubuntu] + runs-on: ubuntu-latest + + steps: + - name: Log Success + run: | + echo "Builds for MacOS and Ubuntu succeeded." diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yml similarity index 99% rename from .github/workflows/codeql.yaml rename to .github/workflows/codeql.yml index 71af1cef..5c7b9917 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yml @@ -17,7 +17,7 @@ on: pull_request: branches: [ "main" ] schedule: - - cron: '26 21 * * 4' + - cron: '42 22 * * 1' jobs: analyze: diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml deleted file mode 100644 index 8fd34337..00000000 --- a/.github/workflows/docs.yaml +++ /dev/null @@ -1,58 +0,0 @@ -name: tbdex SDK Publish Docs to GH Pages - -on: - # Runs on new releases publishing - push: - tags: - - v** - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. -concurrency: - group: "pages" - cancel-in-progress: false - -jobs: - publish-docs: - environment: - name: github-pages-docs - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ ubuntu-latest ] - steps: - - uses: actions/checkout@v3 - # https://cashapp.github.io/hermit/usage/ci/ - - name: Init Hermit - uses: cashapp/activate-hermit@v1 - with: - cache: "true" - - uses: actions/cache@v2 - with: - path: ~/.gradle/caches - key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/versions.properties') }} - - - name: Build Docs - run: gradle dokkaHtmlMultiModule - - - name: Setup Pages - uses: actions/configure-pages@v3 - - - name: Upload artifact - uses: actions/upload-pages-artifact@v2 - with: - path: './build/dokka/htmlMultiModule' - - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v2 diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index 78ea3311..00000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,49 +0,0 @@ -name: Publish package to the Maven Central Repository -on: - workflow_dispatch: - inputs: - version: - description: 'Version to publish. For example "0.0.1"' - required: true - default: '0.0.0' - release: - types: [ published ] -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true - # https://cashapp.github.io/hermit/usage/ci/ - - name: Init Hermit - uses: cashapp/activate-hermit@v1 - with: - cache: "true" - - uses: actions/cache@v3 - with: - path: ~/.gradle/caches - key: gradle-ubuntu-latest-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/versions.properties') }} - - - name: Sonatype Publish Close And Release - run: | - if [ -n "${{ github.event.inputs.version }}" ]; then - gradle -Pversion=${{ github.event.inputs.version }} publishToSonatype closeAndReleaseSonatypeStagingRepository - else - gradle -Pversion=$(echo "${{ github.ref_name }}" | cut -c2-) publishToSonatype closeAndReleaseSonatypeStagingRepository - fi - env: - ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }} - ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }} - ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPEUSERNAME }} - ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPEPASSWORD }} - - - name: Create GitHub Release - uses: softprops/action-gh-release@v1 - # skips snapshot releases - if: contains(github.event.inputs.version, 'SNAPSHOT') == false - with: - tag_name: ${{ github.event.inputs.version }} - draft: false - prerelease: false - generate_release_notes: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..26f0370e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,151 @@ +# Kicks off the release process: +# +# * Sets release version +# * Builds +# * Tests +# * Creates artifacts for binaries and sources +# * Signs artifacts +# * Uploads artifacts to TBD Artifactory +# * Tags git with release number "v$version" +# * Keeps development version in the pom.xml to 0.0.0-main-SNAPSHOT +# * Pushes changes to git +# * Triggers job to: +# * Build from tag and upload to Maven Central +# * Create GitHub Release "v$version" +# * Publish API Docs + +name: Release and Publish +on: + workflow_dispatch: + inputs: + version: + description: '(Required) The version to release. Must be a real version, not a SNAPSHOT (ie. ending in "-SNAPSHOT"). For example "1.0.0", "1.0.0-alpha-1".' + required: true +jobs: + release-publish-tbd-artifactory: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + # https://cashapp.github.io/hermit/usage/ci/ + - name: Init Hermit + uses: cashapp/activate-hermit@v1 + + - uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + # Used in writing commits in the release process + - name: Set Git Config + run: | + git config user.name "tbd-releases" + git config user.email "releases@tbd.email" + + # This will set versions, git tag, sign, and publish to TBD Artifactory. Does not release to Maven Central. + - name: Release and Publish to TBD Artifactory + run: | + + # Get the required provided version + version=${{ github.event.inputs.version }} + # Precondition check; do not allow this to proceed if a version ending in "-SNAPSHOT" was specified + if [[ $version =~ -SNAPSHOT$ ]]; then + echo "Error: The version for release must not end with \"-SNAPSHOT\": $version" + exit 1 + fi + + # Get the existing version from the POM and set it to the nextVersion, keeping the POM effectively versionless + nextVersion=$(grep -oPm1 "(?<=)[^<]+" pom.xml) + if [[ -z $nextVersion ]]; then + echo "Error: Could not find a version in the pom.xml" + exit 1 + fi + + echo "Version to be released: $version" + echo "Setting next development version back to original in pom.xml: $nextVersion" + + mvn -e \ + release:prepare \ + release:perform \ + --batch-mode \ + --settings .maven_settings.xml \ + -DreleaseVersion=$version \ + -DdevelopmentVersion=$nextVersion \ + -P sign-artifacts + env: + ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + TBD_RELEASE_GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.TBD_RELEASE_GITHUB_PERSONAL_ACCESS_TOKEN }} + SIGN_KEY_PASS: ${{ secrets.GPG_SECRET_PASSPHRASE }} + SIGN_KEY: ${{ secrets.GPG_SECRET_KEY }} + + publish-publicly: + needs: release-publish-tbd-artifactory + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: v${{ github.event.inputs.version }} + submodules: true + + # https://cashapp.github.io/hermit/usage/ci/ + - name: Init Hermit + uses: cashapp/activate-hermit@v1 + + - uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Build, Test, and Deploy to Maven Central + run: | + echo $(git describe --tags) + # Maven deploy lifecycle will build, run tests, verify, sign, and deploy + mvn \ + deploy \ + -P ossrh,sign-artifacts \ + --batch-mode \ + --settings .maven_settings.xml + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SIGN_KEY_PASS: ${{ secrets.GPG_SECRET_PASSPHRASE }} + SIGN_KEY: ${{ secrets.GPG_SECRET_KEY }} + + - name: Download Dokka CLI and Build HTML APIDocs + working-directory: . + run: ./scripts/dokka.sh + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: docs + path: target/apidocs + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + tag_name: v${{ github.event.inputs.version }} + draft: false + prerelease: false + generate_release_notes: true + + deploy-api-docs: + runs-on: ubuntu-latest + needs: [publish-publicly] + steps: + - uses: actions/download-artifact@v2 + with: + path: public + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + keep_files: true + publish_dir: ./public + full_commit_message: Publish documentation to GitHub pages diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 80868cac..a4fc135a 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -1,4 +1,4 @@ -name: Scorecard supply-chain security +name: Open Source Security Foundation Scorecard on: # For Branch-Protection check. Only the default branch is supported. See # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yml similarity index 100% rename from .github/workflows/security.yaml rename to .github/workflows/security.yml diff --git a/.github/workflows/tests-publish.yml b/.github/workflows/tests-publish.yml index e1d672dd..feaa97b8 100644 --- a/.github/workflows/tests-publish.yml +++ b/.github/workflows/tests-publish.yml @@ -2,7 +2,7 @@ name: Publish Tests Report on: workflow_run: - workflows: ["tbdex SDK Kotlin CI"] + workflows: ["SDK Kotlin CI"] types: - completed @@ -19,16 +19,16 @@ jobs: name: tests-report-junit path: ./ - - name: Publish Tests Report + - name: Publish Tests Results env: BUILDKITE_ANALYTICS_TOKEN: ${{ secrets.BUILDKITE_ANALYTICS_TOKEN }} WORKFLOW_RUN_ID: ${{ github.event.workflow_run.id }} run: | - declare -a projects=("protocol" "httpclient") + declare -a projects=("httpclient" "httpserver" "protocol") for project in "${projects[@]}"; do # Find Tests Reports in each project and store them in an array - files=($(find "${project}/build/test-results/test" -name '*.xml')) + files=($(find "${project}/target/surefire-reports" -name '*.xml')) # Check if files array is empty if [ ${#files[@]} -eq 0 ]; then diff --git a/.gitignore b/.gitignore index 8ec73278..28abbbc7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ build/ !**/src/main/**/build/ !**/src/test/**/build/ +### Maven +**/target/ + ### IntelliJ IDEA ### .idea .idea/modules.xml @@ -40,4 +43,4 @@ bin/ .vscode/ ### Mac OS ### -.DS_Store \ No newline at end of file +.DS_Store diff --git a/.maven_settings.xml b/.maven_settings.xml new file mode 100644 index 00000000..bd114272 --- /dev/null +++ b/.maven_settings.xml @@ -0,0 +1,29 @@ + + + + github + tbd-releases + ${env.TBD_RELEASE_GITHUB_PERSONAL_ACCESS_TOKEN} + + + tbd-oss-releases + ${env.ARTIFACTORY_USERNAME} + ${env.ARTIFACTORY_PASSWORD} + + + tbd-oss-snapshots + ${env.ARTIFACTORY_USERNAME} + ${env.ARTIFACTORY_PASSWORD} + + + ossrh-snapshots + ${env.SONATYPE_USERNAME} + ${env.SONATYPE_PASSWORD} + + + ossrh-releases + ${env.SONATYPE_USERNAME} + ${env.SONATYPE_PASSWORD} + + + \ No newline at end of file diff --git a/README.md b/README.md index 03844846..579125a4 100644 --- a/README.md +++ b/README.md @@ -1,259 +1,301 @@ # tbdex-kt -[![License](https://img.shields.io/github/license/TBD54566975/tbdex-kt)](https://github.com/TBD54566975/tbdex-kt/blob/main/LICENSE) [![CI](https://github.com/TBD54566975/tbdex-kt/actions/workflows/ci.yaml/badge.svg)](https://github.com/TBD54566975/tbdex-kt/actions/workflows/ci.yaml) [![](https://jitpack.io/v/TBD54566975/tbdex-kt.svg)](https://jitpack.io/#TBD54566975/tbdex-kt) [![Coverage](https://img.shields.io/codecov/c/gh/tbd54566975/tbdex-kt/main?logo=codecov&logoColor=FFFFFF&style=flat-square&token=YI87CKF1LI)](https://codecov.io/github/TBD54566975/tbdex-kt) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/TBD54566975/tbdex-kt/badge)](https://securityscorecards.dev/viewer/?uri=github.com/TBD54566975/tbdex-kt) +[![License](https://img.shields.io/github/license/TBD54566975/tbdex-kt)](https://github.com/TBD54566975/tbdex-kt/blob/main/LICENSE) [![CI](https://github.com/TBD54566975/tbdex-kt/actions/workflows/ci.yaml/badge.svg)](https://github.com/TBD54566975/tbdex-kt/actions/workflows/ci.yaml) [![Coverage](https://img.shields.io/codecov/c/gh/tbd54566975/tbdex-kt/main?logo=codecov&logoColor=FFFFFF&style=flat-square&token=YI87CKF1LI)](https://codecov.io/github/TBD54566975/tbdex-kt) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/TBD54566975/tbdex-kt/badge)](https://securityscorecards.dev/viewer/?uri=github.com/TBD54566975/tbdex-kt) -This repo contains 2 jvm packages: +This repo contains packages: * [`/protocol`](./protocol/) - create, parse, verify, and validate the tbdex messages and resources defined in the [protocol draft specification](https://github.com/TBD54566975/tbdex/blob/main/specs/protocol/README.md) * [`/httpclient`](./httpclient) - An HTTP client that can be used to send tbdex messages to PFIs +* [`/httpserver`](./httpserver) - Base implementation of a tbDEX HTTP server responsible for handling RFQs, orders, and other interactions +* [`/distribution`](./distribution) - The full tbDEX Platform # Usage -tbdex sdk is consumable through Maven Central but some additional repositories are needed for transitive dependencies currently: : +tbDEX is available +[from Maven Central](https://central.sonatype.com/artifact/xyz.block/tbdex). Instructions for +adding the dependency in a variety of build tools including Maven and Gradle are linked there. -# Hermit -This project uses hermit to manage tooling like gradle or openjdk. See [this page](https://cashapp.github.io/hermit/usage/get-started/) to set up Hermit on your machine. -After installing hermit and activating it, you should be able to just run `gradle clean build` to build the project locally. +> [!IMPORTANT] +> tbDEX contains transitive dependencies not +> found in Maven Central. To resolve these, add the +> [TBD thirdparty repository](https://blockxyz.jfrog.io/artifactory/tbd-oss-thirdparty-maven2/) +> to your Maven or Gradle config. +> +> For instance, in your Maven `pom.xml`: +> +> ```shell +> +> +> tbd-oss-thirdparty +> tbd-oss-thirdparty +> +> true +> +> +> false +> +> https://blockxyz.jfrog.io/artifactory/tbd-oss-thirdparty-maven2/ +> +> +> ``` +> +> ...or in your `gradle.settings.kts`: +> +> ```shell +> dependencyResolutionManagement { +> repositories { +> mavenCentral() +> // Thirdparty dependencies of TBD projects not in Maven Central +> maven("https://blockxyz.jfrog.io/artifactory/tbd-oss-thirdparty-maven2/") +> } +> ``` -Currently, we have these packages installed via Hermit (can also view by checking out `hermit status`: -- gradle-8.2 -- openjdk-11.0.10_9 +# Development -You can run `hermit upgrade {package}` to upgrade an existing package, or `hermit install {package}` to install a new package. -Please see [Hermit package management page](https://cashapp.github.io/hermit/usage/management/) for more details. +## Prerequisites -## Gradle -```kotlin -repositories { - mavenCentral() - maven("https://jitpack.io") - maven("https://repo.danubetech.com/repository/maven-public/") -} +### Cloning -dependencies { - // bring in everything: - implementation("xyz.block:tbdex:0.10.0-beta") - // OR if you want to import separate packages (eg may only want client and protocol): - implementation("xyz.block:tbdex-httpclient:0.10.0-beta") - implementation("xyz.block:tbdex-httpserver:0.10.0-beta") - implementation("xyz.block:tbdex-protocol:0.10.0-beta") -} +This repository uses git submodules. To clone this repo with submodules + +```sh +git clone --recurse-submodules git@github.com:TBD54566975/tbdex-kt.git ``` -> [!IMPORTANT] -> The repository at `https://repo.danubetech.com/repository/maven-public/` and `https://jitpack.io` are required for resolving transitive -> dependencies for now, but this should be temporary. -> +Or to add submodules after cloning + +```sh +git submodule update --init +``` + +### Hermit + +This project uses hermit to manage tooling like Maven and Java versions. +See [this page](https://cashapp.github.io/hermit/usage/get-started/) to set up Hermit on your machine - make sure to +download the open source build and activate it for the project. + +Once you've installed Hermit and before running builds on this repo, +run from the root: + +```shell +source ./bin/activate-hermit +``` + +This will set your environment up correctly in the +terminal emulator you're on. + +## Building with Maven -## Maven - -```xml -... - - - jitpack - jitpack - https://jitpack.io - - - danubetech - danubetech - https://repo.danubetech.com/repository/maven-public/ - - - - - - xyz.block - tbdex-httpclient - 0.10.0-beta - - -... +This project is built with the +[Maven Project Management](https://maven.apache.org/) tool. +It is installed via Hermit above. + +If you want to build an artifact on your local filesystem, you can do so by running the +following command - either at the top level or in +any of the subprojects: + +```shell +mvn clean verify +``` + +This will first clean all previous builds and compiled code, then: +compile, test, and build the artifacts in each of the submodules +of this project in the `$moduleName/target` directory, for example: + +```shell +ls -l httpserver/target +``` + +You should see similar to: + +```shell +total 240 +drwxr-xr-x@ 4 alr staff 128 Apr 4 00:29 classes +drwxr-xr-x@ 4 alr staff 128 Apr 4 00:29 generated-sources +drwxr-xr-x@ 4 alr staff 128 Apr 4 00:29 kaptStubs +drwxr-xr-x@ 4 alr staff 128 Apr 4 00:29 kotlin-ic +drwxr-xr-x@ 3 alr staff 96 Apr 4 00:30 kover +drwxr-xr-x@ 3 alr staff 96 Apr 4 00:30 maven-archiver +drwxr-xr-x@ 3 alr staff 96 Apr 4 00:29 maven-status +drwxr-xr-x@ 3 alr staff 96 Apr 4 00:30 site +drwxr-xr-x@ 18 alr staff 576 Apr 4 00:30 surefire-reports +-rw-r--r--@ 1 alr staff 17889 Apr 4 00:30 tbdex-httpserver-0.0.0-main-SNAPSHOT-sources.jar +-rw-r--r--@ 1 alr staff 99334 Apr 4 00:30 tbdex-httpserver-0.0.0-main-SNAPSHOT.jar +drwxr-xr-x@ 11 alr staff 352 Apr 4 00:29 test-classes +drwxr-xr-x@ 4 alr staff 128 Apr 4 00:30 tmp +``` + +If you'd like to skip packaging and test only, run: + +```shell +mvn test +``` + +You may also run a single test; `cd` into the submodule of choice, +then use the `-Dtest=` parameter to denote which test to run, for example: + +```shell +cd httpclient; \ +mvn test -Dtest=TestClassName ``` -
- Expand for complete mvn pom.xml example using kotlin - - pom.xml: -```xml - - - - 4.0.0 - website.tbd.developer.site - kotlin-testsuite - 0.1.0-SNAPSHOT - - kotlin-testsuite - http://developer.tbd.website - - - UTF-8 - 17 - true - 3.25.2 - 1.9.22 - true - 5.10.1 - - - 0.10.0-beta - - - - - - - - org.jetbrains.kotlin - kotlin-stdlib - ${version.kotlin} - - - - - xyz.block - tbdex-httpclient - ${version.tbdex} - - - xyz.block - tbdex-httpserver - ${version.tbdex} - - - xyz.block - tbdex-protocol - ${version.tbdex} - - - - - - - - org.jetbrains.kotlin - kotlin-stdlib - - - - - xyz.block - tbdex-httpclient - - - xyz.block - tbdex-protocol - - - - - ${project.basedir}/src/main/kotlin - ${project.basedir}/src/test/kotlin - - - - - maven-clean-plugin - 3.1.0 - - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - maven-surefire-plugin - 2.22.1 - - - maven-jar-plugin - 3.0.2 - - - maven-install-plugin - 2.5.2 - - - maven-deploy-plugin - 2.8.2 - - - - maven-site-plugin - 3.7.1 - - - maven-project-info-reports-plugin - 3.0.0 - - - kotlin-maven-plugin - org.jetbrains.kotlin - ${version.kotlin} - - - - - - kotlin-maven-plugin - org.jetbrains.kotlin - true - - ${kotlin.jvm.target} - - - - - - - - - jitpack - jitpack - https://jitpack.io - - - danubetech - danubetech - https://repo.danubetech.com/repository/maven-public/ - - - +To install builds into your local Maven repository, run from the root: + +```shell +mvn install ``` -```xml -... - - - jitpack - jitpack - https://jitpack.io - - - danubetech - danubetech - https://repo.danubetech.com/repository/maven-public/ - - -... - - - xyz.block - tbdex-httpclient - ${version.tbdex} - -... +For more, see the documentation on [Maven Lifecycle](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html). + +## Generating API Docs Locally + +We use [Dokka](https://kotlinlang.org/docs/dokka-cli.html) to create the +HTML API Documentation for this project. This is done using the Dokka CLI +because the [Dokka Maven Plugin](https://kotlinlang.org/docs/dokka-maven.html) +does not yet support multimodule builds. To run locally, obtain the Dokka CLI. +Run from the root of this repo: + +```shell +# it will download the jars into the `target/dokka-cli` folder and generate the docs +./scripts/dokka.sh ``` -
+These will be available in `target/apidocs`. + +This step is handled during releases and published via GitHub Actions. + +## Publishing Docs + +API reference documentation is automatically updated are available +at [https://tbd54566975.github.io/tbdex-kt/docs/](https://tbd54566975.github.io/tbdex-kt/docs/) +following each automatically generated release. + +## Dependency Management + +As tbDEX is a platform intended to run alongside Web5 in a single `ClassLoader`, +versions and dependencies must be aligned among the subprojects +(sometimes called modules) of this project. To address, we declare +versions in `pom.xml`'s `` section and +import references defined there in the subproject `pom.xml`s' `` +sections. Versions themselves are defined as properties in the root `pom.xml`. +See further documentation on versioning and dependency management there. + +The root `pom.xml` may also be imported in projects building atop +tbDEX in `import` scope to respect these dependency declarations. + +### Updating the Web5 Dependency + +This build extends from the Web5 build. Therefore, updates to Web5 must be +done in 2 places in the root `pom.xml`: + +1. In ``, where `` is defined. +2. In the ``, where the `tbdex-parent` has a + parent of `web5-parent`. This version number cannot be referenced from + the version property defined by 1., so it must be updated in tandem. + +## Release Guidelines + +### Pre-releases + +In Kotlin we use the SNAPSHOT convention to build and publish a pre-release package that can be consumed for preview/testing/development purposes. + +These SNAPSHOTs are generated and published whenever there's a new push to `main`. If you want to manually kick that off to preview some changes introduced in a PR branch: + +1. Open the [SDK Kotlin CI Workflow](https://github.com/TBD54566975/tbdex-kt/actions/workflows/ci.yml), press the **Run workflow button** selecting the branch you want to generate the snapshot from. + +2. In the version field, insert the current version, a short meaningful identifier and the `-SNAPSHOT` suffix, ie: + + - 0.11.0.pr123-SNAPSHOT + - 0.11.0.shortsha-SNAPSHOT + - 0.11.0.fixsomething-SNAPSHOT + +3. Run workflow! + +You **MUST** use the `-SNAPSHOT` suffix, otherwise it's not a valid preview `SNAPSHOT` and it will be rejected. + +`SNAPSHOT`s will be available in [TBD's Artifactory `tbd-oss-snapshots-maven2` Repository](https://blockxyz.jfrog.io/artifactory/tbd-oss-snapshots-maven2). + +### Releasing New Versions + +To release a new version, execute the following steps: + +1. Open the [Release and Publish](https://github.com/TBD54566975/tbdex-kt/actions/workflows/release.yml), press the **Run workflow button** selecting the branch you want to generate the snapshot from. + +2. In the version field, declare the version to be released. ie: + + - 0.15.2 + - 0.17.0-alpha-3 + - 1.6.3 + + - **Choose an appropriate version number based on semver rules. Remember that versions are immutable once published to Maven Central; they cannot be altered or removed.** + +3. Press the **Run workflow button** and leave the main branch selected (unless its a rare case where you don't want to build from the main branch for the release). + +4. Run workflow! This: + +- Builds +- Tests +- Creates artifacts for binaries and sources +- Signs artifacts +- Uploads artifacts to TBD Artifactory +- Tags git with release number "v$version" +- Keeps development version in the pom.xml to 0.0.0-main-SNAPSHOT +- Pushes changes to git +- Triggers job to: + - Build from tag and upload to Maven Central + - Create GitHub Release "v$version"built and **published to maven central**, **docs will be published** (see below) and **the GitHub release will be automatically generated**! + - Publish API Docs + +### Publishing a `SNAPSHOT` from a Local Dev Machine + +Please take care to only publish `-SNAPSHOT` builds (ie. +when the `` field of the `pom.xml` ends in +`-SNAPSHOT`.) unless there's good reason +to deploy a non-`SNAPSHOT` release. Releases are typically handled via automation +in GitHub Actions s documented above. + +To deploy to TBD's Artifactory instance for sharing with others, you +need your Artifactory username and password handy (available to TBD-employed engineers). +Set environment variables: + +```shell +export ARTIFACTORY_USERNAME=yourUsername; \ +export ARTIFACTORY_PASSWORD=yourPassword +``` + +...then run: + +```shell +mvn deploy --settings .maven_settings.xml +``` +## Working with the `tbdex` submodule + +### Pulling + +You may need to update the `tbdex` submodule after pulling. + +```sh +git pull +git submodule update +``` +### Pushing + +If you have made changes to the `tbdex` submodule, you should push your changes to the `tbdex` remote as well as +pushing changes to `tbdex-kt`. + +```sh +cd tbdex +git checkout main +git checkout -b my-branch +git add . +git commit -m "your commit message" +git push +cd .. +git add . +git commit -m "updating tbdex submodule" +git push +``` ## Sample `Main.kt` @@ -267,24 +309,10 @@ fun main() { } ``` -# Development - -## JSON Schemas - -the [tbdex]() repo acts as the source of truth for all json schemas and test vectors. For this reason, the `tbdex` repo is a git -submodule -of this repo. By default, `git clone` does not actually check out the submodule's files. Using `--recurse-submodules` -option when cloning automatically initializes, fetches, and does a checkout of the appropriate commit for the submodule. -If you've already cloned the repo without `--recurse-submodules`, you can do the following: - -```bash -git submodule update --init -``` - # Other Docs -* [API Reference Guide](https://tbd54566975.github.io/tbdex-kt/) +* [API Reference Guide](https://tbd54566975.github.io/tbdex-kt/docs/) * [Developer Docs](https://developer.tbd.website/docs/tbdex/) -* [Guidelines](./CONVENTIONS.md) +* [Coding Guidelines](./CONVENTIONS.md) * [Code of Conduct](./CODE_OF_CONDUCT.md) * [Governance](./GOVERNANCE.md) diff --git a/bin/.gradle-8.2.pkg b/bin/.maven-3.9.6.pkg similarity index 100% rename from bin/.gradle-8.2.pkg rename to bin/.maven-3.9.6.pkg diff --git a/bin/gradle b/bin/gradle deleted file mode 120000 index 3b1d2891..00000000 --- a/bin/gradle +++ /dev/null @@ -1 +0,0 @@ -.gradle-8.2.pkg \ No newline at end of file diff --git a/bin/mvn b/bin/mvn new file mode 120000 index 00000000..50c2105e --- /dev/null +++ b/bin/mvn @@ -0,0 +1 @@ +.maven-3.9.6.pkg \ No newline at end of file diff --git a/bin/mvnDebug b/bin/mvnDebug new file mode 120000 index 00000000..50c2105e --- /dev/null +++ b/bin/mvnDebug @@ -0,0 +1 @@ +.maven-3.9.6.pkg \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts deleted file mode 100644 index 8a95632f..00000000 --- a/build.gradle.kts +++ /dev/null @@ -1,284 +0,0 @@ -import io.gitlab.arturbosch.detekt.Detekt -import org.gradle.api.tasks.testing.logging.TestExceptionFormat -import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.gradle.DokkaTaskPartial -import org.jetbrains.kotlin.gradle.dsl.JvmTarget -import java.net.URL - -plugins { - id("org.jetbrains.kotlin.jvm") version "1.9.22" - id("base") - id("io.gitlab.arturbosch.detekt") version "1.23.1" - `maven-publish` - id("org.jetbrains.dokka") version "1.9.0" - id("org.jetbrains.kotlinx.kover") version "0.7.3" - signing - id("io.github.gradle-nexus.publish-plugin") version "1.3.0" - id("version-catalog") -} - -repositories { - mavenCentral() - // block's cache artifactory for tbd's oss third party dependencies - // that do not live in maven central - maven { - name = "tbd-oss-thirdparty" - url = uri("https://blockxyz.jfrog.io/artifactory/tbd-oss-thirdparty-maven2/") - mavenContent { - releasesOnly() - } - } -} - -dependencies { - api(project(":protocol")) - api(project(":httpclient")) - api(project(":httpserver")) - detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.1") -} - -/** - * Dependency forcing for build dependencies; this is separate from the code - * dependencies below in the "allprojects" block because it concerns the - * build itself. - * - * "allprojects" block below has documentation detailing why forced resolution - * strategies are necessary. - */ -buildscript { - configurations.all { - resolutionStrategy { - // Address https://github.com/TBD54566975/tbdex-kt/issues/167 - force("com.fasterxml.woodstox:woodstox-core:6.4.0") - } - } -} - -allprojects { - group = "xyz.block" - tasks.findByName("wrapper")?.enabled = false - - configurations.all { - /** - * In this section we address build issues including security vulnerabilities - * in transitive dependencies we don't explicitly declare in - * `gradle/libs.versions.toml`. Forced actions taken here will override any - * declarations we make, so use with care. Also note: these are in place for a - * point in time. As we maintain this software, the manual forced resolution we do - * here may: - * - * 1) No longer be necessary (if we have removed a dependency path leading to dep) - * 2) Break an upgrade (if we upgrade a dependency and this forces a lower version - * of a transitive dependency it brings in) - * - * So we need to exercise care here, and, when upgrading our deps, check to see if - * these forces aren't breaking things. - * - * When adding forces here, please reference the issue which explains why we - * needed to do this; it will help future maintainers understand if the force - * is still valid, should be removed, or handled in another way. - * - * When in doubt, ask! :) - */ - resolutionStrategy { - // Addresss https://github.com/TBD54566975/tbdex-kt/issues/167 - force("com.fasterxml.woodstox:woodstox-core:6.4.0") - // Addresss https://github.com/TBD54566975/tbdex-kt/issues/168 - force("com.google.guava:guava:32.0.0-android") - // Addresss https://github.com/TBD54566975/tbdex-kt/issues/169 - force("com.google.protobuf:protobuf-javalite:3.19.6") - // Addresses https://github.com/TBD54566975/tbdex-kt/issues/170 - force("com.squareup.okio:okio:3.6.0") - // Addresses CVE-2024-29025 - force("io.netty:netty-codec-http:4.1.108.Final") - } - } -} - -subprojects { - repositories { - mavenCentral() - } - apply { - plugin("io.gitlab.arturbosch.detekt") - plugin("org.jetbrains.kotlin.jvm") - plugin("java-library") - plugin("maven-publish") - plugin("org.jetbrains.dokka") - plugin("org.jetbrains.kotlinx.kover") - plugin("signing") - plugin("version-catalog") - } - - tasks.withType().configureEach { - jvmTarget = "1.8" - } - dependencies { - detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.1") - } - - detekt { - config.setFrom("$rootDir/config/detekt.yml") - } - - kotlin { - jvmToolchain(11) - compilerOptions { - jvmTarget.set(JvmTarget.JVM_11) - apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9) - languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9) - } - } - - java { - withJavadocJar() - withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - - val publicationName = "${rootProject.name}-${project.name}" - publishing { - publications { - create(publicationName) { - groupId = project.group.toString() - artifactId = name - description = name - version = project.property("version").toString() - from(components["java"]) - } - - withType { - pom { - name = publicationName - packaging = "jar" - description.set("tbDEX SDK for the JVM") - url.set("https://github.com/TBD54566975/tbdex-kt") - inceptionYear.set("2023") - licenses { - license { - name.set("The Apache License, Version 2.0") - url.set("https://github.com/TBD54566975/tbdex-kt/blob/main/LICENSE") - } - } - developers { - developer { - id.set("TBD54566975") - name.set("Block Inc.") - email.set("tbd-releases@tbd.email") - } - } - scm { - connection.set("scm:git:git@github.com:TBD54566975/tbdex-kt.git") - developerConnection.set("scm:git:ssh:git@github.com:TBD54566975/tbdex-kt.git") - url.set("https://github.com/TBD54566975/tbdex-kt") - } - } - } - } - - if (!project.hasProperty("skipSigning") || project.property("skipSigning") != "true") { - signing { - val signingKey: String? by project - val signingPassword: String? by project - useInMemoryPgpKeys(signingKey, signingPassword) - sign(publishing.publications[publicationName]) - } - } - } - - tasks.withType().configureEach { - dokkaSourceSets.configureEach { - documentedVisibilities.set( - setOf( - DokkaConfiguration.Visibility.PUBLIC, - DokkaConfiguration.Visibility.PROTECTED - ) - ) - - sourceLink { - val exampleDir = "https://github.com/TBD54566975/tbdex-kt/tree/main" - - localDirectory.set(rootProject.projectDir) - remoteUrl.set(URL(exampleDir)) - remoteLineSuffix.set("#L") - } - } - } - - tasks.test { - useJUnitPlatform() - reports { - junitXml - } - testLogging { - events("passed", "skipped", "failed", "standardOut", "standardError") - exceptionFormat = TestExceptionFormat.FULL - showExceptions = true - showCauses = true - showStackTraces = true - } - } -} - -// Configures only the parent MultiModule task, -// this will not affect subprojects -tasks.dokkaHtmlMultiModule { - moduleName.set("tbdex SDK Documentation") -} - -publishing { - publications { - create(rootProject.name) { - groupId = project.group.toString() - artifactId = name - description = name - version = project.property("version").toString() - from(components["java"]) - - pom { - packaging = "pom" - name = "tbDEX SDK for the JVM" - description.set("tbDEX SDK for the JVM") - url.set("https://github.com/TBD54566975/tbdex-kt") - inceptionYear.set("2023") - licenses { - license { - name.set("The Apache License, Version 2.0") - url.set("https://github.com/TBD54566975/tbdex-kt/blob/main/LICENSE") - } - } - developers { - developer { - id.set("TBD54566975") - name.set("Block Inc.") - email.set("tbd-releases@tbd.email") - } - } - scm { - connection.set("scm:git:git@github.com:TBD54566975/tbdex-kt.git") - developerConnection.set("scm:git:ssh:git@github.com:TBD54566975/tbdex-kt.git") - url.set("https://github.com/TBD54566975/tbdex-kt") - } - } - } - } -} - -if (!project.hasProperty("skipSigning") || project.property("skipSigning") != "true") { - signing { - val signingKey: String? by project - val signingPassword: String? by project - useInMemoryPgpKeys(signingKey, signingPassword) - sign(publishing.publications["tbdex"]) - } -} - -nexusPublishing { - repositories { - sonatype { //only for users registered in Sonatype after 24 Feb 2021 - nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) - } - } -} \ No newline at end of file diff --git a/distribution/pom.xml b/distribution/pom.xml new file mode 100644 index 00000000..c98ed081 --- /dev/null +++ b/distribution/pom.xml @@ -0,0 +1,58 @@ + + + + + + xyz.block + tbdex-parent + 0.0.0-main-SNAPSHOT + ../pom.xml + + + + 4.0.0 + + + tbdex + tbDEX Distribution + Single-POM Definition to export the tbDEX Dependencies in proper scope + pom + + + + + + + + + + + + + + + xyz.block + tbdex-httpclient + ${project.version} + + + xyz.block + tbdex-httpserver + ${project.version} + + + xyz.block + tbdex-protocol + ${project.version} + + + + + + + + + + + diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml deleted file mode 100644 index 3e0e422c..00000000 --- a/gradle/libs.versions.toml +++ /dev/null @@ -1,51 +0,0 @@ -### -# This section is where we declare the versioning and scope for dependencies of -# the tbDEX platform and projects building atop the tbDEX platform. -# -# Submodules of tbDEX are not able to define their own dependency versions -# because these must all co-exist in the same ClassLoading environment, and -# therefore have to be aligned across submodules. Thus we declare the versioning -# requirements here at the platform level. -# -# Additionally, dependencies shared with Web5 must be version aligned because tbDEX -# is built atop Web5 and these two platforms must co-exist in the same ClassLoading -# environment as well. Default to versions already defined in Web5 if present, and do -# not override here. -# -# If a submodule needs to introduce a new dependency or upgrade, define that -# dependency and version here such that other submodules in the build may pick -# up the same version. This will guarantee that submodule test suites are running -# in the correct ClassLoading environment aligned throughout the tbDEX and Web5 platforms. -# -# More about Gradle Version Catalogs: -# https://docs.gradle.org/current/userguide/platforms.html -# -# Helpful Blog: -# https://umang91.medium.com/version-catalogs-in-gradle-7-0-816873b59b47 -### - -[versions] -com_fasterxml_jackson = "2.14.2" -com_networknt = "1.0.87" -com_squareup_okhttp = "4.12.0" -de_fxlae = "0.2.0" -io_ktor = "2.3.7" -xyz_block_web5 = "0.17.0" - -[libraries] -comFasterXmlJacksonModuleKotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "com_fasterxml_jackson" } -comFasterXmlJacksonDatatypeJsr310 = { module = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310", version.ref = "com_fasterxml_jackson" } -comNetworkntJsonSchemaValidator = { module = "com.networknt:json-schema-validator", version.ref = "com_networknt" } -comSquareupOkhttpOkhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "com_squareup_okhttp" } -comSquareupOkhttpMockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "com_squareup_okhttp" } -deFxlaeTypeId = { module = "de.fxlae:typeid-java-jdk8", version.ref = "de_fxlae" } -ioKtorClientAuth = { module = "io.ktor:ktor-client-auth", version.ref = "io_ktor" } -ioKtorSerializationJackson = { module = "io.ktor:ktor-serialization-jackson", version.ref = "io_ktor" } -ioKtorServerContentNegotiation = { module = "io.ktor:ktor-server-content-negotiation", version.ref = "io_ktor" } -ioKtorServerNetty = { module = "io.ktor:ktor-server-netty", version.ref = "io_ktor" } -xyzBlockWeb5 = { module = "xyz.block:web5", version.ref = "xyz_block_web5" } - -[bundles] -testBundleName = [ - "xyzBlockWeb5" -] \ No newline at end of file diff --git a/httpclient/build.gradle.kts b/httpclient/build.gradle.kts deleted file mode 100644 index 014476b8..00000000 --- a/httpclient/build.gradle.kts +++ /dev/null @@ -1,71 +0,0 @@ -import org.gradle.api.tasks.testing.logging.TestExceptionFormat - -plugins { - id("org.jetbrains.kotlin.jvm") - id("java-library") -} - -repositories { - mavenCentral() - // block's cache artifactory for tbd's oss third party dependencies - // that do not live in maven central - maven { - name = "tbd-oss-thirdparty" - url = uri("https://blockxyz.jfrog.io/artifactory/tbd-oss-thirdparty-maven2/") - mavenContent { - releasesOnly() - } - } -} - -val jackson_version = "2.14.2" - -dependencies { - - /** - * Maintainers - please do not declare versioning here at the module level; - * dependencies are either pulled in transitively via web5-kt, or - * centralized for the platform in $projectRoot/gradle/libs.versions.toml - * - * Deps are declared in alphabetical order. - */ - - // API - api(libs.xyzBlockWeb5) - - // Project - implementation(project(":protocol")) - - // Implementation - implementation(libs.deFxlaeTypeId) - implementation(libs.comSquareupOkhttpOkhttp) - implementation(libs.comFasterXmlJacksonModuleKotlin) - - // Test - /** - * Test dependencies may declare direct versions; they are not exported - * and therefore are within the remit of this module to self-define - * if desired. - */ - testImplementation(kotlin("test")) - testImplementation(libs.comSquareupOkhttpMockwebserver) - testImplementation("com.willowtreeapps.assertk:assertk:0.27.0") - testImplementation("io.mockk:mockk:1.13.9") - -} - -tasks.test { - useJUnitPlatform() - testLogging { - events("passed", "skipped", "failed", "standardOut", "standardError") - exceptionFormat = TestExceptionFormat.FULL - showExceptions = true - showCauses = true - showStackTraces = true - } -} - -java { - withJavadocJar() - withSourcesJar() -} \ No newline at end of file diff --git a/httpclient/pom.xml b/httpclient/pom.xml new file mode 100644 index 00000000..5507a1d3 --- /dev/null +++ b/httpclient/pom.xml @@ -0,0 +1,62 @@ + + + + + + xyz.block + tbdex-parent + 0.0.0-main-SNAPSHOT + ../pom.xml + + + + 4.0.0 + + + tbdex-httpclient + tbDEX HTTP Client + HTTP Client for tbDEX + + + + + + + + + + + + + + + xyz.block + tbdex-protocol + ${project.version} + + + + + + + io.mockk + mockk-jvm + 1.13.9 + test + + + com.squareup.okhttp3 + mockwebserver + 4.12.0 + test + + + + + + + + + + \ No newline at end of file diff --git a/httpserver/build.gradle.kts b/httpserver/build.gradle.kts deleted file mode 100644 index 03a504d5..00000000 --- a/httpserver/build.gradle.kts +++ /dev/null @@ -1,85 +0,0 @@ -import org.gradle.api.tasks.testing.logging.TestExceptionFormat - -plugins { - id("org.jetbrains.kotlin.jvm") - id("java-library") - id("io.ktor.plugin") version "2.3.7" -} - -repositories { - mavenCentral() - // block's cache artifactory for tbd's oss third party dependencies - // that do not live in maven central - maven { - name = "tbd-oss-thirdparty" - url = uri("https://blockxyz.jfrog.io/artifactory/tbd-oss-thirdparty-maven2/") - mavenContent { - releasesOnly() - } - } -} -application { - mainClass.set("tbdex.sdk.httpserver.TbdexHttpServerKt") -} - -dependencies { - - /** - * Maintainers - please do not declare versioning here at the module level; - * dependencies are either pulled in transitively via web5-kt, or - * centralized for the platform in $projectRoot/gradle/libs.versions.toml - * - * Deps are declared in alphabetical order. - */ - - // API - api(libs.xyzBlockWeb5) - - /* - * API Leak: https://github.com/TBD54566975/tbdex-kt/issues/161 - * - * Change and move to "implementation" when completed - */ - api(libs.deFxlaeTypeId) - - // Project - implementation(project(":protocol")) - implementation(project(":httpclient")) - - // Implementation - implementation(libs.comFasterXmlJacksonDatatypeJsr310) - implementation(libs.ioKtorClientAuth) - implementation(libs.ioKtorSerializationJackson) - implementation(libs.ioKtorServerContentNegotiation) - implementation(libs.ioKtorServerNetty) - - // Test - /** - * Test dependencies may declare direct versions; they are not exported - * and therefore are within the remit of this module to self-define - * if desired. - */ - testImplementation(kotlin("test")) - testImplementation("com.willowtreeapps.assertk:assertk:0.27.0") - testImplementation("io.ktor:ktor-server-test-host") - testImplementation("io.ktor:ktor-client-content-negotiation") - testImplementation("io.mockk:mockk:1.11.0") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") -} - -tasks.test { - useJUnitPlatform() - testLogging { - events("passed", "skipped", "failed", "standardOut", "standardError") - exceptionFormat = TestExceptionFormat.FULL - showExceptions = true - showCauses = true - showStackTraces = true - } -} - -java { - withJavadocJar() - withSourcesJar() -} \ No newline at end of file diff --git a/httpserver/pom.xml b/httpserver/pom.xml new file mode 100644 index 00000000..f786863c --- /dev/null +++ b/httpserver/pom.xml @@ -0,0 +1,91 @@ + + + + + + xyz.block + tbdex-parent + 0.0.0-main-SNAPSHOT + ../pom.xml + + + + 4.0.0 + + + tbdex-httpserver + tbDEX HTTP Server + HTTP Server for tbDEX + + + + + + + + + + + + + + + xyz.block + tbdex-httpclient + ${project.version} + + + + + io.ktor + ktor-server-content-negotiation-jvm + + + io.ktor + ktor-server-netty-jvm + + + + + io.ktor + ktor-client-auth-jvm + test + + + io.ktor + ktor-client-content-negotiation-jvm + test + + + io.ktor + ktor-server-test-host-jvm + test + + + io.mockk + mockk + + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + tbdex.sdk.httpserver.TbdexHttpServerKt + + + + + + + + \ No newline at end of file diff --git a/jitpack.yml b/jitpack.yml deleted file mode 100644 index 1e41e00b..00000000 --- a/jitpack.yml +++ /dev/null @@ -1,2 +0,0 @@ -jdk: - - openjdk17 \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..bf244700 --- /dev/null +++ b/pom.xml @@ -0,0 +1,382 @@ + + + + + 4.0.0 + + + xyz.block + tbdex-parent + 0.0.0-main-SNAPSHOT + pom + + xyz.block + web5-parent + + commit-89fc453-SNAPSHOT + + tbDEX SDK for the JVM Build Parent + https://developer.tbd.website + Build Aggregator and Parent for tbDEX SDK for the JVM + 2024 + + + + scm:git:git://github.com/TBD54566975/tbdex-kt.git + + scm:git:https://github.com/TBD54566975/tbdex-kt.git + https://github.com/TBD54566975/tbdex-kt + HEAD + + + + + + TBD54566975 + Block, Inc. + releases@tbd.email + + + + + + github + https://github.com/TBD54566975/tbdex-kt/issues + + + + + + Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + distribution + httpclient + httpserver + protocol + + + + + + UTF-8 + 11 + true + + github + + + + + + commit-89fc453-SNAPSHOT + + + 0.2.0 + + + 0.27.0 + 1.11.0 + + + 4.1.108.Final + + + + + + + + + + + + xyz.block + web5-parent + ${version.xyz.block.web5} + pom + import + + + + + de.fxlae + typeid-java-jdk8 + ${version.de.fxlae} + + + + xyz.block + web5 + ${version.xyz.block.web5} + pom + + + + + com.willowtreeapps.assertk + assertk-jvm + ${version.com.willowtreeapps.assertk} + test + + + io.mockk + mockk + ${version.io.mockk} + test + + + + + + + io.netty + netty-codec-http + ${version.io.netty} + + + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + ${version.com.fasterxml.jackson} + + + io.ktor + ktor-client-auth-jvm + + ${version.io.ktor} + + + io.ktor + ktor-client-content-negotiation-jvm + + ${version.io.ktor} + + + io.ktor + ktor-server-content-negotiation-jvm + + ${version.io.ktor} + + + io.ktor + ktor-server-netty-jvm + + ${version.io.ktor} + + + io.ktor + ktor-server-test-host-jvm + + ${version.io.ktor} + + + + + + + + + + + + + + com.willowtreeapps.assertk + assertk-jvm + + + org.assertj + assertj-core + + + org.jetbrains.kotlin + kotlin-stdlib + + + org.jetbrains.kotlin + kotlin-test + + + org.jetbrains.kotlin + kotlin-test-junit5 + + + org.junit.jupiter + junit-jupiter-api + + + org.junit.jupiter + junit-jupiter-engine + + + + + + + + + + org.codehaus.mojo + exec-maven-plugin + false + + + git submodule update + initialize + + git + + submodule + update + --init + --recursive + + + + exec + + + + + + + + + + + + + + + + + + + + tbd-oss-snapshots + tbd-oss-snapshots + + false + + + true + + https://blockxyz.jfrog.io/artifactory/tbd-oss-snapshots-maven2/ + + + tbd-oss-releases + tbd-oss-releases + + true + + + false + + https://blockxyz.jfrog.io/artifactory/tbd-oss-releases-maven2/ + + + + + + + + \ No newline at end of file diff --git a/protocol/build.gradle.kts b/protocol/build.gradle.kts deleted file mode 100644 index 93a4f265..00000000 --- a/protocol/build.gradle.kts +++ /dev/null @@ -1,84 +0,0 @@ -import org.gradle.api.tasks.testing.logging.TestExceptionFormat - -plugins { - id("org.jetbrains.kotlin.jvm") - id("java-library") -} - -repositories { - mavenCentral() - // block's cache artifactory for tbd's oss third party dependencies - // that do not live in maven central - maven { - name = "tbd-oss-thirdparty" - url = uri("https://blockxyz.jfrog.io/artifactory/tbd-oss-thirdparty-maven2/") - mavenContent { - releasesOnly() - } - } -} - -dependencies { - - /** - * Maintainers - please do not declare versioning here at the module level; - * dependencies are either pulled in transitively via web5-kt, or - * centralized for the platform in $projectRoot/gradle/libs.versions.toml - * - * Deps are declared in alphabetical order. - */ - - // API - api(libs.xyzBlockWeb5) - - - // Project - - // Implementation - implementation(libs.deFxlaeTypeId) - implementation(libs.comFasterXmlJacksonModuleKotlin) - implementation(libs.comFasterXmlJacksonDatatypeJsr310) - implementation(libs.comNetworkntJsonSchemaValidator) - - // Test - /** - * Test dependencies may declare direct versions; they are not exported - * and therefore are within the remit of this module to self-define - * if desired. - */ - testImplementation(kotlin("test")) - testImplementation("com.willowtreeapps.assertk:assertk:0.27.0") -} - -sourceSets { - val test by getting { - val resourceDirs = listOf( - "../tbdex/hosted/test-vectors/protocol/vectors", - ) - resources.setSrcDirs(resourceDirs) - } - - main { - val resourceDirs = listOf( - "../tbdex/hosted/json-schemas" - ) - - resources.setSrcDirs(resourceDirs) - } -} - -tasks.test { - useJUnitPlatform() - testLogging { - events("passed", "skipped", "failed", "standardOut", "standardError") - exceptionFormat = TestExceptionFormat.FULL - showExceptions = true - showCauses = true - showStackTraces = true - } -} - -java { - withJavadocJar() - withSourcesJar() -} \ No newline at end of file diff --git a/protocol/pom.xml b/protocol/pom.xml new file mode 100644 index 00000000..61a1e95a --- /dev/null +++ b/protocol/pom.xml @@ -0,0 +1,64 @@ + + + + + + xyz.block + tbdex-parent + 0.0.0-main-SNAPSHOT + ../pom.xml + + + + 4.0.0 + + + tbdex-protocol + tbDEX Protocol + Protocol for tbDEX + + + + + + + + + + + + + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + de.fxlae + typeid-java-jdk8 + + + xyz.block + web5 + pom + + + + + + + + + + + ../tbdex/hosted/json-schemas + + + + + ../tbdex/hosted/test-vectors/protocol/vectors + + + + \ No newline at end of file diff --git a/scripts/dokka-configuration.json b/scripts/dokka-configuration.json new file mode 100644 index 00000000..292dab9d --- /dev/null +++ b/scripts/dokka-configuration.json @@ -0,0 +1,33 @@ +{ + "moduleName": "tbDEX SDK Documentation", + "failOnWarning": false, + "suppressObviousFunctions": true, + "suppressInheritedMembers": false, + "offlineMode": false, + "outputDir": "./target/apidocs", + "sourceSets": [ + { + "documentedVisibilities": [ + "PUBLIC", + "PROTECTED" + ], + "sourceSetID": { + "scopeId": "tbdex", + "sourceSetName": "main" + }, + "sourceRoots": [ + "httpclient/src/main/kotlin", + "httpserver/src/main/kotlin", + "protocol/src/main/kotlin" + ], + "includes": [ + ] + } + ], + "pluginsClasspath": [ + "./target/dokka-cli/dokka-base.jar", + "./target/dokka-cli/kotlinx-html-jvm.jar", + "./target/dokka-cli/analysis-kotlin-descriptors.jar", + "./target/dokka-cli/freemarker.jar" + ] +} \ No newline at end of file diff --git a/scripts/dokka.sh b/scripts/dokka.sh new file mode 100755 index 00000000..ce03a4c5 --- /dev/null +++ b/scripts/dokka.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# setup dokka cli +if [ ! -d "./target/dokka-cli" ]; then + mkdir -p ./target/dokka-cli + wget -O ./target/dokka-cli/dokka-cli.jar https://repo1.maven.org/maven2/org/jetbrains/dokka/dokka-cli/1.9.20/dokka-cli-1.9.20.jar + wget -O ./target/dokka-cli/dokka-base.jar https://repo1.maven.org/maven2/org/jetbrains/dokka/dokka-base/1.9.20/dokka-base-1.9.20.jar + wget -O ./target/dokka-cli/analysis-kotlin-descriptors.jar https://repo1.maven.org/maven2/org/jetbrains/dokka/analysis-kotlin-descriptors/1.9.20/analysis-kotlin-descriptors-1.9.20.jar + wget -O ./target/dokka-cli/kotlinx-html-jvm.jar https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-html-jvm/0.8.0/kotlinx-html-jvm-0.8.0.jar + wget -O ./target/dokka-cli/freemarker.jar https://repo1.maven.org/maven2/org/freemarker/freemarker/2.3.31/freemarker-2.3.31.jar +fi + +java -jar ./target/dokka-cli/dokka-cli.jar ./scripts/dokka-configuration.json diff --git a/settings.gradle.kts b/settings.gradle.kts deleted file mode 100644 index 656ea3a5..00000000 --- a/settings.gradle.kts +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = "tbdex" -include("httpclient", "protocol", "httpserver") \ No newline at end of file