├── .gitignore ├── .mvn ├── jvm.config ├── maven.config └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── LICENSE ├── README.adoc ├── spring-cloud-app-starter-doc-maven-plugin ├── .mvn │ ├── jvm.config │ ├── maven.config │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── README.adoc ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── springframework │ │ └── cloud │ │ └── stream │ │ └── app │ │ └── documentation │ │ └── plugin │ │ └── ConfigurationMetadataDocumentationMojo.java │ └── test │ └── java │ └── org │ └── springframework │ └── cloud │ └── stream │ └── app │ └── documentation │ └── plugin │ └── ConfigurationMetadataDocumentationMojoTests.java ├── spring-cloud-app-starter-metadata-gradle-plugin ├── README.adoc ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src │ ├── main │ └── java │ │ └── org │ │ └── springframework │ │ └── cloud │ │ └── stream │ │ └── app │ │ └── documentation │ │ └── plugin │ │ ├── SpringMetadataPlugin.java │ │ └── SpringMetadataTask.java │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── cloud │ │ └── stream │ │ └── app │ │ └── documentation │ │ └── plugin │ │ └── SpringMetadataTaskTest.java │ └── resources │ └── testProject │ ├── build.gradle │ └── src │ └── main │ └── resources │ └── META-INF │ ├── spring-configuration-metadata-whitelist.properties │ └── spring-configuration-metadata.json ├── spring-cloud-app-starter-metadata-maven-plugin ├── README.adoc ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── springframework │ │ └── cloud │ │ └── stream │ │ └── app │ │ └── documentation │ │ └── plugin │ │ └── MetadataAggregationMojo.java │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── cloud │ │ ├── dataflow │ │ └── completion │ │ │ └── Expresso.java │ │ └── stream │ │ └── app │ │ └── documentation │ │ └── plugin │ │ ├── EnumHintProviderTest.java │ │ └── MergeWhitelistPropertiesTest.java │ └── resources │ └── META-INF │ ├── spring-configuration-metadata.json │ ├── whitelist-1.properties │ └── whitelist-2.properties └── spring-cloud-stream-app-maven-plugin ├── .mvn ├── jvm.config ├── maven.config └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── LICENSE ├── README.adoc ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── org │ │ └── springframework │ │ └── cloud │ │ └── stream │ │ └── app │ │ └── plugin │ │ ├── MavenXmlWriter.java │ │ ├── SpringCloudStreamAppGeneratorMojo.java │ │ └── generator │ │ ├── AppBom.java │ │ ├── AppDefinition.java │ │ ├── ProjectGenerator.java │ │ └── ProjectGeneratorProperties.java └── resources │ ├── template │ ├── .mvn │ │ ├── jvm.config │ │ ├── maven.config │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── App.java │ ├── AppTests.java │ ├── README.adoc │ ├── app-pom.xml │ ├── app.properties │ ├── apps-container-pom.xml │ ├── mvnw │ └── mvnw.cmd │ └── templates │ └── assembly.xml └── test ├── java └── org │ └── springframework │ └── cloud │ └── stream │ └── app │ └── plugin │ ├── MojoHarnessTest.java │ └── SpringCloudStreamAppGeneratorMojoTest.java └── resources └── unit └── http-source-apps ├── pom.xml └── src └── main └── resources └── test.txt /.gitignore: -------------------------------------------------------------------------------- 1 | /application.yml 2 | /application.properties 3 | asciidoctor.css 4 | *~ 5 | .#* 6 | *# 7 | target/ 8 | build/ 9 | bin/ 10 | _site/ 11 | .classpath 12 | .project 13 | .settings 14 | .springBeans 15 | .DS_Store 16 | *.sw* 17 | *.iml 18 | *.ipr 19 | *.iws 20 | .idea/ 21 | .factorypath 22 | spring-xd-samples/*/xd 23 | dump.rdb 24 | coverage-error.log 25 | .apt_generated 26 | /spring-cloud-app-starter-metadata-gradle-plugin/.gradle/ 27 | -------------------------------------------------------------------------------- /.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local -P spring 2 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-attic/spring-cloud-app-starters-maven-plugins/7a06cdbcd2f47cf83c2ad1ccd8eeff285bbd56c6/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2015-Present Pivotal Software Inc. 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | 204 | 205 | 206 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | # spring-cloud-app-starters-maven-plugins is no longer actively maintained by VMware, Inc. 2 | 3 | = Spring Cloud Stream, Task & Data Flow Maven Plugins 4 | 5 | This repository contains several maven plugins related to the Spring Cloud Data Flow portfolio of projects. 6 | 7 | * *App Starter Doc Maven Plugin:* A plugin to generate Assciidoc snippets 8 | documenting the "whitelisted properties" of a Stream/Task app starter. 9 | * *App Starter Metadata Maven Plugin:* A plugin to gather and aggregate into 10 | a single artifact the Boot metadata json files (and dataflow whitelist properties). -------------------------------------------------------------------------------- /spring-cloud-app-starter-doc-maven-plugin/.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom -------------------------------------------------------------------------------- /spring-cloud-app-starter-doc-maven-plugin/.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local -P spring 2 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-doc-maven-plugin/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-attic/spring-cloud-app-starters-maven-plugins/7a06cdbcd2f47cf83c2ad1ccd8eeff285bbd56c6/spring-cloud-app-starter-doc-maven-plugin/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-app-starter-doc-maven-plugin/.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 2 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-doc-maven-plugin/README.adoc: -------------------------------------------------------------------------------- 1 | = Spring Cloud Stream & Task Maven Documentation Plugin 2 | 3 | Maven plugin for generating documentation for Spring Cloud stream and task app starters. 4 | 5 | Assuming a Spring Cloud Stream / Task app (or app starter) has 6 | specified selected configuration properties to be visible (i.e., providing src/main/resources/META-INF/dataflow-configuration-metadata.properties), 7 | this plugin will help automate the documentation of such properties. 8 | https://docs.spring.io/spring-cloud-dataflow/docs/1.1.0.M2/reference/html/spring-cloud-dataflow-register-apps.html#spring-cloud-dataflow-stream-app-whitelisting[whitelisted] 9 | some configuration properties, this plugin will help automate the documentation of such properties. 10 | 11 | == Usage 12 | 13 | To use this plugin, simply add the following markers to your project `README.adoc` file: 14 | 15 | ``` 16 | //tag::configuration-properties[] 17 | //enc::configuration-properties[] 18 | ``` 19 | 20 | 21 | Then, configure this plugin for your app project (either directly or through a parent POM): 22 | ``` 23 | 24 | 25 | 26 | org.springframework.cloud.stream.app.plugin 27 | spring-cloud-stream-app-documentation-maven-plugin 28 | 1.0.0.BUILD-SNAPSHOT 29 | 30 | 31 | generate-documentation 32 | verify 33 | 34 | generate-documentation 35 | 36 | 37 | 38 | 39 | 40 | 41 | ``` 42 | 43 | Documentation for the visible properties shall appear on next build, which should be committed under VCS. 44 | 45 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-doc-maven-plugin/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 | # https://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 | # 58 | # Look for the Apple JDKs first to preserve the existing behaviour, and then look 59 | # for the new JDKs provided by Oracle. 60 | # 61 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then 62 | # 63 | # Apple JDKs 64 | # 65 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home 66 | fi 67 | 68 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then 69 | # 70 | # Apple JDKs 71 | # 72 | export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 73 | fi 74 | 75 | if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then 76 | # 77 | # Oracle JDKs 78 | # 79 | export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 80 | fi 81 | 82 | if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then 83 | # 84 | # Apple JDKs 85 | # 86 | export JAVA_HOME=`/usr/libexec/java_home` 87 | fi 88 | ;; 89 | esac 90 | 91 | if [ -z "$JAVA_HOME" ] ; then 92 | if [ -r /etc/gentoo-release ] ; then 93 | JAVA_HOME=`java-config --jre-home` 94 | fi 95 | fi 96 | 97 | if [ -z "$M2_HOME" ] ; then 98 | ## resolve links - $0 may be a link to maven's home 99 | PRG="$0" 100 | 101 | # need this for relative symlinks 102 | while [ -h "$PRG" ] ; do 103 | ls=`ls -ld "$PRG"` 104 | link=`expr "$ls" : '.*-> \(.*\)$'` 105 | if expr "$link" : '/.*' > /dev/null; then 106 | PRG="$link" 107 | else 108 | PRG="`dirname "$PRG"`/$link" 109 | fi 110 | done 111 | 112 | saveddir=`pwd` 113 | 114 | M2_HOME=`dirname "$PRG"`/.. 115 | 116 | # make it fully qualified 117 | M2_HOME=`cd "$M2_HOME" && pwd` 118 | 119 | cd "$saveddir" 120 | # echo Using m2 at $M2_HOME 121 | fi 122 | 123 | # For Cygwin, ensure paths are in UNIX format before anything is touched 124 | if $cygwin ; then 125 | [ -n "$M2_HOME" ] && 126 | M2_HOME=`cygpath --unix "$M2_HOME"` 127 | [ -n "$JAVA_HOME" ] && 128 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 129 | [ -n "$CLASSPATH" ] && 130 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 131 | fi 132 | 133 | # For Migwn, ensure paths are in UNIX format before anything is touched 134 | if $mingw ; then 135 | [ -n "$M2_HOME" ] && 136 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 137 | [ -n "$JAVA_HOME" ] && 138 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 139 | # TODO classpath? 140 | fi 141 | 142 | if [ -z "$JAVA_HOME" ]; then 143 | javaExecutable="`which javac`" 144 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 145 | # readlink(1) is not available as standard on Solaris 10. 146 | readLink=`which readlink` 147 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 148 | if $darwin ; then 149 | javaHome="`dirname \"$javaExecutable\"`" 150 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 151 | else 152 | javaExecutable="`readlink -f \"$javaExecutable\"`" 153 | fi 154 | javaHome="`dirname \"$javaExecutable\"`" 155 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 156 | JAVA_HOME="$javaHome" 157 | export JAVA_HOME 158 | fi 159 | fi 160 | fi 161 | 162 | if [ -z "$JAVACMD" ] ; then 163 | if [ -n "$JAVA_HOME" ] ; then 164 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 165 | # IBM's JDK on AIX uses strange locations for the executables 166 | JAVACMD="$JAVA_HOME/jre/sh/java" 167 | else 168 | JAVACMD="$JAVA_HOME/bin/java" 169 | fi 170 | else 171 | JAVACMD="`which java`" 172 | fi 173 | fi 174 | 175 | if [ ! -x "$JAVACMD" ] ; then 176 | echo "Error: JAVA_HOME is not defined correctly." >&2 177 | echo " We cannot execute $JAVACMD" >&2 178 | exit 1 179 | fi 180 | 181 | if [ -z "$JAVA_HOME" ] ; then 182 | echo "Warning: JAVA_HOME environment variable is not set." 183 | fi 184 | 185 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 186 | 187 | # For Cygwin, switch paths to Windows format before running java 188 | if $cygwin; then 189 | [ -n "$M2_HOME" ] && 190 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 191 | [ -n "$JAVA_HOME" ] && 192 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 193 | [ -n "$CLASSPATH" ] && 194 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 195 | fi 196 | 197 | # traverses directory structure from process work directory to filesystem root 198 | # first directory with .mvn subdirectory is considered project base directory 199 | find_maven_basedir() { 200 | local basedir=$(pwd) 201 | local wdir=$(pwd) 202 | while [ "$wdir" != '/' ] ; do 203 | if [ -d "$wdir"/.mvn ] ; then 204 | basedir=$wdir 205 | break 206 | fi 207 | wdir=$(cd "$wdir/.."; pwd) 208 | done 209 | echo "${basedir}" 210 | } 211 | 212 | # concatenates all lines of a file 213 | concat_lines() { 214 | if [ -f "$1" ]; then 215 | echo "$(tr -s '\n' ' ' < "$1")" 216 | fi 217 | } 218 | 219 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} 220 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 221 | 222 | # Provide a "standardized" way to retrieve the CLI args that will 223 | # work with both Windows and non-Windows executions. 224 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 225 | export MAVEN_CMD_LINE_ARGS 226 | 227 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 228 | 229 | echo "Running version check" 230 | VERSION=$( sed '\!//' -e 's!.*$!!' ) 231 | echo "The found version is [${VERSION}]" 232 | 233 | if echo $VERSION | egrep -q 'M|RC'; then 234 | echo Activating \"milestone\" profile for version=\"$VERSION\" 235 | echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pmilestone" 236 | else 237 | echo Deactivating \"milestone\" profile for version=\"$VERSION\" 238 | echo $MAVEN_ARGS | grep -q milestone && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pmilestone//') 239 | fi 240 | 241 | exec "$JAVACMD" \ 242 | $MAVEN_OPTS \ 243 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 244 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 245 | ${WRAPPER_LAUNCHER} ${MAVEN_ARGS} "$@" 246 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-doc-maven-plugin/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 https://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 enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | set MAVEN_CMD_LINE_ARGS=%* 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="".\.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_CMD_LINE_ARGS% 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 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-doc-maven-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.cloud 7 | spring-cloud-build 8 | 3.0.0.M1 9 | 10 | 11 | spring-cloud-app-starter-doc-maven-plugin 12 | 3.0.0.BUILD-SNAPSHOT 13 | maven-plugin 14 | 15 | 16 | 17 | org.apache.maven 18 | maven-plugin-api 19 | 3.5.2 20 | 21 | 22 | org.apache.maven 23 | maven-core 24 | 3.5.2 25 | 26 | 27 | org.springframework.cloud 28 | spring-cloud-dataflow-configuration-metadata 29 | 2.7.0-SNAPSHOT 30 | 31 | 32 | 33 | org.apache.maven.plugin-tools 34 | maven-plugin-annotations 35 | 3.4 36 | provided 37 | 38 | 39 | 40 | junit 41 | junit 42 | 4.12 43 | test 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.apache.maven.plugins 51 | maven-plugin-plugin 52 | 3.5 53 | 54 | 55 | org.apache.maven.plugins 56 | maven-compiler-plugin 57 | 58 | 1.8 59 | 1.8 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | spring 68 | 69 | 70 | 71 | true 72 | 73 | spring-snapshots 74 | Spring Snapshots 75 | https://repo.spring.io/libs-snapshot-local 76 | 77 | 78 | 79 | false 80 | 81 | spring-milestones 82 | Spring Milestones 83 | https://repo.spring.io/libs-milestone-local 84 | 85 | 86 | 87 | false 88 | 89 | spring-releases 90 | Spring Releases 91 | https://repo.spring.io/release 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-doc-maven-plugin/src/test/java/org/springframework/cloud/stream/app/documentation/plugin/ConfigurationMetadataDocumentationMojoTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.stream.app.documentation.plugin; 18 | 19 | import org.junit.Test; 20 | 21 | import static org.junit.Assert.*; 22 | 23 | public class ConfigurationMetadataDocumentationMojoTests { 24 | 25 | 26 | @Test 27 | public void testJavaTypeBeautifier() { 28 | ConfigurationMetadataDocumentationMojo mojo = new ConfigurationMetadataDocumentationMojo(); 29 | String s = mojo.niceType("java.lang.String"); 30 | assertEquals("String", s); 31 | 32 | s = mojo.niceType("java.lang.Class"); 33 | assertEquals("Class", s); 34 | 35 | s = mojo.niceType("java.util.Map$Entry>>"); 36 | assertEquals("Entry>>", s); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-gradle-plugin/README.adoc: -------------------------------------------------------------------------------- 1 | = Spring Cloud Stream & Task Gradle Metadata Plugin 2 | 3 | Gradle plugin for aggregating Spring Boot metadata from all dependencies of a project into 4 | a single metadata-only artifact. 5 | 6 | == Usage 7 | 8 | To use this plugin, configure this plugin for your app project: 9 | ``` 10 | apply plugin: 'org.springframework.cloud.stream.app.documentation.aggregate-metadata' 11 | ``` 12 | 13 | This will add task `metadataJar` that produces and attaches to the build a jar file named `--metadata.jar` (`metadata` being the 14 | maven classifier used for the artifact.) + 15 | Of cause, you can customize the `metadataJar` task which is regular gradle `jar` type task. 16 | 17 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-gradle-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "java-gradle-plugin" 3 | } 4 | repositories { 5 | mavenCentral() 6 | maven { url "https://repo.spring.io/plugins-release/" } 7 | } 8 | 9 | 10 | 11 | gradlePlugin { 12 | plugins { 13 | springMD { 14 | id = "org.springframework.cloud.stream.app.documentation.aggregate-metadata" 15 | implementationClass = "org.springframework.cloud.stream.app.documentation.plugin.SpringMetadataPlugin" 16 | } 17 | } 18 | } 19 | 20 | 21 | 22 | dependencies { 23 | compile "org.springframework.boot:spring-boot-configuration-processor:1.5.9.RELEASE" 24 | testCompile "junit:junit:4.12" 25 | 26 | } 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-gradle-plugin/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-attic/spring-cloud-app-starters-maven-plugins/7a06cdbcd2f47cf83c2ad1ccd8eeff285bbd56c6/spring-cloud-app-starter-metadata-gradle-plugin/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-gradle-plugin/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Jan 31 16:37:06 IST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-all.zip 7 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-gradle-plugin/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 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-gradle-plugin/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 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-gradle-plugin/src/main/java/org/springframework/cloud/stream/app/documentation/plugin/SpringMetadataPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.cloud.stream.app.documentation.plugin; 17 | 18 | import org.gradle.api.Plugin; 19 | import org.gradle.api.Project; 20 | import org.gradle.api.Task; 21 | import org.gradle.api.plugins.JavaPlugin; 22 | 23 | /** 24 | * A gradle spring metadata plugin 25 | * 26 | * @author Furer Alexander 27 | */ 28 | public class SpringMetadataPlugin implements Plugin { 29 | @Override 30 | public void apply(Project project) { 31 | SpringMetadataTask metadataTask = project.getTasks().create(SpringMetadataTask.NAME, SpringMetadataTask.class); 32 | 33 | project.afterEvaluate(p -> { 34 | Task buildTask = p.getTasks().findByName("build"); 35 | if (null != buildTask) { 36 | buildTask.dependsOn(metadataTask); 37 | } 38 | p.getArtifacts().add("archives", metadataTask); 39 | 40 | if (p.getPlugins().hasPlugin(JavaPlugin.class)) { 41 | metadataTask.dependsOn(JavaPlugin.COMPILE_JAVA_TASK_NAME, JavaPlugin.PROCESS_RESOURCES_TASK_NAME); 42 | } 43 | }); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-gradle-plugin/src/main/java/org/springframework/cloud/stream/app/documentation/plugin/SpringMetadataTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.cloud.stream.app.documentation.plugin; 17 | 18 | import org.gradle.api.plugins.JavaPlugin; 19 | import org.gradle.api.tasks.bundling.Jar; 20 | import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata; 21 | import org.springframework.boot.configurationprocessor.metadata.JsonMarshaller; 22 | 23 | import java.io.*; 24 | import java.util.Properties; 25 | import java.util.Set; 26 | import java.util.function.Consumer; 27 | import java.util.stream.Collectors; 28 | import java.util.stream.Stream; 29 | import java.util.zip.ZipEntry; 30 | import java.util.zip.ZipFile; 31 | 32 | /** 33 | * A gradle task that will gather all Spring Boot metadata files from all transitive dependencies and will aggregate 34 | * them in one metadata-only artifact. 35 | * 36 | * @author Furer Alexander 37 | */ 38 | public class SpringMetadataTask extends Jar { 39 | 40 | public static final String NAME = "metadataJar"; 41 | 42 | private File configurationMdFile; 43 | private File propsFile; 44 | private File mdDir; 45 | 46 | public SpringMetadataTask() { 47 | setClassifier("metadata"); 48 | 49 | mdDir = new File(getProject().getBuildDir(), "springMetadata"); 50 | 51 | configurationMdFile = new File(mdDir, "spring-configuration-metadata.json"); 52 | propsFile = new File(mdDir, "spring-configuration-metadata-whitelist.properties"); 53 | getOutputs().upToDateWhen(t -> false); 54 | getOutputs().dir(mdDir); 55 | 56 | from(mdDir, copySpec -> copySpec 57 | .into("META-INF") 58 | .include(propsFile.getName(), configurationMdFile.getName()) 59 | ); 60 | } 61 | 62 | @Override 63 | protected void copy() { 64 | try { 65 | boolean dirCreated = mdDir.mkdirs(); 66 | getLogger().info(mdDir.getAbsolutePath() + " created :" + dirCreated); 67 | aggregateConfigurationMetadata(); 68 | aggregateWhiteListedProperties(); 69 | } catch (Exception e) { 70 | throw new RuntimeException(e); 71 | } 72 | 73 | super.copy(); 74 | } 75 | 76 | private void aggregateConfigurationMetadata() throws Exception { 77 | 78 | ConfigurationMetadata metadata = new ConfigurationMetadata(); 79 | JsonMarshaller jsonMarshaller = new JsonMarshaller(); 80 | 81 | Set ownedFiles = findOwnedFiles("META-INF/spring-configuration-metadata.json"); 82 | for (File f : ownedFiles) { 83 | try (FileInputStream fis = new FileInputStream(f)) { 84 | metadata.merge(jsonMarshaller.read(fis)); 85 | } 86 | } 87 | withDependencies("META-INF/spring-configuration-metadata.json", is -> { 88 | try { 89 | metadata.merge(jsonMarshaller.read(is)); 90 | } catch (Exception e) { 91 | throw new RuntimeException(e); 92 | } 93 | }); 94 | 95 | 96 | try (FileOutputStream fos = new FileOutputStream(configurationMdFile)) { 97 | jsonMarshaller.write(metadata, fos); 98 | } 99 | } 100 | 101 | private void aggregateWhiteListedProperties() throws Exception { 102 | Properties aggregated = new Properties(); 103 | 104 | Set ownedFiles = findOwnedFiles("META-INF/spring-configuration-metadata-whitelist.properties"); 105 | for (File f : ownedFiles) { 106 | try (FileInputStream fis = new FileInputStream(f)) { 107 | mergeProperties(aggregated, fis); 108 | } 109 | } 110 | 111 | withDependencies("META-INF/spring-configuration-metadata-whitelist.properties", is -> { 112 | try { 113 | mergeProperties(aggregated, is); 114 | } catch (IOException e) { 115 | throw new RuntimeException(e); 116 | } 117 | }); 118 | 119 | try (FileOutputStream fos = new FileOutputStream(propsFile)) { 120 | aggregated.store(fos, null); 121 | } 122 | } 123 | 124 | private void mergeProperties(Properties seed, InputStream is) throws IOException { 125 | 126 | Properties properties = new Properties(); 127 | properties.load(is); 128 | 129 | properties.forEach((k, v) -> 130 | seed.merge(k, v, (v1, v2) -> 131 | Stream.concat(Stream.of(((String) v1).split(",")), Stream.of(((String) v2).split(","))) 132 | .map(String::trim) 133 | .distinct() 134 | .collect(Collectors.joining(",")) 135 | ) 136 | ); 137 | } 138 | 139 | private Set findOwnedFiles(String pattern) { 140 | return getProject().getTasks().getAt(JavaPlugin.COMPILE_JAVA_TASK_NAME).getOutputs().getFiles() 141 | .plus(getProject().getTasks().getAt(JavaPlugin.PROCESS_RESOURCES_TASK_NAME).getOutputs().getFiles()) 142 | .getAsFileTree() 143 | .matching(p -> p.include(pattern)) 144 | .getFiles(); 145 | } 146 | 147 | private void withDependencies(String pattern, Consumer consumer) throws Exception { 148 | Set zipFiles = getProject().getConfigurations().getByName("runtime").resolve(); 149 | for (File f : zipFiles) { 150 | ZipFile zipFile = new ZipFile(f); 151 | ZipEntry mdEntry = zipFile.getEntry(pattern); 152 | if (null != mdEntry) { 153 | try (InputStream is = zipFile.getInputStream(mdEntry)) { 154 | consumer.accept(is); 155 | } 156 | } 157 | } 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-gradle-plugin/src/test/java/org/springframework/cloud/stream/app/documentation/plugin/SpringMetadataTaskTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.cloud.stream.app.documentation.plugin; 17 | 18 | import org.gradle.testkit.runner.BuildResult; 19 | import org.gradle.testkit.runner.GradleRunner; 20 | import org.gradle.testkit.runner.TaskOutcome; 21 | import org.hamcrest.CoreMatchers; 22 | import org.junit.Assert; 23 | import org.junit.Test; 24 | import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata; 25 | import org.springframework.boot.configurationprocessor.metadata.ItemMetadata; 26 | import org.springframework.boot.configurationprocessor.metadata.JsonMarshaller; 27 | 28 | import java.io.File; 29 | import java.io.InputStream; 30 | import java.util.List; 31 | import java.util.Optional; 32 | import java.util.Properties; 33 | import java.util.zip.ZipEntry; 34 | import java.util.zip.ZipFile; 35 | 36 | import static org.hamcrest.MatcherAssert.assertThat; 37 | 38 | /** 39 | * Gradle spring metadata plugin test 40 | * 41 | * @author Furer Alexander 42 | */ 43 | public class SpringMetadataTaskTest { 44 | 45 | @Test 46 | public void simpleTest() throws Exception { 47 | 48 | //run build 49 | File testProjectDir = new File(getClass().getResource("/testProject/build.gradle").toURI()).getParentFile(); 50 | 51 | BuildResult result = GradleRunner.create() 52 | .withProjectDir(testProjectDir) 53 | .withPluginClasspath() 54 | .forwardOutput() 55 | .withDebug(true) 56 | .withArguments("clean", "build", "-S") 57 | .build(); 58 | 59 | result.getTasks() 60 | .forEach(t -> assertThat(t.getOutcome(), CoreMatchers.not(CoreMatchers.is(TaskOutcome.FAILED)))); 61 | 62 | // get the generated md jar 63 | File generatedMdFile = new File(getClass().getResource("/testProject/build/libs/testProject-metadata.jar").toURI()); 64 | ZipFile generatedMdZipFile = new ZipFile(generatedMdFile); 65 | 66 | JsonMarshaller jsonMarshaller = new JsonMarshaller(); 67 | 68 | // assert that spring-configuration-metadata.json contains custom node and nodes from spring boot 69 | ZipEntry configMdEntry = generatedMdZipFile.getEntry("META-INF/spring-configuration-metadata.json"); 70 | Assert.assertNotNull(configMdEntry); 71 | 72 | try (InputStream is = generatedMdZipFile.getInputStream(configMdEntry)) { 73 | ConfigurationMetadata configurationMetadata = jsonMarshaller.read(is); 74 | List items = configurationMetadata.getItems(); 75 | 76 | //expect the metadata to be aggregated with spring boot dependency 77 | Assert.assertTrue(1 < items.size()); 78 | Optional customItem = items 79 | .stream() 80 | .filter(i -> "my.custom".equals(i.getName())) 81 | .findFirst(); 82 | 83 | //expect the metadata to be aggregated with owned items 84 | Assert.assertTrue(customItem.isPresent()); 85 | Assert.assertEquals("java.lang.String", customItem.get().getType()); 86 | Assert.assertEquals("Custom test description", customItem.get().getDescription()); 87 | 88 | } 89 | // assert that spring-configuration-metadata-whitelist.properties exists 90 | ZipEntry whiteListedPropsEntry = generatedMdZipFile.getEntry("META-INF/spring-configuration-metadata-whitelist.properties"); 91 | Assert.assertNotNull(whiteListedPropsEntry); 92 | try (InputStream is = generatedMdZipFile.getInputStream(whiteListedPropsEntry)) { 93 | Properties wlProps = new Properties(); 94 | wlProps.load(is); 95 | Assert.assertEquals("com.custom.Properties", wlProps.getProperty("configuration-properties.classes")); 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-gradle-plugin/src/test/resources/testProject/build.gradle: -------------------------------------------------------------------------------- 1 | plugins{ 2 | id 'java' 3 | id 'org.springframework.cloud.stream.app.documentation.aggregate-metadata' 4 | 5 | } 6 | 7 | repositories { 8 | mavenCentral() 9 | maven { url "https://repo.spring.io/plugins-release/" } 10 | } 11 | dependencies{ 12 | compile "org.springframework.boot:spring-boot:1.5.9.RELEASE" 13 | } 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-gradle-plugin/src/test/resources/testProject/src/main/resources/META-INF/spring-configuration-metadata-whitelist.properties: -------------------------------------------------------------------------------- 1 | configuration-properties.classes=com.custom.Properties 2 | 3 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-gradle-plugin/src/test/resources/testProject/src/main/resources/META-INF/spring-configuration-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "properties": [ 4 | { 5 | "name": "my.custom", 6 | "type": "java.lang.String", 7 | "description": "Custom test description" 8 | 9 | } 10 | ] 11 | 12 | } -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-maven-plugin/README.adoc: -------------------------------------------------------------------------------- 1 | = Spring Cloud Stream & Task Maven Metadata Plugin 2 | 3 | Maven plugin for aggregating Spring Boot metadata from all dependencies of a project into 4 | a single metadata-only artifact. 5 | 6 | == Usage 7 | 8 | To use this plugin, configure this plugin for your app project (either directly or through a parent POM): 9 | ``` 10 | 11 | 12 | 13 | org.springframework.cloud.stream.app.plugin 14 | spring-cloud-app-starter-metadata-maven-plugin 15 | 2.0.0.BUILD-SNAPSHOT 16 | 17 | 18 | aggregate-metadata 19 | compile 20 | 21 | aggregate-metadata 22 | 23 | 24 | 25 | 26 | 27 | 28 | ``` 29 | 30 | This will produce and attach to the build a jar file named `--metadata.jar` (`metadata` being the 31 | maven classifier used for the artifact, which can be customized as such:) 32 | ``` 33 | 34 | 35 | 36 | org.springframework.cloud.stream.app.plugin 37 | spring-cloud-app-starter-metadata-maven-plugin 38 | 2.0.0.BUILD-SNAPSHOT 39 | 40 | 41 | aggregate-metadata 42 | compile 43 | 44 | aggregate-metadata 45 | 46 | 47 | foobar 48 | 49 | 50 | 51 | 52 | 53 | 54 | ``` 55 | 56 | You can filter in subset of the gathered metadata and store it into a java property file: `META-INF/spring-configuration-metadata-encoded.properties`. 57 | This file has single property `org.springframework.cloud.dataflow.spring.configuration.metadata.json` which contains the pre-filtered metadata encoded as Base64. 58 | To activate this feature you need to set the `storeFilteredMetadata` parameter to `true`. Use the `metadataFilter` to configure the whitelisted metadata content to include. 59 | For example: 60 | ``` 61 | 62 | 63 | 64 | org.springframework.cloud 65 | spring-cloud-app-starter-metadata-maven-plugin 66 | 2.0.0.BUILD-SNAPSHOT 67 | 68 | 69 | true 70 | 71 | 72 | 73 | server.port 74 | 75 | 76 | io.pivotal.java.function.http.supplier.HttpSourceProperties 77 | io.pivotal.java.function.http.supplier.HttpSourceProperties$Cors 78 | 79 | 80 | 81 | 82 | 83 | 84 | aggregate-metadata 85 | compile 86 | 87 | aggregate-metadata 88 | 89 | 90 | 91 | 92 | 93 | 94 | ``` 95 | 96 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-maven-plugin/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 | # https://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 | # 58 | # Look for the Apple JDKs first to preserve the existing behaviour, and then look 59 | # for the new JDKs provided by Oracle. 60 | # 61 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then 62 | # 63 | # Apple JDKs 64 | # 65 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home 66 | fi 67 | 68 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then 69 | # 70 | # Apple JDKs 71 | # 72 | export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 73 | fi 74 | 75 | if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then 76 | # 77 | # Oracle JDKs 78 | # 79 | export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 80 | fi 81 | 82 | if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then 83 | # 84 | # Apple JDKs 85 | # 86 | export JAVA_HOME=`/usr/libexec/java_home` 87 | fi 88 | ;; 89 | esac 90 | 91 | if [ -z "$JAVA_HOME" ] ; then 92 | if [ -r /etc/gentoo-release ] ; then 93 | JAVA_HOME=`java-config --jre-home` 94 | fi 95 | fi 96 | 97 | if [ -z "$M2_HOME" ] ; then 98 | ## resolve links - $0 may be a link to maven's home 99 | PRG="$0" 100 | 101 | # need this for relative symlinks 102 | while [ -h "$PRG" ] ; do 103 | ls=`ls -ld "$PRG"` 104 | link=`expr "$ls" : '.*-> \(.*\)$'` 105 | if expr "$link" : '/.*' > /dev/null; then 106 | PRG="$link" 107 | else 108 | PRG="`dirname "$PRG"`/$link" 109 | fi 110 | done 111 | 112 | saveddir=`pwd` 113 | 114 | M2_HOME=`dirname "$PRG"`/.. 115 | 116 | # make it fully qualified 117 | M2_HOME=`cd "$M2_HOME" && pwd` 118 | 119 | cd "$saveddir" 120 | # echo Using m2 at $M2_HOME 121 | fi 122 | 123 | # For Cygwin, ensure paths are in UNIX format before anything is touched 124 | if $cygwin ; then 125 | [ -n "$M2_HOME" ] && 126 | M2_HOME=`cygpath --unix "$M2_HOME"` 127 | [ -n "$JAVA_HOME" ] && 128 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 129 | [ -n "$CLASSPATH" ] && 130 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 131 | fi 132 | 133 | # For Migwn, ensure paths are in UNIX format before anything is touched 134 | if $mingw ; then 135 | [ -n "$M2_HOME" ] && 136 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 137 | [ -n "$JAVA_HOME" ] && 138 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 139 | # TODO classpath? 140 | fi 141 | 142 | if [ -z "$JAVA_HOME" ]; then 143 | javaExecutable="`which javac`" 144 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 145 | # readlink(1) is not available as standard on Solaris 10. 146 | readLink=`which readlink` 147 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 148 | if $darwin ; then 149 | javaHome="`dirname \"$javaExecutable\"`" 150 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 151 | else 152 | javaExecutable="`readlink -f \"$javaExecutable\"`" 153 | fi 154 | javaHome="`dirname \"$javaExecutable\"`" 155 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 156 | JAVA_HOME="$javaHome" 157 | export JAVA_HOME 158 | fi 159 | fi 160 | fi 161 | 162 | if [ -z "$JAVACMD" ] ; then 163 | if [ -n "$JAVA_HOME" ] ; then 164 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 165 | # IBM's JDK on AIX uses strange locations for the executables 166 | JAVACMD="$JAVA_HOME/jre/sh/java" 167 | else 168 | JAVACMD="$JAVA_HOME/bin/java" 169 | fi 170 | else 171 | JAVACMD="`which java`" 172 | fi 173 | fi 174 | 175 | if [ ! -x "$JAVACMD" ] ; then 176 | echo "Error: JAVA_HOME is not defined correctly." >&2 177 | echo " We cannot execute $JAVACMD" >&2 178 | exit 1 179 | fi 180 | 181 | if [ -z "$JAVA_HOME" ] ; then 182 | echo "Warning: JAVA_HOME environment variable is not set." 183 | fi 184 | 185 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 186 | 187 | # For Cygwin, switch paths to Windows format before running java 188 | if $cygwin; then 189 | [ -n "$M2_HOME" ] && 190 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 191 | [ -n "$JAVA_HOME" ] && 192 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 193 | [ -n "$CLASSPATH" ] && 194 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 195 | fi 196 | 197 | # traverses directory structure from process work directory to filesystem root 198 | # first directory with .mvn subdirectory is considered project base directory 199 | find_maven_basedir() { 200 | local basedir=$(pwd) 201 | local wdir=$(pwd) 202 | while [ "$wdir" != '/' ] ; do 203 | if [ -d "$wdir"/.mvn ] ; then 204 | basedir=$wdir 205 | break 206 | fi 207 | wdir=$(cd "$wdir/.."; pwd) 208 | done 209 | echo "${basedir}" 210 | } 211 | 212 | # concatenates all lines of a file 213 | concat_lines() { 214 | if [ -f "$1" ]; then 215 | echo "$(tr -s '\n' ' ' < "$1")" 216 | fi 217 | } 218 | 219 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} 220 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 221 | 222 | # Provide a "standardized" way to retrieve the CLI args that will 223 | # work with both Windows and non-Windows executions. 224 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 225 | export MAVEN_CMD_LINE_ARGS 226 | 227 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 228 | 229 | echo "Running version check" 230 | VERSION=$( sed '\!//' -e 's!.*$!!' ) 231 | echo "The found version is [${VERSION}]" 232 | 233 | if echo $VERSION | egrep -q 'M|RC'; then 234 | echo Activating \"milestone\" profile for version=\"$VERSION\" 235 | echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pmilestone" 236 | else 237 | echo Deactivating \"milestone\" profile for version=\"$VERSION\" 238 | echo $MAVEN_ARGS | grep -q milestone && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pmilestone//') 239 | fi 240 | 241 | exec "$JAVACMD" \ 242 | $MAVEN_OPTS \ 243 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 244 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 245 | ${WRAPPER_LAUNCHER} ${MAVEN_ARGS} "$@" 246 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-maven-plugin/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 https://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 enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | set MAVEN_CMD_LINE_ARGS=%* 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="".\.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_CMD_LINE_ARGS% 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 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-maven-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.springframework.cloud 6 | spring-cloud-build 7 | 2.3.1.RELEASE 8 | 9 | 10 | spring-cloud-app-starter-metadata-maven-plugin 11 | 2.0.3.BUILD-SNAPSHOT 12 | maven-plugin 13 | 14 | 15 | 3.6.3 16 | 4.12 17 | 3.11.1 18 | 1.8 19 | 5.2.8.RELEASE 20 | 1.26 21 | 22 | 23 | 24 | 25 | org.apache.maven 26 | maven-plugin-api 27 | ${maven.version} 28 | provided 29 | 30 | 31 | org.springframework 32 | spring-core 33 | ${spring.version} 34 | 35 | 36 | org.springframework 37 | spring-beans 38 | ${spring.version} 39 | 40 | 41 | org.yaml 42 | snakeyaml 43 | ${snakeyaml.version} 44 | 45 | 46 | org.apache.maven 47 | maven-core 48 | ${maven.version} 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-configuration-processor 53 | 2.3.2.RELEASE 54 | 55 | 56 | io.rsocket 57 | rsocket-core 58 | 1.0.1 59 | 60 | 61 | org.springframework.boot 62 | spring-boot-loader 63 | 2.3.2.RELEASE 64 | 65 | 66 | junit 67 | junit 68 | ${junit.version} 69 | test 70 | 71 | 72 | org.assertj 73 | assertj-core 74 | ${assertj.version} 75 | test 76 | 77 | 78 | org.apache.maven.plugin-tools 79 | maven-plugin-annotations 80 | 3.4 81 | provided 82 | 83 | 84 | org.apache.commons 85 | commons-text 86 | ${commons-text.version} 87 | 88 | 89 | 90 | 91 | 92 | 93 | org.apache.maven.plugins 94 | maven-plugin-plugin 95 | 3.5 96 | 97 | 98 | org.apache.maven.plugins 99 | maven-compiler-plugin 100 | 101 | 1.8 102 | 1.8 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | spring 111 | 112 | 113 | 114 | true 115 | 116 | spring-snapshots 117 | Spring Snapshots 118 | https://repo.spring.io/libs-snapshot-local 119 | 120 | 121 | 122 | false 123 | 124 | spring-milestones 125 | Spring Milestones 126 | https://repo.spring.io/libs-milestone-local 127 | 128 | 129 | 130 | false 131 | 132 | spring-releases 133 | Spring Releases 134 | https://repo.spring.io/release 135 | 136 | 137 | 138 | false 139 | 140 | spring-libs-release 141 | Spring Libs Release 142 | https://repo.spring.io/libs-release 143 | 144 | 145 | 146 | false 147 | 148 | spring-milestone-release 149 | Spring Milestone Release 150 | https://repo.spring.io/libs-milestone 151 | 152 | 153 | 154 | 155 | 156 | true 157 | 158 | spring-snapshots 159 | Spring Snapshots 160 | https://repo.spring.io/libs-snapshot-local 161 | 162 | 163 | 164 | false 165 | 166 | spring-milestones 167 | Spring Milestones 168 | https://repo.spring.io/libs-milestone-local 169 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-maven-plugin/src/test/java/org/springframework/cloud/dataflow/completion/Expresso.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.dataflow.completion; 18 | 19 | /** 20 | * @author David Turanski 21 | **/ 22 | public enum Expresso { 23 | SINGLE, 24 | DOUBLE; 25 | } 26 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-maven-plugin/src/test/java/org/springframework/cloud/stream/app/documentation/plugin/EnumHintProviderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.stream.app.documentation.plugin; 18 | 19 | import java.io.IOException; 20 | 21 | import org.junit.Test; 22 | 23 | import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata; 24 | import org.springframework.boot.configurationprocessor.metadata.ItemHint; 25 | import org.springframework.boot.configurationprocessor.metadata.JsonMarshaller; 26 | import org.springframework.cloud.dataflow.completion.Expresso; 27 | import org.springframework.core.io.ClassPathResource; 28 | 29 | import static org.assertj.core.api.Assertions.assertThat; 30 | 31 | /** 32 | * @author David Turanski 33 | **/ 34 | public class EnumHintProviderTest { 35 | private JsonMarshaller jsonMarshaller = new JsonMarshaller(); 36 | 37 | @Test 38 | public void test() throws Exception { 39 | ConfigurationMetadata configurationMetadata = jsonMarshaller.read(new ClassPathResource("META-INF/spring" 40 | + "-configuration-metadata.json").getInputStream()); 41 | 42 | new MetadataAggregationMojo().addEnumHints(configurationMetadata, this.getClass().getClassLoader()); 43 | 44 | assertThat(configurationMetadata.getHints()).hasSize(1); 45 | 46 | ItemHint itemHint = configurationMetadata.getHints().get(0); 47 | 48 | 49 | // equals fails on ValueHint so ... 50 | // assertThat(new ItemHint.ValueHint("SINGLE",null)).isEqualTo(new ItemHint.ValueHint("SINGLE",null)); 51 | 52 | assertThat(itemHint.getValues()).hasSize(2); 53 | 54 | assertThat(itemHint.getValues().get(0).getValue()).isEqualTo(Expresso.SINGLE); 55 | assertThat(itemHint.getValues().get(1).getValue()).isEqualTo(Expresso.DOUBLE); 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-maven-plugin/src/test/java/org/springframework/cloud/stream/app/documentation/plugin/MergeWhitelistPropertiesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.cloud.stream.app.documentation.plugin; 17 | 18 | import java.io.IOException; 19 | import java.util.Properties; 20 | 21 | import org.junit.Test; 22 | 23 | import org.springframework.core.io.ClassPathResource; 24 | 25 | import static org.assertj.core.api.Assertions.assertThat; 26 | import static org.springframework.cloud.stream.app.documentation.plugin.MetadataAggregationMojo.CONFIGURATION_PROPERTIES_CLASSES; 27 | import static org.springframework.cloud.stream.app.documentation.plugin.MetadataAggregationMojo.CONFIGURATION_PROPERTIES_NAMES; 28 | 29 | /** 30 | * @author David Turanski 31 | **/ 32 | 33 | public class MergeWhitelistPropertiesTest { 34 | 35 | @Test 36 | public void merge() throws IOException { 37 | Properties properties1 = new Properties(); 38 | properties1.load(new ClassPathResource("META-INF/whitelist-1.properties").getInputStream()); 39 | 40 | Properties properties2 = new MetadataAggregationMojo().merge(properties1, 41 | new ClassPathResource("META-INF/whitelist-2.properties").getInputStream()); 42 | 43 | assertThat(properties2).containsKeys(CONFIGURATION_PROPERTIES_CLASSES, CONFIGURATION_PROPERTIES_NAMES); 44 | } 45 | 46 | @Test 47 | public void mergeReverseOrder() throws IOException { 48 | Properties properties1 = new Properties(); 49 | properties1.load(new ClassPathResource("META-INF/whitelist-2.properties").getInputStream()); 50 | 51 | Properties properties2 = new MetadataAggregationMojo().merge(properties1, 52 | new ClassPathResource("META-INF/whitelist-1.properties").getInputStream()); 53 | 54 | assertThat(properties2).containsKeys(CONFIGURATION_PROPERTIES_CLASSES, CONFIGURATION_PROPERTIES_NAMES); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-maven-plugin/src/test/resources/META-INF/spring-configuration-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "groups": [ 3 | { 4 | "name": "filter", 5 | "type": "foo.bar.FilterProperties", 6 | "sourceType": "foo.bar.FilterProperties" 7 | } 8 | ], 9 | "properties": [ 10 | { 11 | "name": "filter.expression", 12 | "type": "org.springframework.expression.Expression", 13 | "description": "A predicate to evaluate", 14 | "sourceType": "foo.bar.FilterProperties", 15 | "defaultValue": "true" 16 | }, 17 | { 18 | "name": "filter.expresso", 19 | "type": "org.springframework.cloud.dataflow.completion.Expresso", 20 | "description": "A property of type enum and whose name starts like 'expression'", 21 | "sourceType": "foo.bar.FilterProperties" 22 | } 23 | ], 24 | "hints": [ 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-maven-plugin/src/test/resources/META-INF/whitelist-1.properties: -------------------------------------------------------------------------------- 1 | configuration-properties.classes=\ 2 | org.springframework.cloud.stream.app.tasklaunchrequest.DataflowTaskLaunchRequestProperties 3 | -------------------------------------------------------------------------------- /spring-cloud-app-starter-metadata-maven-plugin/src/test/resources/META-INF/whitelist-2.properties: -------------------------------------------------------------------------------- 1 | configuration-properties.classes=\ 2 | org.springframework.cloud.stream.app.trigger.TriggerPropertiesMaxMessagesDefaultUnlimited 3 | configuration-properties.names=\ 4 | sftp.auto-create-local-dir,\ 5 | sftp.delete-remote-files,\ 6 | sftp.directories,\ 7 | sftp.factories,\ 8 | sftp.factory.allow-unknown-keys,\ 9 | sftp.factory.cache-sessions,\ 10 | sftp.factory.host,\ 11 | sftp.factory.known-hosts-expression,\ 12 | sftp.factory.pass-phrase,\ 13 | sftp.factory.password,\ 14 | sftp.factory.port,\ 15 | sftp.factory.private-key,\ 16 | sftp.factory.username,\ 17 | sftp.fair,\ 18 | sftp.filename-pattern,\ 19 | sftp.filename-regex,\ 20 | sftp.list-only,\ 21 | sftp.local-dir,\ 22 | sftp.max-fetch,\ 23 | sftp.preserve-timestamp,\ 24 | sftp.remote-dir,\ 25 | sftp.remote-file-separator 26 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local -P spring 2 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-attic/spring-cloud-app-starters-maven-plugins/7a06cdbcd2f47cf83c2ad1ccd8eeff285bbd56c6/spring-cloud-stream-app-maven-plugin/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | https://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 | https://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 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/README.adoc: -------------------------------------------------------------------------------- 1 | = spring-cloud-stream-app-maven-plugin 2 | Maven plugin for generating spring cloud stream applications from the spring-cloud-stream-app-starters repository 3 | 4 | == Build 5 | 6 | mvn clean package [Requires JDK 8] 7 | 8 | == Sample Configuration for generating spring cloud stream apps 9 | 10 | [source, xml] 11 | ---- 12 | 13 | org.springframework.cloud.stream.app.plugin 14 | spring-cloud-stream-app-maven-plugin 15 | 2.0.1.BUILD-SNAPSHOT 16 | 17 | 1.8 18 | ${spring-boot.version} 19 | ${app-metadata-maven-plugin-version} 20 | 21 | 22 | app-starters-core-dependencies 23 | org.springframework.cloud.stream.app 24 | app-starters-core-dependencies 25 | ${app-starters-core-dependencies.version} 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | counter 34 | sink 35 | ${project.version} 36 | io.pivotal.java.function.counter.consumer.CounterConsumerConfiguration.class 37 | counterConsumer 38 | 39 | 40 | spring.cloud.stream.propagateOriginalContentType=false 41 | 42 | 43 | 44 | io.pivotal.java.function 45 | counter-consumer 46 | ${java-functions.version} 47 | 48 | 49 | 50 | 51 | org.springframework.cloud.stream.app 52 | app-starters-security-common 53 | 54 | 55 | org.springframework.cloud 56 | spring-cloud-starter-config 57 | 58 | 59 | org.springframework.cloud.stream.app 60 | app-starters-micrometer-common 61 | 62 | 63 | io.micrometer 64 | micrometer-registry-influx 65 | 66 | 67 | io.micrometer 68 | micrometer-registry-prometheus 69 | 70 | 71 | org.springframework.cloud 72 | spring-cloud-cloudfoundry-connector 73 | 74 | 75 | org.springframework.cloud 76 | spring-cloud-spring-service-connector 77 | 78 | 79 | io.micrometer.prometheus 80 | prometheus-rsocket-spring 81 | 82 | 83 | 84 | 85 | ---- 86 | 87 | The bom for stream apps is specified in spring-cloud-stream-app-dependencies 88 | (group id: org.springframework.cloud.stream.app) 89 | 90 | and for tasks it is spring-cloud-task-app-dependencies 91 | (group id: org.springframework.cloud.task.app). 92 | 93 | Extra dependency management can be added as additional boms to the plugin using the property 94 | -DbomsWithHigherPrecedence and value based on the pattern groupId:artfiactId:version. This can 95 | be a comma separated collection of boms. Any bom added like this will get priority in the order 96 | they are specified over any default values used in the plugin configuration. 97 | 98 | Spring Boot version used in the generated app can be overridden using the plugin property 99 | -DbootVersion=. 100 | 101 | 102 | ==== Copy Third-Party Resources 103 | The `copyResources` configuration block permits copying Resources from third-party jar dependencies into the 104 | generated App Starter classpath. 105 | 106 | Form example if you want to copy a truststore and a self-signed certificate (`clientKeyStore.jks`, `cacerts`) bundled inside the 107 | `org.springframework.cloud.stream.app:coap-app-starters-common:2.0.0.BUILD-SNAPSHOT` dependency you can add this to the 108 | `spring-cloud-stream-app-maven-plugin` configuration: 109 | 110 | [source, xml] 111 | ---- 112 | 113 | org.springframework.cloud.stream.app.plugin 114 | spring-cloud-stream-app-maven-plugin 115 | 116 | ${session.executionRootDirectory}/apps 117 | ${project.version} 118 | .... 119 | 120 | 121 | 122 | 123 | 124 | org.springframework.cloud.stream.app 125 | coap-app-starters-common 126 | 2.0.0.BUILD-SNAPSHOT 127 | clientKeyStore.jks,cacerts 128 | 129 | 130 | 131 | 132 | 133 | ---- 134 | 135 | Later will add the following `maven-dependency-plugin` definition to the generated aps starter pom: 136 | 137 | [source, xml] 138 | ---- 139 | 140 | maven-dependency-plugin 141 | 142 | 143 | 144 | unpack 145 | 146 | 147 | 148 | 149 | org.springframework.cloud.stream.app 150 | coap-app-starters-common 151 | 2.0.0.BUILD-SNAPSHOT 152 | clientKeyStore.jks,cacerts 153 | 154 | 155 | ${project.build.directory}/classes/ 156 | 157 | 158 | 159 | 160 | ---- 161 | 162 | This will ensure that the clientKeyStore.jks,cacerts files will be copied to the AppStarter's `BOOT-INF/classes/` 163 | 164 | ==== Insert additional properties into the application.properties file for the created app. 165 | The `additionalAppProperties` configuration block permits adding of additional properties to the application.properties file. 166 | [source, xml] 167 | ---- 168 | 169 | org.springframework.cloud.stream.app.plugin 170 | spring-cloud-stream-app-maven-plugin 171 | 172 | ${session.executionRootDirectory}/apps 173 | ${project.version} 174 | .... 175 | 176 | 177 | 178 | 179 | spring.cloud.task.closecontextEnabled=true 180 | 181 | 182 | 183 | 184 | ---- 185 | In the example above we added the`spring.cloud.task.closecontextEnabled` property to the application.properties of the created app. 186 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/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 | # https://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 | # 58 | # Look for the Apple JDKs first to preserve the existing behaviour, and then look 59 | # for the new JDKs provided by Oracle. 60 | # 61 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then 62 | # 63 | # Apple JDKs 64 | # 65 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home 66 | fi 67 | 68 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then 69 | # 70 | # Apple JDKs 71 | # 72 | export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 73 | fi 74 | 75 | if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then 76 | # 77 | # Oracle JDKs 78 | # 79 | export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 80 | fi 81 | 82 | if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then 83 | # 84 | # Apple JDKs 85 | # 86 | export JAVA_HOME=`/usr/libexec/java_home` 87 | fi 88 | ;; 89 | esac 90 | 91 | if [ -z "$JAVA_HOME" ] ; then 92 | if [ -r /etc/gentoo-release ] ; then 93 | JAVA_HOME=`java-config --jre-home` 94 | fi 95 | fi 96 | 97 | if [ -z "$M2_HOME" ] ; then 98 | ## resolve links - $0 may be a link to maven's home 99 | PRG="$0" 100 | 101 | # need this for relative symlinks 102 | while [ -h "$PRG" ] ; do 103 | ls=`ls -ld "$PRG"` 104 | link=`expr "$ls" : '.*-> \(.*\)$'` 105 | if expr "$link" : '/.*' > /dev/null; then 106 | PRG="$link" 107 | else 108 | PRG="`dirname "$PRG"`/$link" 109 | fi 110 | done 111 | 112 | saveddir=`pwd` 113 | 114 | M2_HOME=`dirname "$PRG"`/.. 115 | 116 | # make it fully qualified 117 | M2_HOME=`cd "$M2_HOME" && pwd` 118 | 119 | cd "$saveddir" 120 | # echo Using m2 at $M2_HOME 121 | fi 122 | 123 | # For Cygwin, ensure paths are in UNIX format before anything is touched 124 | if $cygwin ; then 125 | [ -n "$M2_HOME" ] && 126 | M2_HOME=`cygpath --unix "$M2_HOME"` 127 | [ -n "$JAVA_HOME" ] && 128 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 129 | [ -n "$CLASSPATH" ] && 130 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 131 | fi 132 | 133 | # For Migwn, ensure paths are in UNIX format before anything is touched 134 | if $mingw ; then 135 | [ -n "$M2_HOME" ] && 136 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 137 | [ -n "$JAVA_HOME" ] && 138 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 139 | # TODO classpath? 140 | fi 141 | 142 | if [ -z "$JAVA_HOME" ]; then 143 | javaExecutable="`which javac`" 144 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 145 | # readlink(1) is not available as standard on Solaris 10. 146 | readLink=`which readlink` 147 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 148 | if $darwin ; then 149 | javaHome="`dirname \"$javaExecutable\"`" 150 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 151 | else 152 | javaExecutable="`readlink -f \"$javaExecutable\"`" 153 | fi 154 | javaHome="`dirname \"$javaExecutable\"`" 155 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 156 | JAVA_HOME="$javaHome" 157 | export JAVA_HOME 158 | fi 159 | fi 160 | fi 161 | 162 | if [ -z "$JAVACMD" ] ; then 163 | if [ -n "$JAVA_HOME" ] ; then 164 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 165 | # IBM's JDK on AIX uses strange locations for the executables 166 | JAVACMD="$JAVA_HOME/jre/sh/java" 167 | else 168 | JAVACMD="$JAVA_HOME/bin/java" 169 | fi 170 | else 171 | JAVACMD="`which java`" 172 | fi 173 | fi 174 | 175 | if [ ! -x "$JAVACMD" ] ; then 176 | echo "Error: JAVA_HOME is not defined correctly." >&2 177 | echo " We cannot execute $JAVACMD" >&2 178 | exit 1 179 | fi 180 | 181 | if [ -z "$JAVA_HOME" ] ; then 182 | echo "Warning: JAVA_HOME environment variable is not set." 183 | fi 184 | 185 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 186 | 187 | # For Cygwin, switch paths to Windows format before running java 188 | if $cygwin; then 189 | [ -n "$M2_HOME" ] && 190 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 191 | [ -n "$JAVA_HOME" ] && 192 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 193 | [ -n "$CLASSPATH" ] && 194 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 195 | fi 196 | 197 | # traverses directory structure from process work directory to filesystem root 198 | # first directory with .mvn subdirectory is considered project base directory 199 | find_maven_basedir() { 200 | local basedir=$(pwd) 201 | local wdir=$(pwd) 202 | while [ "$wdir" != '/' ] ; do 203 | if [ -d "$wdir"/.mvn ] ; then 204 | basedir=$wdir 205 | break 206 | fi 207 | wdir=$(cd "$wdir/.."; pwd) 208 | done 209 | echo "${basedir}" 210 | } 211 | 212 | # concatenates all lines of a file 213 | concat_lines() { 214 | if [ -f "$1" ]; then 215 | echo "$(tr -s '\n' ' ' < "$1")" 216 | fi 217 | } 218 | 219 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} 220 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 221 | 222 | # Provide a "standardized" way to retrieve the CLI args that will 223 | # work with both Windows and non-Windows executions. 224 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 225 | export MAVEN_CMD_LINE_ARGS 226 | 227 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 228 | 229 | echo "Running version check" 230 | VERSION=$( sed '\!//' -e 's!.*$!!' ) 231 | echo "The found version is [${VERSION}]" 232 | 233 | if echo $VERSION | egrep -q 'M|RC'; then 234 | echo Activating \"milestone\" profile for version=\"$VERSION\" 235 | echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pmilestone" 236 | else 237 | echo Deactivating \"milestone\" profile for version=\"$VERSION\" 238 | echo $MAVEN_ARGS | grep -q milestone && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pmilestone//') 239 | fi 240 | 241 | if echo $VERSION | egrep -q 'RELEASE'; then 242 | echo Activating \"central\" profile for version=\"$VERSION\" 243 | echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pcentral" 244 | else 245 | echo Deactivating \"central\" profile for version=\"$VERSION\" 246 | echo $MAVEN_ARGS | grep -q central && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pcentral//') 247 | fi 248 | 249 | exec "$JAVACMD" \ 250 | $MAVEN_OPTS \ 251 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 252 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 253 | ${WRAPPER_LAUNCHER} ${MAVEN_ARGS} "$@" 254 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/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 https://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 enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | set MAVEN_CMD_LINE_ARGS=%* 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="".\.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_CMD_LINE_ARGS% 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 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.springframework.cloud.stream.app.plugin 6 | spring-cloud-stream-app-maven-plugin 7 | 2.0.0.BUILD-SNAPSHOT 8 | maven-plugin 9 | spring cloud stream and task app generator plugin 10 | 11 | spring-cloud-stream-app-maven-plugin Maven Plugin 12 | 13 | https://spring.io 14 | 15 | 16 | Pivotal Software, Inc. 17 | https://www.spring.io 18 | 19 | 20 | 21 | Apache License, Version 2.0 22 | https://www.apache.org/licenses/LICENSE-2.0 23 | 24 | Copyright 2014-2016 the original author or authors. 25 | 26 | Licensed under the Apache License, Version 2.0 (the "License"); 27 | you may not use this file except in compliance with the License. 28 | You may obtain a copy of the License at 29 | 30 | https://www.apache.org/licenses/LICENSE-2.0 31 | 32 | Unless required by applicable law or agreed to in writing, software 33 | distributed under the License is distributed on an "AS IS" BASIS, 34 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 35 | implied. 36 | 37 | See the License for the specific language governing permissions and 38 | limitations under the License. 39 | 40 | 41 | 42 | 43 | 44 | UTF-8 45 | 3.6.3 46 | 3.6.0 47 | 1.15 48 | 5.2.8.RELEASE 49 | 50 | 51 | 52 | https://github.com/spring-cloud/spring-cloud-stream-app-maven-plugin 53 | scm:git:git://github.com/spring-cloud/spring-cloud-stream-app-maven-plugin.git 54 | scm:git:ssh://git@github.com/spring-cloud/spring-cloud-stream-app-maven-plugin.git 55 | HEAD 56 | 57 | 58 | 59 | 60 | schacko 61 | Soby Chacko 62 | schacko at pivotal.io 63 | Pivotal Software, Inc. 64 | https://www.spring.io 65 | 66 | Developer 67 | 68 | 69 | 70 | tzolov 71 | Christian Tzolov 72 | ctzolov at pivotal.io 73 | Pivotal Software, Inc. 74 | http://www.spring.io 75 | 76 | Developer 77 | 78 | 79 | 80 | 81 | 82 | 83 | com.samskivert 84 | jmustache 85 | ${jmustache.version} 86 | 87 | 88 | 89 | org.springframework 90 | spring-core 91 | ${spring.version} 92 | 93 | 94 | 95 | org.apache.maven 96 | maven-plugin-api 97 | provided 98 | ${maven.version} 99 | 100 | 101 | org.apache.maven 102 | maven-core 103 | ${maven.version} 104 | 105 | 106 | org.apache.maven.plugin-tools 107 | maven-plugin-annotations 108 | ${maven.plugin.version} 109 | provided 110 | 111 | 112 | 113 | junit 114 | junit 115 | 4.13 116 | test 117 | 118 | 119 | org.apache.maven.plugin-testing 120 | maven-plugin-testing-harness 121 | 3.3.0 122 | test 123 | 124 | 125 | org.apache.maven 126 | maven-compat 127 | ${maven.version} 128 | test 129 | 130 | 131 | org.assertj 132 | assertj-core 133 | 3.15.0 134 | test 135 | 136 | 137 | 138 | 139 | 140 | 141 | org.apache.maven.plugins 142 | maven-plugin-plugin 143 | ${maven.plugin.version} 144 | 145 | generate-app 146 | true 147 | 148 | 149 | 150 | mojo-descriptor 151 | 152 | descriptor 153 | 154 | 155 | 156 | help-goal 157 | 158 | helpmojo 159 | 160 | 161 | 162 | 163 | 164 | org.apache.maven.plugins 165 | maven-compiler-plugin 166 | 167 | 1.8 168 | 1.8 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | repo.spring.io 177 | Spring Release Repository 178 | https://repo.spring.io/libs-release-local 179 | 180 | 181 | repo.spring.io 182 | Spring Snapshot Repository 183 | https://repo.spring.io/libs-snapshot-local 184 | 185 | 186 | 187 | 188 | 189 | run-its 190 | 191 | 192 | 193 | org.apache.maven.plugins 194 | maven-invoker-plugin 195 | 3.2.1 196 | 197 | true 198 | ${project.build.directory}/it 199 | 200 | */pom.xml 201 | 202 | verify 203 | ${project.build.directory}/local-repo 204 | src/it/settings.xml 205 | 206 | clean 207 | test-compile 208 | 209 | 210 | 211 | 212 | integration-test 213 | 214 | install 215 | integration-test 216 | verify 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | milestone 227 | 228 | 229 | repo.spring.io 230 | Spring Milestone Repository 231 | https://repo.spring.io/libs-milestone-local 232 | 233 | 234 | 235 | 236 | central 237 | 238 | 239 | 240 | org.apache.maven.plugins 241 | maven-gpg-plugin 242 | 243 | 244 | sign-artifacts 245 | verify 246 | 247 | sign 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | sonatype-nexus-snapshots 257 | Sonatype Nexus Snapshots 258 | https://oss.sonatype.org/content/repositories/snapshots/ 259 | 260 | 261 | sonatype-nexus-staging 262 | Nexus Release Repository 263 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | true 273 | 274 | spring-snapshots 275 | Spring Snapshots 276 | https://repo.spring.io/libs-snapshot-local 277 | 278 | 279 | 280 | false 281 | 282 | spring-milestones 283 | Spring Milestones 284 | https://repo.spring.io/libs-milestone-local 285 | 286 | 287 | 288 | false 289 | 290 | spring-releases 291 | Spring Releases 292 | https://repo.spring.io/release 293 | 294 | 295 | 296 | 297 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/java/org/springframework/cloud/stream/app/plugin/MavenXmlWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.stream.app.plugin; 18 | 19 | import java.io.StringReader; 20 | import java.io.StringWriter; 21 | import java.io.Writer; 22 | import java.lang.reflect.Method; 23 | import java.util.function.Consumer; 24 | import java.util.stream.Collectors; 25 | import java.util.stream.IntStream; 26 | 27 | import org.apache.maven.model.Plugin; 28 | import org.apache.maven.model.io.xpp3.MavenXpp3Writer; 29 | import org.codehaus.plexus.util.xml.Xpp3Dom; 30 | import org.codehaus.plexus.util.xml.Xpp3DomBuilder; 31 | import org.codehaus.plexus.util.xml.pull.MXSerializer; 32 | import org.codehaus.plexus.util.xml.pull.XmlSerializer; 33 | 34 | /** 35 | * Uses the private MavenXpp3Writer write methods to convert Model elements into XML strings. 36 | * 37 | * @author Christian Tzolov 38 | */ 39 | public class MavenXmlWriter { 40 | 41 | /** 42 | * Serializes any instance of a e.g. org.apache.maven.model.XXXX class into XML text. 43 | * Via reflections calls the private MavenXpp3Writer#writeXXXX(XXXX, String, XmlSerializer) method. 44 | * As xml tag uses the lower case of the XXXX class name (e.g. xxxx). 45 | * 46 | * If above name conventions don't hold or additional processing is required implement a dedicated overload method. 47 | * For example see {@link #toXml(Plugin)} 48 | */ 49 | public static String toXml(T element) { 50 | String privateMethodName = "write" + element.getClass().getSimpleName(); 51 | String xmlTagName = element.getClass().getSimpleName().toLowerCase(); 52 | return write(serializer -> invokeMavenXppWriteMethod(element, privateMethodName, xmlTagName, serializer)); 53 | } 54 | 55 | /** 56 | * Serializes an {@link Plugin} instance into XML text, using reflection to invoke the private 57 | * MavenXpp3Writer#writePlugin(Plugin, String, XmlSerializer) method. The Plugin Configuration block (when present) 58 | * requires special handling to convert String values into Xpp3Dom object before writing. 59 | * 60 | * For Plugin Configuration you mast nest the configuration content into a CDATA block like shown here: 61 | * 62 | * 63 | * 64 | * com.google.cloud.tools 65 | * jib-maven-plugin 66 | * 2.6.0 67 | * 68 | * springcloud/openjdk 70 | * 71 | * springcloudstream:${project.artifactId} 72 | * latest 73 | * 74 | * 75 | * Docker 76 | * 77 | * ]]> 78 | * 79 | * 80 | * 81 | * 82 | */ 83 | public static String toXml(Plugin plugin) { 84 | try { 85 | Object configuration = plugin.getConfiguration(); 86 | if (configuration != null && !(configuration instanceof Xpp3Dom)) { 87 | plugin.setConfiguration(Xpp3DomBuilder.build(new StringReader( 88 | "" + configuration.toString() + ""))); 89 | } 90 | } 91 | catch (Exception ex) { 92 | throw new IllegalStateException("Issue creating config for additional plugin", ex); 93 | } 94 | 95 | return write(serializer -> invokeMavenXppWriteMethod( 96 | plugin, "writePlugin", "plugin", serializer)); 97 | } 98 | 99 | public static String write(Consumer elementWriter) { 100 | try { 101 | Writer writer = new StringWriter(); 102 | 103 | XmlSerializer serializer = new MXSerializer(); 104 | serializer.setProperty("http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " "); 105 | serializer.setProperty("http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n"); 106 | serializer.setOutput(writer); 107 | 108 | serializer.startDocument("UTF-8", null); 109 | elementWriter.accept(serializer); 110 | serializer.endDocument(); 111 | 112 | String result = writer.toString(); 113 | return result.substring(result.indexOf('\n') + 1); // remove first line (e.g. remove the ) 114 | } 115 | catch (Exception e) { 116 | throw new IllegalStateException(e); 117 | } 118 | } 119 | 120 | /** 121 | * Uses the private MavenXpp3Writer methods to convert Model elements into XML strings. 122 | * 123 | * @param modelElementToWrite a parameterizable org.apache.maven.model.T instance to serialize. 124 | * @param The actual org.apache.maven.model's class type. 125 | * @param writeMethodName Name of the private {@link MavenXpp3Writer} method to call. 126 | * @param xmlTagName Name for the XML tag to surround the serialized model instance. 127 | * @param serializer The XmlSerializer used to write the xml. 128 | */ 129 | public static void invokeMavenXppWriteMethod(T modelElementToWrite, String writeMethodName, 130 | String xmlTagName, XmlSerializer serializer) { 131 | 132 | try { 133 | MavenXpp3Writer pomWriter = new MavenXpp3Writer(); 134 | Method method = pomWriter.getClass().getDeclaredMethod( 135 | writeMethodName, modelElementToWrite.getClass(), String.class, XmlSerializer.class); 136 | method.setAccessible(true); // allow invoking private method. 137 | method.invoke(pomWriter, modelElementToWrite, xmlTagName, serializer); 138 | } 139 | catch (Exception e) { 140 | throw new IllegalStateException(e); 141 | } 142 | } 143 | 144 | public static String indent(String input, int indentation) { 145 | String indentPrefix = "\n" + IntStream.range(0, indentation).mapToObj(i -> " ").collect(Collectors.joining()); 146 | String indentedInput = input.replace("\n", indentPrefix); 147 | return indentedInput.substring(0, indentedInput.lastIndexOf(indentPrefix)); // remove the last empty line. 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/java/org/springframework/cloud/stream/app/plugin/generator/AppBom.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.cloud.stream.app.plugin.generator; 17 | 18 | /** 19 | * @author Christian Tzolov 20 | */ 21 | public class AppBom { 22 | /** 23 | * Spring Boot version to use. 24 | */ 25 | private String springBootVersion; 26 | 27 | private String appMetadataMavenPluginVersion; 28 | 29 | 30 | public String getSpringBootVersion() { 31 | return springBootVersion; 32 | } 33 | 34 | public void setSpringBootVersion(String springBootVersion) { 35 | this.springBootVersion = springBootVersion; 36 | } 37 | 38 | public AppBom withSpringBootVersion(String springBootVersion) { 39 | this.springBootVersion = springBootVersion; 40 | return this; 41 | } 42 | 43 | public String getAppMetadataMavenPluginVersion() { 44 | return appMetadataMavenPluginVersion; 45 | } 46 | 47 | public void setAppMetadataMavenPluginVersion(String appMetadataMavenPluginVersion) { 48 | this.appMetadataMavenPluginVersion = appMetadataMavenPluginVersion; 49 | } 50 | 51 | public AppBom withAppMetadataMavenPluginVersion(String appMetadataMavenPluginVersion) { 52 | this.appMetadataMavenPluginVersion = appMetadataMavenPluginVersion; 53 | return this; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/java/org/springframework/cloud/stream/app/plugin/generator/AppDefinition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.cloud.stream.app.plugin.generator; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | /** 22 | * @author Christian Tzolov 23 | */ 24 | public class AppDefinition { 25 | 26 | public enum ContainerImageFormat {Docker, OCI} 27 | 28 | public enum AppType {source, processor, sink} 29 | 30 | private String name; 31 | 32 | private AppType type; 33 | 34 | private String version; 35 | 36 | private String configClass; 37 | 38 | private String functionDefinition; 39 | 40 | private List metadataSourceTypeFilters = new ArrayList<>(); 41 | 42 | private List metadataNameFilters = new ArrayList<>(); 43 | 44 | private List additionalProperties = new ArrayList<>(); 45 | 46 | private List mavenManagedDependencies = new ArrayList<>(); 47 | 48 | private List mavenDependencies = new ArrayList<>(); 49 | 50 | private List mavenPlugins = new ArrayList<>(); 51 | 52 | /** 53 | * Allow to generate either Docker or OCI image formats 54 | */ 55 | private ContainerImageFormat containerImageFormat = ContainerImageFormat.Docker; 56 | 57 | /** 58 | * True will attempt to inline the (white) filtered Spring Boot metadata as Base64 encoded property. 59 | */ 60 | private boolean enableContainerImageMetadata = false; 61 | 62 | private String containerImageOrgName = "springcloudstream"; 63 | 64 | private String containerImageTag = "latest"; 65 | 66 | public String getName() { 67 | return name; 68 | } 69 | 70 | public void setName(String name) { 71 | this.name = name; 72 | } 73 | 74 | public AppType getType() { 75 | return type; 76 | } 77 | 78 | public void setType(AppType type) { 79 | this.type = type; 80 | } 81 | 82 | public String getVersion() { 83 | return version; 84 | } 85 | 86 | public void setVersion(String version) { 87 | this.version = version; 88 | } 89 | 90 | public List getAdditionalProperties() { 91 | return additionalProperties; 92 | } 93 | 94 | public void setAdditionalProperties(List additionalProperties) { 95 | this.additionalProperties = additionalProperties; 96 | } 97 | 98 | public List getMavenDependencies() { 99 | return mavenDependencies; 100 | } 101 | 102 | public void setMavenDependencies(List mavenDependencies) { 103 | this.mavenDependencies = mavenDependencies; 104 | } 105 | 106 | public List getMavenManagedDependencies() { 107 | return mavenManagedDependencies; 108 | } 109 | 110 | public void setMavenManagedDependencies(List mavenManagedDependencies) { 111 | this.mavenManagedDependencies = mavenManagedDependencies; 112 | } 113 | 114 | public List getMavenPlugins() { 115 | return mavenPlugins; 116 | } 117 | 118 | public void setMavenPlugins(List mavenPlugins) { 119 | this.mavenPlugins = mavenPlugins; 120 | } 121 | 122 | public boolean isSupplier() { 123 | return type == AppType.source; 124 | } 125 | 126 | public boolean isConsumer() { 127 | return type == AppType.sink; 128 | } 129 | 130 | public boolean isFunction() { 131 | return type == AppType.processor; 132 | } 133 | 134 | public String getConfigClass() { 135 | return configClass; 136 | } 137 | 138 | public void setConfigClass(String configClass) { 139 | this.configClass = configClass; 140 | } 141 | 142 | public List getMetadataSourceTypeFilters() { 143 | return metadataSourceTypeFilters; 144 | } 145 | 146 | public void setMetadataSourceTypeFilters(List metadataSourceTypeFilters) { 147 | this.metadataSourceTypeFilters = metadataSourceTypeFilters; 148 | } 149 | 150 | public List getMetadataNameFilters() { 151 | return metadataNameFilters; 152 | } 153 | 154 | public void setMetadataNameFilters(List metadataNameFilters) { 155 | this.metadataNameFilters = metadataNameFilters; 156 | } 157 | 158 | public ContainerImageFormat getContainerImageFormat() { 159 | return containerImageFormat; 160 | } 161 | 162 | public void setContainerImageFormat(ContainerImageFormat containerImageFormat) { 163 | this.containerImageFormat = containerImageFormat; 164 | } 165 | 166 | public boolean isEnableContainerImageMetadata() { 167 | return enableContainerImageMetadata; 168 | } 169 | 170 | public void setEnableContainerImageMetadata(boolean enableContainerImageMetadata) { 171 | this.enableContainerImageMetadata = enableContainerImageMetadata; 172 | } 173 | 174 | public String getContainerImageOrgName() { 175 | return containerImageOrgName; 176 | } 177 | 178 | public void setContainerImageOrgName(String containerImageOrgName) { 179 | this.containerImageOrgName = containerImageOrgName; 180 | } 181 | 182 | public String getContainerImageTag() { 183 | return containerImageTag; 184 | } 185 | 186 | public void setContainerImageTag(String containerImageTag) { 187 | this.containerImageTag = containerImageTag; 188 | } 189 | 190 | public String getFunctionDefinition() { 191 | return functionDefinition; 192 | } 193 | 194 | public void setFunctionDefinition(String functionDefinition) { 195 | this.functionDefinition = functionDefinition; 196 | } 197 | } 198 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/java/org/springframework/cloud/stream/app/plugin/generator/ProjectGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.cloud.stream.app.plugin.generator; 17 | 18 | import java.io.ByteArrayInputStream; 19 | import java.io.File; 20 | import java.io.IOException; 21 | import java.io.InputStream; 22 | import java.io.InputStreamReader; 23 | import java.nio.file.Files; 24 | import java.nio.file.StandardCopyOption; 25 | import java.util.Arrays; 26 | import java.util.HashMap; 27 | import java.util.Map; 28 | import java.util.Objects; 29 | 30 | import com.samskivert.mustache.Mustache; 31 | import com.samskivert.mustache.Template; 32 | import org.apache.commons.io.FileUtils; 33 | 34 | import org.springframework.util.Assert; 35 | 36 | /** 37 | * @author Christian Tzolov 38 | */ 39 | public class ProjectGenerator { 40 | 41 | private ProjectGenerator() { 42 | } 43 | 44 | public static ProjectGenerator getInstance() { 45 | return new ProjectGenerator(); 46 | } 47 | 48 | public void generate(ProjectGeneratorProperties generatorProperties) throws IOException { 49 | 50 | Map containerTemplateProperties = new HashMap<>(); 51 | // register {{#capitalize}}...{{/capitalize}} function. 52 | containerTemplateProperties.put("capitalize", (Mustache.Lambda) (frag, out) -> out.write(capitalize(frag.execute().trim()))); 53 | // register {{#camelCase}}...{{/camelCase}} function. 54 | containerTemplateProperties.put("camelCase", (Mustache.Lambda) (frag, out) -> out.write(camelCase(frag.execute().trim()))); 55 | 56 | containerTemplateProperties.put("bom", generatorProperties.getAppBom()); 57 | containerTemplateProperties.put("app", generatorProperties.getAppDefinition()); 58 | containerTemplateProperties.put("binders", generatorProperties.getBinders()); 59 | 60 | // --------------------------------- 61 | // Generate apps container POM 62 | // --------------------------------- 63 | File appParentDir = mkdirs(generatorProperties.getOutputFolder()); 64 | copy(materialize("template/apps-container-pom.xml", containerTemplateProperties), 65 | file(appParentDir, "pom.xml")); 66 | // maven wrapper 67 | copyMavenWrapper(appParentDir); 68 | 69 | // --------------------------------- 70 | // Generate App projects 71 | // --------------------------------- 72 | Assert.notEmpty(generatorProperties.getBinders(), "At least one Binder must be provided"); 73 | for (String binder : generatorProperties.getBinders()) { 74 | generateAppProject(appParentDir, containerTemplateProperties, generatorProperties.getAppDefinition(), 75 | generatorProperties.getProjectResourcesDirectory(), binder); 76 | } 77 | } 78 | 79 | private void generateAppProject(File appRootDirectory, Map containerTemplateProperties, 80 | AppDefinition appDefinition, File projectResourcesDirectory, String binder) throws IOException { 81 | 82 | String appClassName = String.format("%s%s%sApplication", 83 | camelCase(appDefinition.getName()), 84 | capitalize(appDefinition.getType().name()), 85 | capitalize(binder)); 86 | 87 | String appPackageName = String.format("org.springframework.cloud.stream.app.%s.%s.%s", 88 | toPkg(appDefinition.getName()), 89 | appDefinition.getType(), 90 | binder); 91 | 92 | Map appTemplateProperties = new HashMap<>(containerTemplateProperties); 93 | 94 | // Shortcut substitutions. Prevent complicated expressions in the templates. 95 | appTemplateProperties.put("app-class-name", appClassName); 96 | appTemplateProperties.put("app-package-name", appPackageName); 97 | appTemplateProperties.put("app-binder", binder); 98 | 99 | // app POM 100 | File appDir = 101 | mkdirs(file(appRootDirectory, appDefinition.getName() + "-" + appDefinition.getType() + "-" + binder)); 102 | 103 | copy(materialize("template/app-pom.xml", appTemplateProperties), file(appDir, "pom.xml")); 104 | 105 | File appMainSrcDir = mkdirs(pkgToDir(appDir, "src.main.java." + appPackageName)); 106 | 107 | File appMainResourceDir = mkdirs(pkgToDir(appDir, "src.main.resources")); 108 | 109 | // application.properties 110 | copy(materialize("template/app.properties", appTemplateProperties), 111 | file(appMainResourceDir, "application.properties")); 112 | 113 | // copy the entire project's src/main/resources directory 114 | if (projectResourcesDirectory != null && projectResourcesDirectory.exists()) { 115 | FileUtils.copyDirectory(projectResourcesDirectory, appMainResourceDir); 116 | } 117 | 118 | copy(materialize("template/App.java", appTemplateProperties), 119 | file(appMainSrcDir, appClassName + ".java")); 120 | 121 | // TESTS 122 | File appTestSrcDir = mkdirs(pkgToDir(appDir, "src.test.java." + appPackageName)); 123 | 124 | copy(materialize("template/AppTests.java", appTemplateProperties), 125 | file(appTestSrcDir, appClassName + "Tests.java")); 126 | 127 | // README 128 | copy(materialize("template/README.adoc", appTemplateProperties), 129 | file(appDir, "README.adoc")); 130 | 131 | // maven wrapper 132 | copyMavenWrapper(appDir); 133 | } 134 | 135 | private void copyMavenWrapper(File appDir) throws IOException { 136 | 137 | // mvnw 138 | copyResource("template/mvnw", file(appDir, "mvnw")); 139 | file(appDir, "mvnw").setExecutable(true); 140 | 141 | copyResource("template/mvnw.cmd", file(appDir, "mvnw.cmd")); 142 | 143 | File dotMavenDir = mkdirs(new File(appDir, ".mvn")); 144 | 145 | // .mvn/jvm.config 146 | copyResource("template/.mvn/jvm.config", file(dotMavenDir, "jvm.config")); 147 | 148 | // .mvn/maven.config 149 | copyResource("template/.mvn/maven.config", file(dotMavenDir, "maven.config")); 150 | 151 | File dotMavenWrapper = mkdirs(file(appDir, ".mvn/wrapper")); 152 | 153 | // .mvn/wrapper/maven-wrapper.jar 154 | copyResource("template/.mvn/wrapper/maven-wrapper.jar", 155 | file(dotMavenWrapper, "maven-wrapper.jar")); 156 | 157 | // .mvn/wrapper/maven-wrapper.properties 158 | copyResource("template/.mvn/wrapper/maven-wrapper.properties", 159 | file(dotMavenWrapper, "maven-wrapper.properties")); 160 | 161 | // .mvn/wrapper/MavenWrapperDownloader.java 162 | copyResource("template/.mvn/wrapper/MavenWrapperDownloader.java", 163 | file(dotMavenWrapper, "MavenWrapperDownloader.java")); 164 | } 165 | 166 | private String materialize(String templatePath, Map templateProperties) throws IOException { 167 | try (InputStreamReader resourcesTemplateReader = new InputStreamReader( 168 | Objects.requireNonNull(this.getClass().getClassLoader().getResourceAsStream(templatePath)))) { 169 | Template resourceTemplate = Mustache.compiler().escapeHTML(false).compile(resourcesTemplateReader); 170 | return resourceTemplate.execute(templateProperties); 171 | } 172 | } 173 | 174 | private void copyResource(String resourcePath, File toFile) throws IOException { 175 | try (InputStream resourcesStream = 176 | Objects.requireNonNull(this.getClass().getClassLoader().getResourceAsStream(resourcePath))) { 177 | Files.copy(resourcesStream, toFile.toPath(), StandardCopyOption.REPLACE_EXISTING); 178 | } 179 | } 180 | 181 | // Utils 182 | public static File mkdirs(File dir) { 183 | if (!dir.exists()) { 184 | dir.mkdirs(); 185 | } 186 | if (!dir.isDirectory()) { 187 | throw new IllegalStateException("Not a directory: " + dir); 188 | } 189 | return dir; 190 | } 191 | 192 | public static void copy(String content, File file) throws IOException { 193 | Files.copy(new ByteArrayInputStream(content.getBytes()), file.toPath(), StandardCopyOption.REPLACE_EXISTING); 194 | } 195 | 196 | public static String toPkg(String text) { 197 | return text.replace("-", "."); 198 | } 199 | 200 | public static String capitalize(String text) { 201 | return text.substring(0, 1).toUpperCase() + text.substring(1); 202 | } 203 | 204 | public static String camelCase(String text) { 205 | return Arrays.stream(text.split("-")).reduce("", (r, p) -> r + capitalize(p)); 206 | } 207 | 208 | public static File pkgToDir(File parent, String packageName) { 209 | String[] names = packageName.split("\\."); 210 | File result = parent; 211 | for (String p : names) { 212 | result = file(result, p); 213 | } 214 | return result; 215 | } 216 | 217 | public static File file(File parent, String child) { 218 | return new File(parent, child); 219 | } 220 | } 221 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/java/org/springframework/cloud/stream/app/plugin/generator/ProjectGeneratorProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.cloud.stream.app.plugin.generator; 17 | 18 | import java.io.File; 19 | import java.util.List; 20 | 21 | /** 22 | * @author Christian Tzolov 23 | */ 24 | public class ProjectGeneratorProperties { 25 | 26 | /** 27 | * Common pom versions 28 | */ 29 | private AppBom appBom; 30 | 31 | /** 32 | * Source, processor and sink application configuration 33 | */ 34 | private AppDefinition appDefinition; 35 | 36 | /** 37 | * Location where the project source files are written. 38 | */ 39 | private File outputFolder = new File("./target/output"); 40 | 41 | /** 42 | * List of binders to generate applications for. 43 | */ 44 | private List binders; 45 | 46 | /** 47 | * The location of a project's src/main/resources directory. 48 | */ 49 | private File projectResourcesDirectory; 50 | 51 | public File getOutputFolder() { 52 | return outputFolder; 53 | } 54 | 55 | public void setOutputFolder(File outputFolder) { 56 | this.outputFolder = outputFolder; 57 | } 58 | 59 | public AppBom getAppBom() { 60 | return appBom; 61 | } 62 | 63 | public void setAppBom(AppBom appBom) { 64 | this.appBom = appBom; 65 | } 66 | 67 | public AppDefinition getAppDefinition() { 68 | return appDefinition; 69 | } 70 | 71 | public void setAppDefinition(AppDefinition appDefinition) { 72 | this.appDefinition = appDefinition; 73 | } 74 | 75 | public List getBinders() { 76 | return binders; 77 | } 78 | 79 | public void setBinders(List binders) { 80 | this.binders = binders; 81 | } 82 | 83 | public File getProjectResourcesDirectory() { 84 | return projectResourcesDirectory; 85 | } 86 | 87 | public void setProjectResourcesDirectory(File projectResourcesDirectory) { 88 | this.projectResourcesDirectory = projectResourcesDirectory; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/resources/template/.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/resources/template/.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local -P spring 2 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/resources/template/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | https://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | import java.net.*; 21 | import java.io.*; 22 | import java.nio.channels.*; 23 | import java.util.Properties; 24 | 25 | public class MavenWrapperDownloader { 26 | 27 | /** 28 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 29 | */ 30 | private static final String DEFAULT_DOWNLOAD_URL = 31 | "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; 32 | 33 | /** 34 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 35 | * use instead of the default one. 36 | */ 37 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 38 | ".mvn/wrapper/maven-wrapper.properties"; 39 | 40 | /** 41 | * Path where the maven-wrapper.jar will be saved to. 42 | */ 43 | private static final String MAVEN_WRAPPER_JAR_PATH = 44 | ".mvn/wrapper/maven-wrapper.jar"; 45 | 46 | /** 47 | * Name of the property which should be used to override the default download url for the wrapper. 48 | */ 49 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 50 | 51 | public static void main(String args[]) { 52 | System.out.println("- Downloader started"); 53 | File baseDirectory = new File(args[0]); 54 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 55 | 56 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 57 | // wrapperUrl parameter. 58 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 59 | String url = DEFAULT_DOWNLOAD_URL; 60 | if(mavenWrapperPropertyFile.exists()) { 61 | FileInputStream mavenWrapperPropertyFileInputStream = null; 62 | try { 63 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 64 | Properties mavenWrapperProperties = new Properties(); 65 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 66 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 67 | } catch (IOException e) { 68 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 69 | } finally { 70 | try { 71 | if(mavenWrapperPropertyFileInputStream != null) { 72 | mavenWrapperPropertyFileInputStream.close(); 73 | } 74 | } catch (IOException e) { 75 | // Ignore ... 76 | } 77 | } 78 | } 79 | System.out.println("- Downloading from: : " + url); 80 | 81 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 82 | if(!outputFile.getParentFile().exists()) { 83 | if(!outputFile.getParentFile().mkdirs()) { 84 | System.out.println( 85 | "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 86 | } 87 | } 88 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 89 | try { 90 | downloadFileFromURL(url, outputFile); 91 | System.out.println("Done"); 92 | System.exit(0); 93 | } catch (Throwable e) { 94 | System.out.println("- Error downloading"); 95 | e.printStackTrace(); 96 | System.exit(1); 97 | } 98 | } 99 | 100 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 101 | URL website = new URL(urlString); 102 | ReadableByteChannel rbc; 103 | rbc = Channels.newChannel(website.openStream()); 104 | FileOutputStream fos = new FileOutputStream(destination); 105 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 106 | fos.close(); 107 | rbc.close(); 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/resources/template/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-attic/spring-cloud-app-starters-maven-plugins/7a06cdbcd2f47cf83c2ad1ccd8eeff285bbd56c6/spring-cloud-stream-app-maven-plugin/src/main/resources/template/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/resources/template/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/resources/template/App.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package {{app-package-name}}; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | import org.springframework.context.annotation.Import; 22 | 23 | 24 | @SpringBootApplication 25 | @Import({ {{app.configClass}} }) 26 | public class {{app-class-name}} { 27 | 28 | public static void main(String[] args) { 29 | SpringApplication.run({{app-class-name}}.class, args); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/resources/template/AppTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package {{app-package-name}}; 18 | 19 | import org.junit.Test; 20 | import org.junit.runner.RunWith; 21 | import org.springframework.boot.test.context.SpringBootTest; 22 | import org.springframework.test.context.junit4.SpringRunner; 23 | 24 | @RunWith(SpringRunner.class) 25 | @SpringBootTest 26 | public class {{app-class-name}}Tests { 27 | 28 | @Test 29 | public void contextLoads() { 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/resources/template/README.adoc: -------------------------------------------------------------------------------- 1 | = Spring Cloud Stream {{#camelCase}}{{app.name}}{{/camelCase}} {{#capitalize}}{{app.type}}{{/capitalize}} {{#capitalize}}{{app-binder}}{{/capitalize}} Binder Application 2 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/resources/template/app-pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | {{bom.springBootVersion}} 10 | 11 | 12 | org.springframework.cloud.stream.app 13 | {{app.name}}-{{app.type}}-{{app-binder}} 14 | {{app.version}} 15 | {{app.name}}-{{app.type}}-{{app-binder}} 16 | Spring Cloud Stream {{#camelCase}}{{app.name}}{{/camelCase}} {{#capitalize}}{{app.type}}{{/capitalize}} {{#capitalize}}{{app-binder}}{{/capitalize}} Binder Application 17 | 18 | 19 | 20 | 21 | repo.spring.io 22 | Spring Release Repository 23 | https://repo.spring.io/libs-release-local 24 | 25 | 26 | repo.spring.io 27 | Spring Snapshot Repository 28 | https://repo.spring.io/libs-snapshot-local 29 | 30 | 31 | 32 | 33 | true 34 | UTF-8 35 | 36 | 37 | 38 | 39 | 40 | {{#app.mavenManagedDependencies}} 41 | {{this}} 42 | {{/app.mavenManagedDependencies}} 43 | 44 | 45 | 46 | 47 | 48 | 49 | {{#app.mavenDependencies}} 50 | {{this}} 51 | {{/app.mavenDependencies}} 52 | 53 | 54 | org.springframework.cloud 55 | spring-cloud-stream-binder-{{app-binder}} 56 | 57 | 58 | org.springframework.cloud.stream.app 59 | stream-applications-postprocessor-common 60 | ${project.version} 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-starter-test 65 | test 66 | 67 | 68 | 69 | 70 | 71 | 72 | true 73 | 74 | spring-snapshots 75 | Spring Snapshots 76 | https://repo.spring.io/snapshot 77 | 78 | 79 | 80 | false 81 | 82 | spring-milestones 83 | Spring Milestones 84 | https://repo.spring.io/milestone 85 | 86 | 87 | 88 | 89 | 90 | true 91 | 92 | spring-snapshots 93 | Spring Snapshots 94 | https://repo.spring.io/snapshot 95 | 96 | 97 | 98 | false 99 | 100 | spring-milestones 101 | Spring Milestones 102 | https://repo.spring.io/milestone 103 | 104 | 105 | 106 | 107 | 108 | {{#app.mavenPlugins}} 109 | {{this}} 110 | {{/app.mavenPlugins}} 111 | 112 | 113 | org.springframework.boot 114 | spring-boot-maven-plugin 115 | 116 | 117 | 118 | com.google.cloud.tools 119 | jib-maven-plugin 120 | 2.6.0 121 | 122 | 123 | springcloud/openjdk 124 | 125 | 126 | {{app.containerImageOrgName}}/${project.artifactId} 127 | 128 | {{app.containerImageTag}} 129 | 130 | 131 | 132 | USE_CURRENT_TIMESTAMP 133 | {{app.containerImageFormat}} 134 | {{#app.enableContainerImageMetadata}} 135 | 136 | 137 | ${org.springframework.cloud.dataflow.spring.configuration.metadata.json} 138 | 139 | 140 | {{/app.enableContainerImageMetadata}} 141 | 142 | 143 | 144 | 145 | {{#app.enableContainerImageMetadata}} 146 | 150 | 151 | org.codehaus.mojo 152 | properties-maven-plugin 153 | 1.0.0 154 | 155 | 156 | process-classes 157 | 158 | read-project-properties 159 | 160 | 161 | 162 | 163 | ${project.build.outputDirectory}/META-INF/spring-configuration-metadata-encoded.properties 164 | 165 | 166 | 167 | 168 | 169 | 170 | {{/app.enableContainerImageMetadata}} 171 | 172 | 173 | org.springframework.cloud 174 | spring-cloud-app-starter-metadata-maven-plugin 175 | {{bom.appMetadataMavenPluginVersion}} 176 | 177 | {{#app.enableContainerImageMetadata}} 178 | true 179 | 180 | 181 | {{#app.metadataNameFilters}} 182 | {{this}} 183 | {{/app.metadataNameFilters}} 184 | 185 | 186 | {{#app.metadataSourceTypeFilters}} 187 | {{this}} 188 | {{/app.metadataSourceTypeFilters}} 189 | 190 | 191 | {{/app.enableContainerImageMetadata}} 192 | 193 | 194 | 195 | aggregate-metadata 196 | compile 197 | 198 | aggregate-metadata 199 | 200 | 201 | 202 | 203 | 204 | maven-surefire-plugin 205 | 2.21.0 206 | 207 | ${skipTests} 208 | 209 | 210 | 211 | maven-javadoc-plugin 212 | 213 | 214 | javadoc 215 | package 216 | 217 | jar 218 | 219 | 220 | 221 | 222 | true 223 | 224 | 225 | 226 | maven-source-plugin 227 | 228 | 229 | attach-sources 230 | package 231 | 232 | jar 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | milestone 242 | 243 | 244 | repo.spring.io 245 | Spring Milestone Repository 246 | https://repo.spring.io/libs-milestone-local 247 | 248 | 249 | 250 | 251 | central 252 | 253 | 254 | 255 | maven-gpg-plugin 256 | 257 | 258 | sign-artifacts 259 | verify 260 | 261 | sign 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | sonatype-nexus-staging 271 | Nexus Release Repository 272 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 273 | 274 | 275 | sonatype-nexus-snapshots 276 | Sonatype Nexus Snapshots 277 | https://oss.sonatype.org/content/repositories/snapshots/ 278 | 279 | 280 | 281 | 282 | 283 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/resources/template/app.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=${vcap.application.name:{{app.name}}-{{app.type}}} 2 | info.app.name=@project.artifactId@ 3 | info.app.description=@project.description@ 4 | info.app.version=@project.version@ 5 | management.endpoints.web.exposure.include=health,info,bindings 6 | 7 | spring.cloud.stream.function.definition={{app.functionDefinition}} 8 | 9 | {{#app.consumer}} 10 | spring.cloud.stream.function.bindings.{{app.functionDefinition}}-in-0=input 11 | {{/app.consumer}} 12 | 13 | {{#app.supplier}} 14 | spring.cloud.stream.function.bindings.{{app.functionDefinition}}-out-0=output 15 | {{/app.supplier}} 16 | 17 | {{#app.function}} 18 | spring.cloud.stream.function.bindings.{{app.functionDefinition}}-in-0=input 19 | spring.cloud.stream.function.bindings.{{app.functionDefinition}}-out-0=output 20 | {{/app.function}} 21 | 22 | {{#app.additionalProperties}} 23 | {{this}} 24 | {{/app.additionalProperties}} 25 | 26 | 27 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/resources/template/apps-container-pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 4.0.0 6 | org.springframework.cloud.stream.app 7 | {{app.name}}-{{app.type}}-apps 8 | {{app.version}} 9 | pom 10 | 11 | Apps Container 12 | Container project for generated apps 13 | http://spring.io/spring-cloud 14 | 15 | 16 | Apache License, Version 2.0 17 | http://www.apache.org/licenses/LICENSE-2.0 18 | Copyright 2014-2020 the original author or authors. 19 | 20 | Licensed under the Apache License, Version 2.0 (the "License"); 21 | you may not use this file except in compliance with the License. 22 | You may obtain a copy of the License at 23 | 24 | http://www.apache.org/licenses/LICENSE-2.0 25 | 26 | Unless required by applicable law or agreed to in writing, software 27 | distributed under the License is distributed on an "AS IS" BASIS, 28 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 29 | implied. 30 | 31 | See the License for the specific language governing permissions and 32 | limitations under the License. 33 | 34 | 35 | 36 | 37 | schacko 38 | Soby Chacko 39 | schacko at pivotal.io 40 | Pivotal Software, Inc. 41 | http://www.spring.io 42 | 43 | developer 44 | 45 | 46 | 47 | tzolov 48 | Christian Tzolov 49 | ctzolov at pivotal.io 50 | Pivotal Software, Inc. 51 | http://www.spring.io 52 | 53 | developer 54 | 55 | 56 | 57 | 58 | 59 | {{#binders}} 60 | {{app.name}}-{{app.type}}-{{this}} 61 | {{/binders}} 62 | 63 | 64 | 65 | scm:git:git://github.com/spring-cloud/spring-cloud-stream-app-starters.git 66 | scm:git:ssh://git@github.com/spring-cloud/spring-cloud-stream-app-starters.git 67 | https://github.com/spring-cloud/spring-cloud-stream-app-starters 68 | 69 | 70 | 71 | repo.spring.io 72 | Spring Release Repository 73 | https://repo.spring.io/libs-release-local 74 | 75 | 76 | repo.spring.io 77 | Spring Snapshot Repository 78 | https://repo.spring.io/libs-snapshot-local 79 | 80 | 81 | 82 | 83 | 84 | com.google.cloud.tools 85 | jib-maven-plugin 86 | 2.6.0 87 | 88 | 89 | 90 | 91 | 92 | milestone 93 | 94 | 95 | repo.spring.io 96 | Spring Milestone Repository 97 | https://repo.spring.io/libs-milestone-local 98 | 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/resources/template/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 | # https://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 | # 58 | # Look for the Apple JDKs first to preserve the existing behaviour, and then look 59 | # for the new JDKs provided by Oracle. 60 | # 61 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then 62 | # 63 | # Apple JDKs 64 | # 65 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home 66 | fi 67 | 68 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then 69 | # 70 | # Apple JDKs 71 | # 72 | export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 73 | fi 74 | 75 | if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then 76 | # 77 | # Oracle JDKs 78 | # 79 | export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 80 | fi 81 | 82 | if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then 83 | # 84 | # Apple JDKs 85 | # 86 | export JAVA_HOME=`/usr/libexec/java_home` 87 | fi 88 | ;; 89 | esac 90 | 91 | if [ -z "$JAVA_HOME" ] ; then 92 | if [ -r /etc/gentoo-release ] ; then 93 | JAVA_HOME=`java-config --jre-home` 94 | fi 95 | fi 96 | 97 | if [ -z "$M2_HOME" ] ; then 98 | ## resolve links - $0 may be a link to maven's home 99 | PRG="$0" 100 | 101 | # need this for relative symlinks 102 | while [ -h "$PRG" ] ; do 103 | ls=`ls -ld "$PRG"` 104 | link=`expr "$ls" : '.*-> \(.*\)$'` 105 | if expr "$link" : '/.*' > /dev/null; then 106 | PRG="$link" 107 | else 108 | PRG="`dirname "$PRG"`/$link" 109 | fi 110 | done 111 | 112 | saveddir=`pwd` 113 | 114 | M2_HOME=`dirname "$PRG"`/.. 115 | 116 | # make it fully qualified 117 | M2_HOME=`cd "$M2_HOME" && pwd` 118 | 119 | cd "$saveddir" 120 | # echo Using m2 at $M2_HOME 121 | fi 122 | 123 | # For Cygwin, ensure paths are in UNIX format before anything is touched 124 | if $cygwin ; then 125 | [ -n "$M2_HOME" ] && 126 | M2_HOME=`cygpath --unix "$M2_HOME"` 127 | [ -n "$JAVA_HOME" ] && 128 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 129 | [ -n "$CLASSPATH" ] && 130 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 131 | fi 132 | 133 | # For Migwn, ensure paths are in UNIX format before anything is touched 134 | if $mingw ; then 135 | [ -n "$M2_HOME" ] && 136 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 137 | [ -n "$JAVA_HOME" ] && 138 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 139 | # TODO classpath? 140 | fi 141 | 142 | if [ -z "$JAVA_HOME" ]; then 143 | javaExecutable="`which javac`" 144 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 145 | # readlink(1) is not available as standard on Solaris 10. 146 | readLink=`which readlink` 147 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 148 | if $darwin ; then 149 | javaHome="`dirname \"$javaExecutable\"`" 150 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 151 | else 152 | javaExecutable="`readlink -f \"$javaExecutable\"`" 153 | fi 154 | javaHome="`dirname \"$javaExecutable\"`" 155 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 156 | JAVA_HOME="$javaHome" 157 | export JAVA_HOME 158 | fi 159 | fi 160 | fi 161 | 162 | if [ -z "$JAVACMD" ] ; then 163 | if [ -n "$JAVA_HOME" ] ; then 164 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 165 | # IBM's JDK on AIX uses strange locations for the executables 166 | JAVACMD="$JAVA_HOME/jre/sh/java" 167 | else 168 | JAVACMD="$JAVA_HOME/bin/java" 169 | fi 170 | else 171 | JAVACMD="`which java`" 172 | fi 173 | fi 174 | 175 | if [ ! -x "$JAVACMD" ] ; then 176 | echo "Error: JAVA_HOME is not defined correctly." >&2 177 | echo " We cannot execute $JAVACMD" >&2 178 | exit 1 179 | fi 180 | 181 | if [ -z "$JAVA_HOME" ] ; then 182 | echo "Warning: JAVA_HOME environment variable is not set." 183 | fi 184 | 185 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 186 | 187 | # For Cygwin, switch paths to Windows format before running java 188 | if $cygwin; then 189 | [ -n "$M2_HOME" ] && 190 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 191 | [ -n "$JAVA_HOME" ] && 192 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 193 | [ -n "$CLASSPATH" ] && 194 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 195 | fi 196 | 197 | # traverses directory structure from process work directory to filesystem root 198 | # first directory with .mvn subdirectory is considered project base directory 199 | find_maven_basedir() { 200 | local basedir=$(pwd) 201 | local wdir=$(pwd) 202 | while [ "$wdir" != '/' ] ; do 203 | if [ -d "$wdir"/.mvn ] ; then 204 | basedir=$wdir 205 | break 206 | fi 207 | wdir=$(cd "$wdir/.."; pwd) 208 | done 209 | echo "${basedir}" 210 | } 211 | 212 | # concatenates all lines of a file 213 | concat_lines() { 214 | if [ -f "$1" ]; then 215 | echo "$(tr -s '\n' ' ' < "$1")" 216 | fi 217 | } 218 | 219 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} 220 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 221 | 222 | # Provide a "standardized" way to retrieve the CLI args that will 223 | # work with both Windows and non-Windows executions. 224 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 225 | export MAVEN_CMD_LINE_ARGS 226 | 227 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 228 | 229 | echo "Running version check" 230 | VERSION=$( sed '\!//' -e 's!.*$!!' ) 231 | echo "The found version is [${VERSION}]" 232 | 233 | if echo $VERSION | egrep -q 'M|RC'; then 234 | echo Activating \"milestone\" profile for version=\"$VERSION\" 235 | echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pmilestone" 236 | else 237 | echo Deactivating \"milestone\" profile for version=\"$VERSION\" 238 | echo $MAVEN_ARGS | grep -q milestone && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pmilestone//') 239 | fi 240 | 241 | if echo $VERSION | egrep -q 'RELEASE'; then 242 | echo Activating \"central\" profile for version=\"$VERSION\" 243 | echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pcentral" 244 | else 245 | echo Deactivating \"central\" profile for version=\"$VERSION\" 246 | echo $MAVEN_ARGS | grep -q central && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pcentral//') 247 | fi 248 | 249 | exec "$JAVACMD" \ 250 | $MAVEN_OPTS \ 251 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 252 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 253 | ${WRAPPER_LAUNCHER} ${MAVEN_ARGS} "$@" 254 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/resources/template/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 https://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 enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | set MAVEN_CMD_LINE_ARGS=%* 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="".\.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_CMD_LINE_ARGS% 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 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/main/resources/templates/assembly.xml: -------------------------------------------------------------------------------- 1 | 5 | ${artifactId} 6 | 7 | 8 | 9 | ${groupId}:${artifactId} 10 | 11 | . 12 | ${artifactId}.jar 13 | 14 | 15 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/test/java/org/springframework/cloud/stream/app/plugin/MojoHarnessTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.stream.app.plugin; 18 | 19 | import java.io.File; 20 | import java.io.FileInputStream; 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | import java.util.List; 24 | 25 | import org.apache.maven.model.Dependency; 26 | import org.apache.maven.model.Model; 27 | import org.apache.maven.model.Parent; 28 | import org.apache.maven.model.Plugin; 29 | import org.apache.maven.model.io.xpp3.MavenXpp3Reader; 30 | import org.apache.maven.plugin.testing.MojoRule; 31 | import org.codehaus.plexus.util.xml.pull.XmlPullParserException; 32 | import org.junit.Rule; 33 | import org.junit.Test; 34 | import org.junit.rules.TemporaryFolder; 35 | 36 | import static org.assertj.core.api.Assertions.assertThat; 37 | 38 | 39 | /** 40 | * @author Christian Tzolov 41 | */ 42 | public class MojoHarnessTest { 43 | 44 | @Rule 45 | public TemporaryFolder projectHome = new TemporaryFolder(); 46 | 47 | @Rule 48 | public MojoRule mojoRule = new MojoRule(); 49 | 50 | @Test 51 | public void testSomething() throws Exception { 52 | 53 | File pomRoot = new File("src/test/resources/unit/http-source-apps/"); 54 | 55 | SpringCloudStreamAppGeneratorMojo myMojo = (SpringCloudStreamAppGeneratorMojo) 56 | mojoRule.lookupConfiguredMojo(pomRoot, "generate-app"); 57 | 58 | assertThat(myMojo).isNotNull(); 59 | 60 | myMojo.execute(); 61 | 62 | assertThat(new File("./target/apps/http-source-kafka/src/main/resources/test.txt")).exists(); 63 | 64 | Model pomModel = getModel(new File("./target/apps")); 65 | 66 | List dependencies = pomModel.getDependencies(); 67 | assertThat(dependencies.size()).isEqualTo(15); 68 | 69 | assertThat(dependencies.stream() 70 | .filter(d -> d.getArtifactId().equals("http-supplier")).count()).isEqualTo(1); 71 | 72 | assertThat(dependencies.stream() 73 | .filter(d -> d.getArtifactId().equals("stream-applications-postprocessor-common")).count()).isEqualTo(1); 74 | 75 | assertThat(dependencies.stream() 76 | .filter(d -> d.getArtifactId().equals("spring-cloud-stream-binder-kafka")).count()).isEqualTo(1); 77 | 78 | Parent parent = pomModel.getParent(); 79 | assertThat(parent.getArtifactId()).isEqualTo("spring-boot-starter-parent"); 80 | assertThat(parent.getVersion()).isEqualTo("2.3.0.M1"); 81 | 82 | assertThat(pomModel.getArtifactId()).isEqualTo("http-source-kafka"); 83 | assertThat(pomModel.getGroupId()).isEqualTo("org.springframework.cloud.stream.app"); 84 | assertThat(pomModel.getName()).isEqualTo("http-source-kafka"); 85 | assertThat(pomModel.getVersion()).isEqualTo("3.0.0.BUILD-SNAPSHOT"); 86 | assertThat(pomModel.getDescription()).isEqualTo("Spring Cloud Stream Http Source Kafka Binder Application"); 87 | 88 | List plugins = pomModel.getBuild().getPlugins(); 89 | 90 | assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("spring-boot-maven-plugin")).count()).isEqualTo(1); 91 | assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("properties-maven-plugin")).count()).isEqualTo(1); 92 | assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("jib-maven-plugin")).count()).isEqualTo(1); 93 | 94 | Plugin jibPlugin = plugins.stream().filter(p -> p.getArtifactId().equals("jib-maven-plugin")).findFirst().get(); 95 | assertThat(jibPlugin.getConfiguration().toString()) 96 | .contains("" + 97 | "${org.springframework.cloud.dataflow.spring.configuration.metadata.json}" + 98 | ""); 99 | assertThat(jibPlugin.getConfiguration().toString()).contains("testspringcloud/${project.artifactId}"); 100 | assertThat(jibPlugin.getConfiguration().toString()).contains("3.0.0.BUILD-SNAPSHOT"); 101 | 102 | assertThat(pomModel.getRepositories().size()).isEqualTo(2); 103 | } 104 | 105 | private Model getModel(File rootPath) { 106 | File pomXml = new File(new File(rootPath, "http-source-kafka"), "pom.xml"); 107 | try (InputStream is = new FileInputStream(pomXml)) { 108 | return new MavenXpp3Reader().read(is); 109 | } 110 | catch (IOException | XmlPullParserException e) { 111 | throw new IllegalStateException(e); 112 | } 113 | } 114 | } 115 | 116 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/test/java/org/springframework/cloud/stream/app/plugin/SpringCloudStreamAppGeneratorMojoTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.stream.app.plugin; 18 | 19 | import java.io.File; 20 | import java.io.FileInputStream; 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | import java.lang.reflect.Field; 24 | import java.util.Arrays; 25 | import java.util.List; 26 | 27 | import org.apache.maven.model.Dependency; 28 | import org.apache.maven.model.Model; 29 | import org.apache.maven.model.Parent; 30 | import org.apache.maven.model.Plugin; 31 | import org.apache.maven.model.io.xpp3.MavenXpp3Reader; 32 | import org.codehaus.plexus.util.xml.pull.XmlPullParserException; 33 | import org.junit.Before; 34 | import org.junit.Rule; 35 | import org.junit.Test; 36 | import org.junit.rules.TemporaryFolder; 37 | 38 | import org.springframework.cloud.stream.app.plugin.generator.AppDefinition; 39 | import org.springframework.util.ReflectionUtils; 40 | 41 | import static org.assertj.core.api.Assertions.assertThat; 42 | 43 | 44 | /** 45 | * @author Christian Tzolov 46 | */ 47 | public class SpringCloudStreamAppGeneratorMojoTest { 48 | 49 | @Rule 50 | public TemporaryFolder projectHome = new TemporaryFolder(); 51 | 52 | private SpringCloudStreamAppGeneratorMojo springCloudStreamAppMojo = new SpringCloudStreamAppGeneratorMojo(); 53 | 54 | private Class mojoClazz = springCloudStreamAppMojo.getClass(); 55 | 56 | @Before 57 | public void before() throws NoSuchFieldException { 58 | 59 | SpringCloudStreamAppGeneratorMojo.ContainerImage containerImage = new SpringCloudStreamAppGeneratorMojo.ContainerImage(); 60 | containerImage.setFormat(AppDefinition.ContainerImageFormat.Docker); 61 | 62 | setMojoProperty("containerImage", containerImage); 63 | 64 | SpringCloudStreamAppGeneratorMojo.GeneratedApp generatedApp = new SpringCloudStreamAppGeneratorMojo.GeneratedApp(); 65 | generatedApp.setName("log"); 66 | generatedApp.setType(AppDefinition.AppType.sink); 67 | generatedApp.setVersion("3.0.0.BUILD-SNAPSHOT"); 68 | generatedApp.setConfigClass("io.pivotal.java.function.log.consumer.LogConsumerConfiguration.class"); 69 | 70 | setMojoProperty("generatedApp", generatedApp); 71 | 72 | setMojoProperty("metadataSourceTypeFilters", Arrays.asList("io.pivotal.java.function.log.consumer.LogConsumerProperties")); 73 | setMojoProperty("metadataNameFilters", Arrays.asList("server.port")); 74 | 75 | setMojoProperty("additionalAppProperties", Arrays.asList( 76 | "spring.cloud.streamapp.security.enabled=false", 77 | "spring.cloud.streamapp.security.csrf-enabled=false")); 78 | 79 | Dependency dep = new Dependency(); 80 | dep.setGroupId("io.pivotal.java.function"); 81 | dep.setArtifactId("log-consumer"); 82 | dep.setVersion("1.0.0.BUILD-SNAPSHOT"); 83 | setMojoProperty("dependencies", Arrays.asList(dep)); 84 | 85 | 86 | setMojoProperty("binders", Arrays.asList("kafka", "rabbit")); 87 | 88 | // BOM 89 | setMojoProperty("bootVersion", "2.3.0.M1"); 90 | setMojoProperty("appMetadataMavenPluginVersion", "1.0.2.BUILD-SNAPSHOT"); 91 | 92 | //setMojoProperty("generatedProjectHome", "./target/apps"); 93 | setMojoProperty("generatedProjectHome", projectHome.getRoot().getAbsolutePath()); 94 | } 95 | 96 | @Test 97 | public void testWithDisabledContainerMetadata() throws Exception { 98 | 99 | // disable metadata in container image (Default) 100 | SpringCloudStreamAppGeneratorMojo.ContainerImage containerImage = new SpringCloudStreamAppGeneratorMojo.ContainerImage(); 101 | containerImage.setEnableMetadata(false); 102 | setMojoProperty("containerImage", containerImage); 103 | 104 | this.springCloudStreamAppMojo.execute(); 105 | 106 | //Model pomModel = getModel(new File("./target/apps")); 107 | Model pomModel = getModel(new File(projectHome.getRoot().getAbsolutePath())); 108 | List plugins = pomModel.getBuild().getPlugins(); 109 | 110 | // The properties-maven-plugin should not be defined if the container metadata is not enabled. 111 | assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("properties-maven-plugin")).count()).isEqualTo(0); 112 | 113 | assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("jib-maven-plugin")).count()).isEqualTo(1); 114 | 115 | Plugin jibPlugin = plugins.stream().filter(p -> p.getArtifactId().equals("jib-maven-plugin")).findFirst().get(); 116 | assertThat(jibPlugin.getConfiguration().toString()) 117 | .doesNotContain("" + 118 | "${org.springframework.cloud.dataflow.spring.configuration.metadata.json}" + 119 | ""); 120 | } 121 | 122 | @Test 123 | public void testDefaultProjectCreationByPlugin() throws Exception { 124 | 125 | // Enable Metadata in Container Image! 126 | SpringCloudStreamAppGeneratorMojo.ContainerImage containerImage = new SpringCloudStreamAppGeneratorMojo.ContainerImage(); 127 | containerImage.setEnableMetadata(true); 128 | setMojoProperty("containerImage", containerImage); 129 | 130 | this.springCloudStreamAppMojo.execute(); 131 | 132 | //assertGeneratedPomXml(new File("./target/apps")); 133 | assertGeneratedPomXml(new File(projectHome.getRoot().getAbsolutePath())); 134 | } 135 | 136 | private void assertGeneratedPomXml(File rootPath) throws Exception { 137 | 138 | Model pomModel = getModel(rootPath); 139 | 140 | List dependencies = pomModel.getDependencies(); 141 | assertThat(dependencies.size()).isEqualTo(4); 142 | 143 | assertThat(dependencies.stream() 144 | .filter(d -> d.getArtifactId().equals("log-consumer")).count()).isEqualTo(1); 145 | 146 | assertThat(dependencies.stream() 147 | .filter(d -> d.getArtifactId().equals("spring-cloud-stream-binder-kafka")).count()).isEqualTo(1); 148 | 149 | assertThat(dependencies.stream() 150 | .filter(d -> d.getArtifactId().equals("stream-applications-postprocessor-common")).count()).isEqualTo(1); 151 | 152 | Parent parent = pomModel.getParent(); 153 | assertThat(parent.getArtifactId()).isEqualTo("spring-boot-starter-parent"); 154 | assertThat(parent.getVersion()).isEqualTo("2.3.0.M1"); 155 | 156 | assertThat(pomModel.getArtifactId()).isEqualTo("log-sink-kafka"); 157 | assertThat(pomModel.getGroupId()).isEqualTo("org.springframework.cloud.stream.app"); 158 | assertThat(pomModel.getName()).isEqualTo("log-sink-kafka"); 159 | assertThat(pomModel.getVersion()).isEqualTo("3.0.0.BUILD-SNAPSHOT"); 160 | assertThat(pomModel.getDescription()).isEqualTo("Spring Cloud Stream Log Sink Kafka Binder Application"); 161 | 162 | List plugins = pomModel.getBuild().getPlugins(); 163 | assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("spring-boot-maven-plugin")).count()).isEqualTo(1); 164 | assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("properties-maven-plugin")).count()).isEqualTo(1); 165 | assertThat(plugins.stream().filter(p -> p.getArtifactId().equals("jib-maven-plugin")).count()).isEqualTo(1); 166 | 167 | Plugin jibPlugin = plugins.stream().filter(p -> p.getArtifactId().equals("jib-maven-plugin")).findFirst().get(); 168 | assertThat(jibPlugin.getConfiguration().toString()) 169 | .contains("" + 170 | "${org.springframework.cloud.dataflow.spring.configuration.metadata.json}" + 171 | ""); 172 | 173 | assertThat(pomModel.getRepositories().size()).isEqualTo(2); 174 | } 175 | 176 | private Model getModel(File rootPath) { 177 | File pomXml = new File(new File(rootPath, "log-sink-kafka"), "pom.xml"); 178 | try (InputStream is = new FileInputStream(pomXml)) { 179 | return new MavenXpp3Reader().read(is); 180 | } 181 | catch (IOException | XmlPullParserException e) { 182 | throw new IllegalStateException(e); 183 | } 184 | } 185 | 186 | private void setMojoProperty(String propertyName, Object value) throws NoSuchFieldException { 187 | Field mojoProperty = this.mojoClazz.getDeclaredField(propertyName); 188 | mojoProperty.setAccessible(true); 189 | ReflectionUtils.setField(mojoProperty, this.springCloudStreamAppMojo, value); 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/test/resources/unit/http-source-apps/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.cloud.stream.app 7 | http-source-apps 8 | 3.0.0.BUILD-SNAPSHOT 9 | http-source-apps 10 | http source apps 11 | jar 12 | 13 | 14 | 2.3.0.M1 15 | 3.0.0.BUILD-SNAPSHOT 16 | 2.1.1.RELEASE 17 | 1.0.2.BUILD-SNAPSHOT 18 | 19 | 20 | 1.0.0.BUILD-SNAPSHOT 21 | Hoxton.RELEASE 22 | Horsham.SR2 23 | 3.0.2.RELEASE 24 | 25 | 26 | 27 | 28 | 29 | 30 | org.springframework.cloud.stream.app.plugin 31 | spring-cloud-stream-app-maven-plugin 32 | 2.0.0.BUILD-SNAPSHOT 33 | 34 | 35 | app-gen 36 | package 37 | 38 | generate-app 39 | 40 | 41 | 42 | 43 | 44 | 45 | ${spring-boot.version} 46 | 47 | 48 | kafka 49 | rabbit 50 | 51 | 52 | 53 | org.springframework.cloud 54 | spring-cloud-stream-dependencies 55 | ${spring-cloud-stream-dependencies.version} 56 | 57 | 58 | org.springframework.cloud 59 | spring-cloud-function-dependencies 60 | ${spring-cloud-function-dependencies.version} 61 | 62 | 63 | org.springframework.cloud 64 | spring-cloud-dependencies 65 | ${spring-cloud-dependencies.version} 66 | 67 | 68 | 69 | 70 | 71 | org.springframework.cloud.stream.app 72 | stream-apps-security-common 73 | ${stream-apps-core.version} 74 | 75 | 76 | org.springframework.cloud.stream.app 77 | stream-apps-micrometer-common 78 | ${stream-apps-core.version} 79 | 80 | 81 | io.micrometer 82 | micrometer-registry-influx 83 | 84 | 85 | io.micrometer 86 | micrometer-registry-prometheus 87 | 88 | 89 | io.micrometer 90 | micrometer-registry-datadog 91 | 92 | 93 | io.pivotal.cfenv 94 | java-cfenv-boot 95 | ${java-cfenv-boot.version} 96 | 97 | 98 | org.springframework.boot 99 | spring-boot-configuration-processor 100 | 101 | 102 | org.springframework.boot 103 | spring-boot-starter-actuator 104 | 105 | 106 | org.springframework.boot 107 | spring-boot-starter-web 108 | 109 | 110 | org.springframework.boot 111 | spring-boot-starter-logging 112 | 113 | 114 | org.springframework.boot 115 | spring-boot-starter-security 116 | 117 | 118 | 119 | 120 | org.logaritex 121 | test-additional-maven-plugin 122 | 3.0.0 123 | 124 | 126 | springcloud/openjdk 127 | 128 | 129 | springcloudstream:${project.artifactId} 130 | 131 | latest 132 | 133 | 134 | 135 | USE_CURRENT_TIMESTAMP 136 | Docker 137 | 138 | ${org.springframework.cloud.dataflow.spring.configuration.metadata.json} 139 | 140 | 141 | ]]> 142 | 143 | 144 | 145 | sign-artifacts 146 | verify 147 | 148 | sign 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | org.springframework.cloud.stream.app.plugin 162 | spring-cloud-stream-app-maven-plugin 163 | 2.0.0.BUILD-SNAPSHOT 164 | 165 | 166 | ./target/apps 167 | 168 | 169 | testspringcloud 170 | true 171 | 172 | 173 | 174 | http 175 | source 176 | ${project.version} 177 | io.pivotal.java.function.http.supplier.HttpSupplierConfiguration.class 178 | 179 | 180 | 181 | 182 | io.pivotal.java.function 183 | http-supplier 184 | ${java-functions.version} 185 | 186 | 187 | 188 | 189 | spring.main.web-application-type=reactive 190 | spring.cloud.streamapp.security.enabled=false 191 | spring.cloud.streamapp.security.csrf-enabled=false 192 | 193 | 194 | 195 | io.pivotal.java.function.http.supplier.HttpSourceProperties 196 | io.pivotal.java.function.http.supplier.HttpSourceProperties$Cors 197 | 198 | 199 | 200 | server.port 201 | 202 | 203 | 204 | 205 | 206 | org.springframework.cloud 207 | spring-cloud-app-starter-metadata-maven-plugin 208 | 2.0.0.BUILD-SNAPSHOT 209 | 210 | true 211 | 212 | 213 | 214 | server.port 215 | 216 | 217 | io.pivotal.java.function.http.supplier.HttpSourceProperties 218 | io.pivotal.java.function.http.supplier.HttpSourceProperties$Cors 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | -------------------------------------------------------------------------------- /spring-cloud-stream-app-maven-plugin/src/test/resources/unit/http-source-apps/src/main/resources/test.txt: -------------------------------------------------------------------------------- 1 | test 2 | --------------------------------------------------------------------------------