-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
251 lines (216 loc) · 9.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
import org.gradle.api.internal.file.copy.CopyAction
import org.gradle.api.internal.file.copy.CopyActionProcessingStream
import java.text.SimpleDateFormat
/*
* Copyright 2019-2022 Frederic Thevenet
*
* Licensed under the Apache 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.
*/
plugins {
id 'java'
id 'application'
id 'org.kordamp.gradle.markdown' version '2.2.0'
id "signing"
}
ext.IS_TAG = System.getenv('IS_TAG') != null ? System.getenv('IS_TAG') == "true" : false
ext.IS_RELEASE = IS_TAG && !(System.getenv('REPO_TAG_NAME').endsWith('-SNAPSHOT'))
ext.VERSION_STEM = "3.1.0"
ext.PRODUCT_VERSION = "${VERSION_STEM}${IS_RELEASE ? '' : '-SNAPSHOT'}"
ext.OS_NAME = System.getProperty("os.name").toLowerCase()
ext.OS_ARCH = System.getProperty("os.arch")
ext.IS_64 = OS_ARCH.toLowerCase().contains("64")
ext.IS_MAC = OS_NAME.contains("mac") || OS_NAME.contains("darwin")
ext.IS_WINDOWS = OS_NAME.contains("windows")
ext.IS_LINUX = OS_NAME.contains("linux")
ext.OPENJFX_VERSION = "16"
ext.OPENJFX_PLATEFORM_CLASSIFIER = IS_MAC ? 'mac' : IS_WINDOWS ? 'win' : IS_LINUX ? 'linux' : 'unsupported'
ext.DISTRIBUTION_NAME = "${project.name}-${PRODUCT_VERSION}"
ext.DISTRIBUTION_PATH = "${buildDir}/distributions/${DISTRIBUTION_NAME}"
ext.DISTRIBUTION_EXTENSION = "zip"
ext.BINJR_VERSION = '3.5.0'
ext."signing.keyId" = System.getenv('GPG_KEY_NAME')
ext."signing.secretKeyRingFile" = System.getenv('GPG_KEYRING_PATH')
ext."signing.password" = System.getenv('GPG_PASSPHRASE')
group 'eu.binjr'
version "${PRODUCT_VERSION}"
sourceCompatibility = 17
targetCompatibility = 17
description 'binjr demo adapter'
compileJava.options.encoding = 'UTF-8'
dependencies {
compileOnly "eu.binjr:binjr-core:${BINJR_VERSION}"
compileOnly "org.openjfx:javafx-base:$OPENJFX_VERSION:$OPENJFX_PLATEFORM_CLASSIFIER"
compileOnly "org.openjfx:javafx-graphics:$OPENJFX_VERSION:$OPENJFX_PLATEFORM_CLASSIFIER"
compileOnly "org.openjfx:javafx-controls:$OPENJFX_VERSION:$OPENJFX_PLATEFORM_CLASSIFIER"
compileOnly "org.openjfx:javafx-fxml:$OPENJFX_VERSION:$OPENJFX_PLATEFORM_CLASSIFIER"
compileOnly "org.openjfx:javafx-swing:$OPENJFX_VERSION:$OPENJFX_PLATEFORM_CLASSIFIER"
compileOnly "eu.binjr:binjr-adapter-logs:${BINJR_VERSION}"
implementation("org.apache.logging.log4j:log4j-slf4j-impl:2.17.1") {
exclude group: 'org.apache.logging.log4j', module: 'log4j-api'
exclude group: 'org.apache.logging.log4j', module: 'log4j-core'
}
implementation("org.apache.logging.log4j:log4j-1.2-api:2.17.1") {
exclude group: 'org.apache.logging.log4j', module: 'log4j-api'
exclude group: 'org.apache.logging.log4j', module: 'log4j-core'
}
implementation('fr.jrds:jrdsagent:2020.1') {
exclude group: 'mysql', module: 'mysql-connector-java'
exclude group: 'postgresql', module: 'postgresql'
exclude group: 'org.jolokia', module: '*'
exclude group: 'org.glassfish.external', module: 'opendmk_jmxremote_optional_jar'
exclude group: 'commons-fileupload', module: 'commons-fileupload'
exclude group: 'log4j', module: 'log4j'
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
implementation('fr.jrds:jrds-core:2021.1') {
exclude group: 'mysql', module: 'mysql-connector-java'
exclude group: 'postgresql', module: 'postgresql'
exclude group: 'org.jolokia', module: '*'
exclude group: 'org.glassfish.external', module: 'opendmk_jmxremote_optional_jar'
exclude group: 'commons-fileupload', module: 'commons-fileupload'
exclude group: 'log4j', module: 'log4j'
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
implementation('fr.jrds:jrds-core:2021.1:webapp') {
exclude group: 'mysql', module: 'mysql-connector-java'
exclude group: 'postgresql', module: 'postgresql'
exclude group: 'org.jolokia', module: '*'
exclude group: 'org.glassfish.external', module: 'opendmk_jmxremote_optional_jar'
exclude group: 'commons-fileupload', module: 'commons-fileupload'
exclude group: 'log4j', module: 'log4j'
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
}
mainClassName = 'eu.binjr.core.Bootstrap'
jar {
manifest {
attributes(
'Specification-Title': project.name,
'Specification-Version': project.version,
'Implementation-Title': project.name,
'Implementation-Version': project.version,
)
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
task shaded(type: Jar) {
duplicatesStrategy ="EXCLUDE"
manifest {
attributes(
'Specification-Title': project.name,
'Specification-Version': project.version,
'Implementation-Title': project.name,
'Implementation-Version': project.version,
)
}
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
task copyPluginLibs(type: Copy, dependsOn: shaded) {
into "$DISTRIBUTION_PATH"
from project.shaded
}
task copyInfo(type: Copy) {
from "${projectDir}/distribution/info"
into "${buildDir}/tmp/info"
def changeHistory = new File("${projectDir}/CHANGELOG.md").getText("utf-8")
def currentChanges = new File("${projectDir}/UNRELEASED.md").getText("utf-8")
expand(["version" : "$PRODUCT_VERSION",
"releaseDate" : "${new SimpleDateFormat("EEE, d MMM yyyy").format(new Date())}",
"changeHistory" : "$changeHistory",
"currentChanges": "$currentChanges",
"tagName" : "v${PRODUCT_VERSION}"
])
}
markdownToHtml.dependsOn(copyInfo)
markdownToHtml {
sourceDir = file("${buildDir}/tmp/info")
outputDir = file("$DISTRIBUTION_PATH")
doLast {
ConfigurableFileTree tree = fileTree(dir: "$DISTRIBUTION_PATH")
tree.include '**/*.html'
tree.each { File file ->
String path = file.path
File newFile = new File("${DISTRIBUTION_PATH}/tmp_${file.name}")
newFile << "<html lang=\"en\">\n" +
"<head>\n" +
" <title>" + (file.name - ".html") + "</title>\n" +
" <meta charset=\"utf-8\"/>\n" +
" <link rel=\"stylesheet\" href=\"./resources/css/plain.css\">\n" +
"</head>"
newFile << file.getText("utf-8")
if (!file.name.startsWith("LICENSE")) {
newFile << "<footer>\n" +
" <br>\n" +
" <hr>\n" +
" <p style=\"text-align:left;\">\n" +
" (c) 2016-2021 <a href=\"https://www.fthevenet.eu\">Frederic Thevenet</a>\n" +
" <span style=\"float:right;\"><a href=\"https://binjr.eu\">https://binjr.eu</a></span>\n" +
" </p>\n" +
"</footer>"
}
file.delete()
newFile.renameTo(path)
}
}
}
task packageDistributionZip(type: Zip, dependsOn: [copyPluginLibs, markdownToHtml]) {
from DISTRIBUTION_PATH
destinationDirectory = buildDir
archiveFileName = "${DISTRIBUTION_NAME}.zip"
}
task packageDistribution(type: WrapTaskForSigning, dependsOn: packageDistributionZip){
from "${buildDir}/${DISTRIBUTION_NAME}.${DISTRIBUTION_EXTENSION}"
destinationDirectory = buildDir
archiveFileName = "${DISTRIBUTION_NAME}.${DISTRIBUTION_EXTENSION}"
}
signing {
sign packageDistribution
}
/**
* This class is a no-op copy task whose purpose is to allow using the
* standard gradle signing plugin to sign any arbitrary file.
* The idea is to piggy-back on the existing support for signing
* of tasks extending AbstractArchiveTask; to use it, simply declare a
* task of that type and use the path to the file to be signed both as
* the source and target of the archive.
* NB: No copy/move/archiving will actually take place.
*/
class WrapTaskForSigning extends AbstractArchiveTask {
@Override
protected CopyAction createCopyAction() {
return new noopCopyAction();
}
class noopCopyAction implements CopyAction {
@Override
WorkResult execute(CopyActionProcessingStream stream) {
return WorkResults.didWork(true);
}
}
}
repositories {
//mavenLocal()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
run {
systemProperties System.getProperties()
jvmArgs "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005"
}