Previously, users that wanted to document a request field’s constraints had to roll their own solution. This commit introduces a new API that makes it easier to document constraints. Support is provided for discovering Bean Validation constraints and resolving descriptions for them. The constraint descriptions can then be used as required. For example, they can included in a field’s description or in an additional constraints attribute that’s included in an additional table column via the use of a custom snippet template. Closes gh-42
116 lines
3.3 KiB
Groovy
116 lines
3.3 KiB
Groovy
ext {
|
|
hamcrestVersion = '1.3'
|
|
jacocoVersion = '0.7.2.201409121644'
|
|
}
|
|
|
|
apply plugin: 'maven'
|
|
apply plugin: 'sonar-runner'
|
|
|
|
sourceCompatibility = 1.7
|
|
targetCompatibility = 1.7
|
|
|
|
eclipseJdt.onlyIf { false }
|
|
cleanEclipseJdt.onlyIf { false }
|
|
|
|
repositories {
|
|
jcenter()
|
|
}
|
|
|
|
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'
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
jacoco
|
|
jarjar
|
|
jmustache
|
|
}
|
|
|
|
task jmustacheRepackJar(type: Jar) { repackJar ->
|
|
repackJar.baseName = "restdocs-jmustache-repack"
|
|
repackJar.version = dependencyManagement.managedVersions['com.samskivert:jmustache']
|
|
|
|
doLast() {
|
|
project.ant {
|
|
taskdef name: "jarjar", classname: "com.tonicsystems.jarjar.JarJarTask",
|
|
classpath: configurations.jarjar.asPath
|
|
jarjar(destfile: repackJar.archivePath) {
|
|
configurations.jmustache.each { originalJar ->
|
|
zipfileset(src: originalJar, includes: '**/*.class')
|
|
}
|
|
rule(pattern: 'com.samskivert.**', result: 'org.springframework.restdocs.@1')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
compile 'com.fasterxml.jackson.core:jackson-databind'
|
|
compile 'junit:junit'
|
|
compile 'org.springframework:spring-core'
|
|
compile 'org.springframework:spring-test'
|
|
compile 'org.springframework:spring-web'
|
|
compile 'org.springframework:spring-webmvc'
|
|
compile 'javax.servlet:javax.servlet-api'
|
|
compile files(jmustacheRepackJar)
|
|
jacoco 'org.jacoco:org.jacoco.agent::runtime'
|
|
jarjar 'com.googlecode.jarjar:jarjar:1.3'
|
|
jmustache 'com.samskivert:jmustache@jar'
|
|
optional 'javax.validation:validation-api'
|
|
testCompile 'org.springframework.hateoas:spring-hateoas'
|
|
testCompile 'org.mockito:mockito-core'
|
|
testCompile 'org.hamcrest:hamcrest-core'
|
|
testCompile 'org.hamcrest:hamcrest-library'
|
|
testCompile 'org.hibernate:hibernate-validator'
|
|
testRuntime 'org.glassfish:javax.el:3.0.0'
|
|
}
|
|
|
|
jar {
|
|
dependsOn jmustacheRepackJar
|
|
from(zipTree(jmustacheRepackJar.archivePath)) {
|
|
include "org/springframework/restdocs/**"
|
|
}
|
|
}
|
|
|
|
task sourcesJar(type: Jar) {
|
|
classifier = 'sources'
|
|
from project.sourceSets.main.allSource
|
|
}
|
|
|
|
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 = [
|
|
'http://docs.oracle.com/javase/8/docs/api/',
|
|
"http://docs.spring.io/spring-framework/docs/${dependencyManagement.managedVersions['org.springframework:spring-core']}/javadoc-api/",
|
|
'https://docs.jboss.org/hibernate/stable/beanvalidation/api/'
|
|
] as String[]
|
|
options.addStringOption '-quiet'
|
|
}
|
|
|
|
task javadocJar(type: Jar) {
|
|
classifier = "javadoc"
|
|
from javadoc
|
|
}
|
|
|
|
artifacts {
|
|
archives sourcesJar
|
|
archives javadocJar
|
|
}
|
|
|
|
test {
|
|
jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=org.springframework.restdocs.*,excludes=org.springframework.restdocs.mustache.*"
|
|
testLogging {
|
|
exceptionFormat "full"
|
|
}
|
|
} |