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
362 changes: 362 additions & 0 deletions .github/workflows/release.yml

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@ all: they are legacy Eclipse ADT Android projects.

Test results land in `**/build/test-results/test/*.xml`.

## Releasing
Releases are cut by the **Release Java API** workflow (`release.yml`), not from a developer machine,
and need no uprev PR:
1. Run the workflow on `master`. Leave `version` blank for the next patch after the last `API_v`
release, or type one. It tests and builds as CI does, publishes all three artifacts to GitHub
Packages in one `gradlew publish`, tags `API_v<version>`, and creates the GitHub Release with the
jars attached (not marked Latest — that stays with Consensys).
2. It also builds `ShimmerJavaClass.jar` for MATLAB and opens a PR replacing
`Shimmer-MATLAB-ID/libs/ShimmerJavaClass.jar` (needs the `MATLAB_REPO_TOKEN` secret). Review and
merge it.
3. Run `ShimmerAndroidAPI`'s own Release workflow, which builds against the newest Java release unless
told otherwise.

The version is not stored in the source: the three publishing blocks read `-PreleaseVersion`, which
the workflow passes, and fall back to `local`. The `API_v` tags are the record of what was released.

`ShimmerJavaClass.jar` must be Java 8 bytecode, because MATLAB may load it on Java 8. Build it locally
with `cd ShimmerDriverPC && ./gradlew shadowJar -PmatlabJava8`, which compiles all three projects with
`--release 8` — that also rejects any API newer than Java 8, so `Process.onExit()`, `var` and the like
fail the build here instead of throwing `NoSuchMethodError` inside MATLAB.

