Skip to content

Commit dcc5be3

Browse files
committed
Setup build
1 parent 6722369 commit dcc5be3

34 files changed

Lines changed: 1041 additions & 36 deletions
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!DOCTYPE suppressions PUBLIC
3+
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
4+
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
5+
<suppressions>
6+
<suppress checks="(?:(?:Member|Method)Name|DesignForExtension|Javadoc.*)" files=".*[\\/]mixin[\\/].*"/>
7+
<suppress checks="(?:Javadoc.*)" files=".*[\\/]bukkit[\\/]internal[\\/].*"/>
8+
<suppress checks="(?:Javadoc.*)" files=".*[\\/]example-.*[\\/].*"/>
9+
</suppressions>

.checkstyle/checkstyle.xml

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
~
4+
~ MIT License
5+
~
6+
~ Copyright (c) 2024 Incendo
7+
~
8+
~ Permission is hereby granted, free of charge, to any person obtaining a copy
9+
~ of this software and associated documentation files (the "Software"), to deal
10+
~ in the Software without restriction, including without limitation the rights
11+
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
~ copies of the Software, and to permit persons to whom the Software is
13+
~ furnished to do so, subject to the following conditions:
14+
~
15+
~ The above copyright notice and this permission notice shall be included in all
16+
~ copies or substantial portions of the Software.
17+
~
18+
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
~ SOFTWARE.
25+
~
26+
-->
27+
28+
<!DOCTYPE module PUBLIC
29+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
30+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
31+
32+
<!--
33+
34+
Checkstyle configuration that checks the sun coding conventions from:
35+
36+
- the Java Language Specification at
37+
https://docs.oracle.com/javase/specs/jls/se11/html/index.html
38+
39+
- the Sun Code Conventions at https://www.oracle.com/java/technologies/javase/codeconventions-contents.html
40+
41+
- the Javadoc guidelines at
42+
https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html
43+
44+
- the JDK Api documentation https://docs.oracle.com/en/java/javase/11/
45+
46+
- some best practices
47+
48+
Checkstyle is very configurable. Be sure to read the documentation at
49+
https://checkstyle.org (or in your downloaded distribution).
50+
51+
Most Checks are configurable, be sure to consult the documentation.
52+
53+
To completely disable a check, just comment it out or delete it from the file.
54+
To suppress certain violations please review suppression filters.
55+
56+
Finally, it is worth reading the documentation.
57+
58+
-->
59+
60+
<module name="Checker">
61+
62+
<!--
63+
If you set the basedir property below, then all reported file
64+
names will be relative to the specified directory. See
65+
https://checkstyle.org/config.html#Checker
66+
67+
<property name="basedir" value="${basedir}"/>
68+
-->
69+
<property name="severity" value="error"/>
70+
71+
<property name="fileExtensions" value="java, properties"/>
72+
73+
<!-- Excludes all 'module-info.java' files -->
74+
<!-- See https://checkstyle.org/config_filefilters.html -->
75+
<module name="BeforeExecutionExclusionFileFilter">
76+
<property name="fileNamePattern" value="module\-info\.java$"/>
77+
</module>
78+
79+
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
80+
<module name="SuppressionFilter">
81+
<property name="file" value="${config_loc}/checkstyle-suppressions.xml"/>
82+
<property name="optional" value="false"/>
83+
</module>
84+
85+
<!-- Checks that a package-info.java file exists for each package. -->
86+
<!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage -->
87+
<module name="JavadocPackage"/>
88+
89+
<!-- Checks whether files end with a new line. -->
90+
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
91+
<module name="NewlineAtEndOfFile"/>
92+
93+
<!-- Checks that property files contain the same keys. -->
94+
<!-- See https://checkstyle.org/config_misc.html#Translation -->
95+
<module name="Translation"/>
96+
97+
<!-- Checks for Size Violations. -->
98+
<!-- See https://checkstyle.org/config_sizes.html -->
99+
<module name="LineLength">
100+
<property name="fileExtensions" value="java"/>
101+
<property name="max" value="140"/>
102+
<property name="ignorePattern" value="^ *\* "/> <!-- Ignore long JavaDoc lines (i.e. a link) -->
103+
</module>
104+
105+
<!-- Checks for whitespace -->
106+
<!-- See https://checkstyle.org/config_whitespace.html -->
107+
<module name="FileTabCharacter"/>
108+
109+
<!-- Miscellaneous other checks. -->
110+
<!-- See https://checkstyle.org/config_misc.html -->
111+
<module name="RegexpSingleline">
112+
<property name="format" value="\s+$"/>
113+
<property name="minimum" value="0"/>
114+
<property name="maximum" value="0"/>
115+
<property name="message" value="Line has trailing spaces."/>
116+
</module>
117+
118+
<!-- Checks for Headers -->
119+
<!-- See https://checkstyle.org/config_header.html -->
120+
<!-- <module name="Header"> -->
121+
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
122+
<!-- <property name="fileExtensions" value="java"/> -->
123+
<!-- </module> -->
124+
125+
<module name="TreeWalker">
126+
127+
<!-- Checks for Javadoc comments. -->
128+
<!-- See https://checkstyle.org/config_javadoc.html -->
129+
<module name="InvalidJavadocPosition"/>
130+
<module name="JavadocMethod"/>
131+
<module name="JavadocType"/>
132+
<module name="JavadocStyle">
133+
<property name="checkFirstSentence" value="false"/>
134+
</module>
135+
<module name="MissingJavadocMethod"/>
136+
137+
<!-- Checks for Naming Conventions. -->
138+
<!-- See https://checkstyle.org/config_naming.html -->
139+
<module name="ConstantName"/>
140+
<module name="LocalFinalVariableName"/>
141+
<module name="LocalVariableName"/>
142+
<module name="MemberName"/>
143+
<module name="MethodName"/>
144+
<module name="PackageName"/>
145+
<module name="ParameterName"/>
146+
<module name="StaticVariableName"/>
147+
<module name="TypeName"/>
148+
149+
<!-- Checks for imports -->
150+
<!-- See https://checkstyle.org/config_imports.html -->
151+
<module name="AvoidStarImport"/>
152+
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
153+
<module name="RedundantImport"/>
154+
<module name="UnusedImports">
155+
<property name="processJavadoc" value="true"/>
156+
</module>
157+
158+
<!-- https://checkstyle.org/config_imports.html#CustomImportOrder -->
159+
<module name="CustomImportOrder">
160+
<property name="customImportOrderRules" value="THIRD_PARTY_PACKAGE###STATIC"/>
161+
<property name="standardPackageRegExp" value="^$"/>
162+
<property name="sortImportsInGroupAlphabetically" value="true"/>
163+
</module>
164+
165+
<!-- Checks for whitespace -->
166+
<!-- See https://checkstyle.org/config_whitespace.html -->
167+
<module name="EmptyForIteratorPad"/>
168+
<module name="GenericWhitespace"/>
169+
<module name="MethodParamPad"/>
170+
<module name="NoWhitespaceAfter"/>
171+
<module name="NoWhitespaceBefore"/>
172+
<module name="OperatorWrap"/>
173+
<module name="ParenPad"/>
174+
<module name="TypecastParenPad"/>
175+
<module name="WhitespaceAfter"/>
176+
177+
<!-- Modifier Checks -->
178+
<!-- See https://checkstyle.org/config_modifiers.html -->
179+
<module name="ModifierOrder"/>
180+
<module name="RedundantModifier"/>
181+
182+
<!-- Checks for blocks. You know, those {}'s -->
183+
<!-- See https://checkstyle.org/config_blocks.html -->
184+
<module name="AvoidNestedBlocks"/>
185+
<module name="EmptyBlock"/>
186+
<module name="LeftCurly"/>
187+
<module name="NeedBraces"/>
188+
<module name="RightCurly"/>
189+
190+
<!-- Checks for common coding problems -->
191+
<!-- See https://checkstyle.org/config_coding.html -->
192+
<module name="EmptyStatement"/>
193+
<module name="EqualsHashCode"/>
194+
<module name="IllegalInstantiation"/>
195+
<module name="InnerAssignment"/>
196+
<module name="MissingSwitchDefault"/>
197+
<module name="MultipleVariableDeclarations"/>
198+
<module name="SimplifyBooleanExpression"/>
199+
<module name="SimplifyBooleanReturn"/>
200+
201+
<!-- Checks for class design -->
202+
<!-- See https://checkstyle.org/config_design.html -->
203+
<module name="DesignForExtension"/>
204+
<module name="FinalClass"/>
205+
<module name="HideUtilityClassConstructor"/>
206+
<module name="InterfaceIsType"/>
207+
<module name="VisibilityModifier"/>
208+
209+
<!-- Miscellaneous other checks. -->
210+
<!-- See https://checkstyle.org/config_misc.html -->
211+
<module name="ArrayTypeStyle"/>
212+
<module name="FinalParameters"/>
213+
<module name="TodoComment"/>
214+
<module name="UpperEll"/>
215+
216+
<module name="RequireThis">
217+
<property name="validateOnlyOverlapping" value="false"/>
218+
</module>
219+
220+
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
221+
<module name="SuppressionXpathFilter">
222+
<property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}"
223+
default="checkstyle-xpath-suppressions.xml"/>
224+
<property name="optional" value="true"/>
225+
</module>
226+
227+
<!-- https://gitlab.com/stellardrift/stylecheck/-/blob/trunk/src/main/java/ca/stellardrift/stylecheck/AnnotationsCloseToType.java -->
228+
<module name="AnnotationsCloseToType"/>
229+
230+
<!-- Make the @SuppressWarnings annotations available to Checkstyle -->
231+
<module name="SuppressWarningsHolder" />
232+
233+
</module>
234+
235+
<module name="SuppressWarningsFilter" />
236+
237+
</module>

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_size = 4
6+
indent_style = space
7+
insert_final_newline = true
8+
max_line_length = off

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+

