Skip to content

Commit

Permalink
build: spotless, google java-format, github-actions (#6)
Browse files Browse the repository at this point in the history
* Version 0.6.0-SNAPSHOT

* Adding spotless-plugin and google java-format

* License-header fix

* CI fix

* CI fix

* CI fix
  • Loading branch information
kagkarlsson authored Sep 28, 2023
1 parent 77e2b8d commit c74fefb
Show file tree
Hide file tree
Showing 26 changed files with 990 additions and 880 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [kagkarlsson]
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: build
on: [push,pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '11', '17' ]
name: Temurin ${{ matrix.java }}
steps:
- uses: actions/checkout@v3

- name: Set up Java ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'maven'

- name: Run all tests
run: mvn -B clean test --file pom.xml
env:
TZ: UTC
17 changes: 17 additions & 0 deletions .github/workflows/pr-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Validate PR title"

on:
pull_request:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: pull-request-check
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '17' ]
name: Temurin ${{ matrix.java }}
steps:
- uses: actions/checkout@v3

- name: Set up Java ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'maven'

- name: Run all tests
run: mvn -B spotless:check
env:
TZ: UTC
11 changes: 11 additions & 0 deletions .license/license-header.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Copyright (C) Gustav Karlsson

<p>Licensed 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

<p>http://www.apache.org/licenses/LICENSE-2.0

<p>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.
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

30 changes: 27 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.kagkarlsson</groupId>
<artifactId>micro-jdbc</artifactId>
<version>0.5.0-SNAPSHOT</version>
<version>0.6.0-SNAPSHOT</version>

<name>Micro JDBC</name>
<description>Simple low-level helpers for jdbc-access</description>
Expand All @@ -31,6 +31,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<skipChecks>false</skipChecks>
<failOnMissingHeader>true</failOnMissingHeader>
<license.dir>${project.basedir}/.license</license.dir>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -107,7 +108,7 @@
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -140,13 +141,14 @@
<artifactId>license-maven-plugin</artifactId>
<version>2.11</version>
<configuration>
<header>src/main/license-header.txt</header>
<header>${license.dir}/license-header.txt</header>
<strictCheck>true</strictCheck>
<excludes>
<exclude>pom.xml</exclude>
<exclude>LICENSE*</exclude>
<exclude>.java-version</exclude>
<exclude>src/test/**</exclude>
<exclude>.github/**</exclude>
</excludes>
<failIfMissing>${failOnMissingHeader}</failIfMissing>
</configuration>
Expand All @@ -160,6 +162,28 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.39.0</version>
<configuration>
<java>
<includes>
<include>src/main/java/**/*.java</include> <!-- Check application code -->
<include>src/test/java/**/*.java</include> <!-- Check application tests code -->
</includes>
<googleJavaFormat>
<version>1.16.0</version>
<style>GOOGLE</style>
</googleJavaFormat>
<importOrder />
<removeUnusedImports />
<toggleOffOn/>
<trimTrailingWhitespace/>
<endWithNewline/>
</java>
</configuration>
</plugin>

<!-- Release plugins -->
<plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/**
* Copyright (C) Gustav Karlsson
*
* Licensed 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
* <p>Licensed 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
* <p>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
* <p>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.
*/
package com.github.kagkarlsson.jdbc;
Expand All @@ -20,6 +18,5 @@

public interface BatchPreparedStatementSetter<U> {

void setParametersForRow(U value, PreparedStatement preparedStatement) throws SQLException;

void setParametersForRow(U value, PreparedStatement preparedStatement) throws SQLException;
}
21 changes: 10 additions & 11 deletions src/main/java/com/github/kagkarlsson/jdbc/ConnectionSupplier.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/**
* Copyright (C) Gustav Karlsson
*
* Licensed 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
* <p>Licensed 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
* <p>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
* <p>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.
*/
package com.github.kagkarlsson.jdbc;
Expand All @@ -19,8 +17,9 @@
import java.sql.SQLException;

public interface ConnectionSupplier {
Connection getConnection() throws SQLException;
boolean commitWhenAutocommitDisabled();
boolean isExternallyManagedConnection();
Connection getConnection() throws SQLException;

boolean commitWhenAutocommitDisabled();

boolean isExternallyManagedConnection();
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
/**
* Copyright (C) Gustav Karlsson
*
* Licensed 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
* <p>Licensed 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
* <p>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
* <p>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.
*/
package com.github.kagkarlsson.jdbc;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;

public class DataSourceConnectionSupplier implements ConnectionSupplier {
private DataSource dataSource;
private boolean commitWhenAutocommitDisabled;
private DataSource dataSource;
private boolean commitWhenAutocommitDisabled;

public DataSourceConnectionSupplier(DataSource dataSource, boolean commitWhenAutocommitDisabled) {
this.dataSource = dataSource;
this.commitWhenAutocommitDisabled = commitWhenAutocommitDisabled;
}
public DataSourceConnectionSupplier(DataSource dataSource, boolean commitWhenAutocommitDisabled) {
this.dataSource = dataSource;
this.commitWhenAutocommitDisabled = commitWhenAutocommitDisabled;
}

@Override
public Connection getConnection() throws SQLException {
return dataSource.getConnection();
}
@Override
public Connection getConnection() throws SQLException {
return dataSource.getConnection();
}

@Override
public boolean commitWhenAutocommitDisabled() {
return commitWhenAutocommitDisabled;
}
@Override
public boolean commitWhenAutocommitDisabled() {
return commitWhenAutocommitDisabled;
}

@Override
public boolean isExternallyManagedConnection() {
return false;
}
@Override
public boolean isExternallyManagedConnection() {
return false;
}
}
16 changes: 7 additions & 9 deletions src/main/java/com/github/kagkarlsson/jdbc/DoInTransaction.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
/**
* Copyright (C) Gustav Karlsson
*
* Licensed 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
* <p>Licensed 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
* <p>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
* <p>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.
*/
package com.github.kagkarlsson.jdbc;

import java.sql.Connection;

public interface DoInTransaction<T> {
T doInTransaction(Connection c);
T doInTransaction(Connection c);
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/**
* Copyright (C) Gustav Karlsson
*
* Licensed 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
* <p>Licensed 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
* <p>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
* <p>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.
*/
package com.github.kagkarlsson.jdbc;
Expand All @@ -19,24 +17,24 @@

public class ExternallyManagedConnection implements ConnectionSupplier {

private final Connection externallyManagedConnection;
private final Connection externallyManagedConnection;

public ExternallyManagedConnection(Connection externallyManagedConnection) {
this.externallyManagedConnection = externallyManagedConnection;
}
public ExternallyManagedConnection(Connection externallyManagedConnection) {
this.externallyManagedConnection = externallyManagedConnection;
}

@Override
public Connection getConnection() {
return externallyManagedConnection;
}
@Override
public Connection getConnection() {
return externallyManagedConnection;
}

@Override
public boolean commitWhenAutocommitDisabled() {
return false;
}
@Override
public boolean commitWhenAutocommitDisabled() {
return false;
}

@Override
public boolean isExternallyManagedConnection() {
return true;
}
@Override
public boolean isExternallyManagedConnection() {
return true;
}
}
Loading

0 comments on commit c74fefb

Please sign in to comment.