Skip to content

Commit

Permalink
Release 2.0.0 (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
rainbowdashlabs authored Feb 23, 2024
2 parents 8e506cf + 6ef84f3 commit a1d875a
Show file tree
Hide file tree
Showing 236 changed files with 4,204 additions and 4,138 deletions.
8 changes: 4 additions & 4 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>rainbowdashlabs/rainbowdashlabs"
]
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>rainbowdashlabs/rainbowdashlabs"
]
}
4 changes: 2 additions & 2 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@v4
- name: Set up JDK 15
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 15
java-version: 17
- name: Build Javadocs
run: |
echo "Building javadocs with gradle"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up JDK 15
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 15
java-version: 17
- name: Test with Gradle
run: ./gradlew --build-cache test
- name: Publish to Maven Central
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Verify state

on: [push, pull_request]
on: [ push, pull_request ]

jobs:
build:
Expand All @@ -9,10 +9,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up JDK 15
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 15
java-version: 17
- name: Test with Gradle
run: ./gradlew --build-cache test
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
Hello and welcome new contributor.

# Issues

Please make sure to describe your issue as precisely as possible.

# Pull Requests

When you create a new pull request you have to take care of a few things.

- Create a feature branch based on the development branch
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,25 @@ SADU offers support for four different databases at the moment. To use them simp
- `sadu-sqlite`

## Querybuilder

SADU offers a query builder to manage resources, error handling, result set reading and dispatching of queries.

to use it import: `sadu-queries`

