-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
213 lines (182 loc) · 5.6 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
// Gradle plugins
buildscript {
repositories {
maven {
url = 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
url = 'https://dl.bintray.com/lanternpowered/maven/'
}
}
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.4.0'
classpath 'org.lanternpowered:lanterngradle:1.0.0'
}
}
plugins {
id "com.github.hierynomus.license" version "0.13.1"
id "com.github.johnrengelman.shadow" version "1.2.3"
}
// Environment variables for the build set by the build server
ext {
if (!project.hasProperty('artifactory_contextUrl')) artifactory_contextUrl = System.getenv('artifactory_contextUrl')
if (!project.hasProperty('artifactory_username')) artifactory_username = System.getenv('artifactory_username')
if (!project.hasProperty('artifactory_password')) artifactory_password = System.getenv('artifactory_password')
buildNumber = System.env.BUILD_NUMBER ?: System.env.TRAVIS_BUILD_NUMBER ?: '0'
ciSystem = System.env.CI_SYSTEM ?: (System.env.TRAVIS ? 'travis' : null)
commit = System.env.GIT_COMMIT ?: System.env.TRAVIS_COMMIT
branch = System.env.GIT_BRANCH ?: System.env.TRAVIS_BRANCH
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'com.github.hierynomus.license'
apply plugin: 'org.lanternpowered.gradle'
apply plugin: 'org.lanternpowered.run-configs'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
group = 'org.lanternpowered'
archivesBaseName = project.name.toLowerCase()
version = '1.0.1-SNAPSHOT'
ext.runFolder = 'run'
ext.mainClass = 'org.lanternpowered.pingy.Pingy'
repositories {
mavenCentral()
}
configurations {
netty
compile {
extendsFrom netty
}
}
dependencies {
compile group: 'com.google.code.gson', name: 'gson', version: '2.6.2'
netty group: 'io.netty', name: 'netty-all', version: '4.1.1.Final'
}
runConfigurations {
theConfig {
name = 'Pingy Server'
mainClass = project.mainClass
workingDirectory = 'run'
programArguments = '--debug'
}
}
jar {
classifier = 'base'
manifest {
attributes(
'Main-Class': mainClass
)
}
}
processResources {
from 'LICENSE.txt'
}
// A separate task to generate the netty jar,
// doing this separate to avoid long wait times
// Run "nettyJar" to update the jar
task nettyJar(type: ShadowJar) {
// The classifier
classifier = 'netty'
// Exclude empty directories
includeEmptyDirs = false
// Include all the netty classes into the process
from zipTree(project.configurations.netty.first())
// Include all the project files to check
from sourceSets.main.output
// Loop through the files and check for the files which
// should be included in the final jar
transform(DependencyClassTransformer) {
// Check only the netty path for dependencies
dependencyFiles.include 'io/netty/**'
// Just scan all the pingy files
filesToScan.include 'org/lanternpowered/pingy/**'
}
}
// Sadly enough does the "overwrite: true" parameter not work,
// so this task will delete the jar before running nettyJar
task deleteNettyJar(type: Delete) {
delete project.nettyJar.archivePath
}
nettyJar.dependsOn deleteNettyJar
shadowJar {
dependsOn nettyJar
// Empty classifier, this is the final jar
classifier = ''
// Exclude empty directories
includeEmptyDirs = false
// Make sure that the jar is generated
afterEvaluate {
// Include the netty classes
from zipTree(project.nettyJar.archivePath)
}
dependencies {
include dependency('com.google.code.gson:gson')
}
exclude 'LICENSE', 'NOTICE'
}
task sourceJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
assemble.dependsOn shadowJar
assemble.dependsOn sourceJar
if (artifactory_contextUrl && artifactory_username && artifactory_password) {
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
publishing {
publications {
thePublication(MavenPublication) {
artifact shadowJar
artifact sourceJar
artifactId archivesBaseName
}
}
}
artifactory {
contextUrl = artifactory_contextUrl
publish {
repository {
repoKey = project.version.contains("SNAPSHOT") ? 'libs-snapshot-local' : 'libs-release-local'
username = artifactory_username
password = artifactory_password
maven = true
}
defaults {
publications('thePublication')
publishArtifacts = true
}
}
resolve {
repository {
repoKey = 'repo'
username = artifactory_username
password = artifactory_password
maven = true
}
}
}
clientConfig.setIncludeEnvVars(true)
clientConfig.info.setBuildNumber(buildNumber)
if (ciSystem) clientConfig.info.addEnvironmentProperty('ci-system', ciSystem)
}
license {
header rootProject.file('HEADER.txt')
sourceSets = project.sourceSets
include '**/*.java'
strictCheck true
ignoreFailures = false
ext {
name = project.name
url = project.url
organization = project.organization
}
mapping {
java = 'SLASHSTAR_STYLE'
}
}
// Gradle version used for generating the Gradle wrapper
task wrapper(type: Wrapper) {
gradleVersion = '2.14.1'
}