├── .build
├── apache-copyright.header
└── checkstyle.xml
├── .circleci
└── config.yml
├── .editorconfig
├── .gitattributes
├── .gitignore
├── .mvn
└── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── LICENSE
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── mvnw
├── mvnw.cmd
├── pom.xml
├── publishing.gradle
├── settings.gradle
└── src
├── main
└── java
│ └── springfox
│ └── javadoc
│ ├── configuration
│ └── JavadocPluginConfiguration.java
│ ├── doclet
│ ├── DocletOptionParser.java
│ ├── DocletOptions.java
│ ├── DocletOptionsBuilder.java
│ └── SwaggerPropertiesDoclet.java
│ └── plugin
│ └── JavadocBuilderPlugin.java
└── test
└── java
└── springfox
└── javadoc
├── doclet
└── SwaggerPropertiesDocletTest.java
└── example
├── TestController.java
└── package-info.java
/.build/apache-copyright.header:
--------------------------------------------------------------------------------
1 | ^\Q/*\E$
2 | ^\Q *\E$
3 | ^\Q * Copyright \E(20\d\d\-)?20\d\d\Q the original author or authors.\E$
4 | ^\Q *\E$
5 | ^\Q * Licensed under the Apache License, Version 2.0 (the "License");\E$
6 | ^\Q * you may not use this file except in compliance with the License.\E$
7 | ^\Q * You may obtain a copy of the License at\E$
8 | ^\Q *\E$
9 | ^\Q * http://www.apache.org/licenses/LICENSE-2.0\E$
10 | ^\Q *\E$
11 | ^\Q * Unless required by applicable law or agreed to in writing, software\E$
12 | ^\Q * distributed under the License is distributed on an "AS IS" BASIS,\E$
13 | ^\Q * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\E$
14 | ^\Q * See the License for the specific language governing permissions and\E$
15 | ^\Q * limitations under the License.\E$
16 | ^\Q *\E$
17 | ^\Q *\E$
18 | ^\Q */\E$
19 | ^.*$
--------------------------------------------------------------------------------
/.build/checkstyle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
20 |
21 |
22 |
23 |
24 |
26 |
27 |
28 |
32 |
33 |
34 |
35 |
36 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | jobs:
3 | build:
4 | working_directory: ~/code
5 | docker:
6 | - image: circleci/openjdk:8-jdk-node-browsers
7 | environment:
8 | JVM_OPTIONS: -Xmx1024M -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=512M
9 | GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-Xmx3840m -XX:+HeapDumpOnOutOfMemoryError"'
10 | steps:
11 | - checkout
12 | - restore_cache:
13 | key: jars-{{ checksum "build.gradle" }}-{{ checksum "build.gradle" }}
14 | # - run:
15 | # name: Chmod permissions #if permission for Gradlew Dependencies fail, use this.
16 | # command: sudo chmod +x ./gradlew
17 | - run:
18 | name: Download Dependencies
19 | command: ./gradlew dependencies
20 | - run:
21 | name: pre-dependencies
22 | command: npm install codecov
23 | - save_cache:
24 | paths:
25 | - ~/node_modules
26 | - ~/.m2
27 | - ~/.gradle
28 | key: jars-{{ checksum "build.gradle" }}-{{ checksum "build.gradle" }}
29 | - run:
30 | name: Run Tests
31 | command: ./gradlew clean build jacocoTestReport --no-daemon
32 | no_output_timeout: 900s
33 | environment:
34 | _JAVA_OPTIONS: -Xmx1024M -XX:ReservedCodeCacheSize=512M
35 | - run:
36 | name: Post test
37 | command: ./node_modules/.bin/codecov
38 | - run:
39 | name: Save test results
40 | command: |
41 | mkdir -p ~/junit/
42 | mkdir -p ~/reports/
43 | find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/junit/ \;
44 | cp -R build/reports/tests ~/reports
45 | when: always
46 | - store_test_results:
47 | path: ~/junit
48 | - store_test_results:
49 | path: ~/reports
50 | - store_artifacts:
51 | path: ~/junit
52 | - store_artifacts:
53 | path: ~/reports
54 | - deploy:
55 | command: |
56 | if [ "${CIRCLE_BRANCH}" == "master" ]; then
57 | ./gradlew artifactoryPublish -x check
58 | fi
59 | notify:
60 | webhooks:
61 | - url: https://webhooks.gitter.im/e/b30a7db820817acfc6d8
62 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | end_of_line = lf
5 | insert_final_newline = true
6 | trim_trailing_whitespace = true
7 | indent_style = space
8 | indent_size = 4
9 | charset = utf-8
10 | max_line_length = 100
11 |
12 | [*.md]
13 | trim_trailing_whitespace = false
14 |
15 | [*.java]
16 | indent_style = space
17 | indent_size = 4
18 | continuation_indent_size = 2
19 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | src/* linguist-documentation=false
2 | .mvn/* linguist-vendored
3 | mvnw linguist-vendored
4 | mvnw.cmd linguist-vendored
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | #Eclipse files
11 | .classpath
12 | .project
13 | /.settings/
14 |
15 | # Mobile Tools for Java (J2ME)
16 | .mtj.tmp/
17 |
18 | # Package Files #
19 | *.jar
20 | *.war
21 | *.ear
22 | *.zip
23 | *.tar.gz
24 | *.rar
25 |
26 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
27 | hs_err_pid*
28 | /target/
29 | .idea
30 | *.iml
31 | .gradle
32 | .env
33 | build
34 | out
35 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springfox/springfox-javadoc/8d085e9abe566b28664f9dea3d4a224610253810/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # springfox-javadoc
2 |
3 | [](https://circleci.com/gh/springfox/springfox-javadoc) [](https://app.codacy.com/app/dilip-krishnan-github/springfox-javadoc?utm_source=github.com&utm_medium=referral&utm_content=springfox/springfox-javadoc&utm_campaign=badger)
4 | [](https://app.fossa.io/projects/git%2Bgithub.com%2Fspringfox%2Fspringfox-javadoc?ref=badge_shield)
5 |
6 | Ability to use Javadoc for documentation for generating OpenAPI specifications
7 |
8 | To use this, make sure that `JavadocPluginConfiguration` is found by your spring context and add the execution of the javadoc doclet to your build process.
9 |
10 | Maven example:
11 | ```xml
12 |
13 | org.apache.maven.plugins
14 | maven-javadoc-plugin
15 | 2.10.4
16 |
17 |
18 |
19 | javadoc
20 |
21 | process-classes
22 |
23 | springfox.javadoc.doclet.SwaggerPropertiesDoclet
24 |
25 | io.springfox
26 | springfox-javadoc
27 | ${springfox-javadoc.version}
28 |
29 |
30 | -classdir ${project.build.outputDirectory}
31 |
32 | ${project.build.sourceDirectory}
33 | your.rest.service.package
34 | false
35 |
36 |
37 |
38 |
39 | ```
40 |
41 |
42 | ## License
43 | [](https://app.fossa.io/projects/git%2Bgithub.com%2Fspringfox%2Fspringfox-javadoc?ref=badge_large)
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.github.ben-manes.versions' version '0.20.0'
3 | id "com.jfrog.artifactory" version "4.7.5"
4 | id "com.jfrog.bintray" version "1.8.4"
5 | }
6 |
7 | apply plugin: 'idea'
8 | apply plugin: 'java'
9 | apply plugin: 'maven'
10 | apply plugin: 'osgi'
11 | apply plugin: 'jacoco'
12 | apply plugin: 'maven-publish'
13 | apply from: "publishing.gradle"
14 |
15 | group = 'io.springfox'
16 | description = "springfox-javadoc"
17 |
18 | sourceCompatibility = 1.6
19 | targetCompatibility = 1.6
20 |
21 | tasks.withType(JavaCompile) {
22 | options.encoding = 'UTF-8'
23 | options.deprecation = true
24 | options.compilerArgs += ["-Xlint:unchecked", "-parameters"]
25 | }
26 |
27 | repositories {
28 | jcenter()
29 | mavenCentral()
30 | }
31 |
32 | dependencies {
33 | compile 'io.springfox:springfox-swagger2:2.9.2'
34 | compile 'org.springframework:spring-webmvc:4.3.18.RELEASE'
35 | testCompile 'junit:junit:4.12'
36 | testCompile 'org.mockito:mockito-core:2.21.0'
37 | compile files("${System.getProperty('java.home')}/../lib/tools.jar")
38 | }
39 |
40 | jacoco {
41 | toolVersion = "0.8.1"
42 | }
43 |
44 | jacocoTestReport {
45 | reports {
46 | xml.enabled true
47 | html.enabled true
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | version=0.10.0-SNAPSHOT
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springfox/springfox-javadoc/8d085e9abe566b28664f9dea3d4a224610253810/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven2 Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59 | if [ -z "$JAVA_HOME" ]; then
60 | if [ -x "/usr/libexec/java_home" ]; then
61 | export JAVA_HOME="`/usr/libexec/java_home`"
62 | else
63 | export JAVA_HOME="/Library/Java/Home"
64 | fi
65 | fi
66 | ;;
67 | esac
68 |
69 | if [ -z "$JAVA_HOME" ] ; then
70 | if [ -r /etc/gentoo-release ] ; then
71 | JAVA_HOME=`java-config --jre-home`
72 | fi
73 | fi
74 |
75 | if [ -z "$M2_HOME" ] ; then
76 | ## resolve links - $0 may be a link to maven's home
77 | PRG="$0"
78 |
79 | # need this for relative symlinks
80 | while [ -h "$PRG" ] ; do
81 | ls=`ls -ld "$PRG"`
82 | link=`expr "$ls" : '.*-> \(.*\)$'`
83 | if expr "$link" : '/.*' > /dev/null; then
84 | PRG="$link"
85 | else
86 | PRG="`dirname "$PRG"`/$link"
87 | fi
88 | done
89 |
90 | saveddir=`pwd`
91 |
92 | M2_HOME=`dirname "$PRG"`/..
93 |
94 | # make it fully qualified
95 | M2_HOME=`cd "$M2_HOME" && pwd`
96 |
97 | cd "$saveddir"
98 | # echo Using m2 at $M2_HOME
99 | fi
100 |
101 | # For Cygwin, ensure paths are in UNIX format before anything is touched
102 | if $cygwin ; then
103 | [ -n "$M2_HOME" ] &&
104 | M2_HOME=`cygpath --unix "$M2_HOME"`
105 | [ -n "$JAVA_HOME" ] &&
106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
107 | [ -n "$CLASSPATH" ] &&
108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
109 | fi
110 |
111 | # For Mingw, ensure paths are in UNIX format before anything is touched
112 | if $mingw ; then
113 | [ -n "$M2_HOME" ] &&
114 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
115 | [ -n "$JAVA_HOME" ] &&
116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117 | # TODO classpath?
118 | fi
119 |
120 | if [ -z "$JAVA_HOME" ]; then
121 | javaExecutable="`which javac`"
122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
123 | # readlink(1) is not available as standard on Solaris 10.
124 | readLink=`which readlink`
125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
126 | if $darwin ; then
127 | javaHome="`dirname \"$javaExecutable\"`"
128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
129 | else
130 | javaExecutable="`readlink -f \"$javaExecutable\"`"
131 | fi
132 | javaHome="`dirname \"$javaExecutable\"`"
133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
134 | JAVA_HOME="$javaHome"
135 | export JAVA_HOME
136 | fi
137 | fi
138 | fi
139 |
140 | if [ -z "$JAVACMD" ] ; then
141 | if [ -n "$JAVA_HOME" ] ; then
142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
143 | # IBM's JDK on AIX uses strange locations for the executables
144 | JAVACMD="$JAVA_HOME/jre/sh/java"
145 | else
146 | JAVACMD="$JAVA_HOME/bin/java"
147 | fi
148 | else
149 | JAVACMD="`which java`"
150 | fi
151 | fi
152 |
153 | if [ ! -x "$JAVACMD" ] ; then
154 | echo "Error: JAVA_HOME is not defined correctly." >&2
155 | echo " We cannot execute $JAVACMD" >&2
156 | exit 1
157 | fi
158 |
159 | if [ -z "$JAVA_HOME" ] ; then
160 | echo "Warning: JAVA_HOME environment variable is not set."
161 | fi
162 |
163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
164 |
165 | # traverses directory structure from process work directory to filesystem root
166 | # first directory with .mvn subdirectory is considered project base directory
167 | find_maven_basedir() {
168 |
169 | if [ -z "$1" ]
170 | then
171 | echo "Path not specified to find_maven_basedir"
172 | return 1
173 | fi
174 |
175 | basedir="$1"
176 | wdir="$1"
177 | while [ "$wdir" != '/' ] ; do
178 | if [ -d "$wdir"/.mvn ] ; then
179 | basedir=$wdir
180 | break
181 | fi
182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
183 | if [ -d "${wdir}" ]; then
184 | wdir=`cd "$wdir/.."; pwd`
185 | fi
186 | # end of workaround
187 | done
188 | echo "${basedir}"
189 | }
190 |
191 | # concatenates all lines of a file
192 | concat_lines() {
193 | if [ -f "$1" ]; then
194 | echo "$(tr -s '\n' ' ' < "$1")"
195 | fi
196 | }
197 |
198 | BASE_DIR=`find_maven_basedir "$(pwd)"`
199 | if [ -z "$BASE_DIR" ]; then
200 | exit 1;
201 | fi
202 |
203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
204 | if [ "$MVNW_VERBOSE" = true ]; then
205 | echo $MAVEN_PROJECTBASEDIR
206 | fi
207 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
208 |
209 | # For Cygwin, switch paths to Windows format before running java
210 | if $cygwin; then
211 | [ -n "$M2_HOME" ] &&
212 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
213 | [ -n "$JAVA_HOME" ] &&
214 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
215 | [ -n "$CLASSPATH" ] &&
216 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
217 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
218 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
219 | fi
220 |
221 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
222 |
223 | exec "$JAVACMD" \
224 | $MAVEN_OPTS \
225 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
226 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
227 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
228 |
--------------------------------------------------------------------------------
/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM set title of command window
39 | title %0
40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
42 |
43 | @REM set %HOME% to equivalent of $HOME
44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45 |
46 | @REM Execute a user defined script before this one
47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
51 | :skipRcPre
52 |
53 | @setlocal
54 |
55 | set ERROR_CODE=0
56 |
57 | @REM To isolate internal variables from possible post scripts, we use another setlocal
58 | @setlocal
59 |
60 | @REM ==== START VALIDATION ====
61 | if not "%JAVA_HOME%" == "" goto OkJHome
62 |
63 | echo.
64 | echo Error: JAVA_HOME not found in your environment. >&2
65 | echo Please set the JAVA_HOME variable in your environment to match the >&2
66 | echo location of your Java installation. >&2
67 | echo.
68 | goto error
69 |
70 | :OkJHome
71 | if exist "%JAVA_HOME%\bin\java.exe" goto init
72 |
73 | echo.
74 | echo Error: JAVA_HOME is set to an invalid directory. >&2
75 | echo JAVA_HOME = "%JAVA_HOME%" >&2
76 | echo Please set the JAVA_HOME variable in your environment to match the >&2
77 | echo location of your Java installation. >&2
78 | echo.
79 | goto error
80 |
81 | @REM ==== END VALIDATION ====
82 |
83 | :init
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 |
121 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
122 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
123 |
124 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
125 | if ERRORLEVEL 1 goto error
126 | goto end
127 |
128 | :error
129 | set ERROR_CODE=1
130 |
131 | :end
132 | @endlocal & set ERROR_CODE=%ERROR_CODE%
133 |
134 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
135 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
136 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
137 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
138 | :skipRcPost
139 |
140 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
141 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
142 |
143 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
144 |
145 | exit /B %ERROR_CODE%
146 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | io.springfox
7 | springfox-javadoc
8 | 0.9.4-SNAPSHOT
9 | https://github.com/springfox/springfox-javadoc
10 | springfox-javadoc
11 | generate Swagger/OpenAPI documentation from Javadoc using Springfox
12 |
13 | Springfox
14 | http://springfox.io
15 |
16 |
17 |
18 | https://github.com/springfox/springfox-javadoc.git
19 | https://github.com/springfox/springfox-javadoc.git
20 | https://github.com/springfox/springfox-javadoc
21 |
22 |
23 |
24 |
25 | dilipkrish
26 | Dilip Krishnan
27 | https://github.com/dilipkrish
28 |
29 | architect
30 |
31 | America/Chicago
32 |
33 | https://avatars2.githubusercontent.com/u/73257
34 |
35 |
36 |
37 | rgoers
38 | Ralph Goers
39 | rgoers@apache.org
40 | https://github.com/rgoers
41 |
42 | developer
43 |
44 |
45 |
46 | MartinNeumannBeTSE
47 | Martin Neumann
48 | martin.neumann@be-tse.de
49 | https://github.com/MartinNeumannBeTSE
50 | Be Think, Solve, Execute GmbH
51 | http://www.be-tse.de
52 |
53 | architect
54 | developer
55 |
56 | Europe/Berlin
57 |
58 |
59 | neumaennl
60 | Martin Neumann
61 | https://github.com/neumaennl
62 |
63 | architect
64 | developer
65 |
66 | Europe/Berlin
67 |
68 |
69 |
70 |
71 |
72 | Apache License, Version 2.0
73 | https://www.apache.org/licenses/LICENSE-2.0.txt
74 | repo
75 | A business-friendly OSS license
76 |
77 |
78 |
79 |
80 | 1.6
81 | 1.6
82 | 4.3.9.RELEASE
83 | 2.8.0
84 | UTF-8
85 |
86 |
87 |
88 |
89 | bintray-springfox-maven-repo
90 | springfox-maven-repo
91 | https://api.bintray.com/maven/springfox/maven-repo/springfox-javadoc/;publish=1
92 |
93 |
94 | bintray-snapshot-maven
95 | http://oss.jfrog.org/oss-snapshot-local/io/springfox/springfox-javadoc/
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 | org.springframework
104 | spring-webmvc
105 | ${org.springframework.version}
106 | provided
107 |
108 |
109 |
110 |
111 | io.springfox
112 | springfox-swagger2
113 | ${springfox.version}
114 |
115 |
116 |
117 |
118 | com.sun
119 | tools
120 | ${java.source.version}
121 | system
122 | ${java.home}/../lib/tools.jar
123 |
124 |
125 |
126 |
127 | junit
128 | junit
129 | 4.12
130 | test
131 |
132 |
133 |
134 |
135 |
136 |
137 | org.apache.maven.plugins
138 | maven-compiler-plugin
139 | 3.7.0
140 |
141 | ${java.source.version}
142 | ${java.target.version}
143 |
144 |
145 |
147 |
148 | org.apache.maven.plugins
149 | maven-dependency-plugin
150 | 3.0.2
151 |
152 |
153 | build-classpath
154 | generate-sources
155 |
156 | build-classpath
157 |
158 |
159 | ${project.build.directory}/test-classes/.classpath
160 |
161 |
162 |
163 |
164 |
165 | org.apache.maven.plugins
166 | maven-checkstyle-plugin
167 | 3.0.0
168 |
169 |
170 | validate
171 | validate
172 |
173 | .build/checkstyle.xml
174 | UTF-8
175 | true
176 | true
177 | false
178 |
179 |
180 | check
181 |
182 |
183 |
184 |
185 |
186 | org.apache.maven.plugins
187 | maven-source-plugin
188 |
189 |
190 | attach-sources
191 |
192 | jar
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 | src/test/resources
202 | true
203 |
204 |
205 |
206 |
207 |
208 |
209 | org.apache.maven.plugins
210 | maven-checkstyle-plugin
211 | 3.0.0
212 |
213 |
214 |
215 | checkstyle
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
--------------------------------------------------------------------------------
/publishing.gradle:
--------------------------------------------------------------------------------
1 | import java.text.SimpleDateFormat
2 |
3 | Date buildTimeAndDate = new Date()
4 |
5 | ext {
6 | buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate)
7 | buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate)
8 | projectUrl = "https://github.com/springfox/springfox-javadoc"
9 | bintrayUser = project.hasProperty('bintrayUsername') ?
10 | project.property('bintrayUsername') :
11 | System.getenv('BINTRAY_USER_NAME')
12 | bintrayApiKey = project.hasProperty('bintrayApiKey') ?
13 | project.property('bintrayApiKey') :
14 | System.getenv('BINTRAY_PASSWORD')
15 | passphrase = project.hasProperty('gpgPassphrase') ?
16 | project.property('gpgPassphrase') :
17 | System.getenv('GPG_PASSPHRASE')
18 | sonatypeUser = project.hasProperty('ossUser') ?
19 | project.property('ossUser') :
20 | System.getenv('SONATYPE_USER_NAME')
21 | sonatypePassword = project.hasProperty('ossPassword') ?
22 | project.property('ossPassword') :
23 | System.getenv('SONATYPE_PASSWORD')
24 | }
25 |
26 | jar {
27 | manifest {
28 | attributes(
29 | 'Built-By': 'Springfox',
30 | 'Created-By': System.properties['java.version'] + " (" + System.properties['java.vendor'] + " " + System.properties['java.vm.version'] + ")",
31 | 'Build-Date': project.buildDate,
32 | 'Build-Time': project.buildTime,
33 | 'Specification-Title': project.name,
34 | 'Specification-Version': project.version,
35 | 'Implementation-Title': project.name,
36 | 'Implementation-Version': project.name
37 | )
38 | //TODO: handle the package export
39 | // instruction 'Export-Package', '!springfox.*.internal,*'
40 | instruction 'Import-Package', "!${project.osgiManifest().symbolicName}.*,*"
41 | instruction 'Bundle-Description', 'A library to generate documentation from javadocs'
42 | instruction 'Bundle-DocURL', 'https://github.com/springfox/springfox-javadoc'
43 | }
44 | }
45 |
46 | task sourcesJar(type: Jar) {
47 | from sourceSets.main.allSource
48 | classifier = 'sources'
49 | }
50 |
51 | task javadocJar(type: Jar, dependsOn: javadoc) {
52 | classifier = 'javadoc'
53 | from javadoc.destinationDir
54 | }
55 |
56 | artifacts {
57 | archives sourcesJar
58 | archives javadocJar
59 | }
60 |
61 | bintray {
62 | user = project.bintrayUser
63 | key = project.bintrayApiKey
64 | dryRun = false //Whether to run this as dry-run, without deploying
65 | publish = true //If version should be auto published after an upload
66 | publications = ['mavenJava']
67 | pkg {
68 | repo = 'maven-repo'
69 | name = "${project.name}"
70 | userOrg = "springfox"
71 | websiteUrl = "${projectUrl}"
72 | issueTrackerUrl = "$projectUrl/issues"
73 | vcsUrl = "${projectUrl}.git"
74 | desc = project.description
75 | licenses = ['Apache-2.0']
76 | version {
77 | vcsTag = project.version
78 | gpg {
79 | sign = true //Determines whether to GPG sign the files. The default is false
80 | //Optional. The passphrase for GPG signing'
81 | passphrase = project.passphrase
82 | }
83 | mavenCentralSync {
84 | sync = true //Optional (true by default). Determines whether to sync the version to Maven Central.
85 | user = project.sonatypeUser
86 | password = project.sonatypePassword
87 | }
88 | }
89 | }
90 | }
91 |
92 | publishing {
93 | publications {
94 | mavenJava(MavenPublication) {
95 | from components.java
96 | pom.withXml {
97 | def devs = ['dilipkrish': '',
98 | 'rgoers' : 'Ralph Goers',
99 | 'neumaennl' : 'Martin Neumann']
100 | def root = asNode()
101 |
102 | root.dependencies.'*'.findAll() {
103 | it.scope.text() == 'runtime' && project.configurations.compile.allDependencies.find { dep ->
104 | dep.name == it.artifactId.text()
105 | }
106 | }.each() {
107 | it.scope*.value = 'compile'
108 | }
109 |
110 | root.appendNode('name', project.name)
111 | root.appendNode('packaging', 'jar')
112 | root.appendNode('url', project.projectUrl)
113 | root.appendNode('description', project.description)
114 |
115 | def license = root.appendNode('licenses').appendNode('license')
116 | license.appendNode('name', 'Apache-2.0')
117 | license.appendNode('url', "${project.projectUrl}/LICENSE")
118 | license.appendNode('distribution', 'repo')
119 |
120 | root.appendNode('scm').appendNode('url', "${project.projectUrl}.git")
121 |
122 | def developers = root.appendNode('developers')
123 | devs.each {
124 | def d = developers.appendNode('developer')
125 | d.appendNode('id', it.key)
126 | d.appendNode('name', it.value)
127 | }
128 | }
129 | artifact sourcesJar
130 | artifact javadocJar
131 | }
132 | }
133 | }
134 |
135 | artifactory {
136 | contextUrl = 'https://oss.jfrog.org'
137 | resolve {
138 | repository {
139 | repoKey = 'libs-release'
140 | maven = true
141 | }
142 | }
143 | publish {
144 | repository {
145 | repoKey = 'oss-snapshot-local' //The Artifactory repository key to publish to
146 | //when using oss.jfrog.org the credentials are from Bintray. For local build we expect them to be found in
147 | //~/.gradle/gradle.properties, otherwise to be set in the build server
148 | username = project.bintrayUser
149 | password = project.bintrayApiKey
150 | }
151 | defaults {
152 | publications('mavenJava')
153 | }
154 | }
155 | }
156 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'springfox-javadoc'
2 |
--------------------------------------------------------------------------------
/src/main/java/springfox/javadoc/configuration/JavadocPluginConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright 2018-2019 the original author or authors.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | *
18 | */
19 | package springfox.javadoc.configuration;
20 |
21 | import org.springframework.beans.factory.annotation.Autowired;
22 | import org.springframework.context.annotation.Bean;
23 | import org.springframework.context.annotation.ComponentScan;
24 | import org.springframework.context.annotation.Configuration;
25 | import org.springframework.context.annotation.PropertySource;
26 | import springfox.javadoc.doclet.SwaggerPropertiesDoclet;
27 | import springfox.javadoc.plugin.JavadocBuilderPlugin;
28 |
29 | /**
30 | * Spring configuration that adds the properties file generated by the {@link SwaggerPropertiesDoclet} as property
31 | * source and also adds the {@link JavadocBuilderPlugin} to the Spring context.
32 | *
33 | * @author MartinNeumannBeTSE
34 | */
35 | @Configuration
36 | @PropertySource(value = "classpath:/"
37 | + SwaggerPropertiesDoclet.SPRINGFOX_JAVADOC_PROPERTIES, ignoreResourceNotFound = true)
38 | @ComponentScan("springfox.javadoc.plugin")
39 | public class JavadocPluginConfiguration {
40 |
41 | @Autowired
42 | JavadocBuilderPlugin javadocBuilderPlugin;
43 |
44 | @Bean
45 | public JavadocBuilderPlugin javadocBuilder() {
46 | return javadocBuilderPlugin;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/springfox/javadoc/doclet/DocletOptionParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright 2018-2019 the original author or authors.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | *
18 | */
19 | package springfox.javadoc.doclet;
20 |
21 | class DocletOptionParser {
22 | static final String CLASS_DIR_OPTION = "-classdir";
23 | static final String EXCEPTION_REF_OPTION = "-exceptionRef";
24 | private final String[][] options;
25 |
26 | DocletOptionParser(String[][] options) {
27 | this.options = options;
28 | }
29 |
30 | DocletOptions parse() {
31 | String propertyFilePath = "";
32 | Boolean documentExceptions = false;
33 | for (String[] each : options) {
34 | if (CLASS_DIR_OPTION.equalsIgnoreCase(each[0])) {
35 | propertyFilePath = each[1];
36 | }
37 | if (EXCEPTION_REF_OPTION.equalsIgnoreCase(each[0])) {
38 | documentExceptions = Boolean.valueOf(each[1]);
39 | }
40 | }
41 |
42 | return new DocletOptionsBuilder()
43 | .withPropertyFilePath(propertyFilePath)
44 | .withDocumentExceptions(documentExceptions)
45 | .build();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/springfox/javadoc/doclet/DocletOptions.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright 2018-2019 the original author or authors.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | *
18 | */
19 | package springfox.javadoc.doclet;
20 |
21 | public class DocletOptions {
22 | private final String propertyFilePath;
23 | private final boolean documentExceptions;
24 |
25 | DocletOptions(
26 | String propertyFilePath,
27 | boolean documentExceptions) {
28 |
29 | this.propertyFilePath = propertyFilePath;
30 | this.documentExceptions = documentExceptions;
31 | }
32 |
33 | public String getPropertyFilePath() {
34 | return propertyFilePath;
35 | }
36 |
37 | public boolean isDocumentExceptions() {
38 | return documentExceptions;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/springfox/javadoc/doclet/DocletOptionsBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright 2018-2019 the original author or authors.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | *
18 | */
19 | package springfox.javadoc.doclet;
20 |
21 | import com.google.common.base.Strings;
22 |
23 | public class DocletOptionsBuilder {
24 | private String propertyFilePath;
25 | private boolean documentExceptions;
26 |
27 | DocletOptionsBuilder withPropertyFilePath(String propertyFilePath) {
28 | this.propertyFilePath = propertyFilePath;
29 | return this;
30 | }
31 |
32 | DocletOptionsBuilder withDocumentExceptions(boolean documentExceptions) {
33 | this.documentExceptions = documentExceptions;
34 | return this;
35 | }
36 |
37 | DocletOptions build() {
38 | if (Strings.isNullOrEmpty(propertyFilePath)) {
39 | throw new IllegalStateException("Usage: javadoc -classdir classes directory [-exceptionRef true|false (generate references to exception"
40 | + " classes)] -doclet ...");
41 | }
42 | return new DocletOptions(propertyFilePath, documentExceptions);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/springfox/javadoc/doclet/SwaggerPropertiesDoclet.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright 2018-2019 the original author or authors.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | *
18 | */
19 | package springfox.javadoc.doclet;
20 |
21 | import com.sun.javadoc.AnnotationDesc;
22 | import com.sun.javadoc.ClassDoc;
23 | import com.sun.javadoc.DocErrorReporter;
24 | import com.sun.javadoc.MethodDoc;
25 | import com.sun.javadoc.ParamTag;
26 | import com.sun.javadoc.RootDoc;
27 | import com.sun.javadoc.Tag;
28 | import com.sun.javadoc.ThrowsTag;
29 | import springfox.javadoc.plugin.JavadocBuilderPlugin;
30 |
31 | import java.io.File;
32 | import java.io.FileOutputStream;
33 | import java.io.IOException;
34 | import java.io.OutputStream;
35 | import java.util.Properties;
36 |
37 | import static springfox.javadoc.doclet.DocletOptionParser.*;
38 |
39 | // the NOSONAR comment is added to ignore sonar warning about usage of Sun classes
40 | // because doclets can only be written using Sun classes
41 |
42 | /**
43 | * Generate properties file based on Javadoc.
44 | *
45 | * The generated properties file will then be read by the
46 | * {@link JavadocBuilderPlugin} to enhance the Swagger documentation.
47 | *
48 | * @author rgoers
49 | * @author MartinNeumannBeTSE
50 | */
51 | public class SwaggerPropertiesDoclet {
52 |
53 | public static final String SPRINGFOX_JAVADOC_PROPERTIES = "META-INF/springfox.javadoc.properties";
54 | private static final String REQUEST_MAPPING = "org.springframework.web.bind.annotation.RequestMapping";
55 | private static final String REQUEST_GET_MAPPING = "org.springframework.web.bind.annotation.RequestMethod.GET";
56 | private static final String REQUEST_POST_MAPPING = "org.springframework.web.bind.annotation.RequestMethod.POST";
57 | private static final String REQUEST_PUT_MAPPING = "org.springframework.web.bind.annotation.RequestMethod.PUT";
58 | private static final String REQUEST_PATCH_MAPPING = "org.springframework.web.bind.annotation.RequestMethod.PATCH";
59 | private static final String REQUEST_DELETE_MAPPING = "org.springframework.web.bind.annotation.RequestMethod.DELETE";
60 | private static final String DELETE_MAPPING = "org.springframework.web.bind.annotation.DeleteMapping";
61 | private static final String GET_MAPPING = "org.springframework.web.bind.annotation.GetMapping";
62 | private static final String PATCH_MAPPING = "org.springframework.web.bind.annotation.PatchMapping";
63 | private static final String POST_MAPPING = "org.springframework.web.bind.annotation.PostMapping";
64 | private static final String PUT_MAPPING = "org.springframework.web.bind.annotation.PutMapping";
65 | private static final String RETURN = "@return";
66 | private static final String PATH = "path";
67 | private static final String VALUE = "value";
68 | private static final String NEWLINE = "\n";
69 | private static final String EMPTY = "";
70 | private static final String METHOD = "method";
71 |
72 | private static final String[] MAPPINGS = new String[] {
73 | DELETE_MAPPING,
74 | GET_MAPPING,
75 | PATCH_MAPPING,
76 | POST_MAPPING,
77 | PUT_MAPPING,
78 | REQUEST_MAPPING };
79 |
80 | private static final String[][] REQUEST_MAPPINGS = new String[][] {
81 | { REQUEST_DELETE_MAPPING, "DELETE" },
82 | { REQUEST_GET_MAPPING, "GET" },
83 | { REQUEST_PATCH_MAPPING, "PATCH" },
84 | { REQUEST_POST_MAPPING, "POST" },
85 | { REQUEST_PUT_MAPPING, "PUT" }
86 | };
87 |
88 | private static DocletOptions docletOptions;
89 |
90 | private SwaggerPropertiesDoclet() {
91 | throw new UnsupportedOperationException();
92 | }
93 |
94 |
95 | /**
96 | * See Using
98 | * custom command-line options
99 | * @param option option evaluate an expected length for a given option
100 | * @return number of options
101 | */
102 | @SuppressWarnings("WeakerAccess")
103 | public static int optionLength(String option) {
104 | int length = 0;
105 | if (option.equalsIgnoreCase(CLASS_DIR_OPTION)) {
106 | length = 2;
107 | }
108 | if (option.equalsIgnoreCase(EXCEPTION_REF_OPTION)) {
109 | length = 2;
110 | }
111 | return length;
112 | }
113 |
114 | /**
115 | * See Using
117 | * custom command-line options
118 | * @param options command line options split as key value pairs on index 0 and 1
119 | * @param reporter reporter for errors
120 | * @return true if options are valid
121 | */
122 | @SuppressWarnings("WeakerAccess")
123 | public static boolean validOptions(
124 | String[][] options,
125 | DocErrorReporter reporter) {
126 |
127 | DocletOptionParser parser = new DocletOptionParser(options);
128 |
129 | try {
130 | docletOptions = parser.parse();
131 | return true;
132 | } catch (IllegalStateException e) {
133 | reporter.printError(e.getMessage());
134 | }
135 | return false;
136 | }
137 |
138 | /**
139 | * See A
141 | * Simple Example Doclet
142 | * @param root {@link RootDoc}
143 | * @return true if it started successfully
144 | */
145 | @SuppressWarnings({ "unused", "WeakerAccess", "UnusedReturnValue" })
146 | public static boolean start(RootDoc root) {
147 |
148 | String propertyFilePath = docletOptions.getPropertyFilePath();
149 | if (propertyFilePath == null || propertyFilePath.length() == 0) {
150 | root.printError("No output location was specified");
151 | return false;
152 | } else {
153 | StringBuilder sb = new StringBuilder(propertyFilePath);
154 | if (!propertyFilePath.endsWith("/")) {
155 | sb.append("/");
156 | }
157 | sb.append(SPRINGFOX_JAVADOC_PROPERTIES);
158 | String out = sb.toString();
159 | root.printNotice("Writing output to " + out);
160 | File file = new File(out);
161 | //noinspection ResultOfMethodCallIgnored
162 | file.getParentFile().mkdirs();
163 | OutputStream javadoc = null;
164 | try {
165 | javadoc = new FileOutputStream(file);
166 | Properties properties = new Properties();
167 |
168 | for (ClassDoc classDoc : root.classes()) {
169 | sb.setLength(0);
170 | String defaultRequestMethod = processClass(classDoc, sb);
171 | String pathRoot = sb.toString();
172 | for (MethodDoc methodDoc : classDoc.methods()) {
173 | processMethod(
174 | properties,
175 | methodDoc,
176 | defaultRequestMethod,
177 | pathRoot,
178 | docletOptions.isDocumentExceptions());
179 | }
180 | }
181 | properties.store(javadoc, "Springfox javadoc properties");
182 | } catch (IOException e) {
183 | root.printError(e.getMessage());
184 | } finally {
185 | if (javadoc != null) {
186 | try {
187 | javadoc.close();
188 | } catch (IOException e) {
189 | // close for real
190 | }
191 | }
192 | }
193 | }
194 | return true;
195 | }
196 |
197 | private static String processClass(
198 | ClassDoc classDoc,
199 | StringBuilder pathRoot) {
200 |
201 | String defaultRequestMethod = null;
202 | for (AnnotationDesc annotationDesc : classDoc.annotations()) {
203 | if (REQUEST_MAPPING.equals(annotationDesc.annotationType().qualifiedTypeName())) {
204 | for (AnnotationDesc.ElementValuePair pair : annotationDesc.elementValues()) {
205 |
206 | if (VALUE.equals(pair.element().name()) || PATH.equals(pair.element().name())) {
207 | setRoot(pathRoot, pair);
208 | }
209 | if (METHOD.equals(pair.element().name())) {
210 | defaultRequestMethod = pair.value().toString();
211 | }
212 | }
213 | break;
214 | }
215 | }
216 | return defaultRequestMethod;
217 | }
218 |
219 | private static void setRoot(
220 | StringBuilder pathRoot,
221 | AnnotationDesc.ElementValuePair pair) {
222 |
223 | String value = pair.value().toString().replaceAll("\"$|^\"", "");
224 | if (!value.startsWith("/")) {
225 | pathRoot.append("/");
226 | }
227 | if (value.endsWith("/")) {
228 | pathRoot.append(value, 0, value.length() - 1);
229 | } else {
230 | pathRoot.append(value);
231 | }
232 | }
233 |
234 | private static void processMethod(
235 | Properties properties,
236 | MethodDoc methodDoc,
237 | String defaultRequestMethod,
238 | String pathRoot,
239 | boolean exceptionRef) {
240 |
241 | for (AnnotationDesc annotationDesc : methodDoc.annotations()) {
242 | String annotationType = annotationDesc.annotationType().toString();
243 | if (isMapping(annotationType)) {
244 | StringBuilder path = new StringBuilder(pathRoot);
245 | for (AnnotationDesc.ElementValuePair pair : annotationDesc.elementValues()) {
246 | if (VALUE.equals(pair.element().name()) || PATH.equals(pair.element().name())) {
247 | appendPath(path, pair);
248 | break;
249 | }
250 | }
251 | if (!path.substring(path.length() - 1).equals(".")) {
252 | path.append(".");
253 | }
254 | String requestMethod = getRequestMethod(annotationDesc, annotationType, defaultRequestMethod);
255 | if (requestMethod != null) {
256 | path.append(requestMethod);
257 | saveProperty(properties, path.toString() + ".notes", methodDoc.commentText());
258 |
259 | for (ParamTag paramTag : methodDoc.paramTags()) {
260 | saveProperty(properties, path.toString() + ".param." + paramTag.parameterName(),
261 | paramTag.parameterComment());
262 | }
263 | for (Tag tag : methodDoc.tags()) {
264 | if (tag.name().equals(RETURN)) {
265 | saveProperty(properties, path.toString() + ".return", tag.text());
266 | break;
267 | }
268 | }
269 | if (exceptionRef) {
270 | processThrows(properties, methodDoc.throwsTags(), path);
271 | }
272 | }
273 | }
274 | }
275 | }
276 |
277 | private static void appendPath(
278 | StringBuilder path,
279 | AnnotationDesc.ElementValuePair pair) {
280 |
281 | String value = pair.value().toString().replaceAll("\"$|^\"", "");
282 | if (value.startsWith("/")) {
283 | path.append(value).append(".");
284 | } else {
285 | path.append("/").append(value).append(".");
286 | }
287 | }
288 |
289 | private static boolean isMapping(String name) {
290 | for (String mapping : MAPPINGS) {
291 | if (mapping.equals(name)) {
292 | return true;
293 | }
294 | }
295 | return false;
296 | }
297 |
298 | private static String getRequestMethod(
299 | AnnotationDesc annotationDesc,
300 | String name,
301 | String defaultRequestMethod) {
302 |
303 | if (REQUEST_MAPPING.equals(name)) {
304 | for (AnnotationDesc.ElementValuePair pair : annotationDesc.elementValues()) {
305 | if (METHOD.equals(pair.element().name())) {
306 | return resolveRequestMethod(pair, defaultRequestMethod);
307 | }
308 | }
309 | } else if (PUT_MAPPING.equals(name)) {
310 | return "PUT";
311 | } else if (POST_MAPPING.equals(name)) {
312 | return "POST";
313 | } else if (PATCH_MAPPING.equals(name)) {
314 | return "PATCH";
315 | } else if (GET_MAPPING.equals(name)) {
316 | return "GET";
317 | } else if (DELETE_MAPPING.equals(name)) {
318 | return "DELETE";
319 | }
320 | return defaultRequestMethod;
321 | }
322 |
323 | private static String resolveRequestMethod(
324 | AnnotationDesc.ElementValuePair pair,
325 | String defaultRequestMethod) {
326 |
327 | String value = pair.value().toString();
328 | for (String[] each : REQUEST_MAPPINGS) {
329 | if (each[0].equals(value)) {
330 | return each[1];
331 | }
332 | }
333 | return defaultRequestMethod;
334 | }
335 |
336 | private static void processThrows(
337 | Properties properties,
338 | ThrowsTag[] throwsTags,
339 | StringBuilder path) {
340 |
341 | for (int i = 0; i < throwsTags.length; i++) {
342 | String key = path.toString() + ".throws." + i;
343 | String value = throwsTags[i].exceptionType().typeName() + "-" + throwsTags[i].exceptionComment();
344 | saveProperty(properties, key, value);
345 | }
346 | }
347 |
348 | private static void saveProperty(
349 | Properties properties,
350 | String key,
351 | String value) {
352 |
353 | value = value.replaceAll(NEWLINE, EMPTY);
354 | if (value.length() > 0) {
355 | properties.setProperty(key, value);
356 | }
357 | }
358 | }
359 |
--------------------------------------------------------------------------------
/src/main/java/springfox/javadoc/plugin/JavadocBuilderPlugin.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright 2018-2019 the original author or authors.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | *
18 | */
19 | package springfox.javadoc.plugin;
20 |
21 | import com.google.common.annotations.VisibleForTesting;
22 | import com.google.common.base.Optional;
23 | import org.springframework.beans.factory.annotation.Autowired;
24 | import org.springframework.core.Ordered;
25 | import org.springframework.core.annotation.Order;
26 | import org.springframework.core.env.Environment;
27 | import org.springframework.stereotype.Component;
28 | import org.springframework.util.StringUtils;
29 | import springfox.documentation.builders.ResponseMessageBuilder;
30 | import springfox.documentation.schema.ModelRef;
31 | import springfox.documentation.schema.ModelReference;
32 | import springfox.documentation.service.ResolvedMethodParameter;
33 | import springfox.documentation.service.ResponseMessage;
34 | import springfox.documentation.spi.DocumentationType;
35 | import springfox.documentation.spi.service.OperationBuilderPlugin;
36 | import springfox.documentation.spi.service.ParameterBuilderPlugin;
37 | import springfox.documentation.spi.service.contexts.OperationContext;
38 | import springfox.documentation.spi.service.contexts.ParameterContext;
39 | import springfox.javadoc.doclet.SwaggerPropertiesDoclet;
40 |
41 | import java.lang.annotation.Annotation;
42 | import java.lang.reflect.Method;
43 | import java.util.HashSet;
44 | import java.util.Set;
45 |
46 | /**
47 | * Plugin to generate the @ApiParam and @ApiOperation values from the properties
48 | * file generated by the {@link SwaggerPropertiesDoclet}.
49 | *
50 | * @author rgoers
51 | * @author MartinNeumannBeTSE
52 | */
53 | @Component
54 | @Order(Ordered.LOWEST_PRECEDENCE)
55 | public class JavadocBuilderPlugin implements OperationBuilderPlugin, ParameterBuilderPlugin {
56 |
57 | private static final String PERIOD = ".";
58 | private static final String API_PARAM = "io.swagger.annotations.ApiParam";
59 | private static final String REQUEST_PARAM = "org.springframework.web.bind.annotation.RequestParam";
60 | private static final String PATH_VARIABLE = "org.springframework.web.bind.annotation.PathVariable";
61 | @Autowired
62 | private Environment environment;
63 |
64 | private static Annotation annotationFromField(ParameterContext context, String annotationType) {
65 |
66 | ResolvedMethodParameter methodParam = context.resolvedMethodParameter();
67 |
68 | for (Annotation annotation : methodParam.getAnnotations()) {
69 | if (annotation.annotationType().getName().equals(annotationType)) {
70 | return annotation;
71 | }
72 | }
73 | return null;
74 |
75 | }
76 |
77 | @Override
78 | public boolean supports(DocumentationType delimiter) {
79 | return true;
80 | }
81 |
82 | @Override
83 | public void apply(OperationContext context) {
84 |
85 | String notes = context.requestMappingPattern() + PERIOD + context.httpMethod().toString() + ".notes";
86 | if (StringUtils.hasText(notes) && StringUtils.hasText(environment.getProperty(notes))) {
87 | context.operationBuilder().notes("" + context.getName() + " " + environment.getProperty(notes));
88 | }
89 | String returnDescription = context.requestMappingPattern() + PERIOD + context.httpMethod().toString()
90 | + ".return";
91 | if (StringUtils.hasText(returnDescription) && StringUtils.hasText(environment.getProperty(returnDescription))) {
92 | context.operationBuilder().summary("returns " + environment.getProperty(returnDescription));
93 | }
94 | String throwsDescription = context.requestMappingPattern() + PERIOD + context.httpMethod().toString()
95 | + ".throws.";
96 | int i = 0;
97 | Set responseMessages = new HashSet();
98 | while (StringUtils.hasText(throwsDescription + i)
99 | && StringUtils.hasText(environment.getProperty(throwsDescription + i))) {
100 | String[] throwsValues = StringUtils.split(environment.getProperty(throwsDescription + i), "-");
101 | if (throwsValues.length == 2) {
102 | // TODO[MN]: proper mapping once
103 | // https://github.com/springfox/springfox/issues/521 is solved
104 | String thrownExceptionName = throwsValues[0];
105 | String throwComment = throwsValues[1];
106 | ModelReference model = new ModelRef(thrownExceptionName);
107 | ResponseMessage message = new ResponseMessageBuilder().code(500).message(throwComment)
108 | .responseModel(model).build();
109 | responseMessages.add(message);
110 | }
111 | i++;
112 | }
113 | context.operationBuilder().responseMessages(responseMessages);
114 |
115 | }
116 |
117 | @Override
118 | public void apply(ParameterContext context) {
119 | String description = null;
120 | Optional parmName = context.resolvedMethodParameter().defaultName();
121 | Annotation apiParam = annotationFromField(context, API_PARAM);
122 | if (apiParam != null) {
123 | Optional isRequired = isParamRequired(apiParam, context);
124 | if (isRequired.isPresent()) {
125 | context.parameterBuilder().required(isRequired.get());
126 | }
127 | }
128 | if (parmName.isPresent() && (apiParam == null || !hasValue(apiParam, context))) {
129 | String key = context.getOperationContext().requestMappingPattern() + PERIOD
130 | + context.getOperationContext().httpMethod().name() + ".param." + parmName.get();
131 | description = environment.getProperty(key);
132 | }
133 | if (description != null) {
134 | context.parameterBuilder().description(description);
135 | }
136 | }
137 |
138 | @VisibleForTesting
139 | String extractApiParamDescription(Annotation annotation) {
140 | return annotation != null ? annotation.annotationType().getName() : null;
141 | }
142 |
143 | @VisibleForTesting
144 | Optional isParamRequired(Annotation apiParam, ParameterContext context) {
145 | if (apiParam != null) {
146 | Optional required = isRequired(apiParam, context);
147 | if (required.isPresent()) {
148 | return required;
149 | }
150 | }
151 | Annotation annotation = annotationFromField(context, REQUEST_PARAM);
152 | if (annotation == null) {
153 | annotation = annotationFromField(context, PATH_VARIABLE);
154 | }
155 | return annotation != null ? isRequired(annotation, context) : Optional.absent();
156 | }
157 |
158 | @VisibleForTesting
159 | Optional isRequired(Annotation annotation, ParameterContext context) {
160 | for (Method method : annotation.annotationType().getDeclaredMethods()) {
161 | if (method.getName().equals("required")) {
162 | try {
163 | return Optional.of((Boolean) method.invoke(annotation, (Object) null));
164 | } catch (Exception ex) {
165 | return Optional.absent();
166 | }
167 | }
168 | }
169 | return Optional.absent();
170 | }
171 |
172 | @VisibleForTesting
173 | boolean hasValue(Annotation annotation, ParameterContext context) {
174 | for (Method method : annotation.annotationType().getDeclaredMethods()) {
175 | if (method.getName().equals("value")) {
176 | try {
177 | Optional value = Optional.of((String) method.invoke(annotation, (Object) null));
178 | return value.isPresent();
179 | } catch (Exception ex) {
180 | return false;
181 | }
182 | }
183 | }
184 | return false;
185 | }
186 | }
187 |
--------------------------------------------------------------------------------
/src/test/java/springfox/javadoc/doclet/SwaggerPropertiesDocletTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright 2018-2019 the original author or authors.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | *
18 | */
19 | package springfox.javadoc.doclet;
20 |
21 | import com.sun.javadoc.DocErrorReporter;
22 | import com.sun.javadoc.SourcePosition;
23 | import com.sun.tools.javadoc.Main;
24 | import org.junit.AfterClass;
25 | import org.junit.BeforeClass;
26 | import org.junit.Test;
27 |
28 | import java.io.File;
29 | import java.io.FileInputStream;
30 | import java.io.IOException;
31 | import java.io.InputStream;
32 | import java.io.PrintWriter;
33 | import java.io.StringWriter;
34 | import java.util.Properties;
35 |
36 | import static org.junit.Assert.*;
37 | import static springfox.javadoc.doclet.SwaggerPropertiesDoclet.*;
38 |
39 | public class SwaggerPropertiesDocletTest {
40 |
41 | private static final String BUILD_PROPERTY_FILE_LOCATION = "./build/property-file-location";
42 | private static final String GENERATED_PROPERTY_FILE =
43 | String.format("%s/%s", BUILD_PROPERTY_FILE_LOCATION, SPRINGFOX_JAVADOC_PROPERTIES);
44 |
45 | @BeforeClass
46 | public static void setupFixture() {
47 | deletePropertyFile();
48 | }
49 |
50 | @AfterClass
51 | public static void cleanupFixture() {
52 | deletePropertyFile();
53 | }
54 |
55 | @Test
56 | public void testValidOptionLength() {
57 | assertEquals(2, optionLength("-classdir"));
58 | }
59 |
60 | @Test
61 | public void testInvalidOptionLength() {
62 | assertEquals(0, optionLength("dummy"));
63 | }
64 |
65 | @Test
66 | public void testValidOptions() {
67 | String[][] options = new String[][] { new String[] { "foo", "bar" }, new String[] { "-classdir", "dummy" } };
68 | DummyDocErrorReporter reporter = new DummyDocErrorReporter();
69 | assertTrue(validOptions(options, reporter));
70 | assertTrue(reporter.getErrors().isEmpty());
71 | }
72 |
73 | @Test
74 | public void testInvalidOptions() {
75 | String[][] options = new String[][] { new String[] { "foo", "bar" }, new String[] { "baz", "dummy" } };
76 | DummyDocErrorReporter reporter = new DummyDocErrorReporter();
77 | assertFalse(validOptions(options, reporter));
78 | assertTrue(reporter.getErrors().contains("-classdir"));
79 | }
80 |
81 | @Test
82 | public void testPropertiesGeneration() throws IOException {
83 |
84 | StringWriter err = new StringWriter();
85 | StringWriter warn = new StringWriter();
86 | StringWriter notice = new StringWriter();
87 |
88 | String[] args = new String[] {
89 | "-sourcepath",
90 | "./src/test/java",
91 | "-subpackages",
92 | "springfox.javadoc",
93 | "springfox.javadoc",
94 | "-classdir",
95 | BUILD_PROPERTY_FILE_LOCATION
96 | };
97 |
98 | Main.execute(
99 | "SwaggerPropertiesDoclet",
100 | new PrintWriter(err),
101 | new PrintWriter(warn),
102 | new PrintWriter(notice),
103 | SwaggerPropertiesDoclet.class.getName(),
104 | args);
105 |
106 | Properties props = generatedProperties();
107 | assertEquals("test method", props.getProperty("/test/test.GET.notes"));
108 | assertEquals("dummy value", props.getProperty("/test/test.GET.return"));
109 | assertEquals("dummy param", props.getProperty("/test/test.GET.param.param"));
110 | assertEquals("without value or path", props.getProperty("/test.POST.notes"));
111 | assertEquals("retval", props.getProperty("/test.POST.return"));
112 | assertEquals("param", props.getProperty("/test.POST.param.bar"));
113 | }
114 |
115 | private Properties generatedProperties() throws IOException {
116 | // read in the properties file created by the SwaggerPropertiesDoclet
117 | InputStream inputStream = new FileInputStream(GENERATED_PROPERTY_FILE);
118 | assertNotNull(inputStream);
119 |
120 | // check that the properties match the example sources
121 | Properties props = new Properties();
122 | props.load(inputStream);
123 | return props;
124 | }
125 |
126 | private static void deletePropertyFile() {
127 | File propertyFile = new File(GENERATED_PROPERTY_FILE);
128 | if (propertyFile.exists()) {
129 | propertyFile.delete();
130 | }
131 | }
132 |
133 | public class DummyDocErrorReporter implements DocErrorReporter {
134 |
135 |
136 | private final StringBuilder errors = new StringBuilder();
137 | private final StringBuilder notices = new StringBuilder();
138 | private final StringBuilder warnings = new StringBuilder();
139 |
140 | @Override
141 | public void printError(String error) {
142 | errors.append(error).append("\n");
143 | }
144 |
145 | @Override
146 | public void printError(SourcePosition position, String error) {
147 | errors.append(error).append("\n");
148 | }
149 |
150 | @Override
151 | public void printNotice(String notice) {
152 | notices.append(notice).append("\n");
153 | }
154 |
155 | @Override
156 | public void printNotice(SourcePosition position, String notice) {
157 | notices.append(notice).append("\n");
158 | }
159 |
160 | @Override
161 | public void printWarning(String warning) {
162 | warnings.append(warning).append("\n");
163 | }
164 |
165 | @Override
166 | public void printWarning(SourcePosition position, String warning) {
167 | warnings.append(warning).append("\n");
168 | }
169 |
170 | public String getErrors() {
171 | return errors.toString();
172 | }
173 |
174 | public String getNotices() {
175 | return notices.toString();
176 | }
177 |
178 | public String getWarnings() {
179 | return warnings.toString();
180 | }
181 | }
182 | }
183 |
--------------------------------------------------------------------------------
/src/test/java/springfox/javadoc/example/TestController.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright 2018-2019 the original author or authors.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | *
18 | */
19 | package springfox.javadoc.example;
20 |
21 | import org.springframework.web.bind.annotation.GetMapping;
22 | import org.springframework.web.bind.annotation.PostMapping;
23 | import org.springframework.web.bind.annotation.RequestBody;
24 | import org.springframework.web.bind.annotation.RequestMapping;
25 | import org.springframework.web.bind.annotation.RequestMethod;
26 |
27 | /**
28 | * test controller class
29 | *
30 | * @author MartinNeumannBeTSE
31 | */
32 | @RequestMapping(path = "/test", method = RequestMethod.PUT)
33 | public class TestController {
34 |
35 | /**
36 | * test method
37 | *
38 | * @param param
39 | * dummy param
40 | * @return dummy value
41 | */
42 | @GetMapping("test")
43 | public String test(String param) {
44 | return "dummy " + param;
45 | }
46 |
47 | /**
48 | * without value or path
49 | *
50 | * @param bar
51 | * param
52 | * @return retval
53 | */
54 | @PostMapping
55 | public String bla(@RequestBody String bar) {
56 | return "foo" + bar;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/test/java/springfox/javadoc/example/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright 2018-2019 the original author or authors.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | *
18 | */
19 |
20 | /**
21 | * contains example REST controller classes that are only used to test (and
22 | * therefore demonstrate) how the
23 | * {@link springfox.javadoc.doclet.SwaggerPropertiesDoclet} works.
24 | */
25 | package springfox.javadoc.example;
26 |
--------------------------------------------------------------------------------