-
Notifications
You must be signed in to change notification settings - Fork 27
/
build.gradle
203 lines (177 loc) · 6.14 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
import groovy.text.SimpleTemplateEngine
import org.kohsuke.github.GitHub
buildscript {
dependencies {
classpath 'org.kohsuke:github-api:1.326'
}
}
plugins {
id 'groovy'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.gradle.plugin-publish' version '1.3.0'
id 'com.github.ethankhall.semantic-versioning' version '1.1.0'
id 'com.github.ben-manes.versions' version '0.51.0'
id 'com.github.hierynomus.license' version '0.16.1'
id 'org.asciidoctor.jvm.convert' version '4.0.3'
id 'org.ajoberstar.git-publish' version '4.2.2'
}
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
project.version.with {
major = pluginVersionMajor as int
minor = pluginVersionMinor as int
patch = pluginVersionPatch as int
if (project.hasProperty('pluginVersionLabel')) {
preRelease = pluginVersionLabel
}
releaseBuild = pluginReleaseBuild
}
def badassJlinkPluginTag = pluginReleaseBuild ? "v$project.version" : 'master'
group = 'org.beryx'
license {
header file('license-header.txt')
skipExistingHeaders true
ignoreFailures false
excludes(['**/*.properties', '**/*.txt', '**/hello*/', '**/opens-to-jaxb*/', '**/local-deps*/', '**/multi-launch*/'])
tasks.license.dependsOn licenseMain, licenseTest
}
configurations {
asciidoctorExt
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.ow2.asm:asm:9.7.1'
testImplementation 'org.spockframework:spock-core:2.3-groovy-3.0'
asciidoctorExt 'com.bmuschko:asciidoctorj-tabbed-code-extension:0.3'
}
test {
useJUnitPlatform()
}
jar {
manifest.attributes('Implementation-Title': project.name,
'Implementation-Version': project.version)
enabled = false
dependsOn shadowJar
}
shadowJar {
archiveClassifier = null
minimize()
relocate 'org.objectweb.asm', 'org.beryx.jlink.shadow.asm'
}
gradlePlugin {
website = vcsUrl = 'https://github.com/beryx/badass-jlink-plugin'
plugins {
jlink {
id = 'org.beryx.jlink'
implementationClass = 'org.beryx.jlink.JlinkPlugin'
displayName = 'Badass JLink Plugin'
description = 'A Gradle plugin that assembles your modules into a custom runtime image'
tags.set(['jlink', 'jpackage', 'jpms'])
}
}
}
asciidoctor {
configurations 'asciidoctorExt'
setSourceDir file('doc')
baseDirFollowsSourceDir()
sources { include 'index.adoc' }
logDocuments = true
attributes 'source-highlighter': 'coderay',
'coderay-linenums-mode': 'table',
'project-version': project.version,
icons: 'font',
imagesdir: 'img',
linkattrs: true,
linkcss: true,
'git-tag': badassJlinkPluginTag,
'blob-root': "https://github.com/beryx/badass-jlink-plugin/blob/$badassJlinkPluginTag"
}
gitPublish {
repoUri = 'https://github.com/beryx/badass-jlink-plugin.git'
branch = 'gh-pages'
def pgType = project.hasProperty('ghPageType') ? ghPageType : 'latest'
if (pgType == 'init') {
contents.from file('ghpages')
} else if (pgType == 'list') {
gitPublishReset.dependsOn('update-release-list')
contents.from file('build/release-list')
} else {
contents.from file(asciidoctor.outputDir.path)
contents.from file('build/docs')
}
def docDir = pluginReleaseBuild ? 'releases' : 'snapshots'
if (pgType == 'init') {
contents.into '.'
} else if (pgType == 'list') {
contents.into '.'
preserve {
include '**'
exclude 'releases.md'
}
} else if (pgType == 'version') {
gitPublishPush.enabled = (docDir != 'snapshots')
contents.into "$docDir/$project.version"
preserve {
include '**'
exclude "$docDir/$project.version"
}
} else {
contents.into "$docDir/latest"
preserve {
include '**'
exclude "$docDir/latest"
}
}
}
tasks.register('update-release-list') {
doLast {
def docBaseUrl = 'http://badass-jlink-plugin.beryx.org'
def markdown = getReleasesMarkdown(getReleases(), docBaseUrl)
new File(mkdir('build/release-list'), 'releases.md').write(markdown)
}
}
static def getReleases() {
def releases = GitHub.connectAnonymously()
.getRepository('beryx/badass-jlink-plugin')
.getDirectoryContent('releases', 'gh-pages')*.name
releases.removeAll { !it || it == 'latest' }
releases.sort { o1, o2 ->
if (!o1) return o2 ? 1 : 0
if (!o2) return -1
String[] tokens1 = o1.split('\\.')
String[] tokens2 = o2.split('\\.')
int len = Math.min(tokens1.length, tokens2.length)
for (int i = 0; i < len; i++) {
int result
if (tokens2[i].isInteger() && tokens1[i].isInteger()) {
result = Integer.compare(tokens2[i] as int, tokens1[i] as int)
} else {
result = tokens2[i] <=> tokens1[i]
}
if (result != 0) return result
}
tokens2.length <=> tokens1.length
}
return releases
}
static def getReleasesMarkdown(List<String> releases, String docBaseUrl) {
return new SimpleTemplateEngine().createTemplate('''
## List of all releases ##
**Latest snapshot**
- [documentation]($docBaseUrl/snapshots/latest)
- [groovydoc]($docBaseUrl/snapshots/latest/groovydoc)
<% releases.each { %>**Release $it**
- [documentation]($docBaseUrl/releases/$it)
- [groovydoc]($docBaseUrl/releases/$it/groovydoc)
<% } %>
'''.stripIndent())
.make(docBaseUrl: docBaseUrl, releases: releases)
.toString()
}
if (hasProperty('buildScan')) {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
}