Skip to content

Commit

Permalink
Release 1.3.0 (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
rainbowdashlabs authored Apr 6, 2023
2 parents a239c45 + 60a6cc5 commit 3d2dd1c
Show file tree
Hide file tree
Showing 38 changed files with 1,090 additions and 208 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/javadocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 18
- name: Set up JDK 15
uses: actions/setup-java@v3
with:
distribution: adopt
java-version: 18
java-version: 15
- name: Build Javadocs
run: |
echo "Building javadocs with gradle"
Expand All @@ -25,7 +25,7 @@ jobs:
echo "Creating .nojekyll to have Github pages deploy html as is:"
touch .nojekyll
- name: Deploy
uses: JamesIves/[email protected].0
uses: JamesIves/[email protected].1
with:
branch: gh-pages # The branch the action should deploy to.
folder: build/docs/javadoc # The folder the action should deploy.
8 changes: 4 additions & 4 deletions .github/workflows/publish_to_nexus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3.0.2
- name: Set up JDK 18
- uses: actions/checkout@v3.5.0
- name: Set up JDK 15
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 18
distribution: adopt
java-version: 15
- name: Build with Gradle
run: ./gradlew --build-cache build
- name: Test with Gradle
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
name: Gradle build

steps:
- uses: actions/checkout@v3.0.2
- name: Set up JDK 18
- uses: actions/checkout@v3.5.0
- name: Set up JDK 15
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 18
distribution: adopt
java-version: 15
- name: Build with Gradle
run: ./gradlew --build-cache build
- name: Test with Gradle
Expand Down
10 changes: 5 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ plugins {
java
`maven-publish`
`java-library`
id("de.chojo.publishdata") version "1.0.8"
id("de.chojo.publishdata") version "1.2.4"
id("org.cadixdev.licenser") version "0.6.1"
}

group = "de.chojo.sadu"
version = "1.2.0"
version = "1.3.0"

dependencies {
api(project(":sadu-sqlite"))
Expand Down Expand Up @@ -45,8 +45,8 @@ allprojects {
}

dependencies {
testImplementation("org.junit.jupiter", "junit-jupiter-api", "5.9.1")
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", "5.9.1")
testImplementation("org.junit.jupiter", "junit-jupiter-api", "5.9.2")
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", "5.9.2")
testImplementation("org.mockito", "mockito-core", "3.+")
}

Expand All @@ -56,7 +56,7 @@ allprojects {
}

publishData {
useEldoNexusRepos(true)
useEldoNexusRepos()
publishComponent("java")
}

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 8 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,10 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
4 changes: 2 additions & 2 deletions sadu-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dependencies {
api("org.slf4j", "slf4j-api", "2.0.3")
api("org.jetbrains", "annotations", "23.0.0")
api("org.slf4j", "slf4j-api", "2.0.7")
api("org.jetbrains", "annotations", "24.0.1")
api("com.google.code.findbugs", "jsr305", "3.0.2")
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static byte[] convert(UUID uuid) {
* @return new uuid instance
*/
public static UUID convert(byte[] bytes) {
if (bytes == null) return null;
var byteBuffer = ByteBuffer.wrap(bytes);
return new UUID(byteBuffer.getLong(), byteBuffer.getLong());
}
Expand Down
12 changes: 11 additions & 1 deletion sadu-core/src/main/java/de/chojo/sadu/databases/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

package de.chojo.sadu.databases;

import de.chojo.sadu.updater.UpdaterBuilder;
import de.chojo.sadu.databases.exceptions.NotImplementedException;
import de.chojo.sadu.databases.exceptions.NotSupportedException;
import de.chojo.sadu.jdbc.JdbcConfig;
import org.jetbrains.annotations.ApiStatus;

import java.util.Arrays;

Expand All @@ -34,8 +36,9 @@
* }</pre>
*
* @param <T> type of the database defined by the {@link Database}
* @param <U> type of the BaseSqlUpdater
*/
public interface Database<T extends JdbcConfig<?>> {
public interface Database<T extends JdbcConfig<?>, U extends UpdaterBuilder<T, ?>> {

/**
* Creates a query to create a version table on the database.
Expand Down Expand Up @@ -171,4 +174,11 @@ default String[] cleanStatements(String[] queries) {
default boolean hasSchemas() {
return false;
}

/**
* Instantiates an implementation of {@link UpdaterBuilder}
* @return the instance
*/
@ApiStatus.Internal
UpdaterBuilder<T, U> newSqlUpdaterBuilder();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

package de.chojo.sadu.databases;

import de.chojo.sadu.updater.UpdaterBuilder;
import de.chojo.sadu.jdbc.JdbcConfig;

/**
* Represents a default database
*
* @param <T> database type defined by the {@link Database}
*/
public abstract class DefaultDatabase<T extends JdbcConfig<?>> implements Database<T> {
public abstract class DefaultDatabase<T extends JdbcConfig<?>, U extends UpdaterBuilder<T, ?>> implements Database<T, U> {

@Override
public String versionQuery(String table) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package de.chojo.sadu.updater;

/**
* Class representing a version maintained by the {@link SqlUpdater}.
* Class representing a version maintained by the SqlUpdaterBuilder
* <p>
* A version id defined by a major and a patch version.
*/
Expand Down Expand Up @@ -43,4 +43,27 @@ public int major() {
public int patch() {
return patch;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

SqlVersion that = (SqlVersion) o;

if (major != that.major) return false;
return patch == that.patch;
}

@Override
public int hashCode() {
int result = major;
result = 31 * result + patch;
return result;
}

@Override
public String toString() {
return "%s.%s".formatted(major, patch);
}
}
18 changes: 18 additions & 0 deletions sadu-core/src/main/java/de/chojo/sadu/updater/UpdaterBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
*
* Copyright (C) 2022 RainbowDashLabs and Contributor
*/

package de.chojo.sadu.updater;

import de.chojo.sadu.jdbc.JdbcConfig;
import org.jetbrains.annotations.ApiStatus;

import javax.sql.DataSource;

@ApiStatus.Internal
public interface UpdaterBuilder<T extends JdbcConfig<?>, S extends UpdaterBuilder<T, ?>> {
void setSource(DataSource source);
void setVersion(SqlVersion version);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
*
* Copyright (C) 2022 RainbowDashLabs and Contributor
*/

package de.chojo.sadu.conversion;

import org.junit.jupiter.api.Test;

import java.util.UUID;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

class UUIDConverterTest {

@Test
void convert() {
// Check if you can still convert with bytes
UUID uuid = UUID.fromString("7ccf6e1c-68fc-442d-88d0-341b315a29cd");
byte[] uuidAsByte = UUIDConverter.convert(uuid);

assertEquals(UUIDConverter.convert(uuidAsByte), uuid);

// Check if the new null check works
assertNull(UUIDConverter.convert((byte[]) null));
}
}
2 changes: 1 addition & 1 deletion sadu-datasource/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ dependencies {
api(project(":sadu-core"))

testImplementation(project(":sadu-sqlite"))
testImplementation("org.xerial:sqlite-jdbc:3.39.3.0")
testImplementation("org.xerial:sqlite-jdbc:3.41.2.1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import de.chojo.sadu.datasource.stage.ConfigurationStage;
import de.chojo.sadu.datasource.stage.JdbcStage;
import de.chojo.sadu.jdbc.JdbcConfig;
import de.chojo.sadu.updater.UpdaterBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -31,7 +32,7 @@ public class DataSourceCreator<T extends JdbcConfig<?>> implements JdbcStage<T>,
private final T builder;
private HikariConfig hikariConfig;

private DataSourceCreator(Database<T> type) {
private DataSourceCreator(Database<T, ?> type) {
builder = type.jdbcBuilder();
}

Expand All @@ -43,7 +44,7 @@ private DataSourceCreator(Database<T> type) {
* @return a DataSourceCreator in {@link JdbcStage}.
*/
@CheckReturnValue
public static <T extends JdbcConfig<?>> JdbcStage<T> create(Database<T> type) {
public static <T extends JdbcConfig<?>> JdbcStage<T> create(Database<T, ?> type) {
return new DataSourceCreator<>(type);
}

Expand All @@ -69,7 +70,7 @@ private void loadDriverClass() {
try {
Class.forName(builder.driverClass());
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not load driver class. Is class in class path? Use #setDriverClass when using relocation.", e);
throw new DriverClassNotFoundException("Could not load driver class. Is class in class path? Use #setDriverClass when using relocation.", e);
}
}

Expand Down Expand Up @@ -171,6 +172,13 @@ public ConfigurationStage withThreadFactory(ThreadFactory threadFactory) {
return this;
}

@Override
@CheckReturnValue
public ConfigurationStage withHikariConfig(Consumer<HikariConfig> configConsumer) {
configConsumer.accept(hikariConfig);
return this;
}

@Override
@CheckReturnValue
public HikariDataSource build() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* SPDX-License-Identifier: AGPL-3.0-only
*
* Copyright (C) 2022 RainbowDashLabs and Contributor
*/

package de.chojo.sadu.datasource;

/**
* Thrown when a driver class is not found.
*/

public class DriverClassNotFoundException extends RuntimeException {

public DriverClassNotFoundException(String message, ClassNotFoundException e) {
super(message, e);
}
}
Loading

0 comments on commit 3d2dd1c

Please sign in to comment.