Skip to content

Commit

Permalink
initial files
Browse files Browse the repository at this point in the history
.
  • Loading branch information
portlek committed Sep 30, 2024
1 parent 7c43436 commit 3090fdc
Show file tree
Hide file tree
Showing 22 changed files with 719 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"
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: "Build"
"on":
pull_request:
branches:
- "master"
jobs:
build:
name: "Build"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@master"
- uses: "actions/setup-java@master"
with:
distribution: "adopt"
java-version: "11"
- uses: "actions/cache@master"
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- 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 }}"
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: "Release"
"on":
release:
types:
- "released"
jobs:
build:
name: "Release"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@master"
- uses: "actions/setup-java@master"
with:
distribution: "adopt"
java-version: "11"
- uses: "actions/cache@master"
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- 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/
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
# frame
An inventory framework for Minecraft.
[![Maven Central Version](https://img.shields.io/maven-central/v/net.infumia/frame)](https://central.sonatype.com/artifact/net.infumia/frame)
## How to Use (Developers)
### Gradle
```groovy
repositories {
mavenCentral()
}
dependencies {
// Base module
implementation "net.infumia:frame:VERSION"
}
```
### 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.applySpotless

plugins { java }

subprojects { apply<JavaPlugin>() }

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

repositories {
mavenCentral()
gradlePluginPortal()
}

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

kotlin {
jvmToolchain {
languageVersion = JavaLanguageVersion.of(11)
vendor = JvmVendorSpec.ADOPTIUM
}
}
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")) } }
}
21 changes: 21 additions & 0 deletions buildSrc/src/main/kotlin/net/infumia/gradle/java.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package net.infumia.gradle

import org.gradle.api.Project
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.jvm.toolchain.JvmVendorSpec
import org.gradle.kotlin.dsl.*

fun Project.applyJava(javaVersion: Int = 8) {
apply<JavaPlugin>()

repositories.mavenCentral()

extensions.configure<JavaPluginExtension> {
toolchain {
languageVersion = JavaLanguageVersion.of(javaVersion)
vendor = JvmVendorSpec.ADOPTIUM
}
}
}
59 changes: 59 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,59 @@
package net.infumia.gradle

import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.MavenPublishPlugin
import com.vanniktech.maven.publish.SonatypeHost
import com.vanniktech.maven.publish.tasks.JavadocJar
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.*

fun Project.applyPublish(moduleName: String? = null, javaVersion: Int = 8) {
applyJava(javaVersion)
apply<MavenPublishPlugin>()

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

val sourceSets = extensions.getByType<JavaPluginExtension>().sourceSets
tasks.register("sourcesJar", Jar::class) {
dependsOn("classes")
archiveClassifier = "sources"
from(sourceSets["main"].allSource)
}

tasks.withType<JavadocJar> { afterEvaluate { archiveBaseName = name } }

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

pom {
name = projectName
description = "An inventory framework for Minecraft."
url = "https://github.com/Infumia/frame"
licenses {
license {
name = "MIT License"
url = "https://mit-license.org/license.txt"
}
}
developers {
developer {
id = "portlek"
name = "Hasan Demirtaş"
email = "[email protected]"
}
}
scm {
connection = "scm:git:git://github.com/infumia/frame.git"
developerConnection = "scm:git:ssh://github.com/infumia/frame.git"
url = "https://github.com/infumia/frame/"
}
}
}
}
92 changes: 92 additions & 0 deletions buildSrc/src/main/kotlin/net/infumia/gradle/spotless.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package net.infumia.gradle

import com.diffplug.gradle.spotless.SpotlessExtension
import com.diffplug.gradle.spotless.SpotlessPlugin
import com.diffplug.spotless.LineEnding
import org.gradle.api.Project
import org.gradle.kotlin.dsl.*

fun Project.applySpotless() {
val subProjects = subprojects.map { it.projectDir.toRelativeString(projectDir) }

repositories.mavenCentral()

apply<SpotlessPlugin>()

extensions.configure<SpotlessExtension> {
isEnforceCheck = false
lineEndings = LineEnding.UNIX

val prettierConfig =
mapOf(
"prettier" to "3.3.2",
"prettier-plugin-java" to "2.6.0",
"prettier-plugin-toml" to "2.0.1",
)

yaml {
target(".github/**/*.yml")
endWithNewline()
trimTrailingWhitespace()
jackson().yamlFeature("LITERAL_BLOCK_STYLE", true).yamlFeature("SPLIT_LINES", false)
}

json {
target("renovate.json")
endWithNewline()
trimTrailingWhitespace()
jackson()
}

format("toml") {
target("gradle/libs.versions.toml")
endWithNewline()
trimTrailingWhitespace()
prettier(prettierConfig)
.config(
mapOf(
"parser" to "toml",
"plugins" to listOf("prettier-plugin-toml"),
),
)
}

kotlin {
target(
"buildSrc/src/main/kotlin/**/*.kt",
"buildSrc/**/*.gradle.kts",
"*.gradle.kts",
*subProjects.map { "$it/*.gradle.kts" }.toTypedArray(),
*subProjects.map { "$it/src/main/kotlin/**/*.kt" }.toTypedArray(),
)
endWithNewline()
trimTrailingWhitespace()
ktfmt().kotlinlangStyle().configure {
it.setMaxWidth(100)
it.setBlockIndent(4)
it.setContinuationIndent(4)
it.setRemoveUnusedImport(true)
}
}

java {
target(
*subProjects.map { "$it/src/main/java/**/*.java" }.toTypedArray(),
)
importOrder()
removeUnusedImports()
endWithNewline()
trimTrailingWhitespace()
prettier(prettierConfig)
.config(
mapOf(
"parser" to "java",
"tabWidth" to 4,
"useTabs" to false,
"printWidth" to 100,
"plugins" to listOf("prettier-plugin-java"),
),
)
}
}
}
3 changes: 3 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import net.infumia.gradle.applyPublish

applyPublish()
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name=frame
group=net.infumia
version=1.0.0-SNAPSHOT

org.gradle.parallel=true
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[libraries]
nexus-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.29.0" }
spotless-plugin = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "6.25.0" }
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading

0 comments on commit 3090fdc

Please sign in to comment.