Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/pcg-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Partitioned Consumer Groups Main Snapshot

on:
push:
branches:
- main
paths:
- 'pcgroups/**'

jobs:
build:
uses: ./.github/workflows/workflow-main.yml
with:
project-dir: pcgroups
secrets: inherit
14 changes: 14 additions & 0 deletions .github/workflows/pcg-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Partitioned Consumer Groups Pull Request

on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'pcgroups/**'

jobs:
build:
uses: ./.github/workflows/workflow-pr.yml
with:
project-dir: pcgroups
secrets: inherit
12 changes: 12 additions & 0 deletions .github/workflows/pcg-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Partitioned Consumer Groups Release

on:
push:
tags: [ 'pcg/*' ]

jobs:
build:
uses: ./.github/workflows/workflow-release.yml
with:
project-dir: pcgroups
secrets: inherit
51 changes: 51 additions & 0 deletions .github/workflows/workflow-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Reusable Workflow Main Snapshot Build

on:
workflow_call:
inputs:
project-dir:
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./${{ inputs.project-dir }}
env:
BUILD_EVENT: ${{ github.event_name }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
steps:
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
- name: Check out code
uses: actions/checkout@v4
- name: Install Nats Server
run: |
pkill -9 nats-server 2>/dev/null || true
mkdir -p ~/.local/bin
cd $GITHUB_WORKSPACE
git clone https://github.com/nats-io/nats-server.git
cd nats-server
go build -o ~/.local/bin/nats-server
nats-server -v
- name: Compile and Test
run: |
chmod +x gradlew && ./gradlew clean test
- name: Verify Javadoc
run: |
./gradlew javadoc
- name: Publish Snapshot
run: |
./gradlew -i publishToSonatype
- name: Clean up
if: always()
run: pkill -9 nats-server 2>/dev/null || true
48 changes: 48 additions & 0 deletions .github/workflows/workflow-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Reusable Workflow PR Build

on:
workflow_call:
inputs:
project-dir:
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./${{ inputs.project-dir }}
env:
BUILD_EVENT: ${{ github.event_name }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
steps:
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
- name: Check out code
uses: actions/checkout@v4
- name: Install Nats Server
run: |
pkill -9 nats-server 2>/dev/null || true
mkdir -p ~/.local/bin
cd $GITHUB_WORKSPACE
git clone https://github.com/nats-io/nats-server.git
cd nats-server
go build -o ~/.local/bin/nats-server
nats-server -v
- name: Build and Test
run: |
chmod +x gradlew && ./gradlew clean test
- name: Verify Javadoc
run: |
./gradlew javadoc
- name: Clean up
if: always()
run: pkill -9 nats-server 2>/dev/null || true
48 changes: 48 additions & 0 deletions .github/workflows/workflow-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Reusable Workflow Release Build

on:
workflow_call:
inputs:
project-dir:
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./${{ inputs.project-dir }}
env:
BUILD_EVENT: "release"
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
steps:
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
- name: Check out code
uses: actions/checkout@v4
- name: Install Nats Server
run: |
pkill -9 nats-server 2>/dev/null || true
mkdir -p ~/.local/bin
cd $GITHUB_WORKSPACE
git clone https://github.com/nats-io/nats-server.git
cd nats-server
go build -o ~/.local/bin/nats-server
nats-server -v
- name: Compile and Test
run: |
chmod +x gradlew && ./gradlew clean test
- name: Verify, Sign and Publish Release
run: |
./gradlew -i publishToSonatype closeAndReleaseSonatypeStagingRepository
- name: Clean up
if: always()
run: pkill -9 nats-server 2>/dev/null || true
188 changes: 188 additions & 0 deletions pcgroups/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
import aQute.bnd.gradle.Bundle

plugins {
id("java")
id("java-library")
id("maven-publish")
id("jacoco")
id("biz.aQute.bnd.builder") version "7.1.0"
id("org.gradle.test-retry") version "1.6.4"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("signing")
}

def jarVersion = "0.1.0"
group = 'io.synadia'

def isRelease = System.getenv("BUILD_EVENT") == "release"

def tc = System.getenv("TARGET_COMPATIBILITY");
def targetCompat = tc == "21" ? JavaVersion.VERSION_21 : (tc == "17" ? JavaVersion.VERSION_17 : JavaVersion.VERSION_1_8)
def jarEnd = tc == "21" ? "-jdk21" : (tc == "17" ? "-jdk17" : "")
def jarAndArtifactName = "partitioned-consumer-groups" + jarEnd

version = isRelease ? jarVersion : jarVersion + "-SNAPSHOT" // version is the variable the build actually uses.

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = targetCompat
}

repositories {
mavenCentral()
maven { url="https://repo1.maven.org/maven2/" }
maven { url="https://central.sonatype.com/repository/maven-snapshots" }
}

dependencies {
implementation 'io.nats:jnats:2.25.1'
implementation 'com.google.code.gson:gson:2.11.0'
implementation 'org.jspecify:jspecify:1.0.0'

testImplementation 'io.nats:jnats-server-runner:3.1.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.14.1'
testImplementation 'org.junit.platform:junit-platform-launcher:1.14.3'
}

sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
}
test {
java {
srcDirs = ['src/test/java']
}
}
}

