Skip to content

Commit 5066bd2

Browse files
committed
Switch to the Shadow plugin to repackage JMustache
1 parent 8126add commit 5066bd2

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

spring-restdocs-core/build.gradle

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,36 @@
1+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
13
plugins {
24
id 'org.springframework.restdocs.conventions'
35
id "java-library"
46
id "java-test-fixtures"
57
id "maven-publish"
68
id "org.springframework.restdocs.optional-dependencies"
9+
id "com.gradleup.shadow" version "8.3.8" apply false
710
}
811

912
description = "Spring REST Docs Core"
1013

1114
configurations {
12-
jarjar
1315
jmustache
1416
testArtifacts.extendsFrom testRuntime
1517
}
1618

17-
task jmustacheRepackJar(type: Jar) { repackJar ->
18-
repackJar.archiveBaseName = "restdocs-jmustache-repack"
19-
repackJar.archiveVersion = jmustacheVersion
20-
21-
doLast() {
22-
ant {
23-
taskdef name: "jarjar", classname: "com.tonicsystems.jarjar.JarJarTask",
24-
classpath: configurations.jarjar.asPath
25-
jarjar(destfile: repackJar.archiveFile.get()) {
26-
configurations.jmustache.each { originalJar ->
27-
zipfileset(src: originalJar, includes: "**/*.class")
28-
}
29-
rule(pattern: "com.samskivert.**", result: "org.springframework.restdocs.@1")
30-
}
31-
}
32-
}
19+
def jmustacheShadowJar = tasks.register("jmustacheShadowJar", ShadowJar) {
20+
archiveBaseName = "restdocs-jmustache"
21+
archiveVersion = jmustacheVersion
22+
configurations = [ project.configurations.jmustache ]
23+
include("*.jar")
24+
include("com/samskivert/**/*.class")
25+
relocate("com.samskivert", "org.springframework.restdocs")
3326
}
3427

3528
dependencies {
3629
compileOnly("org.apiguardian:apiguardian-api")
3730

3831
implementation("com.fasterxml.jackson.core:jackson-databind")
3932
implementation("org.springframework:spring-web")
40-
implementation(files(jmustacheRepackJar))
41-
42-
jarjar("com.googlecode.jarjar:jarjar:1.3")
33+
implementation(files(jmustacheShadowJar))
4334

4435
jmustache(platform(project(":spring-restdocs-platform")))
4536
jmustache("com.samskivert:jmustache@jar")
@@ -56,7 +47,7 @@ dependencies {
5647

5748
testFixturesCompileOnly("org.apiguardian:apiguardian-api")
5849

59-
testFixturesImplementation(files(jmustacheRepackJar))
50+
testFixturesImplementation(files(jmustacheShadowJar))
6051
testFixturesImplementation("org.hamcrest:hamcrest-library")
6152
testFixturesImplementation("org.mockito:mockito-core")
6253
testFixturesImplementation("org.springframework:spring-core")
@@ -75,9 +66,15 @@ dependencies {
7566
testRuntimeOnly("org.junit.platform:junit-platform-engine")
7667
}
7768

78-
jar {
79-
dependsOn jmustacheRepackJar
80-
from(zipTree(jmustacheRepackJar.archiveFile.get())) {
69+
tasks.named("jar") {
70+
dependsOn jmustacheShadowJar
71+
from(zipTree(jmustacheShadowJar.map { it.archiveFile } )) {
8172
include "org/springframework/restdocs/**"
8273
}
8374
}
75+
76+
tasks.named("javadoc") {
77+
doFirst {
78+
println classpath
79+
}
80+
}

0 commit comments

Comments
 (0)