Merge pull request #1484 from Birdulon/development

Automatic whitespace formatting
This commit is contained in:
Luke H-W 2022-07-11 17:18:24 +09:30 committed by GitHub
commit a1f1af5934
3 changed files with 83 additions and 7 deletions

View File

@ -6,7 +6,6 @@ on:
- "**.java" - "**.java"
branches: branches:
- "stable" - "stable"
- "development"
pull_request: pull_request:
paths: paths:
- "**.java" - "**.java"

48
.github/workflows/build_lint.yml vendored Normal file
View File

@ -0,0 +1,48 @@
name: "Lint and Build"
on:
workflow_dispatch: ~
push:
paths:
- "**.java"
branches:
- "development"
jobs:
Build-Server-Jar:
runs-on: ubuntu-latest
steps:
- name: Checkout LintRatchet
uses: actions/checkout@v2
with:
ref: LintRatchet
- name: Checkout branch
uses: actions/checkout@v2
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: '17'
- name: Cache gradle files
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
./.gradle/loom-cache
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle', 'gradle.properties', '**/*.accesswidener') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run Spotless
run: ./gradlew spotlessApply
- name: Run Gradle
run: ./gradlew && ./gradlew jar
- name: Upload build
uses: actions/upload-artifact@v3
with:
name: Grasscutter
path: grasscutter-*.jar
- name: Commit any Spotless changes
uses: EndBug/add-and-commit@v9
with:
add: '-u'
default_author: github_actions
message: 'Fix whitespace'

View File

@ -34,6 +34,9 @@ plugins {
// Maven // Maven
id 'maven-publish' id 'maven-publish'
id 'signing' id 'signing'
// Spotless formatter
id "com.diffplug.spotless" version "6.8.0"
} }
compileJava.options.encoding = "UTF-8" compileJava.options.encoding = "UTF-8"
@ -103,7 +106,7 @@ configurations.all {
application { application {
// Define the main class for the application // Define the main class for the application
mainClassName = 'emu.grasscutter.Grasscutter' getMainClass().set('emu.grasscutter.Grasscutter')
} }
@ -112,8 +115,10 @@ jar {
attributes 'Main-Class': 'emu.grasscutter.Grasscutter' attributes 'Main-Class': 'emu.grasscutter.Grasscutter'
} }
jar.baseName = 'grasscutter' archiveBaseName = 'grasscutter'
jar.archiveName = project.hasProperty('jarFilename') ? "${jarFilename}.${extension}" : archiveName if (project.hasProperty('jarFilename')) {
archiveFileName = "${jarFilename}.${extension}"
}
from { from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
@ -125,7 +130,7 @@ jar {
include '*.xml' include '*.xml'
} }
destinationDir = file(".") destinationDirectory = file(".")
} }
publishing { publishing {
@ -236,6 +241,30 @@ eclipse {
} }
} }
spotless {
// optional: limit format enforcement to just the files changed by this feature branch
ratchetFrom 'LintRatchet'
format 'misc', {
// define the files to apply `misc` to
target '*.gradle', '*.md', '.gitignore'
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces() // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
}
java {
// don't need to set target, it is inferred from java
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces() // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
replaceRegex('Force one space between if/etc. and ( or {', '(?<=\\b(?:if|for|while|switch|try|else|catch|finally|synchronized)) *(?=[\\(\\{])', ' ')
replaceRegex('Force one space between ) and {', '\\) *\\{(?!\\})', ') {')
}
}
signing { signing {
if(!version.endsWith('-dev')) { if(!version.endsWith('-dev')) {
sign publishing.publications.mavenJava sign publishing.publications.mavenJava