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
26 changes: 26 additions & 0 deletions .github/workflows/create-release-notes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,32 @@ jobs:
asset_name: scalardl-java-client-sdk-${{ steps.version.outputs.version }}.zip
asset_content_type: application/zip

- name: Build HashStore client SDK zip
run: ./gradlew :hash-store:distZip

- name: Upload HashStore client SDK zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_PROJECT_ACCESS_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: hash-store/build/distributions/scalardl-hashstore-java-client-sdk-${{ steps.version.outputs.version }}.zip
asset_name: scalardl-hashstore-java-client-sdk-${{ steps.version.outputs.version }}.zip
asset_content_type: application/zip

- name: Build TableStore client SDK zip
run: ./gradlew :table-store:distZip

- name: Upload TableStore client SDK zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_PROJECT_ACCESS_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: table-store/build/distributions/scalardl-tablestore-java-client-sdk-${{ steps.version.outputs.version }}.zip
asset_name: scalardl-tablestore-java-client-sdk-${{ steps.version.outputs.version }}.zip
asset_content_type: application/zip

- name: Build zip for generic contracts and functions
run: ./gradlew :generic-contracts:distZip

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
if: contains(steps.version.outputs.version, '-SNAPSHOT')
run: ./gradlew publish

- name: Upload the SNAPSHOT versions of scalardl-ledger, scalardl-java-client-sdk, scalardl-common, and scalardl-rpc to Maven Central Repository
- name: Upload the SNAPSHOT versions of scalardl-* libraries to Maven Central Repository
if: contains(steps.version.outputs.version, '-SNAPSHOT')
env:
JRELEASER_NEXUS2_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Prepare artifacts in staging-deploy directories
run: ./gradlew publish

- name: Upload scalardl-ledger, scalardl-java-client-sdk, scalardl-common, and scalardl-rpc to Maven Central Repository
- name: Upload scalardl-* libraries to Maven Central Repository
env:
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/scalar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ jobs:
name: integration_test_reports_for_generic_contracts
path: generic-contracts/build/reports/tests/integrationTest

integration-test-for-hash-store:
name: Integration test for hash store
integration-test-for-hashstore:
name: Integration test for HashStore
runs-on: ubuntu-latest

services:
Expand Down Expand Up @@ -190,8 +190,8 @@ jobs:
name: integration_test_reports_for_hash_store
path: hash-store/build/reports/tests/integrationTest

integration-test-for-table-store:
name: Integration test for table store
integration-test-for-tablestore:
name: Integration test for TableStore
runs-on: ubuntu-latest

services:
Expand Down
47 changes: 47 additions & 0 deletions hash-store/archive.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apply plugin: 'maven-publish'

publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'scalardl-hashstore-java-client-sdk'
from components.java
artifact distTar
artifact distZip
artifact javadocJar
artifact sourcesJar
pom {
name = 'ScalarDL HashStore Java Client SDK'
description = 'A client-side Java library to interact with ScalarDL HashStore.'
url = 'https://github.com/scalar-labs/scalardl'
licenses {
license {
name = 'Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0'
}
}
developers {
developer {
id = 'hiroyuki'
name = 'Hiroyuki Yamada'
email = 'hiroyuki.yamada@scalar-labs.com'
}
developer {
id = 'jnmt'
name = 'Jun Nemoto'
email = 'jun.nemoto@scalar-labs.com'
}
}
scm {
connection = 'scm:git:https://github.com/scalar-labs/scalardl.git'
developerConnection = 'scm:git:https://github.com/scalar-labs/scalardl.git'
url = 'https://github.com/scalar-labs/scalardl'
}
}
}
}
repositories {
maven {
url = layout.buildDirectory.dir('staging-deploy')
}
}
}
25 changes: 24 additions & 1 deletion hash-store/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencies {

task HashStore(type: CreateStartScripts) {
mainClass = 'com.scalar.dl.hashstore.client.tool.HashStoreCommandLine'
applicationName = 'scalardl-hash-store'
applicationName = 'scalardl-hashstore'
outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtimeClasspath
}
Expand Down Expand Up @@ -102,3 +102,26 @@ task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}

javadoc {
title = "ScalarDL HashStore Java Client SDK ${version}"
source += sourceSets.main.java
source += project(':client').sourceSets.main.java
source += project(':common').sourceSets.main.java
include "com/scalar/dl/hashstore/**"
include "com/scalar/dl/client/exception/*.java"
include "com/scalar/dl/ledger/model/*.java"
}