## Subprojects
| Project | Role |
|---|---|
Expand Down
15 changes: 13 additions & 2 deletions ShimmerBluetoothManager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ publishing {

groupId = 'com.shimmerresearch' // Replace with your package's group/organization name
artifactId = 'shimmerbluetoothmanager' // Replace with the name of your package
version = '0.11.8_beta' // Replace with your package version
version = project.findProperty('releaseVersion') ?: 'local' // set by the Release Java API workflow (-PreleaseVersion)
Comment thread
JongChern marked this conversation as resolved.
Resolved

// Jar publication
//(
Expand All @@ -40,7 +40,7 @@ publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ShimmerEngineering/Shimmer-Java-Android-API")
url = uri("https://maven.pkg.github.com/ShimmerResearch/Shimmer-Java-Android-API")
credentials {
/* Create gradle.properties file in GRADLE_USER_HOME/.gradle/
(e.g. C:/Users/YourUsername/.gradle/) with the two lines listed below. Fill in your
Expand Down Expand Up @@ -68,3 +68,14 @@ dependencies {
// 'test.useTestNG()' to your build script.
testImplementation 'junit:junit:4.12'
}

// Without -PreleaseVersion the version is 'local', and GitHub Packages never lets a version be
// overwritten. Releases go through the Release Java API workflow; publishToMavenLocal is unaffected.
tasks.withType(PublishToMavenRepository).configureEach {
doFirst {
if (publication.version == 'local') {
throw new GradleException("Refusing to publish ${publication.artifactId} as version 'local'. " +
"Release with the Release Java API workflow, or pass -PreleaseVersion.")
}
}
}
15 changes: 13 additions & 2 deletions ShimmerDriver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ publishing {

groupId = 'com.shimmerresearch' // Replace with your package's group/organization name
artifactId = 'shimmerdriver' // Replace with the name of your package
version = '0.11.8_beta' // Replace with your package version
version = project.findProperty('releaseVersion') ?: 'local' // set by the Release Java API workflow (-PreleaseVersion)
Comment thread
JongChern marked this conversation as resolved.
Resolved

// Jar publication
//(
Expand All @@ -63,7 +63,7 @@ publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ShimmerEngineering/Shimmer-Java-Android-API")
url = uri("https://maven.pkg.github.com/ShimmerResearch/Shimmer-Java-Android-API")
credentials {
/* Create gradle.properties file in GRADLE_USER_HOME/.gradle/
(e.g. C:/Users/YourUsername/.gradle/) with the two lines listed below. Fill in your
Expand Down Expand Up @@ -173,3 +173,14 @@ tasks.withType(Test).configureEach {
}
}


// Without -PreleaseVersion the version is 'local', and GitHub Packages never lets a version be
// overwritten. Releases go through the Release Java API workflow; publishToMavenLocal is unaffected.
tasks.withType(PublishToMavenRepository).configureEach {
doFirst {
if (publication.version == 'local') {
throw new GradleException("Refusing to publish ${publication.artifactId} as version 'local'. " +
"Release with the Release Java API workflow, or pass -PreleaseVersion.")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,20 @@ public int startServer() throws Exception {
e.printStackTrace();
}
});
runningProcess.onExit().thenAccept(p -> {
int code = p.exitValue();
System.err.println("[BLEGrpcServer] exited: code=" + code +
(code >= 128 ? " (likely signal " + (code - 128) + ")" : ""));
});
// Not Process.onExit(): that is Java 9+, and MATLAB loads this class on Java 8 via
// ShimmerJavaClass.jar, where it throws NoSuchMethodError. Daemon, like onExit()'s pool thread.
final Process process = runningProcess;
Thread exitWatcher = new Thread(() -> {
try {
int code = process.waitFor();
System.err.println("[BLEGrpcServer] exited: code=" + code +
(code >= 128 ? " (likely signal " + (code - 128) + ")" : ""));
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}, "BLEGrpcServer-exit");
exitWatcher.setDaemon(true);
exitWatcher.start();

processThread.start();
return port;
Expand Down
38 changes: 30 additions & 8 deletions ShimmerDriverPC/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ publishing {
publications {
mavenJava(MavenPublication) {
from components.java
// The Shadow plugin adds ShimmerJavaClass.jar (no classifier) to components.java, where it
// collides with the plain jar and fails publish on Gradle 8. Publish the plain jar with its
// dependencies in the POM, as releases up to 0.11.7_beta did; the fat jar goes to MATLAB
// and the GitHub Release instead.
components.java.withVariantsFromConfiguration(configurations.shadowRuntimeElements) { skip() }

groupId = 'com.shimmerresearch' // Replace with your package's group/organization name
artifactId = 'shimmerdriverpc' // Replace with the name of your package
version = '0.11.8_beta' // Replace with your package version
version = project.findProperty('releaseVersion') ?: 'local' // set by the Release Java API workflow (-PreleaseVersion)
Comment thread
JongChern marked this conversation as resolved.
Resolved

// Jar publication
//(
Expand All @@ -57,7 +62,7 @@ publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ShimmerEngineering/Shimmer-Java-Android-API")
url = uri("https://maven.pkg.github.com/ShimmerResearch/Shimmer-Java-Android-API")
credentials {
/* Create gradle.properties file in GRADLE_USER_HOME/.gradle/
(e.g. C:/Users/YourUsername/.gradle/) with the two lines listed below. Fill in your
Expand Down Expand Up @@ -110,12 +115,18 @@ dependencies {
implementation("org.bouncycastle:bcprov-jdk15on:1.61")
}

// Shadow JAR task to create a runnable JAR with dependencies
/*
Change to using the following below for ShimmerDriverPC/ShimmerDriver/ShimmerBluetoothManager
sourceCompatibility = '1.8' // Ensure code is compiled with Java 8
targetCompatibility = '1.8' // Ensure bytecode is compatible with Java 8
*/
// Shadow JAR task to create a runnable JAR with dependencies.
// ShimmerJavaClass.jar is loaded by MATLAB, which may run it on Java 8, so build it as Java 8
// bytecode with: ./gradlew shadowJar -PmatlabJava8
// This applies to the ShimmerDriver and ShimmerBluetoothManager subprojects too, so their build files
// no longer need editing to 1.8 by hand. --release 8 also fails the compile if the code uses an API
// newer than Java 8, which sourceCompatibility = '1.8' alone would let through to fail in MATLAB.
// The "Release Java API" workflow builds the jar this way and opens a PR into Shimmer-MATLAB-ID/libs.
if (hasProperty('matlabJava8')) {
allprojects {
tasks.withType(JavaCompile).configureEach { options.release = 8 }
}
}
shadowJar {
archiveBaseName.set('ShimmerJavaClass') // Use archiveBaseName instead of baseName
archiveClassifier.set('') // Remove classifier so it’s named shimmerjavaclass.jar
Expand All @@ -126,3 +137,14 @@ shadowJar {

mergeServiceFiles() // Merges service files (if any)
}

// Without -PreleaseVersion the version is 'local', and GitHub Packages never lets a version be
// overwritten. Releases go through the Release Java API workflow; publishToMavenLocal is unaffected.
tasks.withType(PublishToMavenRepository).configureEach {
doFirst {
if (publication.version == 'local') {
throw new GradleException("Refusing to publish ${publication.artifactId} as version 'local'. " +
"Release with the Release Java API workflow, or pass -PreleaseVersion.")
}
}
}
2 changes: 1 addition & 1 deletion ShimmerLSL/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ShimmerEngineering/Shimmer-Java-Android-API")
url = uri("https://maven.pkg.github.com/ShimmerResearch/Shimmer-Java-Android-API")
credentials {
/* Create gradle.properties file in GRADLE_USER_HOME/.gradle/
(e.g. C:/Users/YourUsername/.gradle/) with the two lines listed below. Fill in your
Expand Down
2 changes: 1 addition & 1 deletion ShimmerPCBasicExamples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repositories {
}
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ShimmerEngineering/Shimmer-Java-Android-API")
url = uri("https://maven.pkg.github.com/ShimmerResearch/Shimmer-Java-Android-API")
credentials {
/* Create gradle.properties file in GRADLE_USER_HOME/.gradle/
(e.g. C:/Users/YourUsername/.gradle/) with the two lines listed below. Fill in your
Expand Down
Loading