-
Notifications
You must be signed in to change notification settings - Fork 50
/
build.gradle
253 lines (218 loc) · 7.26 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/*
* Gradle build file for RR - Railroad Diagram Generator.
*/
plugins {
id 'java'
id 'war'
id 'com.github.jk1.dependency-license-report' version '2.5'
id 'maven-publish'
id 'signing'
}
defaultTasks 'build'
build.dependsOn 'distZip'
version = '2.2-SNAPSHOT'
group = 'de.bottlecaps.rr'
def buildTime = new Date()
def aceVersion = '1.32.3'
def generatedSrc = "$buildDir/generated-src/main"
sourceSets {
main {
java {
srcDirs += ["$generatedSrc/java"]
}
resources {
srcDirs += ["$generatedSrc/resources"]
}
}
}
repositories {
mavenCentral()
}
configurations {
ace
}
dependencies {
ace "org.webjars.npm:ace-builds:$aceVersion"
compileOnly 'org.apache.tomcat:tomcat-servlet-api:8.5.97'
implementation 'net.sf.saxon:Saxon-HE:12.4'
implementation 'org.xmlresolver:xmlresolver:5.2.2'
implementation 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
implementation 'org.apache.xmlgraphics:batik-all:1.17'
implementation 'xml-apis:xml-apis-ext:1.3.04'
implementation 'org.apache.xmlgraphics:xmlgraphics-commons:2.8'
}
configurations.all {
transitive = false
}
jar {
manifest {
attributes (
'Implementation-Version': archiveVersion,
'Build-Timestamp': new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(buildTime)
)
}
rootSpec.exclude '**/de/bottlecaps/fatjar'
archiveFileName = "${project.name}.jar"
}
licenseReport {
outputDir = "$buildDir/LICENSE"
configurations = ['runtimeClasspath', 'ace']
renderers = [new com.github.jk1.license.render.TextReportRenderer()]
}
task generateSrc {
doFirst {
def aceBuilds = configurations.ace.find { it =~ /ace-builds/ }
def zip = new java.util.zip.ZipFile(aceBuilds)
['ace.js', 'ext-searchbox.js'].each { script ->
def entry = zip.getEntry("META-INF/resources/webjars/ace-builds/$aceVersion/src-min-noconflict/$script")
def file = new File("$generatedSrc/resources/htdocs/$script")
file.parentFile.exists() || file.parentFile.mkdirs()
file.withWriter { it << zip.getInputStream(entry) }
}
def railroadVersion = new File("$generatedSrc/java/de/bottlecaps/railroad", 'RailroadVersion.java')
railroadVersion.parentFile.exists() || railroadVersion.parentFile.mkdirs()
railroadVersion.withWriter {
it << $/package de.bottlecaps.railroad;
public class RailroadVersion
{
public static final String PROJECT_NAME = "$project.name";
public static final String VERSION = "$version";
public static final String DATE = "${new java.text.SimpleDateFormat("MMM dd, yyyy", Locale.US).format(buildTime)}";
}
/$
}
}
}
compileJava {
dependsOn generateSrc
options.release = 11
}
java {
withJavadocJar()
withSourcesJar()
}
task generateLicense {
doFirst {
def calendar = Calendar.getInstance()
calendar.setTime(buildTime)
def year = calendar.get(Calendar.YEAR)
def licenseTxt = new File("$buildDir", 'LICENSE.TXT')
licenseTxt.parentFile.exists() || licenseTxt.parentFile.mkdirs()
licenseTxt.withWriter {
it << $/RR - Railroad Diagram Generator
Copyright 2010-$year Gunther Rademacher <grd@gmx.net>
Licensed under the Apache 2.0 License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing
permissions and limitations under the License.
This distribution also includes
- Saxon-HE from Saxonica.com
- TagSoup
- Apache Batik
- Apache XML Graphics Commons
- Apache XML Commons XML APIs
- Ace Editor
For their license information see THIRD-PARTY-NOTICES.txt.
Thank you for choosing RR - Railroad Diagram Generator.
/$
}
}
}
war {
dependsOn jar, generateLicense, generateLicenseReport
manifest {
attributes (
'Main-Class': 'de.bottlecaps.fatjar.Loader',
'FatJar-Main-Class': 'de.bottlecaps.railroad.Railroad',
'FatJar-Jars': 'WEB-INF/lib/' + jar.archiveFileName.get() + ' ' + configurations.runtimeClasspath.collect{'WEB-INF/lib/' + it.name}.join(' '),
'Implementation-Version': archiveVersion,
'Build-Timestamp': new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(buildTime)
)
}
into('de/bottlecaps/fatjar') {
from("$buildDir/classes/java/main/de/bottlecaps/fatjar")
}
into('LICENSE') {
from "$buildDir/LICENSE.txt"
from "$buildDir/LICENSE/THIRD-PARTY-NOTICES.txt"
}
classpath jar
rootSpec.exclude '**/de'
rootSpec.exclude '**/htdocs'
archiveFileName = "${project.name}.war"
}
task distZip(type:JavaExec) {
dependsOn war
mainClass = '-jar'
args "$buildDir/libs/rr.war", '-distZip'
workingDir = "$buildDir/distributions"
doFirst {
mkdir workingDir
}
}
ext.isReleaseVersion = !version.endsWith("-SNAPSHOT")
void configureMetadata(MavenPublication mavenPublication) {
configure (mavenPublication) {
pom {
name = groupId + ':' + artifactId
description = 'Railroad diagram generator'
url = 'https://www.bottlecaps.de/rr/ui'
licenses {
license {
name = 'Apache-2.0'
url = 'https://opensource.org/licenses/Apache-2.0'
}
}
developers {
developer {
name = 'Gunther Rademacher'
email = 'grd@gmx.net'
organization = 'Gunther Rademacher'
organizationUrl = 'https://www.bottlecaps.de/'
}
}
scm {
connection = 'git@github.com:GuntherRademacher/rr.git'
developerConnection = 'git@github.com:GuntherRademacher/rr.git'
url = 'https://github.com/GuntherRademacher/rr'
}
}
}
}
publishing {
repositories {
maven {
def releaseRepo = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotRepo = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = isReleaseVersion ? releaseRepo : snapshotRepo
credentials {
username = project.hasProperty('ossrhUsername') ? ossrhUsername : "Unknown user"
password = project.hasProperty('ossrhPassword') ? ossrhPassword : "Unknown password"
}
}
}
publications {
jar(MavenPublication) {
artifactId = 'rr-lib'
from components.java
configureMetadata delegate
}
war(MavenPublication) {
artifactId = 'rr-webapp'
from components.web
configureMetadata delegate
}
}
}
signing {
sign publishing.publications.jar
sign publishing.publications.war
}
tasks.withType(Sign) {
onlyIf { isReleaseVersion }
}