-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
162 lines (131 loc) · 4.39 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
// Basics
plugins {
// Apply the java-library plugin for API and implementation separation.
id 'java-library'
// For publishing to Maven Central, we'll probably want these.
id 'maven-publish'
id 'signing'
}
apply from: 'examples.gradle'
group('io.github.lucasstarsz.slopeecs')
version('0.1.0')
repositories {
mavenCentral()
}
dependencies {
// Use JUnit test framework.
testImplementation 'junit:junit:4.13'
}
// Source
sourceSets {
examples {
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}
// Build
java {
withSourcesJar()
withJavadocJar()
}
jar {
manifest {
attributes(
'Implementation-Title': 'slope-ecs',
'Implementation-Version': project.version,
'Module-Name': 'slope.ecs'
)
}
}
javadoc {
source(sourceSets.main.allJava)
failOnError(false)
// use custom stylesheet
options.stylesheetFile(new File(projectDir, "src/main/javadoc/slope-custom.css"))
options.links = [
// resolve links to Java javadocs
'https://docs.oracle.com/en/java/javase/15/docs/api/'
]
}
artifacts {
archives javadocJar, sourcesJar
}
/* 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
}
}
// Testing
import org.gradle.api.internal.tasks.testing.results.DefaultTestResult
tasks.withType(Test) {
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 output = "Test Suite Results: $result.resultType ($result.testCount tests, $passFailSkip) in $totalTestTime ms."
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength) + '\n')
if (("${result.resultType}" != "SUCCESS")) {
System.exit(0)
}
}
}
}
}
// Publishing
def shouldPublish = System.getenv('ossrhUsername') != null && System.getenv('ossrhPassword') != null
publish.onlyIf { shouldPublish }
if (shouldPublish) {
publishing {
publications {
slopePublish(MavenPublication) {
groupId = project.group
artifactId = 'slope-ecs'
version = project.version
pom {
name = 'Slope ECS'
description = 'An Entity Component System written in Java.'
url = 'https://github.com/lucasstarsz/Slope-ECS'
scm {
connection = 'scm:git:https://github.com/lucasstarsz/Slope-ECS.git'
developerConnection = 'scm:git:https://github.com/lucasstarsz/Slope-ECS.git'
url = 'https://github.com/lucasstarsz/Slope-ECS.git'
}
licenses {
license {
name = 'MIT License'
url = 'https://github.com/lucasstarsz/Slope-ECS/blob/main/LICENSE.txt'
}
}
developers {
developer {
id = 'andrewd'
name = 'Andrew Dey'
email = '[email protected]'
}
}
}
from components.java
}
}
repositories {
maven {
url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
credentials {
username = System.getenv('ossrhUsername')
password = System.getenv('ossrhPassword')
}
}
}
}
signing {
sign publishing.publications.slopePublish
}
}