-
Notifications
You must be signed in to change notification settings - Fork 22
/
build.gradle
197 lines (154 loc) · 5.87 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
plugins {
// it's a java library. What did you expect?
id 'java-library'
// For Sonarcloud code coverage testing, these are useful.
id 'org.sonarqube' version '3.3'
id 'jacoco'
// For publishing to Maven Central, we'll want these.
id 'maven-publish'
id 'signing'
// To be able to use Spotless in the project, this will be needed.
id "com.diffplug.spotless" version "6.9.0"
}
group('io.github.lucasstarsz.fastj')
version('1.7.0-SNAPSHOT-2')
description('An open source, Java-based 2D game engine.')
import org.gradle.api.internal.tasks.testing.results.DefaultTestResult
/* ********************* *
* General Configuration *
* ********************* */
sourceCompatibility = 18
targetCompatibility = 18
java.withSourcesJar()
java.withJavadocJar()
javadoc.source(sourceSets.main.allJava)
javadoc.failOnError(false)
javadoc.options.links = ['https://docs.oracle.com/en/java/javase/18/docs/api/', 'https://www.slf4j.org/apidocs/']
javadoc.options.stylesheetFile = file("${projectDir}/src/fastjstyle.css")
javadoc.doLast {
copy {
from "${projectDir}"
into "${projectDir}/build/docs/javadoc"
include "src/jquery-ui.overrides.css"
}
}
sourcesJar.from(sourceSets.main.allSource)
javadocJar.from(javadoc.destinationDir)
artifacts.archives(sourcesJar)
artifacts.archives(javadocJar)
// Java modules need this in order for the module path to be inferred based on module-info.java files.
plugins.withType(JavaPlugin).configureEach {
java.modularity.inferModulePath = true
}
wrapper.gradleVersion = '7.5.1'
wrapper.distributionType = Wrapper.DistributionType.ALL
repositories.mavenCentral()
dependencies.api('org.slf4j:slf4j-api:2.0.0-beta1')
dependencies.api('com.googlecode.soundlibs:mp3spi:1.9.5.4')
dependencies.api('com.googlecode.soundlibs:jorbis:0.0.17.4')
dependencies.api('com.googlecode.soundlibs:tritonus-share:0.3.7.4')
dependencies.api('com.googlecode.soundlibs:vorbisspi:1.0.3.3')
dependencies.testImplementation('org.slf4j:slf4j-simple:2.0.0-alpha7')
dependencies.testImplementation(dependencies.platform('org.junit:junit-bom:5.8.2'))
dependencies.testImplementation('org.junit.jupiter:junit-jupiter:5.8.2')
dependencies.testRuntimeOnly("org.junit.platform:junit-platform-launcher")
/* ********************* *
* Unit Testing *
* ********************* */
tasks.withType(Test) {
useJUnitPlatform()
testLogging {
def totalTestTime = 0
afterTest { desc, DefaultTestResult result ->
totalTestTime += result.endTime - result.startTime
}
afterSuite { desc, DefaultTestResult result ->
if (!desc.parent) { // will match the outermost suite
def passFailSkip = "$result.successfulTestCount passed, $result.failedTestCount failed, $result.skippedTestCount skipped"
def results = "Test Suite Results: $result.resultType ($result.testCount tests, $passFailSkip) in $totalTestTime ms."
def startItem = '| '
def endItem = ' |'
def repeatLength = startItem.length() + results.length() + endItem.length()
def dashes = '-' * repeatLength
logger.info(String.format('%n%n%s%n%s%s%s%n%s%n%n', dashes, startItem, results, endItem, dashes))
}
}
}
}
/* ************************* *
* Spotless Integration *
* ************************* */
spotless {
java {
trimTrailingWhitespace()
importOrder(
'tech.fastj',
'java',
'javax',
'',
'\\#'
)
removeUnusedImports()
}
}
/* ********************* *
* Code Coverage *
* ********************* */
sonarqube.properties {
property 'sonar.projectKey', 'fastjengine_FastJ'
property 'sonar.organization', 'fastjengine'
property 'sonar.host.url', 'https://sonarcloud.io'
property 'sonar.exclusions', ['examples/**']
}
jacocoTestReport {
dependsOn(test) // tests are required to run before generating the report
reports.xml.required.set(true)
reports.csv.required.set(false)
reports.xml.destination(layout.buildDirectory.dir('build/reports/jacoco/test/jacocoTestReport.xml').get().asFile)
}
/* ********************* *
* Publishing *
* ********************* */
def shouldPublish = System.getenv('ossrhUsername') != null && System.getenv('ossrhPassword') != null
publish.onlyIf { shouldPublish }
if (shouldPublish) {
publishing.publications {
fastjPublish(MavenPublication) {
groupId = project.group
version = project.version
artifactId = 'fastj-library'
pom {
name = 'FastJ Game Library'
description = project.description
url = 'https://github.com/fastjengine/FastJ'
scm {
connection = 'scm:git:https://github.com/fastjengine/FastJ.git'
developerConnection = 'scm:git:https://github.com/fastjengine/FastJ.git'
url = 'https://fastj.tech'
}
licenses {
license {
name = 'MIT License'
url = 'https://github.com/fastjengine/FastJ/blob/main/LICENSE.txt'
}
}
developers {
developer {
id = 'andrewd'
name = 'Andrew Dey'
email = '[email protected]'
}
}
}
from(components.java)
}
}
publishing.repositories.maven {
url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
credentials.username = System.getenv('ossrhUsername')
credentials.password = System.getenv('ossrhPassword')
}
signing {
sign publishing.publications.fastjPublish
}
}