1+ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
13plugins {
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
912description = " Spring REST Docs Core"
1013
1114configurations {
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-repack"
21+ archiveVersion = jmustacheVersion
22+ configurations = [ project. configurations. jmustache ]
23+ relocate(" com.samskivert" , " org.springframework.restdocs" )
3324}
3425
3526dependencies {
3627 compileOnly(" org.apiguardian:apiguardian-api" )
3728
3829 implementation(" com.fasterxml.jackson.core:jackson-databind" )
3930 implementation(" org.springframework:spring-web" )
40- implementation(files(jmustacheRepackJar))
41-
42- jarjar(" com.googlecode.jarjar:jarjar:1.3" )
31+ implementation(files(jmustacheShadowJar))
4332
4433 jmustache(platform(project(" :spring-restdocs-platform" )))
4534 jmustache(" com.samskivert:jmustache@jar" )
@@ -56,7 +45,7 @@ dependencies {
5645
5746 testFixturesCompileOnly(" org.apiguardian:apiguardian-api" )
5847
59- testFixturesImplementation(files(jmustacheRepackJar ))
48+ testFixturesImplementation(files(jmustacheShadowJar ))
6049 testFixturesImplementation(" org.hamcrest:hamcrest-library" )
6150 testFixturesImplementation(" org.mockito:mockito-core" )
6251 testFixturesImplementation(" org.springframework:spring-core" )
@@ -75,9 +64,9 @@ dependencies {
7564 testRuntimeOnly(" org.junit.platform:junit-platform-engine" )
7665}
7766
78- jar {
79- dependsOn jmustacheRepackJar
80- from(zipTree(jmustacheRepackJar . archiveFile . get() )) {
67+ tasks . named( " jar" ) {
68+ dependsOn jmustacheShadowJar
69+ from(zipTree(jmustacheShadowJar . map { it . archiveFile } )) {
8170 include " org/springframework/restdocs/**"
8271 }
8372}
0 commit comments