From 6ec522069a2dca8c5ae95a11839afe8636ca09db Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 8 Jan 2015 16:51:47 +0000 Subject: [PATCH] Make things less Gradle-specific and provide Maven config in samples Previously, the project provided a Gradle plugin and was only really intended for use with Gradle. This had influenced a number of design choices that have proven to be less than ideal when attempting to use the project with Maven. This commit backs off from a number of design decisions that worked well with Gradle but less so with Maven. Part of this is that the Gradle plugin is (temporarily?) no more. It's been removed in favour of configuring things directly in build.gradle. While this slightly increases the amount of configuration required it makes things far more flexible. Both samples have been updated with modified Gradle configuration and new Maven configuration. The README has also been updated to reflect these changes. --- .gitignore | 3 +- README.md | 222 ++++++++++--- build.gradle | 9 - rest-notes-spring-data-rest/build.gradle | 39 ++- rest-notes-spring-data-rest/pom.xml | 99 ++++++ .../resources/documentation.properties | 1 - .../asciidoc/api-guide.asciidoc | 0 .../asciidoc/getting-started-guide.asciidoc | 0 .../com/example/notes/ApiDocumentation.java | 0 .../notes/GettingStartedDocumentation.java | 0 rest-notes-spring-hateoas/build.gradle | 39 ++- rest-notes-spring-hateoas/pom.xml | 115 +++++++ .../resources/documentation.properties | 1 - .../asciidoc/api-guide.asciidoc | 0 .../asciidoc/getting-started-guide.asciidoc | 0 .../com/example/notes/ApiDocumentation.java | 0 .../notes/GettingStartedDocumentation.java | 2 + settings.gradle | 3 +- .../core/DocumentationProperties.java | 13 +- .../core/RestDocumentationResultHandlers.java | 17 +- .../.settings/org.eclipse.jdt.core.prefs | 295 ------------------ .../org.eclipse.jdt.groovy.core.prefs | 2 - .../.settings/org.eclipse.jdt.ui.prefs | 62 ---- .../gradle/RestDocumentationPlugin.groovy | 75 ----- .../gradle/RestDocumentationSnippets.groovy | 30 -- .../org.springframework.restdocs.properties | 1 - 26 files changed, 467 insertions(+), 561 deletions(-) create mode 100644 rest-notes-spring-data-rest/pom.xml delete mode 100644 rest-notes-spring-data-rest/src/documentation/resources/documentation.properties rename rest-notes-spring-data-rest/src/{documentation => main}/asciidoc/api-guide.asciidoc (100%) rename rest-notes-spring-data-rest/src/{documentation => main}/asciidoc/getting-started-guide.asciidoc (100%) rename rest-notes-spring-data-rest/src/{documentation => test}/java/com/example/notes/ApiDocumentation.java (100%) rename rest-notes-spring-data-rest/src/{documentation => test}/java/com/example/notes/GettingStartedDocumentation.java (100%) create mode 100644 rest-notes-spring-hateoas/pom.xml delete mode 100644 rest-notes-spring-hateoas/src/documentation/resources/documentation.properties rename rest-notes-spring-hateoas/src/{documentation => main}/asciidoc/api-guide.asciidoc (100%) rename rest-notes-spring-hateoas/src/{documentation => main}/asciidoc/getting-started-guide.asciidoc (100%) rename rest-notes-spring-hateoas/src/{documentation => test}/java/com/example/notes/ApiDocumentation.java (100%) rename rest-notes-spring-hateoas/src/{documentation => test}/java/com/example/notes/GettingStartedDocumentation.java (98%) delete mode 100644 spring-restdocs-gradle-plugin/.settings/org.eclipse.jdt.core.prefs delete mode 100644 spring-restdocs-gradle-plugin/.settings/org.eclipse.jdt.groovy.core.prefs delete mode 100644 spring-restdocs-gradle-plugin/.settings/org.eclipse.jdt.ui.prefs delete mode 100644 spring-restdocs-gradle-plugin/src/main/groovy/org/springframework/restdocs/gradle/RestDocumentationPlugin.groovy delete mode 100644 spring-restdocs-gradle-plugin/src/main/groovy/org/springframework/restdocs/gradle/RestDocumentationSnippets.groovy delete mode 100644 spring-restdocs-gradle-plugin/src/main/resources/META-INF/gradle-plugins/org.springframework.restdocs.properties diff --git a/.gitignore b/.gitignore index f8506e43..91fa34ba 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ .project .settings bin -build \ No newline at end of file +build +target \ No newline at end of file diff --git a/README.md b/README.md index 5cfd9e24..328378e9 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ ## Goal The primary goal of the project is to make it easy to document RESTful services by -combining content that's been hand-written using [AsciiDoctor][1] with auto-generated -examples produced with the [Spring MVC Test][2] framework. The result is intended to -be an easy-to-read user guide, akin to [GitHub's API documentation][3] for example, -rather than the fully automated, dense API documentation produced by tools like -[Swagger][4]. +combining content that's been hand-written with auto-generated examples produced +with the [Spring MVC Test][2] framework. The result is intended to be an easy-to-read +user guide, akin to [GitHub's API documentation][3] for example, rather than the fully +automated, dense API documentation produced by tools like [Swagger][4]. For a broader introduction see the [Documenting RESTful APIs][9] presentation. @@ -18,59 +17,171 @@ $ ./gradlew build install ``` Once the main project's built, take a look at one of the two sample projects. Both -projects implement a RESTful service for creating tagged notes but have different -implementations: `rest-notes-spring-hateoas` is implemented using Spring MVC and Spring -Hateoas while `rest-notes-spring-data-rest` is implemented using Spring Data REST. - -To see the sample project's documentation move into its directory and use Gradle to -build the documentation. For example: - -``` -$ cd rest-notes-spring-data-rest -$ ./gradlew restDocumentation -``` - -Once the build is complete, open one of the following: - -- build/asciidoc/getting-started-guide.html -- build/asciidoc/api-guide.html +projects implement a RESTful service for creating tagged notes and illustrate the use +of Maven or Gradle. The two projects have different implementations: +`rest-notes-spring-hateoas` is implemented using Spring MVC and Spring Hateoas where as +`rest-notes-spring-data-rest` is implemented using Spring Data REST. Every example request and response in the documentation is auto-generated using custom Spring MVC Test result handlers. This ensures that the examples match the service that they are documenting. -## How does it work +### Building a sample with Gradle + +To see the sample project's documentation, move into its directory and use Gradle to +build it. For example: + +``` +$ cd rest-notes-spring-data-rest +$ ./gradlew asciidoctor +``` + +Once the build is complete, open one of the following: + +- build/asciidoc/html5/getting-started-guide.html +- build/asciidoc/html5/api-guide.html + +### Building a sample with Maven + +To see the sample project's documentation, move into its directory and use Maven to build +it. For example: + +``` +$ cd rest-notes-spring-hateoas +$ mvn package +``` + +Once the build is complete, open one of the following: + +- target/generated-docs/getting-started-guide.html +- target/generated-docs/api-guide.html + +## How it works There are three main pieces involved in using this project to document your RESTful service. -### Gradle plugin +### Build configuration -A Gradle plugin is provided. This plugin builds on top of the [AsciiDoctor plugin][5] -and is responsible for producing the documentation during the build. Assuming you've -built and installed the project as described in the quick start, the plugin as -configured in your project as follows: +Both Maven and Gradle are supported. + +#### Gradle configuration + +You can look at either samples' `build.gradle` file to see the required configuration. +The key parts are described below. + +Configure the AsciiDoctor plugin: ```groovy -buildscript { - repositories { - mavenLocal() - jcenter() - } - dependencies { - classpath 'org.springframework.restdocs:spring-restdocs-gradle-plugin:0.1.0.BUILD-SNAPSHOT' - } +plugins { + id "org.asciidoctor.convert" version "1.5.2" +} +``` + +Add a dependency on `spring-restdocs-core` in the `testCompile` configuration: + +```groovy +dependencies { + testCompile 'org.springframework.restdocs:spring-restdocs-core:0.1.0.BUILD-SNAPSHOT' +} +``` + +Configure a property to control the location of the generated snippets: + +```groovy +ext { + generatedDocumentation = file('build/generated-snippets') +} +``` + +Configure the `test` task with a system property to control the location to which the +snippets are generated: + +test { + systemProperty 'org.springframework.restdocs.outputDir', generatedDocumentation + outputs.dir generatedDocumentation } -apply plugin: 'org.springframework.restdocs' +Configure the `asciidoctor` task. The `generated` attribute is used to provide easy +access to the generated snippets: + +```groovy +asciidoctor { + attributes 'generated': generatedDocumentation + inputs.dir generatedDocumentation + dependsOn test +} + +``` + +#### Maven configuration + +You can look at either samples' `pom.xml` file to see the required configuration. The key +parts are described below: + +Add a dependency on `spring-restdocs-core` in the `test` scope: + +```xml + + org.springframework.restdocs + spring-restdocs-core + 0.1.0.BUILD-SNAPSHOT + test + +``` + +Configure the SureFire plugin with a system property to control the location to which +the snippets are generated: + +```xml + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*Documentation.java + + + ${project.build.directory}/generated-snippets + + + +``` + +Configure the AsciiDoctor plugin. The `generated` attribute is used to provide easy +access to the generated snippets: + +```xml + + org.asciidoctor + asciidoctor-maven-plugin + 1.5.2 + + + generate-docs + package + + process-asciidoc + + + html + book + + ${project.build.directory}/generated-snippets + + + + + + ``` ### Programatically generated snippets Spring's MVC Test framework is used to make requests to the service that you are -documenting. Any such request wrapped in a call to `RestDocumentation.document` will -produce individual documentation snippets for its request and its response as well as -a snippet that contains both its request and its response. +documenting. A custom `ResultHandler` is used to produce individual documentation +snippets for its request and its response as well as a snippet that contains both its +request and its response. You can configure the scheme, host, and port of any URIs that appear in the documentation snippets: @@ -105,31 +216,50 @@ public void getIndex() { The code above will perform a `GET` request against the index (`/`) of the service with an accept header indicating that a JSON response is required. It will write the cURL command for the request and the resulting response to files in a directory named -`index` in the project's `build/generated-documentation/` directory. Three files will +`index` in the project's `build/generated-snippets/` directory. Three files will be written: - `index/request.asciidoc` - `index/response.asciidoc` - `index/request-response.asciidoc` -### Documentation written in Asciidoc +### Hand-written documentation Producing high-quality, easily readable documentation is difficult and the process is only made harder by trying to write the documentation in an ill-suited format such as Java annotations. This project addresses this by allowing you to write the bulk of -your documentation's text as an Asciidoc document. These files should be placed in -`src/documentation/asciidoc`. +your documentation's text using [Asciidoctor][1]. The default location for source files +depends on whether you're using Maven or Gradle. By default, AsciiDoctor's Maven plugin +looks in `src/main/asciidoc`, whereas the AsciiDoctor Gradle plugin looks in +`src/docs/asciidoc` To include the programmatically generated snippets in your documentation, you use -Asciidoc's [`include` macro][6]. The Gradle plugin provides an attribute, `generated`, -that you can use to reference the directory to which the snippets are written. For -example, to include both the request and response snippets described above: +Asciidoc's [`include` macro][6]. The Maven and Gradle configuration described above +configures an attribute, `generated`, that you can use to reference the directory to +which the snippets are written. For example, to include both the request and response +snippets described above: ``` include::{generated}/index/request.asciidoc[] include::{generated}/index/response.asciidoc[] ``` +## Generating snippets in your IDE + +As described above, a system property is used to configure the location to which the +generated snippets are written. When running documentation tests in your IDE this system +property will not have been set. If the property is not set the snippets will be written +to standard out. + +If you'd prefer that your IDE writes the snippets to disk you can use a file +in `src/test/resources` named `documentation.properties` to configure the property. +For example: + +```properties +org.springframework.restdocs.outputDir: target/generated-snippets + +``` + ## Learning more To learn more, take a look at the accompanying sample projects: diff --git a/build.gradle b/build.gradle index 55117d1a..e61cbffe 100644 --- a/build.gradle +++ b/build.gradle @@ -20,15 +20,6 @@ project(':spring-restdocs-core') { } } -project(':spring-restdocs-gradle-plugin') { - apply plugin: 'groovy' - - dependencies { - compile gradleApi() - runtime 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.0' - } -} - subprojects { repositories { jcenter() diff --git a/rest-notes-spring-data-rest/build.gradle b/rest-notes-spring-data-rest/build.gradle index 95b693ae..386a81d2 100644 --- a/rest-notes-spring-data-rest/build.gradle +++ b/rest-notes-spring-data-rest/build.gradle @@ -1,26 +1,23 @@ buildscript { repositories { - mavenLocal() - maven { - url 'https://repo.spring.io/libs-milestone' - } + mavenCentral() } dependencies { - classpath 'org.springframework.restdocs:spring-restdocs-gradle-plugin:0.1.0.BUILD-SNAPSHOT' - classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.2.0.M2' + classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.2.1.RELEASE' } } +plugins { + id "org.asciidoctor.convert" version "1.5.2" +} + apply plugin: 'java' apply plugin: 'spring-boot' apply plugin: 'eclipse' -apply plugin: 'org.springframework.restdocs' repositories { mavenLocal() - maven { - url 'https://repo.spring.io/libs-milestone' - } + mavenCentral() } group = 'com.example' @@ -31,12 +28,28 @@ dependencies { runtime 'com.h2database:h2' - documentationCompile 'com.jayway.jsonpath:json-path' - documentationCompile 'org.springframework.boot:spring-boot-starter-test' - documentationCompile 'org.springframework.restdocs:spring-restdocs-core:0.1.0.BUILD-SNAPSHOT' + testCompile 'com.jayway.jsonpath:json-path' + testCompile 'org.springframework.boot:spring-boot-starter-test' + testCompile 'org.springframework.restdocs:spring-restdocs-core:0.1.0.BUILD-SNAPSHOT' } +ext { + generatedDocumentation = file('build/generated-snippets') +} + +test { + systemProperty 'org.springframework.restdocs.outputDir', generatedDocumentation + outputs.dir generatedDocumentation +} + +asciidoctor { + sourceDir 'src/main/asciidoc' // Align with Maven's default location + attributes 'generated': generatedDocumentation + inputs.dir generatedDocumentation + dependsOn test +} + task wrapper(type: Wrapper) { gradleVersion = '2.1' } diff --git a/rest-notes-spring-data-rest/pom.xml b/rest-notes-spring-data-rest/pom.xml new file mode 100644 index 00000000..10a33975 --- /dev/null +++ b/rest-notes-spring-data-rest/pom.xml @@ -0,0 +1,99 @@ + + + 4.0.0 + + com.example + rest-notes-spring-hateoas + 0.0.1-SNAPSHOT + jar + + + org.springframework.boot + spring-boot-starter-parent + 1.2.1.RELEASE + + + + + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-data-rest + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + com.h2database + h2 + runtime + + + + org.springframework.boot + spring-boot-starter-test + test + + + com.jayway.jsonpath + json-path + test + + + org.springframework.restdocs + spring-restdocs-core + 0.1.0.BUILD-SNAPSHOT + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*Documentation.java + + + ${project.build.directory}/generated-snippets + + + + + org.asciidoctor + asciidoctor-maven-plugin + 1.5.2 + + + generate-docs + package + + process-asciidoc + + + html + book + + ${project.build.directory}/generated-snippets + + + + + + + + + \ No newline at end of file diff --git a/rest-notes-spring-data-rest/src/documentation/resources/documentation.properties b/rest-notes-spring-data-rest/src/documentation/resources/documentation.properties deleted file mode 100644 index 901c0049..00000000 --- a/rest-notes-spring-data-rest/src/documentation/resources/documentation.properties +++ /dev/null @@ -1 +0,0 @@ -org.springframework.restdocs.outputDir = build/generated-documentation \ No newline at end of file diff --git a/rest-notes-spring-data-rest/src/documentation/asciidoc/api-guide.asciidoc b/rest-notes-spring-data-rest/src/main/asciidoc/api-guide.asciidoc similarity index 100% rename from rest-notes-spring-data-rest/src/documentation/asciidoc/api-guide.asciidoc rename to rest-notes-spring-data-rest/src/main/asciidoc/api-guide.asciidoc diff --git a/rest-notes-spring-data-rest/src/documentation/asciidoc/getting-started-guide.asciidoc b/rest-notes-spring-data-rest/src/main/asciidoc/getting-started-guide.asciidoc similarity index 100% rename from rest-notes-spring-data-rest/src/documentation/asciidoc/getting-started-guide.asciidoc rename to rest-notes-spring-data-rest/src/main/asciidoc/getting-started-guide.asciidoc diff --git a/rest-notes-spring-data-rest/src/documentation/java/com/example/notes/ApiDocumentation.java b/rest-notes-spring-data-rest/src/test/java/com/example/notes/ApiDocumentation.java similarity index 100% rename from rest-notes-spring-data-rest/src/documentation/java/com/example/notes/ApiDocumentation.java rename to rest-notes-spring-data-rest/src/test/java/com/example/notes/ApiDocumentation.java diff --git a/rest-notes-spring-data-rest/src/documentation/java/com/example/notes/GettingStartedDocumentation.java b/rest-notes-spring-data-rest/src/test/java/com/example/notes/GettingStartedDocumentation.java similarity index 100% rename from rest-notes-spring-data-rest/src/documentation/java/com/example/notes/GettingStartedDocumentation.java rename to rest-notes-spring-data-rest/src/test/java/com/example/notes/GettingStartedDocumentation.java diff --git a/rest-notes-spring-hateoas/build.gradle b/rest-notes-spring-hateoas/build.gradle index 61ccd7d4..30b85f68 100644 --- a/rest-notes-spring-hateoas/build.gradle +++ b/rest-notes-spring-hateoas/build.gradle @@ -1,26 +1,23 @@ buildscript { repositories { - mavenLocal() - maven { - url "https://repo.spring.io/libs-milestone" - } + mavenCentral() } dependencies { - classpath 'org.springframework.restdocs:spring-restdocs-gradle-plugin:0.1.0.BUILD-SNAPSHOT' - classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.2.0.M2' + classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.2.1.RELEASE' } } +plugins { + id "org.asciidoctor.convert" version "1.5.2" +} + apply plugin: 'java' apply plugin: 'spring-boot' apply plugin: 'eclipse' -apply plugin: 'org.springframework.restdocs' repositories { mavenLocal() - maven { - url "https://repo.spring.io/libs-milestone" - } + mavenCentral() } group = 'com.example' @@ -34,9 +31,25 @@ dependencies { runtime 'org.springframework.plugin:spring-plugin-core:1.1.0.RELEASE' runtime 'org.atteo:evo-inflector:1.2' - documentationCompile 'com.jayway.jsonpath:json-path' - documentationCompile 'org.springframework.boot:spring-boot-starter-test' - documentationCompile 'org.springframework.restdocs:spring-restdocs-core:0.1.0.BUILD-SNAPSHOT' + testCompile 'com.jayway.jsonpath:json-path' + testCompile 'org.springframework.boot:spring-boot-starter-test' + testCompile 'org.springframework.restdocs:spring-restdocs-core:0.1.0.BUILD-SNAPSHOT' +} + +ext { + generatedDocumentation = file('build/generated-snippets') +} + +test { + systemProperty 'org.springframework.restdocs.outputDir', generatedDocumentation + outputs.dir generatedDocumentation +} + +asciidoctor { + sourceDir 'src/main/asciidoc' // Align with Maven's default location + attributes 'generated': generatedDocumentation + inputs.dir generatedDocumentation + dependsOn test } task wrapper(type: Wrapper) { diff --git a/rest-notes-spring-hateoas/pom.xml b/rest-notes-spring-hateoas/pom.xml new file mode 100644 index 00000000..3ed34f89 --- /dev/null +++ b/rest-notes-spring-hateoas/pom.xml @@ -0,0 +1,115 @@ + + + 4.0.0 + + com.example + rest-notes-spring-hateoas + 0.0.1-SNAPSHOT + jar + + + org.springframework.boot + spring-boot-starter-parent + 1.2.1.RELEASE + + + + + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.hateoas + spring-hateoas + + + + org.springframework.plugin + spring-plugin-core + 1.1.0.RELEASE + runtime + + + com.h2database + h2 + runtime + + + org.atteo + evo-inflector + 1.2 + runtime + + + + org.springframework.boot + spring-boot-starter-test + test + + + com.jayway.jsonpath + json-path + test + + + org.springframework.restdocs + spring-restdocs-core + 0.1.0.BUILD-SNAPSHOT + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*Documentation.java + + + ${project.build.directory}/generated-snippets + + + + + org.asciidoctor + asciidoctor-maven-plugin + 1.5.2 + + + generate-docs + package + + process-asciidoc + + + html + book + + ${project.build.directory}/generated-snippets + + + + + + + + + \ No newline at end of file diff --git a/rest-notes-spring-hateoas/src/documentation/resources/documentation.properties b/rest-notes-spring-hateoas/src/documentation/resources/documentation.properties deleted file mode 100644 index 901c0049..00000000 --- a/rest-notes-spring-hateoas/src/documentation/resources/documentation.properties +++ /dev/null @@ -1 +0,0 @@ -org.springframework.restdocs.outputDir = build/generated-documentation \ No newline at end of file diff --git a/rest-notes-spring-hateoas/src/documentation/asciidoc/api-guide.asciidoc b/rest-notes-spring-hateoas/src/main/asciidoc/api-guide.asciidoc similarity index 100% rename from rest-notes-spring-hateoas/src/documentation/asciidoc/api-guide.asciidoc rename to rest-notes-spring-hateoas/src/main/asciidoc/api-guide.asciidoc diff --git a/rest-notes-spring-hateoas/src/documentation/asciidoc/getting-started-guide.asciidoc b/rest-notes-spring-hateoas/src/main/asciidoc/getting-started-guide.asciidoc similarity index 100% rename from rest-notes-spring-hateoas/src/documentation/asciidoc/getting-started-guide.asciidoc rename to rest-notes-spring-hateoas/src/main/asciidoc/getting-started-guide.asciidoc diff --git a/rest-notes-spring-hateoas/src/documentation/java/com/example/notes/ApiDocumentation.java b/rest-notes-spring-hateoas/src/test/java/com/example/notes/ApiDocumentation.java similarity index 100% rename from rest-notes-spring-hateoas/src/documentation/java/com/example/notes/ApiDocumentation.java rename to rest-notes-spring-hateoas/src/test/java/com/example/notes/ApiDocumentation.java diff --git a/rest-notes-spring-hateoas/src/documentation/java/com/example/notes/GettingStartedDocumentation.java b/rest-notes-spring-hateoas/src/test/java/com/example/notes/GettingStartedDocumentation.java similarity index 98% rename from rest-notes-spring-hateoas/src/documentation/java/com/example/notes/GettingStartedDocumentation.java rename to rest-notes-spring-hateoas/src/test/java/com/example/notes/GettingStartedDocumentation.java index 9c57ede9..a37e573e 100644 --- a/rest-notes-spring-hateoas/src/documentation/java/com/example/notes/GettingStartedDocumentation.java +++ b/rest-notes-spring-hateoas/src/test/java/com/example/notes/GettingStartedDocumentation.java @@ -23,6 +23,7 @@ import static org.springframework.restdocs.core.RestDocumentation.document; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -172,6 +173,7 @@ public class GettingStartedDocumentation { .andReturn(), "note-tags"); this.mockMvc.perform(get(tagsLocation)) .andExpect(status().isOk()) + .andDo(print()) .andExpect(jsonPath("_embedded.tags", hasSize(1))) .andDo(document("get-tags")); } diff --git a/settings.gradle b/settings.gradle index 5b586ab1..c74ec6c2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,3 @@ rootProject.name = 'spring-restdocs' -include 'spring-restdocs-core' -include 'spring-restdocs-gradle-plugin' \ No newline at end of file +include 'spring-restdocs-core' \ No newline at end of file diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/DocumentationProperties.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/DocumentationProperties.java index ba8c5d18..8ecc84b5 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/DocumentationProperties.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/DocumentationProperties.java @@ -21,13 +21,13 @@ import java.io.IOException; import java.io.InputStream; import java.util.Properties; +import org.springframework.util.StringUtils; + class DocumentationProperties { private final Properties properties = new Properties(); DocumentationProperties() { - this.properties.putAll(System.getProperties()); - InputStream stream = getClass().getClassLoader().getResourceAsStream( "documentation.properties"); if (stream != null) { @@ -47,11 +47,14 @@ class DocumentationProperties { } } } + this.properties.putAll(System.getProperties()); } File getOutputDir() { - return new File(this.properties.getProperty( - "org.springframework.restdocs.outputDir", "generated-documentation")) - .getAbsoluteFile(); + String outputDir = this.properties.getProperty("org.springframework.restdocs.outputDir"); + if (StringUtils.hasText(outputDir)) { + return new File(outputDir).getAbsoluteFile(); + } + return null; } } diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/RestDocumentationResultHandlers.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/RestDocumentationResultHandlers.java index 2745029a..cd1d7c7c 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/RestDocumentationResultHandlers.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/RestDocumentationResultHandlers.java @@ -205,14 +205,21 @@ public abstract class RestDocumentationResultHandlers { if (!outputFile.isAbsolute()) { outputFile = makeAbsolute(outputFile); } - outputFile.getParentFile().mkdirs(); - - return new PrintStream(new FileOutputStream(outputFile)); + + if (outputFile != null) { + outputFile.getParentFile().mkdirs(); + return new PrintStream(new FileOutputStream(outputFile)); + } + + return System.out; } private static File makeAbsolute(File outputFile) { - return new File(new DocumentationProperties().getOutputDir(), - outputFile.getPath()); + File outputDir = new DocumentationProperties().getOutputDir(); + if (outputDir != null) { + return new File(outputDir, outputFile.getPath()); + } + return null; } } diff --git a/spring-restdocs-gradle-plugin/.settings/org.eclipse.jdt.core.prefs b/spring-restdocs-gradle-plugin/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index a92f7ab8..00000000 --- a/spring-restdocs-gradle-plugin/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,295 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=false -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true -org.eclipse.jdt.core.formatter.comment.format_source_code=false -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=false -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=do not insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert -org.eclipse.jdt.core.formatter.comment.line_length=90 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=8 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.join_lines_in_comments=true -org.eclipse.jdt.core.formatter.join_wrapped_lines=true -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=90 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=tab -org.eclipse.jdt.core.formatter.tabulation.size=4 -org.eclipse.jdt.core.formatter.use_on_off_tags=false -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true -org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true diff --git a/spring-restdocs-gradle-plugin/.settings/org.eclipse.jdt.groovy.core.prefs b/spring-restdocs-gradle-plugin/.settings/org.eclipse.jdt.groovy.core.prefs deleted file mode 100644 index a7f72ec6..00000000 --- a/spring-restdocs-gradle-plugin/.settings/org.eclipse.jdt.groovy.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -groovy.compiler.level=23 diff --git a/spring-restdocs-gradle-plugin/.settings/org.eclipse.jdt.ui.prefs b/spring-restdocs-gradle-plugin/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 0fc7e2d2..00000000 --- a/spring-restdocs-gradle-plugin/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,62 +0,0 @@ -cleanup.add_default_serial_version_id=true -cleanup.add_generated_serial_version_id=false -cleanup.add_missing_annotations=true -cleanup.add_missing_deprecated_annotations=true -cleanup.add_missing_methods=false -cleanup.add_missing_nls_tags=false -cleanup.add_missing_override_annotations=true -cleanup.add_missing_override_annotations_interface_methods=true -cleanup.add_serial_version_id=false -cleanup.always_use_blocks=true -cleanup.always_use_parentheses_in_expressions=false -cleanup.always_use_this_for_non_static_field_access=true -cleanup.always_use_this_for_non_static_method_access=false -cleanup.convert_functional_interfaces=false -cleanup.convert_to_enhanced_for_loop=false -cleanup.correct_indentation=false -cleanup.format_source_code=true -cleanup.format_source_code_changes_only=false -cleanup.insert_inferred_type_arguments=false -cleanup.make_local_variable_final=false -cleanup.make_parameters_final=false -cleanup.make_private_fields_final=false -cleanup.make_type_abstract_if_missing_method=false -cleanup.make_variable_declarations_final=false -cleanup.never_use_blocks=false -cleanup.never_use_parentheses_in_expressions=true -cleanup.organize_imports=true -cleanup.qualify_static_field_accesses_with_declaring_class=false -cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -cleanup.qualify_static_member_accesses_with_declaring_class=true -cleanup.qualify_static_method_accesses_with_declaring_class=false -cleanup.remove_private_constructors=true -cleanup.remove_redundant_type_arguments=true -cleanup.remove_trailing_whitespaces=true -cleanup.remove_trailing_whitespaces_all=true -cleanup.remove_trailing_whitespaces_ignore_empty=false -cleanup.remove_unnecessary_casts=true -cleanup.remove_unnecessary_nls_tags=false -cleanup.remove_unused_imports=true -cleanup.remove_unused_local_variables=false -cleanup.remove_unused_private_fields=true -cleanup.remove_unused_private_members=false -cleanup.remove_unused_private_methods=true -cleanup.remove_unused_private_types=true -cleanup.sort_members=false -cleanup.sort_members_all=false -cleanup.use_anonymous_class_creation=false -cleanup.use_blocks=true -cleanup.use_blocks_only_for_return_and_throw=false -cleanup.use_lambda=true -cleanup.use_parentheses_in_expressions=false -cleanup.use_this_for_non_static_field_access=false -cleanup.use_this_for_non_static_field_access_only_if_necessary=false -cleanup.use_this_for_non_static_method_access=false -cleanup.use_this_for_non_static_method_access_only_if_necessary=true -cleanup.use_type_arguments=false -cleanup_profile=_Spring Rest Docs Cleanup Conventions -cleanup_settings_version=2 -eclipse.preferences.version=1 -formatter_profile=_Spring Rest Docs Java Conventions -formatter_settings_version=12 diff --git a/spring-restdocs-gradle-plugin/src/main/groovy/org/springframework/restdocs/gradle/RestDocumentationPlugin.groovy b/spring-restdocs-gradle-plugin/src/main/groovy/org/springframework/restdocs/gradle/RestDocumentationPlugin.groovy deleted file mode 100644 index abfdd8c2..00000000 --- a/spring-restdocs-gradle-plugin/src/main/groovy/org/springframework/restdocs/gradle/RestDocumentationPlugin.groovy +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.restdocs.gradle - -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.plugins.ide.eclipse.GenerateEclipseClasspath - - -class RestDocumentationPlugin implements Plugin { - - void apply(Project project) { - project.sourceSets { - documentation { - java { srcDir 'src/documentation/java' } - - compileClasspath = project.files(project.sourceSets.main.output, - project.configurations.documentationCompile) - runtimeClasspath = project.files(project.sourceSets.main.output, - project.sourceSets.documentation.output, - project.configurations.documentationRuntime) - } - } - - project.configurations.documentationCompile.extendsFrom project.configurations.compile - - project.configurations.documentationRuntime.extendsFrom( - project.configurations.runtime, project.configurations.documentationCompile) - - project.tasks.withType(GenerateEclipseClasspath) { - it.classpath.sourceSets += project.sourceSets.documentation - it.classpath.plusConfigurations += [ - project.configurations.documentationRuntime - ] - } - - def restDocumentationSnippets = project.tasks.create('restDocumentationSnippets', RestDocumentationSnippets) - - - project.apply plugin: 'org.asciidoctor.gradle.asciidoctor' - - project.asciidoctor { - dependsOn restDocumentationSnippets - group '' - sourceDir = project.file 'src/documentation/asciidoc' - options = [ - attributes: [ - generated: new File("$project.buildDir/generated-documentation").toURI().toURL(), - 'allow-uri-read': true - ] - ] - inputs.files restDocumentationSnippets.outputs.files - } - - project.task('restDocumentation') { - dependsOn ':asciidoctor' - description 'Generates RESTful service documentation using AsciiDoctor' - group 'Documentation' - } - } -} \ No newline at end of file diff --git a/spring-restdocs-gradle-plugin/src/main/groovy/org/springframework/restdocs/gradle/RestDocumentationSnippets.groovy b/spring-restdocs-gradle-plugin/src/main/groovy/org/springframework/restdocs/gradle/RestDocumentationSnippets.groovy deleted file mode 100644 index 416d35bd..00000000 --- a/spring-restdocs-gradle-plugin/src/main/groovy/org/springframework/restdocs/gradle/RestDocumentationSnippets.groovy +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.restdocs.gradle; - -import org.gradle.api.tasks.testing.Test - -public class RestDocumentationSnippets extends Test { - - RestDocumentationSnippets() { - description 'Generates snippets for inclusion in the documentation' - inputs.source project.sourceSets.documentation.java.srcDirs - testClassesDir = project.sourceSets.documentation.output.classesDir - classpath = project.sourceSets.documentation.runtimeClasspath - systemProperty 'org.springframework.restdocs.outputDir', new File(project.buildDir, 'generated-documentation') - } -} diff --git a/spring-restdocs-gradle-plugin/src/main/resources/META-INF/gradle-plugins/org.springframework.restdocs.properties b/spring-restdocs-gradle-plugin/src/main/resources/META-INF/gradle-plugins/org.springframework.restdocs.properties deleted file mode 100644 index 30ca3bcf..00000000 --- a/spring-restdocs-gradle-plugin/src/main/resources/META-INF/gradle-plugins/org.springframework.restdocs.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=org.springframework.restdocs.gradle.RestDocumentationPlugin \ No newline at end of file