Learn how to use the query builder [here](https://github.com/RainbowDashLabs/sadu/wiki/SADU-Queries)
Learn how to use the query builder [here](https://sadu.docs.chojo.dev/queries/)

### But why should I use it?

Before I give you a long talk about how much nicer the syntax and code is let me simple show you a comparison.

Without the query builder your code would ideally look like this:

```java
class MyQueries {

DataSource dataSource;
MyQueries(DataSource dataSource){

MyQueries(DataSource dataSource) {
this.dataSource = dataSource;
}

Expand All @@ -71,17 +73,13 @@ class MyQueries {
```

But using the query builder your code becomes this:
```java
class MyQueries extends QueryFactory {
MyQueries(DataSource dataSource){
super(dataSource);
}

public CompletableFuture<Optional<Result>> getResultNew(int id) {
return builder(Result.class)
.query("SELECT result FROM results WHERE id = ?")
.parameters(stmt -> stmt.setInt(id))
.readRow(rs -> new Result(rs.getString("result")))
```java
class MyQueries {
public Optional<Result> getResultNew(int id) {
return Query.query("SELECT result FROM results WHERE id = ?")
.single(Call.of().bind(id))
.map(row -> new Result(rs.getString("result")))
.first();
}
}
Expand All @@ -90,25 +88,27 @@ class MyQueries extends QueryFactory {
Beautiful isnt it? The query builder will enforce try with resources, set parameters in the order defined by you,
read the result set and additionally handle the exceptions for you.

[How does it work?](https://github.com/RainbowDashLabs/sadu/wiki/SADU-Queries#how-does-it-work)
[How does it work?](https://sadu.docs.chojo.dev/queries/)

## Datasource Builder

SADU offsers a data source builder to create data sources for the databases listed above.

to use it import: `sadu-datasource`

Note that in order to use this, you need at least one of the listed databases from above.

Learn how to use the datasource builder [here](https://github.com/RainbowDashLabs/sadu/wiki/SADU-Datasource)
Learn how to use the datasource builder [here](https://sadu.docs.chojo.dev/data_source/)

## Updater

SADU offers a simple sql updater which deploys upgrade and migration scripts to your database.

to use it import: `sadu-updater`

Learn how to use it [here](https://github.com/RainbowDashLabs/sadu/wiki/SADU-Updater)
Learn how to use it [here](https://sadu.docs.chojo.dev/updater/)


[nexus_releases]: https://search.maven.org/search?q=de.chojo.sadu

[nexus_snapshots]: https://s01.oss.sonatype.org/#nexus-search;quick~de.chojo.sadu
17 changes: 8 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ plugins {

publishData {
useEldoNexusRepos(false)
publishingVersion = "1.4.1"
publishingVersion = "2.0.0"
}

group = "de.chojo.sadu"
Expand Down Expand Up @@ -49,8 +49,8 @@ subprojects {

indra {
javaVersions {
target(15)
testWith(15)
target(17)
testWith(17)
}

github("rainbowdashlabs", "sadu") {
Expand Down Expand Up @@ -79,8 +79,8 @@ subprojects {

indra {
javaVersions {
target(15)
testWith(15)
target(17)
testWith(17)
}

github("rainbowdashlabs", "sadu") {
Expand Down Expand Up @@ -122,8 +122,8 @@ allprojects {


dependencies {
testImplementation("org.junit.jupiter", "junit-jupiter-api", "5.10.1")
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", "5.10.1")
testImplementation("org.junit.jupiter", "junit-jupiter-api", "5.10.2")
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", "5.10.2")
testImplementation("org.mockito", "mockito-core", "5.+")
}

Expand Down Expand Up @@ -157,7 +157,6 @@ allprojects {
fun applyJavaDocOptions(options: MinimalJavadocOptions) {
val javaDocOptions = options as StandardJavadocDocletOptions
javaDocOptions.links(
"https://javadoc.io/doc/com.google.code.findbugs/jsr305/latest/",
"https://javadoc.io/doc/org.jetbrains/annotations/latest/",
"https://docs.oracle.com/en/java/javase/${java.toolchain.languageVersion.get().asInt()}/docs/api/"
)
Expand All @@ -167,7 +166,7 @@ tasks {
register<Javadoc>("alljavadoc") {
applyJavaDocOptions(options)

destinationDir = file("${layout.buildDirectory}/docs/javadoc")
setDestinationDir(file("${layout.buildDirectory}/docs/javadoc"))
val projects = project.rootProject.allprojects.filter { p -> !p.name.contains("example") }
setSource(projects.map { p -> p.sourceSets.main.get().allJava })
classpath = files(projects.map { p -> p.sourceSets.main.get().compileClasspath })
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
1 change: 0 additions & 1 deletion sadu-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ description = "SADU core module, containing common logic between modules."
dependencies {
api(libs.slf4j.api)
api("org.jetbrains", "annotations", "24.1.0")
api("com.google.code.findbugs", "jsr305", "3.0.2")
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright (C) RainbowDashLabs and Contributor
*/

package de.chojo.sadu.base;
package de.chojo.sadu.core.base;

import javax.sql.DataSource;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* General base classes.
*/
package de.chojo.sadu.core.base;
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* Copyright (C) RainbowDashLabs and Contributor
*/

package de.chojo.sadu.conversion;
package de.chojo.sadu.core.conversion;

import de.chojo.sadu.types.SqlType;
import de.chojo.sadu.core.types.SqlType;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright (C) RainbowDashLabs and Contributor
*/

package de.chojo.sadu.conversion;
package de.chojo.sadu.core.conversion;

import java.nio.ByteBuffer;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Utilities to convert values
*/
package de.chojo.sadu.core.conversion;
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* Copyright (C) RainbowDashLabs and Contributor
*/

package de.chojo.sadu.databases;
package de.chojo.sadu.core.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 de.chojo.sadu.core.databases.exceptions.NotImplementedException;
import de.chojo.sadu.core.databases.exceptions.NotSupportedException;
import de.chojo.sadu.core.jdbc.JdbcConfig;
import de.chojo.sadu.core.updater.UpdaterBuilder;
import org.jetbrains.annotations.ApiStatus;

import java.util.Arrays;
Expand Down Expand Up @@ -177,6 +177,7 @@ default boolean hasSchemas() {

/**
* Instantiates an implementation of {@link UpdaterBuilder}
*
* @return the instance
*/
@ApiStatus.Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@
* Copyright (C) RainbowDashLabs and Contributor
*/

package de.chojo.sadu.databases;
package de.chojo.sadu.core.databases;

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

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

@Override
public String versionQuery(String table) {
default String versionQuery(String table) {
return String.format("SELECT major, patch FROM %s LIMIT 1", table);
}

@Override
public String insertVersion(String table) {
default String insertVersion(String table) {
return String.format("INSERT INTO %s VALUES (?, ?)", table);
}

@Override
public String deleteVersion(String table) {
default String deleteVersion(String table) {
return String.format("DELETE FROM %s;", table);
}

@Override
public String createVersionTableQuery(String table) {
default String createVersionTableQuery(String table) {
return String.format("CREATE TABLE IF NOT EXISTS %s(major INTEGER, patch INTEGER);", table);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
* Copyright (C) RainbowDashLabs and Contributor
*/

package de.chojo.sadu.databases.exceptions;
package de.chojo.sadu.core.databases.exceptions;

import java.io.Serial;

/**
* Thrown when a method is called which is not implemented but supported by this type.
*/
public class NotImplementedException extends RuntimeException {
@Serial
private static final long serialVersionUID = 1;

public NotImplementedException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
* Copyright (C) RainbowDashLabs and Contributor
*/

package de.chojo.sadu.databases.exceptions;
package de.chojo.sadu.core.databases.exceptions;

import java.io.Serial;

/**
* Thrown when a method is called which is not supported by this type.
*/
public class NotSupportedException extends RuntimeException {
@Serial
private static final long serialVersionUID = 1;

public NotSupportedException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Exceptions that might be thrown when working with a database implementation
*/
package de.chojo.sadu.core.databases.exceptions;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Base for defining a database implementation
*/
package de.chojo.sadu.core.databases;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright (C) RainbowDashLabs and Contributor
*/

package de.chojo.sadu.exceptions;
package de.chojo.sadu.core.exceptions;

import java.sql.SQLException;

Expand Down
Loading

0 comments on commit a1d875a

Please sign in to comment.