Skip to content

Commit cae21cf

Browse files
committed
Use JMustache as a dependency instead of shading it
Closes gh-984
1 parent 5829cc6 commit cae21cf

File tree

9 files changed

+26
-52
lines changed

9 files changed

+26
-52
lines changed

gradle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8
55
org.gradle.parallel=true
66

77
javaFormatVersion=0.0.47
8-
jmustacheVersion=1.16
98
springFrameworkVersion=7.0.0-M8

spring-restdocs-core/build.gradle

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,19 @@
1-
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2-
31
plugins {
42
id 'org.springframework.restdocs.conventions'
53
id "java-library"
64
id "java-test-fixtures"
75
id "maven-publish"
86
id "org.springframework.restdocs.optional-dependencies"
9-
id "com.gradleup.shadow" version "8.3.8" apply false
107
}
118

129
description = "Spring REST Docs Core"
1310

14-
configurations {
15-
jmustache
16-
testArtifacts.extendsFrom testRuntime
17-
}
18-
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")
26-
}
27-
2811
dependencies {
2912
compileOnly("org.apiguardian:apiguardian-api")
3013

3114
implementation("tools.jackson.core:jackson-databind")
3215
implementation("org.springframework:spring-web")
33-
implementation(files(jmustacheShadowJar))
34-
35-
jmustache(platform(project(":spring-restdocs-platform")))
36-
jmustache("com.samskivert:jmustache@jar")
16+
implementation("com.samskivert:jmustache")
3717

3818
optional(platform(project(":spring-restdocs-platform")))
3919
optional("jakarta.validation:jakarta.validation-api")
@@ -47,7 +27,7 @@ dependencies {
4727

4828
testFixturesCompileOnly("org.apiguardian:apiguardian-api")
4929

50-
testFixturesImplementation(files(jmustacheShadowJar))
30+
testFixturesImplementation("com.samskivert:jmustache")
5131
testFixturesImplementation("org.hamcrest:hamcrest-library")
5232
testFixturesImplementation("org.mockito:mockito-core")
5333
testFixturesImplementation("org.springframework:spring-core")
@@ -65,10 +45,3 @@ dependencies {
6545
testRuntimeOnly("org.apache.tomcat.embed:tomcat-embed-el")
6646
testRuntimeOnly("org.junit.platform:junit-platform-engine")
6747
}
68-
69-
tasks.named("jar") {
70-
dependsOn jmustacheShadowJar
71-
from(zipTree(jmustacheShadowJar.map { it.archiveFile } )) {
72-
include "org/springframework/restdocs/**"
73-
}
74-
}

spring-restdocs-core/src/main/java/org/springframework/restdocs/config/RestDocumentationConfigurer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
import java.util.List;
2323
import java.util.Map;
2424

25+
import com.samskivert.mustache.Mustache;
2526
import org.jspecify.annotations.Nullable;
2627

2728
import org.springframework.restdocs.RestDocumentationContext;
28-
import org.springframework.restdocs.mustache.Mustache;
2929
import org.springframework.restdocs.snippet.RestDocumentationContextPlaceholderResolverFactory;
3030
import org.springframework.restdocs.snippet.StandardWriterResolver;
3131
import org.springframework.restdocs.snippet.WriterResolver;

spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/AsciidoctorTableCellContentLambda.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
import java.io.IOException;
2020
import java.io.Writer;
2121

22-
import org.springframework.restdocs.mustache.Mustache.Lambda;
23-
import org.springframework.restdocs.mustache.Template.Fragment;
22+
import com.samskivert.mustache.Mustache.Lambda;
23+
import com.samskivert.mustache.Template.Fragment;
2424

2525
/**
2626
* A {@link Lambda} that escapes {@code |} characters so that the do not break the table's
2727
* formatting.
2828
*
2929
* @author Andy Wilkinson
30-
* @since 1.1.0
30+
* @since 4.0.0
3131
*/
3232
public final class AsciidoctorTableCellContentLambda implements Lambda {
3333

spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/MustacheTemplate.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,29 @@
3030
*/
3131
public class MustacheTemplate implements Template {
3232

33-
private final org.springframework.restdocs.mustache.Template delegate;
33+
private final com.samskivert.mustache.Template delegate;
3434

3535
private final Map<String, Object> context;
3636

3737
/**
3838
* Creates a new {@code MustacheTemplate} that adapts the given {@code delegate}.
3939
* @param delegate the delegate to adapt
40+
* @since 4.0.0
4041
*/
41-
public MustacheTemplate(org.springframework.restdocs.mustache.Template delegate) {
42+
public MustacheTemplate(com.samskivert.mustache.Template delegate) {
4243
this(delegate, Collections.<String, Object>emptyMap());
4344
}
4445

4546
/**
4647
* Creates a new {@code MustacheTemplate} that adapts the given {@code delegate}.
4748
* During rendering, the given {@code context} and the context passed into
4849
* {@link #render(Map)} will be combined and then passed to the delegate when it is
49-
* {@link org.springframework.restdocs.mustache.Template#execute executed}.
50+
* {@link com.samskivert.mustache.Template#execute executed}.
5051
* @param delegate the delegate to adapt
5152
* @param context the context
53+
* @since 4.0.0
5254
*/
53-
public MustacheTemplate(org.springframework.restdocs.mustache.Template delegate, Map<String, Object> context) {
55+
public MustacheTemplate(com.samskivert.mustache.Template delegate, Map<String, Object> context) {
5456
this.delegate = delegate;
5557
this.context = context;
5658
}

spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/mustache/MustacheTemplateEngine.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,17 @@
2323
import java.util.Collections;
2424
import java.util.Map;
2525

26+
import com.samskivert.mustache.Mustache;
27+
import com.samskivert.mustache.Mustache.Compiler;
28+
2629
import org.springframework.core.io.Resource;
27-
import org.springframework.restdocs.mustache.Mustache;
28-
import org.springframework.restdocs.mustache.Mustache.Compiler;
2930
import org.springframework.restdocs.templates.Template;
3031
import org.springframework.restdocs.templates.TemplateEngine;
3132
import org.springframework.restdocs.templates.TemplateResourceResolver;
3233

3334
/**
3435
* A <a href="https://mustache.github.io">Mustache</a>-based {@link TemplateEngine}
3536
* implemented using <a href="https://github.com/samskivert/jmustache">JMustache</a>.
36-
* <p>
37-
* Note that JMustache has been repackaged and embedded to prevent classpath conflicts.
3837
*
3938
* @author Andy Wilkinson
4039
*/
@@ -76,6 +75,7 @@ public MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver,
7675
* {@code compiler} to compile them. Templates will be read as UTF-8.
7776
* @param templateResourceResolver the resolver to use
7877
* @param compiler the compiler to use
78+
* @since 4.0.0
7979
*/
8080
public MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver, Compiler compiler) {
8181
this(templateResourceResolver, compiler, Collections.<String, Object>emptyMap());
@@ -89,7 +89,7 @@ public MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver,
8989
* @param templateResourceResolver the resolver to use
9090
* @param templateEncoding the charset to use when reading the templates
9191
* @param compiler the compiler to use
92-
* @since 2.0.5
92+
* @since 4.0.0
9393
*/
9494
public MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver, Charset templateEncoding,
9595
Compiler compiler) {
@@ -104,8 +104,8 @@ public MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver,
104104
* @param templateResourceResolver the resolver to use
105105
* @param compiler the compiler to use
106106
* @param context the context to pass to compiled templates
107-
* @see MustacheTemplate#MustacheTemplate(org.springframework.restdocs.mustache.Template,
108-
* Map)
107+
* @since 4.0.0
108+
* @see MustacheTemplate#MustacheTemplate(com.samskivert.mustache.Template, Map)
109109
*/
110110
public MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver, Compiler compiler,
111111
Map<String, Object> context) {
@@ -122,9 +122,8 @@ public MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver,
122122
* @param templateEncoding the charset to use when reading the templates
123123
* @param compiler the compiler to use
124124
* @param context the context to pass to compiled templates
125-
* @since 2.0.5
126-
* @see MustacheTemplate#MustacheTemplate(org.springframework.restdocs.mustache.Template,
127-
* Map)
125+
* @since 4.0.0
126+
* @see MustacheTemplate#MustacheTemplate(com.samskivert.mustache.Template, Map)
128127
*/
129128
public MustacheTemplateEngine(TemplateResourceResolver templateResourceResolver, Charset templateEncoding,
130129
Compiler compiler, Map<String, Object> context) {
@@ -145,6 +144,7 @@ public Template compileTemplate(String name) throws IOException {
145144
/**
146145
* Returns the {@link Compiler} used to compile Mustache templates.
147146
* @return the compiler
147+
* @since 4.0.0
148148
*/
149149
protected final Compiler getCompiler() {
150150
return this.compiler;

spring-restdocs-core/src/test/java/org/springframework/restdocs/templates/mustache/AsciidoctorTableCellContentLambdaTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
import java.io.IOException;
2020
import java.io.StringWriter;
2121

22+
import com.samskivert.mustache.Template.Fragment;
2223
import org.junit.jupiter.api.Test;
2324

24-
import org.springframework.restdocs.mustache.Template.Fragment;
25-
2625
import static org.assertj.core.api.Assertions.assertThat;
2726
import static org.mockito.BDDMockito.given;
2827
import static org.mockito.Mockito.mock;

spring-restdocs-core/src/testFixtures/java/org/springframework/restdocs/testfixtures/jupiter/OperationBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@
2626
import java.util.Map;
2727
import java.util.Set;
2828

29+
import com.samskivert.mustache.Mustache;
30+
2931
import org.springframework.http.HttpHeaders;
3032
import org.springframework.http.HttpMethod;
3133
import org.springframework.http.HttpStatus;
3234
import org.springframework.http.HttpStatusCode;
3335
import org.springframework.restdocs.ManualRestDocumentation;
3436
import org.springframework.restdocs.RestDocumentationContext;
35-
import org.springframework.restdocs.mustache.Mustache;
3637
import org.springframework.restdocs.operation.Operation;
3738
import org.springframework.restdocs.operation.OperationRequest;
3839
import org.springframework.restdocs.operation.OperationRequestFactory;

spring-restdocs-platform/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ javaPlatform {
99
dependencies {
1010
constraints {
1111
api("com.google.code.findbugs:jsr305:3.0.2")
12-
api("com.samskivert:jmustache:$jmustacheVersion")
12+
api("com.samskivert:jmustache:1.16")
1313
api("jakarta.servlet:jakarta.servlet-api:6.1.0")
1414
api("jakarta.validation:jakarta.validation-api:3.1.0")
1515
api("org.apache.pdfbox:pdfbox:3.0.5")

0 commit comments

Comments
 (0)