Skip to content

Commit

Permalink
internal development. (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
portlek authored Jul 29, 2024
1 parent eaf296a commit be40ff8
Show file tree
Hide file tree
Showing 39 changed files with 1,490 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
37 changes: 37 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name-template: "$RESOLVED_VERSION"
tag-template: "$RESOLVED_VERSION"
prerelease: true
template: |
# What's Changed
$CHANGES
categories:
- title: "Breaking"
label: "breaking"
- title: "New"
label: "enhancement"
- title: "Bug Fixes"
label: "bug"
- title: "Maintenance"
label: "maintenance"
- title: "Documentation"
label: "documentation"
- title: "Dependency Updates"
label: "dependencies"
version-resolver:
major:
labels:
- "breaking"
minor:
labels:
- "enhancement"
patch:
labels:
- "bug"
- "maintenance"
- "documentation"
- "dependencies"
- "security"
exclude-labels:
- "skip-changelog"
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: "Build"
"on":
pull_request:
branches:
- "master"
jobs:
build:
name: "Build"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "actions/setup-java@v4"
with:
distribution: "adopt"
java-version: "11"
- uses: "actions/cache@v4"
with:
path: "~/.gradle/caches"
key: "${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }}"
restore-keys: |
${{ runner.os }}-gradle-
- uses: "actions/cache@v4"
with:
path: "~/.gradle/wrapper"
key: "${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }}"
restore-keys: |
${{ runner.os }}-gradlew-
- run: |
chmod +x gradlew
./gradlew build
16 changes: 16 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: "Update Changelog"
"on":
push:
branches:
- "master"
jobs:
changelog:
name: "Update Changelog"
runs-on: "ubuntu-latest"
if: "${{ !contains(github.event.head_commit.message, 'skip-snapshot') }}"
steps:
- uses: "release-drafter/release-drafter@master"
id: "release"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: "Release"
"on":
release:
types:
- "released"
jobs:
build:
name: "Release"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "actions/setup-java@v4"
with:
distribution: "adopt"
java-version: "11"
- uses: "actions/cache@v4"
with:
path: "~/.gradle/caches"
key: "${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }}"
restore-keys: |
${{ runner.os }}-gradle-
- uses: "actions/cache@v4"
with:
path: "~/.gradle/wrapper"
key: "${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }}"
restore-keys: |
${{ runner.os }}-gradlew-
- run: |
[[ "${{ github.event.release.tag_name }}" =~ ^[0-9]+(\.[0-9]+)*$ ]] || exit -1
chmod +x gradlew
./gradlew -Psign-required=true publish -Pversion="${{ github.event.release.tag_name }}" -PmavenCentralUsername="${{ secrets.MAVEN_CENTRAL_USERNAME }}" -PmavenCentralPassword="${{ secrets.MAVEN_CENTRAL_PASSWORD }}" -PsigningInMemoryKey="${{ secrets.GPG_PRIVATE_KEY_ARMORED }}" -PsigningInMemoryKeyPassword="${{ secrets.GPG_PASSPHRASE }}"
35 changes: 11 additions & 24 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
.idea/
target/
.gradle/
build/
*.iml
*.project
*.classpath
.settings/
**/bin/
.vscode/
.kotlin/
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
# lock
Simplified lock mechanism using Redis.
[![Maven Central Version](https://img.shields.io/maven-central/v/net.infumia/lock)](https://central.sonatype.com/artifact/net.infumia/lock)
## How to Use (Developers)
### Gradle
```groovy
repositories {
mavenCentral()
}
dependencies {
// Base module
implementation "net.infumia:lock:VERSION"
// Pub/Sub using Redis (Optional)
implementation "net.infumia:lock-redis:VERSION"
// Required, https://mvnrepository.com/artifact/io.lettuce/lettuce-core/
implementation "io.lettuce:lettuce-core:6.3.2.RELEASE"
// Kotlin extensions (Optional)
implementation "net.infumia:lock-kotlin:VERSION"
// Kotlin coroutines (Optional)
implementation "net.infumia:lock-kotlin-coroutines:VERSION"
// Required, https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core/
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1"
}
```
### Code
```kotlin
fun main() {
}
```
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import net.infumia.gradle.spotless

plugins { java }

subprojects { apply<JavaPlugin>() }

spotless()
15 changes: 15 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
plugins { `kotlin-dsl` }

repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
implementation(libs.nexus.plugin)
implementation(libs.kotlin.plugin)
implementation(libs.dokka.plugin)
implementation(libs.spotless.plugin)
}

kotlin { jvmToolchain(11) }
5 changes: 5 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
plugins { id("org.gradle.toolchains.foojay-resolver-convention") }

dependencyResolutionManagement {
versionCatalogs { create("libs") { from(files("../gradle/libs.versions.toml")) } }
}
43 changes: 43 additions & 0 deletions buildSrc/src/main/kotlin/net/infumia/gradle/common.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package net.infumia.gradle

import org.gradle.api.Project
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.tasks.bundling.Jar
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.kotlin.dsl.*
import org.jetbrains.dokka.gradle.DokkaPlugin

fun Project.applyCommon(javaVersion: Int = 8, sources: Boolean = true, javadoc: Boolean = true) {
apply<JavaPlugin>()

if (name.contains("kotlin")) {
apply<DokkaPlugin>()
apply(plugin = "org.jetbrains.kotlin.jvm")
}

repositories.mavenCentral()

extensions.configure<JavaPluginExtension> {
toolchain { languageVersion = JavaLanguageVersion.of(javaVersion) }
}

if (javadoc) {
val javadocJar by
tasks.creating(Jar::class) {
dependsOn("javadoc")
archiveClassifier.set("javadoc")
from(javadoc)
}
}

if (sources) {
val sourceSets = extensions.getByType<JavaPluginExtension>().sourceSets
val sourcesJar by
tasks.creating(Jar::class) {
dependsOn("classes")
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}
}
}
52 changes: 52 additions & 0 deletions buildSrc/src/main/kotlin/net/infumia/gradle/publish.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package net.infumia.gradle

import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.MavenPublishPlugin
import com.vanniktech.maven.publish.SonatypeHost
import org.gradle.api.Project
import org.gradle.kotlin.dsl.*

fun Project.publish(
moduleName: String? = null,
javaVersion: Int = 8,
sources: Boolean = true,
javadoc: Boolean = true
) {
applyCommon(javaVersion, sources, javadoc)
apply<MavenPublishPlugin>()

val projectName = "lock${if (moduleName == null) "" else "-$moduleName"}"
val signRequired = project.hasProperty("sign-required")

extensions.configure<MavenPublishBaseExtension> {
coordinates(project.group.toString(), projectName, project.version.toString())
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, true)
if (signRequired) {
signAllPublications()
}

pom {
name.set(projectName)
description.set("")
url.set("https://github.com/Infumia/lock")
licenses {
license {
name.set("MIT License")
url.set("https://mit-license.org/license.txt")
}
}
developers {
developer {
id.set("portlek")
name.set("Hasan Demirtaş")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:git://github.com/infumia/lock.git")
developerConnection.set("scm:git:ssh://github.com/infumia/lock.git")
url.set("https://github.com/infumia/lock/")
}
}
}
}
Loading

0 comments on commit be40ff8

Please sign in to comment.