Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies, migrate to toml and dependabot #103

Merged
merged 1 commit into from
Aug 24, 2024
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
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
updates:
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "weekly"
assignees:
- "gavlyukovskiy"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
assignees:
- "gavlyukovskiy"

92 changes: 82 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
name: CI
name: Build

on: [ push, pull_request ]
on:
push:
branches:
- master
tags-ignore:
- '*'
pull_request:
branches:
- master
workflow_dispatch:

jobs:

java-17:
concurrency:
# On master, we don't want any jobs cancelled so the sha is used to name the group
# On PR branches, we cancel the job if new commits are pushed
# More info: https://stackoverflow.com/a/68422069/253468
group: ${{ (github.ref == 'refs/heads/master') && format('{0}-{1}', github.workflow_ref, github.sha) || format('{0}-{1}', github.workflow_ref, github.head_ref) }}
cancel-in-progress: true

name: Java 17
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
checks: write # for publishing test results and annotations
steps:
- uses: actions/checkout@v4

- run: git fetch --prune --unshallow --tags
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v4
Expand All @@ -20,5 +36,61 @@ jobs:
java-version: '17'
cache: 'gradle'

- name: Test
run: ./gradlew build
- id: get-snapshot-version
name: Generate snapshot version
shell: bash
run: |
# expects git tag to be in format 'v0.1.0' or 'v0.1.0-rc1'
version=$(git describe --tag --abbrev=0 | cut -c 2-)
regex="^([0-9]+)\.([0-9]+)\.([0-9]+)(-[a-zA-Z0-9]+)?$"
if [[ $version =~ $regex ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
patch="${BASH_REMATCH[3]}"
pre_release="${BASH_REMATCH[4]:-}"

# increment patch version of the latest release to create new snapshot version
# when pre-release - continue snapshots of the same version
# v0.1.0 -> 0.1.0-SNAPSHOT
# v0.1.0-rc -> 0.1.0-SNAPSHOT
if [[ -z $pre_release ]]; then
patch=$(($patch + 1))
fi

snapshot_version="${major}.${minor}.${patch}"

if ! [[ $snapshot_version =~ $regex ]]; then
echo "SNAPSHOT version $snapshot_version is not a valid SemVer"
exit 1
fi

echo "${snapshot_version}-SNAPSHOT"
echo "snapshot-version=${snapshot_version}-SNAPSHOT" >> $GITHUB_OUTPUT
else
echo "Version $version is not a valid SemVer"
exit 1
fi

- name: Build
run: |
./gradlew \
-Pversion=${{ steps.get-snapshot-version.outputs.snapshot-version }} \
build

- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: ${{ !cancelled() }} # always run even if the previous step fails
with:
report_paths: '**/build/test-results/test/TEST-*.xml'

- name: Upload SNAPSHOT artifacts to Sonatype
id: upload_snapshot_artifacts
if: ${{ github.ref == 'refs/heads/master' }}
env:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_KEY: ${{ secrets.GPG_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: ./gradlew \
-Pversion=${{ steps.get-snapshot-version.outputs.snapshot-version }} \
publishToSonatype closeAndReleaseSonatypeStagingRepository
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: Tag & Release Workflow

on:
push:
tags:
- 'v[0-9]+\.[0-9]+\.[0-9]+'

jobs:

release:

if: github.repository == 'gavlyukovskiy/spring-boot-data-source-decorator'
runs-on: ubuntu-latest
steps:
Expand Down
65 changes: 0 additions & 65 deletions .github/workflows/snapshot.yml

This file was deleted.

9 changes: 2 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
java
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin").version("1.3.0")
alias(libs.plugins.nexus.publish)
}

group = "com.github.gavlyukovskiy"
Expand All @@ -29,11 +29,6 @@ nexusPublishing {
subprojects {
apply(plugin = "java")

extra["springBootVersion"] = "3.0.2"
extra["p6SpyVersion"] = "3.9.0"
extra["datasourceProxyVersion"] = "1.9"
extra["flexyPoolVersion"] = "2.2.3"

extra["release"] = listOf(
"datasource-decorator-spring-boot-autoconfigure",
"datasource-proxy-spring-boot-starter",
Expand Down Expand Up @@ -117,7 +112,7 @@ subprojects {
}

if (project.name.contains("sample")) {
tasks.compileJava {
tasks.withType<JavaCompile> {
dependsOn(":datasource-decorator-spring-boot-autoconfigure:publishToMavenLocal")
dependsOn(":datasource-proxy-spring-boot-starter:publishToMavenLocal")
dependsOn(":flexy-pool-spring-boot-starter:publishToMavenLocal")
Expand Down
79 changes: 44 additions & 35 deletions datasource-decorator-spring-boot-autoconfigure/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,48 +1,54 @@
plugins {
`java-library`
alias(libs.plugins.test.logger)
}

dependencies {
implementation("org.springframework.boot:spring-boot:${project.extra["springBootVersion"]}")
implementation("org.springframework.boot:spring-boot-autoconfigure:${project.extra["springBootVersion"]}")
implementation("org.springframework.boot:spring-boot-starter-jdbc:${project.extra["springBootVersion"]}")
implementation(platform(libs.spring.boot.dependencies))
annotationProcessor(platform(libs.spring.boot.dependencies))
compileOnly(platform(libs.spring.boot.dependencies))
testImplementation(platform(libs.spring.boot.dependencies))

annotationProcessor("org.springframework.boot:spring-boot-configuration-processor:${project.extra["springBootVersion"]}")
implementation(libs.spring.boot)
implementation(libs.spring.boot.autoconfigure)
implementation(libs.spring.boot.starter.jdbc)

compileOnly("org.apache.commons:commons-dbcp2:2.9.0")
compileOnly("org.apache.tomcat:tomcat-jdbc:10.1.5")
compileOnly("com.zaxxer:HikariCP:5.0.1")
annotationProcessor(libs.spring.boot.configuration.processor)

compileOnly("p6spy:p6spy:${project.extra["p6SpyVersion"]}")
compileOnly("net.ttddyy:datasource-proxy:${project.extra["datasourceProxyVersion"]}")
compileOnly("com.vladmihalcea.flexy-pool:flexy-pool-core:${project.extra["flexyPoolVersion"]}")
compileOnly("com.vladmihalcea.flexy-pool:flexy-dbcp2:${project.extra["flexyPoolVersion"]}")
compileOnly("com.vladmihalcea.flexy-pool:flexy-hikaricp:${project.extra["flexyPoolVersion"]}")
compileOnly("com.vladmihalcea.flexy-pool:flexy-tomcatcp:${project.extra["flexyPoolVersion"]}")
compileOnly("com.vladmihalcea.flexy-pool:flexy-micrometer-metrics:${project.extra["flexyPoolVersion"]}")
compileOnly(libs.commons.dbcp2)
compileOnly(libs.tomcat.jdbc)
compileOnly(libs.hikari.cp)

compileOnly("org.springframework.boot:spring-boot-starter-actuator:${project.extra["springBootVersion"]}")
compileOnly(libs.p6spy)
compileOnly(libs.datasource.proxy)
compileOnly(libs.flexy.pool.core)
compileOnly(libs.flexy.pool.dbcp2)
compileOnly(libs.flexy.pool.hikaricp)
compileOnly(libs.flexy.pool.tomcatcp)
compileOnly(libs.flexy.pool.micrometer.metrics)

compileOnly(libs.spring.boot.starter.actuator)

// optional (compileOnly) dependencies for SQL formatting
compileOnly("org.hibernate:hibernate-core:6.1.6.Final") // should match the version managed by spring-boot
compileOnly("com.github.vertical-blank:sql-formatter:2.0.4")
compileOnly(libs.hibernate.core)
compileOnly(libs.sql.formatter)

testImplementation("com.h2database:h2:2.1.214")
testImplementation("org.springframework.boot:spring-boot-starter-test:${project.extra["springBootVersion"]}")
testImplementation(libs.h2)
testImplementation(libs.spring.boot.starter.test)

testImplementation("p6spy:p6spy:${project.extra["p6SpyVersion"]}")
testImplementation("net.ttddyy:datasource-proxy:${project.extra["datasourceProxyVersion"]}")
testImplementation("com.vladmihalcea.flexy-pool:flexy-pool-core:${project.extra["flexyPoolVersion"]}")
testImplementation("com.vladmihalcea.flexy-pool:flexy-dbcp2:${project.extra["flexyPoolVersion"]}")
testImplementation("com.vladmihalcea.flexy-pool:flexy-hikaricp:${project.extra["flexyPoolVersion"]}")
testImplementation("com.vladmihalcea.flexy-pool:flexy-tomcatcp:${project.extra["flexyPoolVersion"]}")
testImplementation("com.vladmihalcea.flexy-pool:flexy-micrometer-metrics:${project.extra["flexyPoolVersion"]}")
testImplementation(libs.p6spy)
testImplementation(libs.datasource.proxy)
testImplementation(libs.flexy.pool.core)
testImplementation(libs.flexy.pool.dbcp2)
testImplementation(libs.flexy.pool.hikaricp)
testImplementation(libs.flexy.pool.tomcatcp)
testImplementation(libs.flexy.pool.micrometer.metrics)

testImplementation("commons-dbcp:commons-dbcp:1.4")
testImplementation("org.apache.commons:commons-dbcp2:2.9.0")
testImplementation("org.apache.tomcat:tomcat-jdbc:10.1.5")
testImplementation("com.zaxxer:HikariCP:5.0.1")
testImplementation("org.flywaydb:flyway-core:9.5.1")
testImplementation(libs.commons.dbcp)
testImplementation(libs.commons.dbcp2)
testImplementation(libs.tomcat.jdbc)
testImplementation(libs.hikari.cp)
testImplementation(libs.flyway.core)
}

tasks {
Expand All @@ -53,13 +59,16 @@ tasks {
withType<JavaCompile> {
options.compilerArgs.add("-Xlint:unchecked")
options.compilerArgs.add("-Xlint:deprecation")
options.encoding = "UTF-8"
}

javadoc {
val options = options as StandardJavadocDocletOptions
options.addBooleanOption("html5", true)
options.addStringOption("Xdoclint:all,-missing", "-quiet")
}

test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}
}
2 changes: 1 addition & 1 deletion datasource-proxy-spring-boot-starter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ plugins {

dependencies {
api(project(":datasource-decorator-spring-boot-autoconfigure"))
api("net.ttddyy:datasource-proxy:${project.extra["datasourceProxyVersion"]}")
api(libs.datasource.proxy)
}
8 changes: 5 additions & 3 deletions flexy-pool-spring-boot-starter/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import org.gradle.internal.impldep.org.junit.experimental.categories.Categories.CategoryFilter.exclude

plugins {
`java-library`
}

dependencies {
api(project(":datasource-decorator-spring-boot-autoconfigure"))
api("com.vladmihalcea.flexy-pool:flexy-pool-core:${project.extra["flexyPoolVersion"]}")
api("com.vladmihalcea.flexy-pool:flexy-hikaricp:${project.extra["flexyPoolVersion"]}") {
api(libs.flexy.pool.core)
api(libs.flexy.pool.hikaricp) {
exclude(group = "com.vladmihalcea.flexy-pool", module = "flexy-dropwizard-metrics")
}
api("com.vladmihalcea.flexy-pool:flexy-micrometer-metrics:${project.extra["flexyPoolVersion"]}")
api(libs.flexy.pool.micrometer.metrics)
}
Loading