Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsBodewig committed Aug 28, 2023
1 parent 991a311 commit 4b51c5a
Show file tree
Hide file tree
Showing 13 changed files with 1,818 additions and 38 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Builds the project with Maven Wrapper using the 'release' profile and publishes to Maven Central
# ---
# Add the following Github secrets from your Secret Manager
# - MAVEN_USERNAME: your Sonatype username
# - MAVEN_CENTRAL_TOKEN: an Access Token generated in your Sonatype profile
# - MAVEN_GPG_PASSPHRASE: your GPG passphrase
# - MAVEN_GPG_PRIVATE_KEY: your GPG private key

name: Maven Publish
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Publish to Apache Maven Central
run: mvnw clean deploy -B -P release
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.classpath
.mvn/wrapper/maven-wrapper.jar
.project
.settings/
target/
18 changes: 18 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
707 changes: 674 additions & 33 deletions LICENSE

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Template
db2ascii
Copyright 2023 Lars Bodewig

This product includes software developed by:
The Apache Software Foundation (https://www.apache.org/)


The respective license information resides in the bundled libraries.
The respective license information resides in the bundled libraries or files.
54 changes: 52 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,55 @@
# Template
# db2ascii

Template to include license information and useful files in all projects
A small utility to quickly dump your database query results as a formatted ascii table.

* Supports both classic `ResultSet` objects and JPA `TypedQuery` objects.
* Offers functions to print to `System.out`, a designated `PrintStream` or return a formatted `String`


## Example output

```
+----+-------+--------+--------+
| ID | PRICE | COLOR | NAME |
+----+-------+--------+--------+
| 1 | 1.5 | yellow | Banana |
+----+-------+--------+--------+
```


## Usage

```xml
<dependency>
<groupId>dev.bodewig.db2ascii</groupId>
<artifactId>db2ascii</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
```

```java
import dev.bodewig.db2ascii.Db2Ascii;

/* usage with classic java.sql.ResultSet (and java.io.PrintStream) */
Db2Ascii.printResultSet(resultSet) // prints to System.out
Db2Ascii.printResultSet(resultSet, printStream)
String formattedResult = Db2Ascii.resultSetToString(resultSet)

/* usage with JPA jakarta.persistence.TypedQuery<X> (and java.io.PrintStream) */
Db2Ascii.queryResultToString(typedQuery) // prints to System.out
Db2Ascii.queryResultToString(typedQuery, printStream)
String formattedResult = Db2Ascii.queryResultToString(typedQuery)
```

You can check out the [unit tests](https://github.com/LarsBodewig/db2ascii/blob/main/src/test/java/dev/bodewig/db2ascii/Db2AsciiTest.java) for more complete examples.


### This dependency should only be used for testing purposes!

It is licensed under GPL-3.0 but can be used without any limitation as long as it is not modified or distributed - so it should be safe to use as a Maven dependency with the scope `test` (**but this is no legal advise**).


---

Run `git config --add include.path ../.gitconfig` to include the template config in your project config.
Loading

0 comments on commit 4b51c5a

Please sign in to comment.