1
+ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2
+
1
3
plugins {
2
4
id ' org.springframework.restdocs.conventions'
3
5
id " java-library"
4
6
id " java-test-fixtures"
5
7
id " maven-publish"
6
8
id " org.springframework.restdocs.optional-dependencies"
9
+ id " com.gradleup.shadow" version " 8.3.8" apply false
7
10
}
8
11
9
12
description = " Spring REST Docs Core"
10
13
11
14
configurations {
12
- jarjar
13
15
jmustache
14
16
testArtifacts. extendsFrom testRuntime
15
17
}
16
18
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" )
33
24
}
34
25
35
26
dependencies {
36
27
compileOnly(" org.apiguardian:apiguardian-api" )
37
28
38
29
implementation(" com.fasterxml.jackson.core:jackson-databind" )
39
30
implementation(" org.springframework:spring-web" )
40
- implementation(files(jmustacheRepackJar))
41
-
42
- jarjar(" com.googlecode.jarjar:jarjar:1.3" )
31
+ implementation(files(jmustacheShadowJar))
43
32
44
33
jmustache(platform(project(" :spring-restdocs-platform" )))
45
34
jmustache(" com.samskivert:jmustache@jar" )
@@ -56,7 +45,7 @@ dependencies {
56
45
57
46
testFixturesCompileOnly(" org.apiguardian:apiguardian-api" )
58
47
59
- testFixturesImplementation(files(jmustacheRepackJar ))
48
+ testFixturesImplementation(files(jmustacheShadowJar ))
60
49
testFixturesImplementation(" org.hamcrest:hamcrest-library" )
61
50
testFixturesImplementation(" org.mockito:mockito-core" )
62
51
testFixturesImplementation(" org.springframework:spring-core" )
@@ -75,9 +64,9 @@ dependencies {
75
64
testRuntimeOnly(" org.junit.platform:junit-platform-engine" )
76
65
}
77
66
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 } )) {
81
70
include " org/springframework/restdocs/**"
82
71
}
83
72
}
0 commit comments