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
11 changes: 8 additions & 3 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
name: Create Release
on:
push:
# run only on tags
tags:
- '**'
pull_request:
# Release a new SNAPSHOT version every time a PR is merged to v6.
types: [closed]
branches: ['v6']

jobs:
release:
name: Deploy
if: startsWith(github.ref, 'refs/tags')
if: >
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags'))
|| (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -39,7 +44,7 @@ jobs:
retention-days: 1
gh-release:
name: Create a GitHub Release
if: startsWith(github.ref, 'refs/tags')
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
needs: [ release ]
steps:
Expand Down
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,27 @@ To start using Weaviate Java Client add the dependency to `pom.xml`:

### Uber JAR🫙

If you're building a uber-JAR with something like `maven-assembly-plugin`, use a shaded version with classifier `all`.
If you're building a uber-JAR with something like `maven-assembly-plugin`, use a shaded version with classifier `all`.
This ensures that all dynamically-loaded dependecies of `io.grpc` are resolved correctly.

### SNAPSHOT releases

The latest development version of `client6` is released after every merged pull request. Set the version to `6.0.0-SNAPSHOT` to include it in your project.
Please be mindful of the fact that this is not a stable release and breaking changes may be introduced.

Snapshot releases overwrite each other, so no two releases are alike. If you find a bug in one of the `SNAPSHOT` versions that you'd like to report, please include the output of `Debug.printBuildInfo()` in the ticket's description.

```java
import io.weaviate.client6.v1.internal.Debug;

public class App {
public static void main(String[] args) {
Debug.printBuildInfo();

// ...the rest of your application code...
}
}
```

### Gson and reflective access to internal JDK classes

Expand All @@ -41,14 +59,11 @@ applicationDefaultJvmArgs += listOf(
)
```

## Documentation
## Useful resources

- [Documentation](https://weaviate.io/developers/weaviate/current/client-libraries/java.html).

## Support

- [Stackoverflow for questions](https://stackoverflow.com/questions/tagged/weaviate).
- [Github for issues](https://github.com/weaviate/java-client/issues).
- [StackOverflow for questions about Weaviate](https://stackoverflow.com/questions/tagged/weaviate).
- [Github for issues in client6](https://github.com/weaviate/java-client/issues).

## Contributing

Expand Down
26 changes: 26 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,28 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.9.10</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<useNativeGit>true</useNativeGit>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/client6-git.properties</generateGitPropertiesFilename>
<commitIdGenerationMode>full</commitIdGenerationMode>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand Down Expand Up @@ -522,6 +544,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/io/weaviate/client6/v1/internal/BuildInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.weaviate.client6.v1.internal;

import java.io.IOException;
import java.util.Properties;

public final class BuildInfo {
/** Prevent public initialization. */
private BuildInfo() {
}

public static final String BRANCH;
public static final String COMMIT_ID;
public static final String COMMIT_ID_ABBREV;

static {
var properties = new Properties();

try {
properties.load(BuildInfo.class.getClassLoader().getResourceAsStream("client6-git.properties"));
} catch (IOException | NullPointerException e) {
System.out.println("failed to load client6-git.properties, no build information will be available");
}

BRANCH = String.valueOf(properties.get("git.branch"));
COMMIT_ID = String.valueOf(properties.get("git.commit.id.full"));
COMMIT_ID_ABBREV = String.valueOf(properties.get("git.commit.id.abbrev"));
}
}
28 changes: 28 additions & 0 deletions src/main/java/io/weaviate/client6/v1/internal/Debug.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.weaviate.client6.v1.internal;

import java.util.function.Consumer;

import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.MessageOrBuilder;
import com.google.protobuf.util.JsonFormat;
Expand All @@ -24,4 +26,30 @@ private static final String proto2json(MessageOrBuilder proto) {

return out;
}

/**
* Write build info to an output. See {@link #printBuildInfo}.
*
* <p>
* Usage:
*
* <pre>{@code
* // Log to stdout
* Debug.writeBuildInfo(System.out::println);
*
* // Write to custom logger
* Debug.writeBuildInfo(mylog::info);
* }</pre>
*
* @param writer Output writer.
*/
public static final void writeBuildInfo(Consumer<String> writer) {
writer.accept("[io.weaviate.client6.v1.internal.BuildInfo] branch=%s commit_id=%s"
.formatted(BuildInfo.BRANCH, BuildInfo.COMMIT_ID_ABBREV));
}

/** Print build info to stdout. */
public static final void printBuildInfo() {
writeBuildInfo(System.out::println);
}
}
46 changes: 46 additions & 0 deletions src/test/java/io/weaviate/client6/v1/internal/BuildInfoTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package io.weaviate.client6.v1.internal;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import org.assertj.core.api.Assertions;
import org.junit.Assume;
import org.junit.Test;

public class BuildInfoTest {
private static final String BRANCH = gitBranch();
private static final String COMMIT_ID = gitCommit();

@Test
public void testBuildInfo() throws IOException {
Assume.assumeNotNull(BRANCH, COMMIT_ID);
Assume.assumeTrue("found git branch", !BRANCH.isBlank());
Assume.assumeTrue("found git commit", !COMMIT_ID.isBlank());

Assertions.assertThat(BuildInfo.BRANCH).as("branch").isEqualTo(BRANCH);
Assertions.assertThat(BuildInfo.COMMIT_ID).as("commit.full").isEqualTo(COMMIT_ID);
Assertions.assertThat(COMMIT_ID).as("commit.abbrev").startsWith(BuildInfo.COMMIT_ID_ABBREV);
}

/** Get current non-abbreviated Git commit hash. */
private static String gitCommit() {
return runCommand("/usr/bin/git", "rev-parse", "HEAD");
}

/** Get current git branch. */
private static String gitBranch() {
return runCommand("/usr/bin/git", "branch", "--show-current");
}

/** Run shell command and return the output as multi-line string. */
private static String runCommand(String... cmdarray) {
try {
var process = Runtime.getRuntime().exec(cmdarray);
var r = new BufferedReader(new InputStreamReader(process.getInputStream()));
return String.join("\n", (Iterable<String>) () -> r.lines().iterator());
} catch (IOException e) {
return null;
}
}
}