Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
abendt committed May 3, 2024
0 parents commit f3c2df8
Show file tree
Hide file tree
Showing 28 changed files with 1,142 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
trim_trailing_whitespace = true

[*.{kt,kts}]
max_line_length=140

[*.kt]
ij_kotlin_name_count_to_use_star_import = 99
ij_kotlin_name_count_to_use_star_import_for_members = 99

ktlint_standard_import-ordering = disabled
ktlint_standard_filename = disabled

[*.kts]
ktlint_gradle-kotlin-dsl_gradle-kotlin-dsl-blank-lines = disabled
ktlint_gradle-kotlin-dsl_gradle-kotlin-dsl-imports = disabled
ktlint_gradle-kotlin-dsl_visibility-modifiers-own-lin = disabled

[*.bat]
end_of_line = crlf
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
55 changes: 55 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI

on:
push:
pull_request:

permissions:
contents: read
actions: read
checks: write

jobs:
gradle-build:
runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 21

- name: Setup Gradle
uses: gradle/gradle-build-action@v3

- name: Run build with Gradle Wrapper
run: ./gradlew build

- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Test reports
path: build/test-results/**/TEST-*.xml
reporter: java-junit

auto-merge-dependabot:
name: 🤖 Auto merge dependabot PR
timeout-minutes: 10
needs: [ gradle-build ]
if: ${{ github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- name: 🤖 Merge PR from dependabot
uses: fastify/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
target: minor
merge-method: squash
22 changes: 22 additions & 0 deletions .github/workflows/dependency-submission.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Dependency Submission

on: [ push ]

permissions:
contents: write

jobs:
dependency-submission:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21

- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@v3
10 changes: 10 additions & 0 deletions .github/workflows/wrapper-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "Validate Gradle Wrapper"
on: [push, pull_request]

jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v3
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build

.idea
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
- repo: https://github.com/jguttman94/pre-commit-gradle
rev: v0.3.0
hooks:
- id: gradle-spotless
args: [ --wrapper, --output ]
- id: gradle-task
name: gradle spotless [buildSrc]
args: [ --wrapper, -p buildSrc, spotlessApply]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: check-json
- id: check-xml
- id: check-yaml

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 red green coding

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Kotlin single module project blueprint
======================================

Buildtool
* Gradle (Kotlin DSL)

Basic dependencies
* Kotlin JVM
* Kotlin Logging
* slf4j + logback

Testing
* Kotest
* mockk

## pre-commit hooks

Dependencies: https://pre-commit.com/#installation

* Install git hook: https://pre-commit.com/#3-install-the-git-hook-scripts
```bash
pre-commit install
```
* Test hook:
```bash
pre-commit run --all-files
```
42 changes: 42 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
id("module-conventions")

id("com.google.devtools.ksp") version "1.9.23-1.0.20"

kotlin("plugin.serialization") version "1.9.23"

// https://foso.github.io/Ktorfit/
id("de.jensklingenberg.ktorfit") version "1.13.0"
}

dependencies {
implementation(platform("io.arrow-kt:arrow-stack:1.2.4"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")

implementation("io.arrow-kt:arrow-core")
implementation("io.arrow-kt:arrow-fx-coroutines")
implementation("io.arrow-kt:arrow-optics")
implementation("io.arrow-kt:arrow-exact:0.1.0")
ksp("io.arrow-kt:arrow-optics-ksp-plugin:1.2.4")

val ktorfitVersion = "1.13.0"

ksp("de.jensklingenberg.ktorfit:ktorfit-ksp:$ktorfitVersion")

implementation("de.jensklingenberg.ktorfit:ktorfit-lib:$ktorfitVersion")

testImplementation("io.kotest.extensions:kotest-assertions-arrow:1.4.0")

implementation(platform("io.ktor:ktor-bom:2.3.10"))

testImplementation("io.ktor:ktor-client-content-negotiation")
testImplementation("io.ktor:ktor-serialization-kotlinx-json")

testImplementation("io.ktor:ktor-client-logging")
}

spotless {
kotlin {
targetExclude("build/generated/**")
}
}
32 changes: 32 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
plugins {
`kotlin-dsl`
id("com.diffplug.spotless") version libs.versions.gradleSpotlessPlugin.get()
}

repositories {
gradlePluginPortal()
}

dependencies {
val kotlinVersion = libs.versions.kotlin.get()
val testLoggerPluginVersion = libs.versions.gradleTestLoggerPlugin.get()
val spotlessVersion = libs.versions.gradleSpotlessPlugin.get()

implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("com.adarshr:gradle-test-logger-plugin:$testLoggerPluginVersion")
implementation("com.diffplug.spotless:spotless-plugin-gradle:$spotlessVersion")

// workaround to be able to use the version catalog inside of gradle convention plugins
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}

configure<com.diffplug.gradle.spotless.SpotlessExtension> {
// ratchetFrom("origin/main")

kotlin {
ktlint()
}
kotlinGradle {
ktlint()
}
}
7 changes: 7 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
53 changes: 53 additions & 0 deletions buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.gradle.accessors.dm.LibrariesForLibs

plugins {
id("org.jetbrains.kotlin.jvm")
}

repositories {
mavenCentral()
}

val libs = the<LibrariesForLibs>()

kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(libs.versions.java.get()))
}
}

dependencies {
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
}

// Align versions of all Kotlin components
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))

// Use the Kotlin JDK 8 standard library.
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
}

val isIdea = providers.systemProperty("idea.version").isPresent

tasks.withType(KotlinCompile::class.java).configureEach {
kotlinOptions {
// don't fail the build when running tests in idea!
allWarningsAsErrors = !isIdea

incremental = true
freeCompilerArgs = listOf("-Xjsr305=strict", "-Xcontext-receivers")

if (isIdea) {
freeCompilerArgs += "-Xdebug"
}

jvmTarget = libs.versions.java.get()
}
}

tasks.withType<JavaCompile> {
sourceCompatibility = libs.versions.java.get()
targetCompatibility = libs.versions.java.get()
}
Loading

0 comments on commit f3c2df8

Please sign in to comment.