Skip to content

Commit 9146bf0

Browse files
committed
feat: adding kotlin project template
1 parent 36cf4da commit 9146bf0

26 files changed

Lines changed: 1023 additions & 1 deletion

File tree

.github/pull_request_template.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Pull Request
2+
3+
<!--
4+
Please make sure to have read the CONTRIBUTING.md guidelines.
5+
-->
6+
7+
## Description
8+
9+
<!--
10+
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
11+
12+
Fixes # (issue)
13+
-->
14+
15+
## Type of change
16+
17+
<!--
18+
Please delete options that are not relevant.
19+
-->
20+
21+
- [ ] Bug fix (non-breaking change which fixes an issue)
22+
- [ ] New feature (non-breaking change which adds functionality)
23+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
24+
- [ ] Documentation update
25+
- [ ] Code style update
26+
- [ ] Refactoring
27+
- [ ] Build-related changes
28+
- [ ] CI-related changes
29+
30+
## How has this been tested?
31+
32+
<!--
33+
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.
34+
-->
35+
36+
All tests pass.
37+
38+
<!--
39+
## Checklist:
40+
41+
- [ ] My code follows the style guidelines of this project
42+
- [ ] I have performed a self-review of my own code
43+
- [ ] I have commented my code, particularly in hard-to-understand areas
44+
- [ ] I have made corresponding changes to the documentation
45+
- [ ] My changes generate no new warnings
46+
- [ ] I have added tests that prove my fix is effective or that my feature works
47+
- [ ] New and existing unit tests pass locally with my changes
48+
- [ ] Any dependent changes have been merged and published in downstream modules
49+
-->

.github/workflows/build.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Build
2+
on:
3+
push:
4+
branches: [ "develop" ]
5+
pull_request:
6+
branches: [ "develop" ]
7+
jobs:
8+
Build:
9+
if: github.repository == 'YourRepositoryNameHere'
10+
name: Build
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
checks: write
15+
pull-requests: write
16+
steps:
17+
- name: Check out the repo
18+
uses: actions/checkout@v4
19+
20+
- name: Setup OpenJDK 25
21+
uses: actions/setup-java@v4
22+
with:
23+
distribution: 'temurin'
24+
java-version: '25'
25+
26+
- name: Perform commit linting
27+
uses: wagoid/commitlint-github-action@v6
28+
29+
- name: Build using Gradle
30+
run: ./gradlew build
31+
32+
- name: Test using Gradle
33+
run: ./gradlew test
34+
35+
- name: Publish Test Report
36+
uses: mikepenz/action-junit-report@v6
37+
if: success() || failure()
38+
with:
39+
report_paths: '**/build/test-results/test/TEST-*.xml'
40+
annotate_only: true

.github/workflows/docker.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish Docker image
2+
on:
3+
release:
4+
types: [ published ]
5+
push:
6+
branches:
7+
- master
8+
- develop
9+
jobs:
10+
PushDockerImage:
11+
if: github.repository == 'YourRepositoryNameHere'
12+
name: Push Docker Image
13+
runs-on: ubuntu-latest
14+
permissions:
15+
packages: write
16+
contents: read
17+
attestations: write
18+
id-token: write
19+
steps:
20+
- name: Check out the repo
21+
uses: actions/checkout@v4
22+
23+
- name: Log in to Docker Hub
24+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
25+
with:
26+
username: ${{ secrets.DOCKER_USERNAME }}
27+
password: ${{ secrets.DOCKER_PASSWORD }}
28+
29+
- name: Extract metadata (tags, labels) for Docker
30+
id: meta
31+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
32+
with:
33+
images: collaborativestatemachines/cirrina
34+
tags: |
35+
type=semver,pattern={{version}},enable=${{ github.event_name == 'release' }}
36+
type=raw,value=stable,enable=${{ github.event_name == 'release' }}
37+
38+
type=raw,value=nightly,enable=${{ github.ref == 'refs/heads/master' }}
39+
type=sha,enable=${{ github.ref == 'refs/heads/master' }}
40+
41+
type=raw,value=unstable,enable=${{ github.ref == 'refs/heads/develop' }}
42+
type=sha,enable=${{ github.ref == 'refs/heads/develop' }}
43+
44+
- name: Build and push Docker image
45+
id: push
46+
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
47+
with:
48+
context: .
49+
file: ./Dockerfile
50+
push: true
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Ours
2+
.idea/
3+
.kotlin/
4+
5+
**/build/
6+
7+
# From: https://github.com/github/gitignore/blob/main/Gradle.gitignore
8+
.gradle
9+
**/build/
10+
!**/src/**/build/
11+
12+
# Ignore Gradle GUI config
13+
gradle-app.setting
14+
15+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
16+
!gradle-wrapper.jar
17+
18+
# Avoid ignore Gradle wrapper properties
19+
!gradle-wrapper.properties
20+
21+
# Cache of project
22+
.gradletasknamecache
23+
24+
# Eclipse Gradle plugin generated files
25+
# Eclipse Core
26+
.project
27+
# JDT-specific (Eclipse Java Development Tools)
28+
.classpath