distZip {
archiveFileName = "scalardl-hashstore-java-client-sdk-${project.version}.zip"
}

archivesBaseName = "scalardl-hashstore-java-client-sdk"

// for archiving and uploading to maven central
if (!project.gradle.startParameter.taskNames.isEmpty() &&
(project.gradle.startParameter.taskNames[0].endsWith('publish') ||
project.gradle.startParameter.taskNames[0].endsWith('publishToMavenLocal'))) {
apply from: 'archive.gradle'
Comment on lines +123 to +126

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The condition project.gradle.startParameter.taskNames[0].endsWith(...) is fragile. It only checks the first task specified on the command line. If other tasks are run before the publish task (e.g., gradle clean publish), this condition will be false, and the publishing configuration will not be applied.

To make this more robust, you should check if any of the requested tasks is a publish task. This will correctly detect the intention to publish regardless of other tasks on the command line.

if (project.gradle.startParameter.taskNames.any { it.endsWith('publish') || it.endsWith('publishToMavenLocal') }) {
    apply from: 'archive.gradle'
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import picocli.CommandLine.HelpCommand;

@Command(
name = "scalardl-hash-store",
name = "scalardl-hashstore",
subcommands = {
HelpCommand.class,
Bootstrap.class,
Expand All @@ -28,7 +28,7 @@
CollectionHistoryGet.class,
LedgerValidation.class,
},
description = {"These are ScalarDL Hash Store commands used in various situations:"})
description = {"These are ScalarDL HashStore commands used in various situations:"})
public class HashStoreCommandLine {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void displaysGroupedSubcommands() {
String expected =
String.join(
System.lineSeparator(),
"Usage: scalardl-hash-store [COMMAND]",
"These are ScalarDL Hash Store commands used in various situations:",
"Usage: scalardl-hashstore [COMMAND]",
"These are ScalarDL HashStore commands used in various situations:",
"",
"bootstrap the hash store",
" bootstrap Bootstrap the hash store by registering identity and",
Expand Down Expand Up @@ -76,7 +76,7 @@ void setup() {
@Test
@DisplayName("member values are properly set")
void memberValuesAreProperlySet() {
assertThat(command.name()).isEqualTo("scalardl-hash-store");
assertThat(command.name()).isEqualTo("scalardl-hashstore");
assertThat(command.subcommands())
.isEqualTo(
new Class[] {
Expand Down Expand Up @@ -114,7 +114,7 @@ public void parseCommandSucceeds() {
// Verify that the argument contains only the top-level command.
assertThat(parsed.size()).isEqualTo(1);

// Verify that the top-level command is "scalardl-hash-store".
// Verify that the top-level command is "scalardl-hashstore".
assertThat(parsed.get(0).getCommand().getClass()).isEqualTo(HashStoreCommandLine.class);
}
}
Expand Down
47 changes: 47 additions & 0 deletions table-store/archive.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apply plugin: 'maven-publish'

publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'scalardl-tablestore-java-client-sdk'
from components.java
artifact distTar
artifact distZip
artifact javadocJar
artifact sourcesJar
pom {
name = 'ScalarDL TableStore Java Client SDK'
description = 'A client-side Java library to interact with ScalarDL TableStore.'
url = 'https://github.com/scalar-labs/scalardl'
licenses {
license {
name = 'Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0'
}
}
developers {
developer {
id = 'hiroyuki'
name = 'Hiroyuki Yamada'
email = 'hiroyuki.yamada@scalar-labs.com'
}
developer {
id = 'jnmt'
name = 'Jun Nemoto'
email = 'jun.nemoto@scalar-labs.com'
}
}
scm {
connection = 'scm:git:https://github.com/scalar-labs/scalardl.git'
developerConnection = 'scm:git:https://github.com/scalar-labs/scalardl.git'
url = 'https://github.com/scalar-labs/scalardl'
}
}
}
}
repositories {
maven {
url = layout.buildDirectory.dir('staging-deploy')
}
}
}
25 changes: 24 additions & 1 deletion table-store/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies {

task TableStore(type: CreateStartScripts) {
mainClass = 'com.scalar.dl.tablestore.client.tool.TableStoreCommandLine'
applicationName = 'scalardl-table-store'
applicationName = 'scalardl-tablestore'
outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtimeClasspath
}
Expand Down Expand Up @@ -101,3 +101,26 @@ task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}

javadoc {
title = "ScalarDL TableStore Java Client SDK ${version}"
source += sourceSets.main.java
source += project(':client').sourceSets.main.java
source += project(':common').sourceSets.main.java
include "com/scalar/dl/tablestore/**"
include "com/scalar/dl/client/exception/*.java"
include "com/scalar/dl/ledger/model/*.java"
}

distZip {
archiveFileName = "scalardl-tablestore-java-client-sdk-${project.version}.zip"
}

archivesBaseName = "scalardl-tablestore-java-client-sdk"

// for archiving and uploading to maven central
if (!project.gradle.startParameter.taskNames.isEmpty() &&
(project.gradle.startParameter.taskNames[0].endsWith('publish') ||
project.gradle.startParameter.taskNames[0].endsWith('publishToMavenLocal'))) {
apply from: 'archive.gradle'
Comment on lines +122 to +125

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The condition project.gradle.startParameter.taskNames[0].endsWith(...) is fragile. It only checks the first task specified on the command line. If other tasks are run before the publish task (e.g., gradle clean publish), this condition will be false, and the publishing configuration will not be applied.

To make this more robust, you should check if any of the requested tasks is a publish task. This will correctly detect the intention to publish regardless of other tasks on the command line.

if (project.gradle.startParameter.taskNames.any { it.endsWith('publish') || it.endsWith('publishToMavenLocal') }) {
    apply from: 'archive.gradle'
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.Immutable;
import javax.json.JsonObject;
import javax.json.JsonValue;

/**
Expand All @@ -60,7 +59,7 @@
*
* TableStoreClientService service = factory.create(new ClientConfig(new File(properties));
* try {
* String statement = ...; // prepare a PartiQL statement
* String statement = ...; // prepare an SQL statement
* StatementExecutionResult result = service.executeStatement(statement);
* result.getResult().ifPresent(System.out::println);
* } catch (ClientException e) {
Expand Down Expand Up @@ -130,18 +129,6 @@ private void registerContracts() {
}
}

/**
* Retrieves a list of contracts for the certificate holder specified in {@code ClientConfig}. If
* specified with a contract ID, it will return the matching contract only.
*
* @param id a contract ID
* @return {@link JsonObject}
* @throws ClientException if a request fails for some reason
*/
public JsonObject listContracts(String id) {
return clientService.listContracts(id);
}

/**
* Executes the specified statement.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
import picocli.CommandLine.HelpCommand;

@Command(
name = "scalardl-table-store",
name = "scalardl-tablestore",
subcommands = {
Bootstrap.class,
HelpCommand.class,
LedgerValidation.class,
StatementExecution.class,
},
description = {"These are ScalarDL Table Store commands:"})
description = {"These are ScalarDL TableStore commands:"})
public class TableStoreCommandLine {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,6 @@ public void bootstrap_OtherExceptionThrown_ShouldThrowException() {
assertThat(((ClientException) thrown).getStatusCode()).isEqualTo(StatusCode.INVALID_REQUEST);
}

@Test
public void listContracts_ShouldCallClientServiceListContracts() {
// Arrange
when(clientService.listContracts(ANY_ID)).thenReturn(ANY_JSON_OBJECT);

// Act
JsonObject result = service.listContracts(ANY_ID);

// Assert
verify(clientService).listContracts(ANY_ID);
assertThat(result).isEqualTo(ANY_JSON_OBJECT);
}

@Test
public void executeStatement_ValidStatement_ShouldReturnStatementExecutionResult() {
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void displaysGroupedSubcommands() {
String expected =
String.join(
System.lineSeparator(),
"Usage: scalardl-table-store [COMMAND]",
"These are ScalarDL Table Store commands:",
"Usage: scalardl-tablestore [COMMAND]",
"These are ScalarDL TableStore commands:",
"",
"bootstrap the table store",
" bootstrap Bootstrap the table store by registering identity and",
Expand Down Expand Up @@ -67,7 +67,7 @@ void setup() {
@Test
@DisplayName("member values are properly set")
void memberValuesAreProperlySet() {
assertThat(command.name()).isEqualTo("scalardl-table-store");
assertThat(command.name()).isEqualTo("scalardl-tablestore");
assertThat(command.subcommands())
.isEqualTo(
new Class[] {
Expand Down Expand Up @@ -98,7 +98,7 @@ public void parseCommandSucceeds() {
// Verify that the argument contains only the top-level command.
assertThat(parsed.size()).isEqualTo(1);

// Verify that the top-level command is "scalardl-table-store".
// Verify that the top-level command is "scalardl-tablestore".
assertThat(parsed.get(0).getCommand().getClass()).isEqualTo(TableStoreCommandLine.class);
}
}
Expand Down