Skip to content

Commit

Permalink
chore: Refactor into separate libraries to avoid requiring specific c…
Browse files Browse the repository at this point in the history
…onnector implementations
  • Loading branch information
blackspherefollower committed Aug 8, 2023
1 parent aae2510 commit c6cee4a
Show file tree
Hide file tree
Showing 82 changed files with 457 additions and 120 deletions.
117 changes: 4 additions & 113 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,114 +1,5 @@
plugins {
id 'java-library'
id 'jacoco'
id 'maven-publish'
id 'checkstyle'
id 'signing'
}

group = 'io.github.blackspherefollower'
version = "3.0." + ("${System.env.GITHUB_RUN_NUMBER ?: 1}") + ("${System.env.GITHUB_REF_TYPE}" == "tag" ? "" : "-SNAPSHOT")

repositories {
mavenCentral()
}

dependencies {
api 'jakarta.websocket:jakarta.websocket-api:2.1.1'
api 'org.eclipse.jetty.websocket:websocket-javax-client:10.0.15'
api 'com.fasterxml.jackson.core:jackson-annotations:2.15.2'
api 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
testImplementation 'org.eclipse.jetty.websocket:websocket-javax-server:10.0.15'
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
withJavadocJar()
withSourcesJar()
}
checkstyle {
configFile = file("${rootDir}/checkstyle.xml")
showViolations = false
ignoreFailures = true
}
test {
finalizedBy jacocoTestReport
finalizedBy check
}
jacocoTestReport {
dependsOn test
}
tasks.named('test') {
useJUnitPlatform()
}

jacocoTestReport {
reports {
xml.required = true
csv.required = true
}
}

publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/${System.env.GITHUB_REPOSITORY}")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
}
}
maven {
name = "ossrh"
url = version.contains("-SNAPSHOT") ?
uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") :
uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")

credentials {
username = project.findProperty("maven.user") ?:System.getenv("MAVEN_USER")
password = project.findProperty("maven.pass") ?:System.getenv("MAVEN_PASS")
}
}
}
publications {
mavenJava(MavenPublication) {
from(components.java)
pom {
name = 'Buttplug for Java'
description = 'A pure Java Buttplug Client implementation'
url = 'https://github.com/blackspherefollower/buttplug4j'
inceptionYear = '2017'

licenses {
license {
name = 'BSDv3 License'
url = 'https://github.com/blackspherefollower/buttplug4j/'
}
}
developers {
developer {
id = 'blackspherefollower'
name = 'BlackSphereFollower'
email = 'blackspherefollower@iostindex.com'
}
}
scm {
connection='scm:git:git:github.com/blackspherefollower/buttplug4j.git'
developerConnection='scm:git:https://github.com/blackspherefollower/buttplug4j.git'
url='https://github.com/blackspherefollower/buttplug4j'
}
}
}
}
}

signing {
def gpgKey = project.findProperty("gpg.key") ?: System.getenv("OSSRH_GPG") ?: ""
def gpgPass = project.findProperty("gpg.pass") ?: System.getenv("OSSRH_GPG_PASS") ?: ""
useInMemoryPgpKeys(gpgKey.replaceAll("\\\\n", "\n"), gpgPass)
sign publishing.publications.mavenJava
}
subprojects {
group = 'io.github.blackspherefollower'
version = "3.1." + ("${System.env.GITHUB_RUN_NUMBER ?: 1}") + ("${System.env.GITHUB_REF_TYPE}" == "tag" ? "" : "-SNAPSHOT")
}
108 changes: 108 additions & 0 deletions client/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
plugins {
id 'java-library'
id 'jacoco'
id 'maven-publish'
id 'checkstyle'
id 'signing'
}

repositories {
mavenCentral()
}

dependencies {
api 'com.fasterxml.jackson.core:jackson-annotations:2.15.1'
api 'com.fasterxml.jackson.core:jackson-databind:2.15.1'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
withJavadocJar()
withSourcesJar()
}
checkstyle {
configFile = file("${rootDir}/checkstyle.xml")
showViolations = false
ignoreFailures = true
}
test {
finalizedBy jacocoTestReport
finalizedBy check
}
jacocoTestReport {
dependsOn test
}
tasks.named('test') {
useJUnitPlatform()
}

jacocoTestReport {
reports {
xml.required = true
csv.required = true
}
}

publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/${System.env.GITHUB_REPOSITORY}")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
}
}
maven {
name = "ossrh"
url = version.contains("-SNAPSHOT") ?
uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") :
uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")

credentials {
username = project.findProperty("maven.user") ?:System.getenv("MAVEN_USER")
password = project.findProperty("maven.pass") ?:System.getenv("MAVEN_PASS")
}
}
}
publications {
mavenJava(MavenPublication) {
from(components.java)
pom {
name = 'Buttplug for Java'
description = 'A pure Java Buttplug Client implementation'
url = 'https://github.com/blackspherefollower/buttplug4j'
inceptionYear = '2017'

licenses {
license {
name = 'BSDv3 License'
url = 'https://github.com/blackspherefollower/buttplug4j/'
}
}
developers {
developer {
id = 'blackspherefollower'
name = 'BlackSphereFollower'
email = 'blackspherefollower@iostindex.com'
}
}
scm {
connection='scm:git:git:github.com/blackspherefollower/buttplug4j.git'
developerConnection='scm:git:https://github.com/blackspherefollower/buttplug4j.git'
url='https://github.com/blackspherefollower/buttplug4j'
}
}
}
}
}

