-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
175 lines (148 loc) · 6.11 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
buildscript {
dependencies {
classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.0.0"
}
}
plugins {
id "com.jfrog.artifactory" version "3.1.1"
id "java-library"
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'com.github.spotbugs'
apply plugin: 'maven-publish'
apply plugin: 'java-library'
group = 'org.terasology'
archivesBaseName = 'splash-screen' // for local jar files
tasks.compileJava {
java.sourceCompatibility JavaVersion.VERSION_1_8
java.targetCompatibility JavaVersion.VERSION_1_8
}
// We use both Maven Central and our own Artifactory instance, which contains module builds, extra libs, and so on
repositories {
mavenCentral()
maven {
def repoViaEnv = System.getenv()["RESOLUTION_REPO"]
if (rootProject.hasProperty("alternativeResolutionRepo")) {
// If the user supplies an alternative repo via gradle.properties then use that
name "from alternativeResolutionRepo property"
url alternativeResolutionRepo
} else if (repoViaEnv != null && repoViaEnv != "") {
name "from \$RESOLUTION_REPO"
url = repoViaEnv
} else {
// Our default is the main virtual repo containing everything except repos for testing Artifactory itself
name "Terasology Artifactory"
url "http://artifactory.terasology.org/artifactory/virtual-repo-live"
allowInsecureProtocol true // 😱
}
}
}
configurations {
codeMetrics
}
dependencies {
codeMetrics(group: 'org.terasology.config', name: 'codemetrics', version: '1.4.0', ext: 'zip')
// GLFW splash screen
implementation platform("org.lwjgl:lwjgl-bom:3.2.3")
implementation 'org.lwjgl:lwjgl'
implementation 'org.lwjgl:lwjgl-opengl'
implementation 'org.lwjgl:lwjgl-glfw'
implementation group: 'de.matthiasmann.twl', name: 'PNGDecoder', version: '1111'
implementation group: 'org.joml', name: 'joml', version: '1.9.25'
testImplementation group: 'junit', name: 'junit', version: '4.12'
//testRuntime group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.3'
}
task sourceJar(type: Jar) {
description = "Create a JAR with all sources"
from sourceSets.main.allSource
archiveClassifier = 'sources'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
description = "Create a JAR with the JavaDoc for the java sources"
from javadoc.destinationDir
archiveClassifier = 'javadoc'
}
// Define the artifacts we want to publish (the .pom will also be included since the Maven plugin is active)
artifacts {
archives sourceJar
archives javadocJar
}
javadoc {
failOnError = false
}
checkstyle {
ignoreFailures = true
config = resources.text.fromArchiveEntry(configurations.codeMetrics, "checkstyle/checkstyle.xml")
// this assigns the property variable ${samedir} in checkstyle.xml
configProperties.samedir = config.asFile().parent
}
configure([checkstyleMain, checkstyleTest]) {
doFirst {
def suppressions = resources.text.fromArchiveEntry(configurations.codeMetrics, "checkstyle/suppressions.xml")
// the asFile() method extracts the file from the zip archive and puts it next to checkstyle.xml
// this procedure should not be done in the config phase, since the clean task would erase the file before it can be used
suppressions.asFile()
}
}
pmd {
ignoreFailures = true
ruleSetConfig = resources.text.fromArchiveEntry(configurations.codeMetrics, "pmd/pmd.xml")
ruleSets = []
}
spotbugs {
ignoreFailures = true
effort = 'max'
reportLevel = 'medium'
toolVersion = '4.0.0'
excludeFilter = new File(rootDir, "config/metrics/findbugs/findbugs-exclude.xml")
}
publishing {
publications {
"$project.name"(MavenPublication) {
// Without this we get a .pom with no dependencies
from components.java
artifact source: sourceJar, classifier: 'sources'
artifact source: javadocJar, classifier: 'javadoc'
repositories {
maven {
name = 'TerasologyOrg'
if (rootProject.hasProperty("publishRepo")) {
// This first option is good for local testing, you can set a full explicit target repo in gradle.properties
url = "http://artifactory.terasology.org/artifactory/$publishRepo"
allowInsecureProtocol true // 😱
logger.info("Changing PUBLISH repoKey set via Gradle property to {}", publishRepo)
} else {
// Support override from the environment to use a different target publish org
String deducedPublishRepo = System.getenv()["PUBLISH_ORG"]
if (deducedPublishRepo == null || deducedPublishRepo == "") {
// If not then default
deducedPublishRepo = "terasology"
}
// Base final publish repo on whether we're building a snapshot or a release
if (project.version.endsWith('SNAPSHOT')) {
deducedPublishRepo += "-snapshot-local"
} else {
deducedPublishRepo += "-release-local"
}
logger.info("The final deduced publish repo is {}", deducedPublishRepo)
url = "http://artifactory.terasology.org/artifactory/$deducedPublishRepo"
allowInsecureProtocol true
}
if (rootProject.hasProperty("mavenUser") && rootProject.hasProperty("mavenPass")) {
credentials {
username = "$mavenUser"
password = "$mavenPass"
}
authentication {
basic(BasicAuthentication)
}
}
}
}
}
}
}