.github/workflows/build.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Build
2+
on:
3+
push:
4+
branches: [ "**" ]
5+
tags-ignore: [ "**" ]
6+
pull_request:
7+
release:
8+
types: [ released ]
9+
jobs:
10+
build:
11+
# Only run on PRs if the source branch is on someone else's repo
12+
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
13+
runs-on: "ubuntu-latest"
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: gradle/wrapper-validation-action@v1
17+
- name: Set up JDK
18+
uses: actions/setup-java@v3
19+
with:
20+
distribution: 'temurin'
21+
java-version: 17
22+
- uses: gradle/gradle-build-action@v2
23+
- name: Build
24+
run: ./gradlew build
25+
- name: Determine Status
26+
run: |
27+
if [ "$(./gradlew properties | awk '/^version:/ { print $2; }' | grep '\-SNAPSHOT')" ]; then
28+
echo "STATUS=snapshot" >> $GITHUB_ENV
29+
else
30+
echo "STATUS=release" >> $GITHUB_ENV
31+
fi
32+
- name: Publish Snapshot
33+
if: "${{ env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/master' }}"
34+
run: ./gradlew publish
35+
env:
36+
ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SONATYPE_USERNAME }}"
37+
ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SONATYPE_PASSWORD }}"
38+
- name: Publish Release
39+
if: "${{ env.STATUS == 'release' && github.event_name == 'release' }}"
40+
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
41+
env:
42+
ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SONATYPE_USERNAME }}"
43+
ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SONATYPE_PASSWORD }}"
44+
ORG_GRADLE_PROJECT_signingKey: "${{ secrets.SIGNING_KEY }}"
45+
ORG_GRADLE_PROJECT_signingPassword: "${{ secrets.SIGNING_PASSWORD }}"

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# Ignore Gradle build output directory
5+
build
6+
7+
.idea/
8+
9+
run/

.spotless/cloud.importorder

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Cloud import order
2+
0=
3+
1=\#

HEADER

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// MIT License
3+
//
4+
// Copyright (c) 2024 Incendo
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in all
14+
// copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
// SOFTWARE.
23+
//

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Incendo
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
plugins {
2+
alias(libs.plugins.cloud.buildLogic.rootProject.publishing)
3+
alias(libs.plugins.cloud.buildLogic.rootProject.spotless)
4+
}
5+
6+
spotlessPredeclare {
7+
kotlin { ktlint(libs.versions.ktlint.get()) }
8+
kotlinGradle { ktlint(libs.versions.ktlint.get()) }
9+
}
10+
11+
tasks {
12+
spotlessCheck {
13+
dependsOn(gradle.includedBuild("build-logic").task(":spotlessCheck"))
14+
}
15+
spotlessApply {
16+
dependsOn(gradle.includedBuild("build-logic").task(":spotlessApply"))
17+
}
18+
}

0 commit comments

Comments
 (0)