tasks.register('bundle', Bundle) {
from sourceSets.main.output
}

jar {
bundle {
bnd("Bundle-Name": "io.synadia.partitioned.consumer.groups",
"Bundle-Vendor": "synadia.io",
"Bundle-Description": "NATS JetStream Partitioned Consumer Groups Library for Java",
"Bundle-DocURL": "https://synadia.io"
)
}
}

test {
// Use junit platform for unit tests
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
events "started", "passed", "skipped", "failed"
showStandardStreams = true
}
retry {
failOnPassedAfterRetry = false
maxFailures = 3
maxRetries = 3
}
systemProperty 'junit.jupiter.execution.timeout.default', '3m'
}

javadoc {
source = sourceSets.main.allJava
title = "Synadia Communications Inc. NATS JetStream Partitioned Consumer Groups"
classpath = sourceSets.main.runtimeClasspath
}

tasks.register('javadocJar', Jar) {
archiveClassifier.set('javadoc')
from javadoc
}

tasks.register('sourcesJar', Jar) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}

tasks.register('testsJar', Jar) {
archiveClassifier.set('tests')
from sourceSets.test.allSource
}

artifacts {
archives javadocJar, sourcesJar, testsJar
}

jacoco {
toolVersion = "0.8.12"
}

jacocoTestReport {
reports {
xml.required = true // coveralls plugin depends on xml format report
html.required = true
}
afterEvaluate { // only report on main library not examples
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
exclude: ['**/examples**','**/Debug**'])
}))
}
}

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
username = System.getenv('OSSRH_USERNAME')
password = System.getenv('OSSRH_PASSWORD')
}
}
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
artifact testsJar
pom {
name = jarAndArtifactName
packaging = "jar"
groupId = group
artifactId = jarAndArtifactName
description = "Synadia Communications Inc. NATS JetStream Partitioned Consumer Groups"
url = "https://github.com/synadia-io/orbit.java/tree/main/pcgroups"
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = "synadia"
name = "Synadia"
email = "info@synadia.com"
url = "https://synadia.io"
}
}
scm {
url = "https://github.com/synadia-io/orbit.java"
}
}
}
}
}

if (isRelease) {
signing {
def signingKeyId = System.getenv('SIGNING_KEY_ID')
def signingKey = System.getenv('SIGNING_KEY')
def signingPassword = System.getenv('SIGNING_PASSWORD')
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign configurations.archives
sign publishing.publications.mavenJava
}
}
12 changes: 12 additions & 0 deletions pcgroups/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format

[versions]
commons-math3 = "3.6.1"
guava = "33.4.5-jre"
junit-jupiter = "5.12.1"

[libraries]
commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "commons-math3" }
guava = { module = "com.google.guava:guava", version.ref = "guava" }
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
Binary file added pcgroups/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading