In 1.0, the reliance on JUnit was more widespread than it should have been. It should have been isolated to the JUnit TestRule implementation, RestDocumentation. Unfortunately, RestDocumentation was also an argument to MockMvcRestDocumentation.documentationConfiguration which made it impossible to use Spring REST Docs without having JUnit on the classpath. This commit introduces JUnitRestDocumentation and ManualRestDocumentation. The format is a direct replacement for RestDocumentation which has been reworked to delegate to JUnitRestDocumentation. The latter allows manual management of the RestDocumentationContext, primarily for use with TestNG. A new interface, RestDocumentationContextProvider, has been introduced. It is implemented by RestDocumentation, JUnitRestDocumentation and ManualRestDocumentation. MockMvcRestDocumentation.documentationConfiguration has been overridden to also accept a RestDocumentationContextProvider. The method that accepts a RestDocumentation has been deprecated, as has RestDocumentation itself. The documentation has been updated to encourage the use of JUnitRestDocumentation and a sample illustrating the use of Spring REST Docs with TestNG has been added. Closes gh-171
223 lines
5.5 KiB
Groovy
223 lines
5.5 KiB
Groovy
buildscript {
|
|
repositories {
|
|
jcenter()
|
|
maven { url 'https://repo.spring.io/plugins-release' }
|
|
}
|
|
dependencies {
|
|
classpath 'io.spring.gradle:dependency-management-plugin:0.5.5.RELEASE'
|
|
classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.7'
|
|
classpath 'io.spring.gradle:spring-io-plugin:0.0.5.RELEASE'
|
|
}
|
|
}
|
|
|
|
allprojects {
|
|
group = 'org.springframework.restdocs'
|
|
repositories {
|
|
jcenter()
|
|
}
|
|
}
|
|
|
|
apply plugin: 'samples'
|
|
apply plugin: 'sonar-runner'
|
|
|
|
sonarRunner {
|
|
sonarProperties {
|
|
property 'sonar.jacoco.reportPath', "${buildDir.name}/jacoco.exec"
|
|
property 'sonar.java.coveragePlugin', 'jacoco'
|
|
property 'sonar.links.ci', 'https://build.spring.io/browse/SRD'
|
|
property 'sonar.links.homepage', 'https://github.com/spring-projects/spring-restdocs'
|
|
property 'sonar.links.issue', 'https://github.com/spring-projects/spring-restdocs'
|
|
property 'sonar.links.scm', 'https://github.com/spring-projects/spring-restdocs'
|
|
}
|
|
}
|
|
|
|
ext {
|
|
springVersion = '4.1.8.RELEASE'
|
|
javadocLinks = [
|
|
'http://docs.oracle.com/javase/8/docs/api/',
|
|
"http://docs.spring.io/spring-framework/docs/$springVersion/javadoc-api/",
|
|
'https://docs.jboss.org/hibernate/stable/beanvalidation/api/'
|
|
] as String[]
|
|
}
|
|
|
|
subprojects {
|
|
apply plugin: 'io.spring.dependency-management'
|
|
apply plugin: 'java'
|
|
apply plugin: 'eclipse'
|
|
apply plugin: 'propdeps'
|
|
apply plugin: 'propdeps-eclipse'
|
|
apply plugin: 'propdeps-maven'
|
|
apply plugin: 'maven'
|
|
|
|
sourceCompatibility = 1.7
|
|
targetCompatibility = 1.7
|
|
|
|
dependencyManagement {
|
|
imports {
|
|
mavenBom "org.springframework:spring-framework-bom:$springVersion"
|
|
}
|
|
dependencies {
|
|
dependency 'com.fasterxml.jackson.core:jackson-databind:2.4.6.1'
|
|
dependency 'com.jayway.restassured:rest-assured:2.8.0'
|
|
dependency 'com.samskivert:jmustache:1.11'
|
|
dependency 'commons-codec:commons-codec:1.10'
|
|
dependency 'javax.servlet:javax.servlet-api:3.1.0'
|
|
dependency 'javax.validation:validation-api:1.1.0.Final'
|
|
dependency 'junit:junit:4.12'
|
|
dependency 'org.hamcrest:hamcrest-core:1.3'
|
|
dependency 'org.hamcrest:hamcrest-library:1.3'
|
|
dependency 'org.hibernate:hibernate-validator:5.2.2.Final'
|
|
dependency 'org.mockito:mockito-core:1.10.19'
|
|
dependency 'org.springframework.hateoas:spring-hateoas:0.19.0.RELEASE'
|
|
dependency 'org.jacoco:org.jacoco.agent:0.7.5.201505241946'
|
|
}
|
|
}
|
|
|
|
test {
|
|
testLogging {
|
|
exceptionFormat "full"
|
|
}
|
|
}
|
|
|
|
eclipseJdt {
|
|
inputFile = rootProject.file('config/eclipse/org.eclipse.jdt.core.prefs')
|
|
doLast {
|
|
project.file('.settings/org.eclipse.jdt.ui.prefs').withWriter { writer ->
|
|
writer << rootProject.file('config/eclipse/org.eclipse.jdt.ui.prefs').text
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
configure(subprojects - project(":docs")) { subproject ->
|
|
|
|
apply plugin: 'checkstyle'
|
|
apply from: "${rootProject.projectDir}/gradle/publish-maven.gradle"
|
|
|
|
if (project.hasProperty('platformVersion')) {
|
|
apply plugin: 'spring-io'
|
|
|
|
repositories {
|
|
maven { url "https://repo.spring.io/libs-snapshot" }
|
|
}
|
|
|
|
dependencyManagement {
|
|
springIoTestRuntime {
|
|
imports {
|
|
mavenBom "io.spring.platform:platform-bom:${platformVersion}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
checkstyle {
|
|
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
|
|
configProperties = [ 'checkstyle.config.dir' : rootProject.file('config/checkstyle') ]
|
|
toolVersion = '6.10.1'
|
|
}
|
|
|
|
configurations {
|
|
jacoco
|
|
}
|
|
|
|
dependencies {
|
|
jacoco 'org.jacoco:org.jacoco.agent::runtime'
|
|
}
|
|
|
|
javadoc {
|
|
description = "Generates project-level javadoc for use in -javadoc jar"
|
|
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
|
|
options.author = true
|
|
options.header = "Spring REST Docs $version"
|
|
options.docTitle = "${options.header} API"
|
|
options.links = javadocLinks
|
|
options.addStringOption '-quiet'
|
|
}
|
|
|
|
task sourcesJar(type: Jar) {
|
|
classifier = 'sources'
|
|
from project.sourceSets.main.allSource
|
|
}
|
|
|
|
task javadocJar(type: Jar) {
|
|
classifier = "javadoc"
|
|
from javadoc
|
|
}
|
|
|
|
artifacts {
|
|
archives sourcesJar
|
|
archives javadocJar
|
|
}
|
|
}
|
|
|
|
samples {
|
|
dependOn 'spring-restdocs-core:install'
|
|
dependOn 'spring-restdocs-mockmvc:install'
|
|
|
|
restNotesSpringHateoas {
|
|
workingDir "$projectDir/samples/rest-notes-spring-hateoas"
|
|
}
|
|
|
|
restNotesSpringDataRest {
|
|
workingDir "$projectDir/samples/rest-notes-spring-data-rest"
|
|
}
|
|
|
|
testNg {
|
|
workingDir "$projectDir/samples/testng"
|
|
}
|
|
}
|
|
|
|
task api (type: Javadoc) {
|
|
group = "Documentation"
|
|
description = "Generates aggregated Javadoc API documentation."
|
|
dependsOn {
|
|
subprojects.collect {
|
|
it.tasks.getByName("jar")
|
|
}
|
|
}
|
|
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
|
|
options.author = true
|
|
options.header = "Spring REST Docs $version"
|
|
options.splitIndex = true
|
|
options.links = javadocLinks
|
|
options.addStringOption '-quiet'
|
|
|
|
source subprojects.collect { project ->
|
|
project.sourceSets.main.allJava
|
|
}
|
|
|
|
destinationDir = new File(buildDir, "api")
|
|
|
|
doFirst {
|
|
classpath = files(subprojects.collect { it.sourceSets.main.compileClasspath })
|
|
}
|
|
}
|
|
|
|
task docsZip(type: Zip, dependsOn: [':docs:asciidoctor', ':api', ':buildSamples']) {
|
|
group = 'Distribution'
|
|
baseName = 'spring-restdocs'
|
|
classifier = 'docs'
|
|
description = "Builds -${classifier} archive containing API and reference documentation"
|
|
destinationDir = file("${project.buildDir}/distributions")
|
|
|
|
from(project.tasks.findByPath(':docs:asciidoctor')) {
|
|
into 'reference'
|
|
}
|
|
|
|
from(api) {
|
|
into 'api'
|
|
}
|
|
|
|
from(file('samples/rest-notes-spring-hateoas/build/asciidoc/html5')) {
|
|
into 'samples/restful-notes'
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
archives
|
|
}
|
|
|
|
artifacts {
|
|
archives docsZip
|
|
} |