ATTRIBUTIONS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Dependencies
2+
3+
This project makes use of the following dependencies:
4+
5+
| Dependency Name | Website | License | License Text URL |
6+
|-----------------|---------|---------|------------------|
7+
| | | | |

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM gradle:9.3.0-jdk25 AS build
2+
3+
COPY --chown=gradle:gradle . /usr/src/projectname
4+
5+
WORKDIR /usr/src/projectname
6+
7+
ARG GIT_HASH=unknown
8+
ENV GIT_HASH=${GIT_HASH}
9+
10+
RUN gradle :app:installDist --no-daemon
11+
12+
FROM gcr.io/distroless/java25-debian13 AS runtime
13+
14+
COPY --from=build /usr/src/projectname/app/build/install/projectname /opt/projectname
15+
16+
ENTRYPOINT [ \
17+
"java", \
18+
"-cp", "/opt/projectname/lib/*", \
19+
"at.ac.uibk.dps.projectname.ProjectNameKt" \
20+
]

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,36 @@
1-
# Template-Kotlin
1+
# Project Template
2+
3+
Template repository for initializing new GitHub projects within the organization.
4+
5+
## Module Structure
6+
7+
- `app/` - Main application executable.
8+
- `lib/` - Shared library code and core logic.
9+
- `bench/` - Benchmarking suite for evaluating shared functions.
10+
- `buildinfo/` - Build metadata and versioning configuration.
11+
12+
## Build & Execution
13+
14+
This project utilizes Gradle as its build system.
15+
16+
```bash
17+
# Build all modules and execute tests
18+
./gradlew build
19+
20+
# Run the main application
21+
./gradlew :app:run
22+
23+
# Execute benchmarking suite
24+
./gradlew :bench:benchmark
25+
```
26+
27+
## Continuous Integration
28+
29+
Continuous integration is enforced via GitHub Actions. Push and pull request events trigger automated builds, tests, and
30+
formatting checks.
31+
32+
## Contributing
33+
34+
Refer to [CONTRIBUTING.md](https://github.com/CollaborativeStateMachines/.github/blob/main/CONTRIBUTING.md) for strict
35+
organizational guidelines regarding code style, commit
36+
conventions, and the review process.

app/build.gradle.kts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
plugins {
2+
application
3+
id("com.ncorti.ktfmt.gradle")
4+
kotlin("kapt")
5+
kotlin("jvm")
6+
}
7+
8+
group = "ac.at.uibk.dps.projectname"
9+
10+
version =
11+
providers
12+
.fileContents(rootProject.layout.projectDirectory.file("version.txt"))
13+
.asText
14+
.get()
15+
.trim()
16+
17+
application {
18+
mainClass.set("at.ac.uibk.dps.projectname.ProjectNameKt")
19+
applicationName = "projectname"
20+
}
21+
22+
java { toolchain { languageVersion.set(JavaLanguageVersion.of(25)) } }
23+
24+
ktfmt { googleStyle() }
25+
26+
dependencies {
27+
implementation(project(":buildinfo"))
28+
implementation(project(":lib"))
29+
30+
implementation(kotlin("stdlib-jdk8"))
31+
32+
// Logging
33+
implementation("io.github.oshai:kotlin-logging-jvm:8.0.4")
34+
implementation("ch.qos.logback:logback-classic:1.5.34")
35+
36+
// Dagger
37+
implementation("com.google.dagger:dagger:2.59.2")
38+
kapt("com.google.dagger:dagger-compiler:2.59.2")
39+
40+
// Guava
41+
implementation("com.google.guava:guava:33.6.0-jre")
42+
43+
// JUnit
44+
testImplementation(platform("org.junit:junit-bom:5.11.0"))
45+
testImplementation("org.junit.jupiter:junit-jupiter")
46+
testImplementation("org.junit-pioneer:junit-pioneer:2.3.0")
47+
}
48+
49+
repositories {
50+
mavenCentral()
51+
gradlePluginPortal()
52+
}
53+
54+
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
55+
compilerOptions { jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_25) }
56+
}
57+
58+
tasks.named("compileKotlin") { dependsOn(tasks.named("ktfmtFormat")) }
59+
60+
tasks.named<Test>("test") { useJUnitPlatform() }
61+
62+
tasks.named<Zip>("distZip") { archiveFileName.set("projectname.zip") }
63+
64+
tasks.withType<Jar>().configureEach {
65+
manifest {
66+
attributes(
67+
mapOf(
68+
"Main-Class" to "at.ac.uibk.dps.projectname.ProjectNameKt",
69+
"Implementation-Version" to project.version.toString(),
70+
"Enable-Native-Access" to "ALL-UNNAMED",
71+
)
72+
)
73+
}
74+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package at.ac.uibk.dps.projectname
2+
3+
import at.ac.uibk.dps.projectname.di.DaggerAppComponent
4+
import at.ac.uibk.dps.projectname.generated.BuildInfo
5+
import io.github.oshai.kotlinlogging.KotlinLogging
6+
7+
private val logger = KotlinLogging.logger {}
8+
9+
fun main() {
10+
logger.info { "Version ${BuildInfo.VERSION}" }
11+
12+
val component = DaggerAppComponent.create()
13+
14+
logger.info { Primes.approximate().take(50).toList() }
15+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package at.ac.uibk.dps.projectname.di
2+
3+
import dagger.Component
4+
import javax.inject.Singleton
5+
6+
@Singleton @Component(modules = [AppModule::class]) interface AppComponent

0 commit comments

Comments
 (0)