forked from wttech/gradle-aem-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
319 lines (277 loc) · 10 KB
/
build.gradle.kts
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.dokka.gradle.DokkaTask
import io.gitlab.arturbosch.detekt.Detekt
plugins {
id("java-gradle-plugin")
id("maven-publish")
id("org.jetbrains.kotlin.jvm") version "1.3.72"
id("org.jetbrains.dokka") version "0.10.1"
id("com.gradle.plugin-publish") version "0.11.0"
id("io.gitlab.arturbosch.detekt") version "1.7.0"
id("com.jfrog.bintray") version "1.8.4"
id("net.researchgate.release") version "2.8.1"
id("com.github.breadmoirai.github-release") version "2.2.10"
id("com.neva.fork") version "5.0.0"
}
group = "com.cognifide.gradle"
description = "Gradle AEM Plugin"
defaultTasks(":publishToMavenLocal", ":launcher:publishToMavenLocal")
val functionalTestSourceSet = sourceSets.create("functionalTest")
gradlePlugin.testSourceSets(functionalTestSourceSet)
configurations.getByName("functionalTestImplementation").apply {
extendsFrom(configurations.getByName("testImplementation"))
}
repositories {
mavenLocal()
jcenter()
gradlePluginPortal()
}
dependencies {
implementation(gradleApi())
implementation("com.cognifide.gradle:common-plugin:0.1.51")
implementation("org.jsoup:jsoup:1.12.1")
implementation("org.buildobjects:jproc:2.3.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5")
implementation("org.apache.commons:commons-lang3:3.9")
implementation("commons-io:commons-io:2.6")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.10.3")
implementation("org.apache.httpcomponents:httpclient:4.5.12")
implementation("biz.aQute.bnd:biz.aQute.bnd.gradle:5.0.1")
implementation("net.lingala.zip4j:zip4j:2.5.1")
implementation("org.osgi:org.osgi.core:6.0.0")
testImplementation("org.junit.jupiter:junit-jupiter:5.5.2")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.7.0")
}
tasks {
register<Zip>("tailerZip") {
from("dists/gradle-aem-tailer")
archiveFileName.set("gradle-aem-tailer.zip")
destinationDirectory.set(file("dists"))
}
register<Zip>("assetsZip") {
from("src/asset")
archiveFileName.set("assets.zip")
destinationDirectory.set(file("$buildDir/resources/main"))
}
register<Jar>("sourcesJar") {
archiveClassifier.set("sources")
dependsOn("classes")
from(sourceSets["main"].allSource)
}
register<DokkaTask>("dokkaJavadoc") {
outputFormat = "javadoc"
outputDirectory = "$buildDir/javadoc"
}
register<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
dependsOn("dokkaJavadoc")
from("$buildDir/javadoc")
}
withType<JavaCompile>().configureEach{
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
}
withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
freeCompilerArgs = freeCompilerArgs + "-Xuse-experimental=kotlin.Experimental"
}
}
withType<Detekt>().configureEach {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
withType<Test>().configureEach {
testLogging.showStandardStreams = true
useJUnitPlatform()
}
withType<DokkaTask>().configureEach {
onlyIf { project.gradle.taskGraph.hasTask(":release")}
}
test {
dependsOn("detektTest")
}
register<Test>("functionalTest") {
testClassesDirs = functionalTestSourceSet.output.classesDirs
classpath = functionalTestSourceSet.runtimeClasspath
systemProperties(System.getProperties().asSequence().map {
it.key.toString() to it.value.toString() }.filter {
it.first.run { startsWith("fileTransfer.") || startsWith("localInstance.") }
}.toMap()
)
useJUnitPlatform()
mustRunAfter("test")
dependsOn("jar", "detektFunctionalTest")
outputs.dir("build/functionalTest")
}
build {
dependsOn("sourcesJar", "javadocJar")
}
val buildProperties = register("buildProperties") {
val json = """
|{
| "pluginVersion": "${project.version}",
| "gradleVersion": "${project.gradle.gradleVersion}"
|}""".trimMargin()
val file = file("$buildDir/resources/main/build.json")
dependsOn("assetsZip")
inputs.property("buildJson", json)
outputs.file(file)
doLast { file.writeText(json) }
}
jar {
dependsOn(buildProperties)
}
publishToMavenLocal {
dependsOn(jar)
}
afterReleaseBuild {
dependsOn("bintrayUpload", "publishPlugins")
}
named("githubRelease") {
mustRunAfter("release")
}
register("fullRelease") {
dependsOn("release", "githubRelease")
}
}
detekt {
config.from(file("detekt.yml"))
parallel = true
autoCorrect = true
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
artifact(tasks["sourcesJar"])
artifact(tasks["javadocJar"])
}
}
}
gradlePlugin {
plugins {
create("common") {
id = "com.cognifide.aem.common"
implementationClass = "com.cognifide.gradle.aem.common.CommonPlugin"
displayName = "AEM Common Plugin"
description = "Provides AEM DSL extension to build script on which all other logic is based."
}
create("package") {
id = "com.cognifide.aem.package"
implementationClass = "com.cognifide.gradle.aem.pkg.PackagePlugin"
displayName = "AEM Package Plugin"
description = "Provides tasks for working with CRX packages."
}
create("package.sync") {
id = "com.cognifide.aem.package.sync"
implementationClass = "com.cognifide.gradle.aem.pkg.PackageSyncPlugin"
displayName = "AEM Package Sync Plugin"
description = "Provides tasks for synchronizing JCR content from running AEM instance."
}
create("bundle") {
id = "com.cognifide.aem.bundle"
implementationClass = "com.cognifide.gradle.aem.bundle.BundlePlugin"
displayName = "AEM Bundle Plugin"
description = "Adds support for building OSGi bundles."
}
create("instance") {
id = "com.cognifide.aem.instance"
implementationClass = "com.cognifide.gradle.aem.instance.InstancePlugin"
displayName = "AEM Instance Plugin"
description = "Provides tasks for working with remote AEM instances."
}
create("instance.local") {
id = "com.cognifide.aem.instance.local"
implementationClass = "com.cognifide.gradle.aem.instance.LocalInstancePlugin"
displayName = "AEM Local Instance Plugin"
description = "Provides tasks for working with local AEM instances."
}
}
}
pluginBundle {
website = "https://github.com/Cognifide/gradle-aem-plugin"
vcsUrl = "https://github.com/Cognifide/gradle-aem-plugin.git"
description = "Gradle AEM Plugin"
tags = listOf("aem", "cq", "vault", "scr")
}
bintray {
user = (findProperty("bintray.user") ?: System.getenv("BINTRAY_USER"))?.toString()
key = (findProperty("bintray.key") ?: System.getenv("BINTRAY_KEY"))?.toString()
setPublications("mavenJava")
with(pkg) {
repo = "maven-public"
name = "gradle-aem-plugin"
userOrg = "cognifide"
setLicenses("Apache-2.0")
vcsUrl = "https://github.com/Cognifide/gradle-aem-plugin.git"
setLabels("aem", "cq", "vault", "scr")
with(version) {
name = project.version.toString()
desc = "${project.description} ${project.version}"
vcsTag = project.version.toString()
}
}
publish = (project.findProperty("bintray.publish") ?: "true").toString().toBoolean()
override = (project.findProperty("bintray.override") ?: "false").toString().toBoolean()
}
githubRelease {
owner("Cognifide")
repo("gradle-aem-plugin")
token((findProperty("github.token") ?: "").toString())
tagName(project.version.toString())
releaseName(project.version.toString())
draft((findProperty("github.draft") ?: "false").toString().toBoolean())
prerelease((findProperty("github.prerelease") ?: "false").toString().toBoolean())
overwrite((findProperty("github.override") ?: "true").toString().toBoolean())
gradle.projectsEvaluated {
releaseAssets(listOf("jar", "sourcesJar", "javadocJar").map { tasks.named(it) }
+ project(":launcher").tasks.named("jar"))
}
body { """
|# What's new
|
|TBD
|
|# Upgrade notes
|
|Nothing to do.
|
|# Contributions
|
|None.
""".trimMargin()
}
}
fork {
properties {
define("Local instance", mapOf(
"localInstanceQuickstartJarUri" to {
label = "Quickstart URI"
description = "For file named 'cq-quickstart-x.x.x.jar'"
},
"localInstanceQuickstartLicenseUri" to {
label = "Quickstart License URI"
description = "For file named 'license.properties'"
}
))
define("File transfer", mapOf(
"companyUser" to {
label = "User"
description = "Authorized to access AEM files"
defaultValue = System.getProperty("user.name").orEmpty()
optional()
},
"companyPassword" to {
label = "Password"
description = "For above user"
optional()
},
"companyDomain" to {
label = "Domain"
description = "Needed only when accessing AEM files over SMB"
defaultValue = System.getenv("USERDOMAIN").orEmpty()
optional()
}
))
}
}