signing {
def gpgKey = project.findProperty("gpg.key") ?: System.getenv("OSSRH_GPG") ?: ""
def gpgPass = project.findProperty("gpg.pass") ?: System.getenv("OSSRH_GPG_PASS") ?: ""
useInMemoryPgpKeys(gpgKey.replaceAll("\\\\n", "\n"), gpgPass)
sign publishing.publications.mavenJava
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public ButtplugClientDevice(final ButtplugClient bpClient, final DeviceAdded dev
}
}

public ButtplugClientDevice(final ButtplugClientWSEndpoint bpClient, final DeviceRemoved deviceRemoved) {
public ButtplugClientDevice(final ButtplugClient bpClient, final DeviceRemoved deviceRemoved) {
this.client = bpClient;
this.deviceIndex = deviceRemoved.getDeviceIndex();
this.name = "";
Expand Down
108 changes: 108 additions & 0 deletions connectors/javax/wsclient/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
plugins {
id 'java-library'
id 'jacoco'
id 'maven-publish'
id 'checkstyle'
id 'signing'
}

repositories {
mavenCentral()
}

dependencies {
api project(':connectors:javax:wscommon')
api 'org.eclipse.jetty.websocket:websocket-javax-client:10.0.15'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
withJavadocJar()
withSourcesJar()
}
checkstyle {
configFile = file("${rootDir}/checkstyle.xml")
showViolations = false
ignoreFailures = true
}
test {
finalizedBy jacocoTestReport
finalizedBy check
}
jacocoTestReport {
dependsOn test
}
tasks.named('test') {
useJUnitPlatform()
}

jacocoTestReport {
reports {
xml.required = true
csv.required = true
}
}

publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/${System.env.GITHUB_REPOSITORY}")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
}
}
maven {
name = "ossrh"
url = version.contains("-SNAPSHOT") ?
uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") :
uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")

credentials {
username = project.findProperty("maven.user") ?:System.getenv("MAVEN_USER")
password = project.findProperty("maven.pass") ?:System.getenv("MAVEN_PASS")
}
}
}
publications {
mavenJava(MavenPublication) {
from(components.java)
pom {
name = 'Buttplug for Java'
description = 'A pure Java Buttplug Client implementation'
url = 'https://github.com/blackspherefollower/buttplug4j'
inceptionYear = '2017'

licenses {
license {
name = 'BSDv3 License'
url = 'https://github.com/blackspherefollower/buttplug4j/'
}
}
developers {
developer {
id = 'blackspherefollower'
name = 'BlackSphereFollower'
email = 'blackspherefollower@iostindex.com'
}
}
scm {
connection='scm:git:git:github.com/blackspherefollower/buttplug4j.git'
developerConnection='scm:git:https://github.com/blackspherefollower/buttplug4j.git'
url='https://github.com/blackspherefollower/buttplug4j'
}
}
}
}
}

signing {
def gpgKey = project.findProperty("gpg.key") ?: System.getenv("OSSRH_GPG") ?: ""
def gpgPass = project.findProperty("gpg.pass") ?: System.getenv("OSSRH_GPG_PASS") ?: ""
useInMemoryPgpKeys(gpgKey.replaceAll("\\\\n", "\n"), gpgPass)
sign publishing.publications.mavenJava
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.blackspherefollower.buttplug4j.client;
package io.github.blackspherefollower.buttplug4j.connectors.javax.client;

import io.github.blackspherefollower.buttplug4j.client.ButtplugClient;
import io.github.blackspherefollower.buttplug4j.connectors.javax.common.ButtplugClientWSEndpoint;
import org.eclipse.jetty.util.component.LifeCycle;

import javax.websocket.ClientEndpoint;
Expand All @@ -26,7 +28,7 @@ public void connect(final URI url) throws IllegalStateException, DeploymentExcep
if (client != null && getSession() != null && getSession().isOpen()) {
throw new IllegalStateException("WS is already open");
}
setConnectionState(ConnectionState.CONNECTING);
setConnectionState(ButtplugClient.ConnectionState.CONNECTING);

CompletableFuture<Boolean> promise = new CompletableFuture<>();
setOnConnected(client -> promise.complete(true));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.blackspherefollower.buttplug4j.client;
package io.github.blackspherefollower.buttplug4j.connectors.javax.client;

import io.github.blackspherefollower.buttplug4j.client.ButtplugClientDevice;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

Expand Down
Loading

0 comments on commit c6cee4a

Please sign in to comment.