├── .circleci
└── config.yml
├── .github
└── workflows
│ ├── tagged-linux.yml
│ ├── tagged-macos.yml
│ └── tagged-windows.yml
├── .gitignore
├── .mvn
├── extensions.xml
├── jgitver.config.xml
└── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── .sdkmanrc
├── LICENSE
├── README.md
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
├── main
├── java
│ └── dev
│ │ └── dashaun
│ │ └── shell
│ │ └── initializr
│ │ └── plusplus
│ │ ├── Application.java
│ │ ├── ApplicationConfigCommands.java
│ │ ├── CloudFunctionExample.java
│ │ ├── MavenExtensionCommands.java
│ │ ├── PipelineCommands.java
│ │ ├── PomFileCommands.java
│ │ ├── ReadMeCommands.java
│ │ └── models
│ │ ├── Dependencies.java
│ │ ├── Plugins.java
│ │ ├── Profiles.java
│ │ ├── Properties.java
│ │ └── Repositories.java
└── resources
│ └── application.yml
└── test
└── java
└── dev
└── dashaun
└── shell
└── initializr
└── plusplus
└── ApplicationTests.java
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2.1
2 |
3 | orbs:
4 | gh: circleci/github-cli@2.2.0
5 | sdkman: joshdholtz/sdkman@0.2.0
6 |
7 | jobs:
8 | create-gh-release:
9 | machine:
10 | image: ubuntu-2004:current
11 | resource_class: medium
12 | steps:
13 | - checkout
14 | - gh/setup
15 | - run:
16 | name: "upload release asset"
17 | command: gh release create "${CIRCLE_TAG}" -t "${CIRCLE_TAG}" -n "${CIRCLE_TAG}"
18 | arm64-native:
19 | machine:
20 | image: ubuntu-2004:current
21 | resource_class: arm.medium
22 | steps:
23 | - checkout
24 | - sdkman/setup-sdkman
25 | - sdkman/sdkman-install:
26 | candidate: java
27 | version: 22.3.1.r17-grl
28 | - run:
29 | name: "native compile"
30 | command: "./mvnw -Pnative clean native:compile"
31 | - gh/setup
32 | - run:
33 | name: "upload release asset"
34 | command: gh release upload "${CIRCLE_TAG}" ./target/initializr-plusplus-linux-aarch_64
35 | macos-arm64-native:
36 | docker:
37 | - image: cimg/base:current
38 | resource_class: dashaun/juice-v2
39 | steps:
40 | - checkout
41 | - sdkman/setup-sdkman
42 | - sdkman/sdkman-install:
43 | candidate: java
44 | version: 22.3.1.r17-grl
45 | - run:
46 | name: "native compile"
47 | command: "sdk env && ./mvnw -Pnative clean native:compile -DskipTests"
48 | - run:
49 | name: "upload release asset"
50 | command: gh release upload "${CIRCLE_TAG}" ./target/initializr-plusplus-osx-aarch_64
51 | workflows:
52 | create-gh-release:
53 | jobs:
54 | - create-gh-release:
55 | context:
56 | - dashaun-github
57 | filters:
58 | tags:
59 | only: /^v.*/
60 | branches:
61 | ignore: /.*/
62 | arm64-native-workflow:
63 | jobs:
64 | - arm64-native:
65 | context:
66 | - dashaun-github
67 | filters:
68 | tags:
69 | only: /^v.*/
70 | branches:
71 | ignore: /.*/
72 | macos-arm64-workflow:
73 | jobs:
74 | - macos-arm64-native:
75 | context:
76 | - dashaun-github
77 | filters:
78 | tags:
79 | only: /^v.*/
80 | branches:
81 | ignore: /.*/
--------------------------------------------------------------------------------
/.github/workflows/tagged-linux.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: "tagged-linux"
3 |
4 | on:
5 | push:
6 | tags:
7 | - "v*"
8 |
9 | jobs:
10 |
11 | tagged-linux:
12 | name: "Tagged linux"
13 | runs-on: ubuntu-latest
14 |
15 | steps:
16 | - uses: graalvm/setup-graalvm@v1
17 | with:
18 | version: 'latest'
19 | java-version: '17'
20 | components: 'native-image'
21 | github-token: "${{ secrets.GH_TOKEN }}"
22 |
23 | - uses: actions/checkout@v3
24 | with:
25 | ref: '${{github.ref_name}}'
26 |
27 | - name: Cache Maven packages
28 | uses: actions/cache@v1
29 | with:
30 | path: ~/.m2
31 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
32 | restore-keys: ${{ runner.os }}-m2
33 |
34 | - name: Build Image
35 | run: ./mvnw -Pnative native:compile
36 |
37 | - uses: ncipollo/release-action@v1
38 | with:
39 | artifacts: "./target/initializr-plusplus-linux-x86_64,LICENSE"
40 | allowUpdates: true
41 | token: ${{ secrets.GH_TOKEN }}
--------------------------------------------------------------------------------
/.github/workflows/tagged-macos.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: "tagged-macos"
3 |
4 | on:
5 | push:
6 | tags:
7 | - "v*"
8 |
9 | jobs:
10 |
11 | tagged-macos:
12 | name: "Tagged macos"
13 | runs-on: macos-latest
14 |
15 | steps:
16 | - uses: graalvm/setup-graalvm@v1
17 | with:
18 | version: 'latest'
19 | java-version: '17'
20 | components: 'native-image'
21 | github-token: "${{ secrets.GH_TOKEN }}"
22 |
23 | - uses: actions/checkout@v3
24 | with:
25 | ref: '${{github.ref_name}}'
26 |
27 | - name: Cache Maven packages
28 | uses: actions/cache@v1
29 | with:
30 | path: ~/.m2
31 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
32 | restore-keys: ${{ runner.os }}-m2
33 |
34 | - name: Build Image
35 | run: ./mvnw -Pnative native:compile
36 |
37 | - uses: ncipollo/release-action@v1
38 | with:
39 | artifacts: "./target/initializr-plusplus-osx-x86_64,LICENSE"
40 | allowUpdates: true
41 | token: ${{ secrets.GH_TOKEN }}
--------------------------------------------------------------------------------
/.github/workflows/tagged-windows.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: "tagged-windows"
3 |
4 | on:
5 | push:
6 | tags:
7 | - "v*"
8 |
9 | jobs:
10 |
11 | tagged-windows:
12 | name: "Tagged windows"
13 | runs-on: windows-latest
14 |
15 | steps:
16 | - uses: graalvm/setup-graalvm@v1
17 | with:
18 | version: 'latest'
19 | java-version: '17'
20 | components: 'native-image'
21 | github-token: "${{ secrets.GH_TOKEN }}"
22 |
23 | - uses: actions/checkout@v3
24 | with:
25 | ref: '${{github.ref_name}}'
26 |
27 | - name: Cache Maven packages
28 | uses: actions/cache@v1
29 | with:
30 | path: ~/.m2
31 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
32 | restore-keys: ${{ runner.os }}-m2
33 |
34 | - name: Build Image
35 | run: .\mvnw.cmd -Pnative native:compile
36 |
37 | - uses: ncipollo/release-action@v1
38 | with:
39 | artifacts: "./target/initializr-plusplus-windows-x86_64.exe,LICENSE"
40 | allowUpdates: true
41 | token: ${{ secrets.GH_TOKEN }}
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
35 | spring-shell.log
--------------------------------------------------------------------------------
/.mvn/extensions.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | fr.brouillard.oss
5 | jgitver-maven-plugin
6 | 1.9.0
7 |
8 |
9 | kr.motd.maven
10 | os-maven-plugin
11 | 1.7.0
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.mvn/jgitver.config.xml:
--------------------------------------------------------------------------------
1 |
4 | CONFIGURABLE
5 | MAX
6 | true
7 | true
8 | false
9 | false
10 | 8
11 | main
12 | true
13 |
14 | .m2
15 |
16 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dashaun/initializr-plusplus/3f46c57684d2c0ae4bcb71b085e28d4e845c0108/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
3 |
--------------------------------------------------------------------------------
/.sdkmanrc:
--------------------------------------------------------------------------------
1 | # Enable auto-env through the sdkman_auto_env config
2 | # Add key=value pairs of SDKs to use below
3 | java=23.1.2.r21-nik
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [![Contributors][contributors-shield]][contributors-url]
2 | [![Forks][forks-shield]][forks-url]
3 | [![Stargazers][stars-shield]][stars-url]
4 | [![Issues][issues-shield]][issues-url]
5 | [![License][license-shield]][license-url]
6 |
7 | [](https://github.com/dashaun/spring-initializer-next-step/actions/workflows/tagged-linux.yml)
8 | [](https://github.com/dashaun/spring-initializer-next-step/actions/workflows/tagged-windows.yml)
9 | [](https://github.com/dashaun/spring-initializer-next-step/actions/workflows/tagged-macos.yml)
10 |
11 | # initializr-plusplus
12 | ### CLI for making changes to [Spring Initializr](https://start.spring.io) projects.
13 |
14 | - Use [Spring Initializr](https://start.spring.io) it is awesome, I highly recommend it.
15 | - Then get your project to production.
16 | - This tool decreases the amount of time between `T-Initialize` and `T-Production`
17 | - This improves the `Fifth Metric` Mean Time To Dopamine (MTTD)
18 | - This tool provides commands via CLI and interactive shell
19 | - Add the `jgitver-maven-plugin` and `os-maven-plugin` as Maven Extensions
20 | - Update the `project-description`
21 | - Update the `project-name`
22 | - Update the `project-version`
23 | - Enable all `actuator` management endpoints
24 | - Update `spring-cloud-function-context` to a specific starter
25 |
26 | ## | [Quick Start](#quick-start) | [Usage](#usage) | [Built With](#built-with) | [Develop](#develop) |
27 |
28 | ## Quick Start
29 |
30 | Download the latest release and put it on your path.
31 |
32 | ```bash
33 | # Download
34 | curl -L https://github.com/dashaun/initializr-plusplus/releases/download/v#.#.#/initializr-plusplus-linux-amd64 --output initializr-plusplus
35 | # Download and extract an example project from start.sprint.io
36 | curl https://start.spring.io/starter.tgz -d dependencies=web,data-jpa -d type=maven-project -d baseDir=./ | tar -xzvf -
37 | # Use help command
38 | ./initializr-plusplus help
39 | # Add extensions
40 | ./initializr-plusplus extensions
41 | # Interactive mode
42 | ./initializr-plusplus
43 | ```
44 |
45 | ## Usage
46 |
47 | ```text
48 | AVAILABLE COMMANDS
49 |
50 | Application Config Commands
51 | expose-mgmt: expose all management endpoints via web
52 |
53 | Built-In Commands
54 | help: Display help about available commands
55 | history: Display or save the history of previously run commands
56 | version: Show version info
57 | script: Read and execute commands from a file.
58 |
59 | Cloud Function Example
60 | hello-world-function-bean: Update DemoApplication with 'Hello World' @Bean Function
61 |
62 | Maven Extension Commands
63 | extensions: add mvn extensions and config
64 |
65 | Pom File Commands
66 | native-maven-plugin: Support for GraalVM native-image compiler.
67 | multi-arch-builder: Add multi-architecture builder support.
68 | project-name: Update the project name
69 | tiny-buildpack-profile: Create Native OCI Images with paketobuildpacks/builder:tiny
70 | project-version: Update the project version
71 | lambda-profile: Add AWS Lambda profile for Spring Cloud Functions
72 | webflux-profile: Add a 'webflux' profile for Spring Cloud Functions
73 | project-description: Update the project description
74 | ```
75 |
76 | ## Built with:
77 |
78 | * [Spring Shell](https://spring.io/projects/spring-shell)
79 |
80 | ## Develop
81 |
82 | ### Normal build
83 |
84 | - `./mvnw clean package`
85 | - `java -jar target/plusplus-0.0.2.jar`
86 | or
87 | - `./mvnw spring-boot:run`
88 |
89 | ### Native build
90 |
91 | - `./mvnw -Pnative clean native:compile -DskipTests`
92 |
93 | ### Release
94 |
95 | - `git tag v#.#.#`
96 | - `git push origin v#.#.#`
97 |
98 | > gh release upload v#.#.# target/initializr-plusplus-$OS-$ARCH
99 |
100 | ### Roadmap
101 |
102 | See the [open issues](https://github.com/dashaun/initializr-plusplus/issues) for a list of proposed features (and known issues).
103 |
104 | ### Notes
105 |
106 | Before running `native:compile` on Windows
107 | > C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat
108 | >
109 | ### Contributing
110 |
111 | Pull-requests are welcomed!
112 |
113 | ### License
114 |
115 | Distributed under the Apache-2.0 License. See `LICENSE` for more information.
116 |
117 | [contributors-shield]: https://img.shields.io/github/contributors/dashaun/spring-initializer-next-step.svg?style=for-the-badge
118 | [contributors-url]: https://github.com/dashaun/spring-initializer-next-step/graphs/contributors
119 | [forks-shield]: https://img.shields.io/github/forks/dashaun/spring-initializer-next-step.svg?style=for-the-badge
120 | [forks-url]: https://github.com/dashaun/spring-initializer-next-step/network/members
121 | [stars-shield]: https://img.shields.io/github/stars/dashaun/spring-initializer-next-step.svg?style=for-the-badge
122 | [stars-url]: https://github.com/dashaun/spring-initializer-next-step/stargazers
123 | [issues-shield]: https://img.shields.io/github/issues/dashaun/spring-initializer-next-step.svg?style=for-the-badge
124 | [issues-url]: https://github.com/dashaun/spring-initializer-next-step/issues
125 | [license-shield]: https://img.shields.io/github/license/dashaun/spring-initializer-next-step.svg?style=for-the-badge
126 | [license-url]: https://github.com/dashaun/spring-initializer-next-step/blob/master/LICENSE.txt
127 |
--------------------------------------------------------------------------------
/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 | # Maven 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 /usr/local/etc/mavenrc ] ; then
40 | . /usr/local/etc/mavenrc
41 | fi
42 |
43 | if [ -f /etc/mavenrc ] ; then
44 | . /etc/mavenrc
45 | fi
46 |
47 | if [ -f "$HOME/.mavenrc" ] ; then
48 | . "$HOME/.mavenrc"
49 | fi
50 |
51 | fi
52 |
53 | # OS specific support. $var _must_ be set to either true or false.
54 | cygwin=false;
55 | darwin=false;
56 | mingw=false
57 | case "`uname`" in
58 | CYGWIN*) cygwin=true ;;
59 | MINGW*) mingw=true;;
60 | Darwin*) darwin=true
61 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
62 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
63 | if [ -z "$JAVA_HOME" ]; then
64 | if [ -x "/usr/libexec/java_home" ]; then
65 | export JAVA_HOME="`/usr/libexec/java_home`"
66 | else
67 | export JAVA_HOME="/Library/Java/Home"
68 | fi
69 | fi
70 | ;;
71 | esac
72 |
73 | if [ -z "$JAVA_HOME" ] ; then
74 | if [ -r /etc/gentoo-release ] ; then
75 | JAVA_HOME=`java-config --jre-home`
76 | fi
77 | fi
78 |
79 | if [ -z "$M2_HOME" ] ; then
80 | ## resolve links - $0 may be a link to maven's home
81 | PRG="$0"
82 |
83 | # need this for relative symlinks
84 | while [ -h "$PRG" ] ; do
85 | ls=`ls -ld "$PRG"`
86 | link=`expr "$ls" : '.*-> \(.*\)$'`
87 | if expr "$link" : '/.*' > /dev/null; then
88 | PRG="$link"
89 | else
90 | PRG="`dirname "$PRG"`/$link"
91 | fi
92 | done
93 |
94 | saveddir=`pwd`
95 |
96 | M2_HOME=`dirname "$PRG"`/..
97 |
98 | # make it fully qualified
99 | M2_HOME=`cd "$M2_HOME" && pwd`
100 |
101 | cd "$saveddir"
102 | # echo Using m2 at $M2_HOME
103 | fi
104 |
105 | # For Cygwin, ensure paths are in UNIX format before anything is touched
106 | if $cygwin ; then
107 | [ -n "$M2_HOME" ] &&
108 | M2_HOME=`cygpath --unix "$M2_HOME"`
109 | [ -n "$JAVA_HOME" ] &&
110 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
111 | [ -n "$CLASSPATH" ] &&
112 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
113 | fi
114 |
115 | # For Mingw, ensure paths are in UNIX format before anything is touched
116 | if $mingw ; then
117 | [ -n "$M2_HOME" ] &&
118 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
119 | [ -n "$JAVA_HOME" ] &&
120 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
121 | fi
122 |
123 | if [ -z "$JAVA_HOME" ]; then
124 | javaExecutable="`which javac`"
125 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
126 | # readlink(1) is not available as standard on Solaris 10.
127 | readLink=`which readlink`
128 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
129 | if $darwin ; then
130 | javaHome="`dirname \"$javaExecutable\"`"
131 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
132 | else
133 | javaExecutable="`readlink -f \"$javaExecutable\"`"
134 | fi
135 | javaHome="`dirname \"$javaExecutable\"`"
136 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
137 | JAVA_HOME="$javaHome"
138 | export JAVA_HOME
139 | fi
140 | fi
141 | fi
142 |
143 | if [ -z "$JAVACMD" ] ; then
144 | if [ -n "$JAVA_HOME" ] ; then
145 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
146 | # IBM's JDK on AIX uses strange locations for the executables
147 | JAVACMD="$JAVA_HOME/jre/sh/java"
148 | else
149 | JAVACMD="$JAVA_HOME/bin/java"
150 | fi
151 | else
152 | JAVACMD="`\\unset -f command; \\command -v java`"
153 | fi
154 | fi
155 |
156 | if [ ! -x "$JAVACMD" ] ; then
157 | echo "Error: JAVA_HOME is not defined correctly." >&2
158 | echo " We cannot execute $JAVACMD" >&2
159 | exit 1
160 | fi
161 |
162 | if [ -z "$JAVA_HOME" ] ; then
163 | echo "Warning: JAVA_HOME environment variable is not set."
164 | fi
165 |
166 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
167 |
168 | # traverses directory structure from process work directory to filesystem root
169 | # first directory with .mvn subdirectory is considered project base directory
170 | find_maven_basedir() {
171 |
172 | if [ -z "$1" ]
173 | then
174 | echo "Path not specified to find_maven_basedir"
175 | return 1
176 | fi
177 |
178 | basedir="$1"
179 | wdir="$1"
180 | while [ "$wdir" != '/' ] ; do
181 | if [ -d "$wdir"/.mvn ] ; then
182 | basedir=$wdir
183 | break
184 | fi
185 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
186 | if [ -d "${wdir}" ]; then
187 | wdir=`cd "$wdir/.."; pwd`
188 | fi
189 | # end of workaround
190 | done
191 | echo "${basedir}"
192 | }
193 |
194 | # concatenates all lines of a file
195 | concat_lines() {
196 | if [ -f "$1" ]; then
197 | echo "$(tr -s '\n' ' ' < "$1")"
198 | fi
199 | }
200 |
201 | BASE_DIR=`find_maven_basedir "$(pwd)"`
202 | if [ -z "$BASE_DIR" ]; then
203 | exit 1;
204 | fi
205 |
206 | ##########################################################################################
207 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
208 | # This allows using the maven wrapper in projects that prohibit checking in binary data.
209 | ##########################################################################################
210 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
211 | if [ "$MVNW_VERBOSE" = true ]; then
212 | echo "Found .mvn/wrapper/maven-wrapper.jar"
213 | fi
214 | else
215 | if [ "$MVNW_VERBOSE" = true ]; then
216 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
217 | fi
218 | if [ -n "$MVNW_REPOURL" ]; then
219 | jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
220 | else
221 | jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
222 | fi
223 | while IFS="=" read key value; do
224 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
225 | esac
226 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
227 | if [ "$MVNW_VERBOSE" = true ]; then
228 | echo "Downloading from: $jarUrl"
229 | fi
230 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
231 | if $cygwin; then
232 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
233 | fi
234 |
235 | if command -v wget > /dev/null; then
236 | if [ "$MVNW_VERBOSE" = true ]; then
237 | echo "Found wget ... using wget"
238 | fi
239 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
240 | wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
241 | else
242 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
243 | fi
244 | elif command -v curl > /dev/null; then
245 | if [ "$MVNW_VERBOSE" = true ]; then
246 | echo "Found curl ... using curl"
247 | fi
248 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
249 | curl -o "$wrapperJarPath" "$jarUrl" -f
250 | else
251 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
252 | fi
253 |
254 | else
255 | if [ "$MVNW_VERBOSE" = true ]; then
256 | echo "Falling back to using Java to download"
257 | fi
258 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
259 | # For Cygwin, switch paths to Windows format before running javac
260 | if $cygwin; then
261 | javaClass=`cygpath --path --windows "$javaClass"`
262 | fi
263 | if [ -e "$javaClass" ]; then
264 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
265 | if [ "$MVNW_VERBOSE" = true ]; then
266 | echo " - Compiling MavenWrapperDownloader.java ..."
267 | fi
268 | # Compiling the Java class
269 | ("$JAVA_HOME/bin/javac" "$javaClass")
270 | fi
271 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
272 | # Running the downloader
273 | if [ "$MVNW_VERBOSE" = true ]; then
274 | echo " - Running MavenWrapperDownloader.java ..."
275 | fi
276 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
277 | fi
278 | fi
279 | fi
280 | fi
281 | ##########################################################################################
282 | # End of extension
283 | ##########################################################################################
284 |
285 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
286 | if [ "$MVNW_VERBOSE" = true ]; then
287 | echo $MAVEN_PROJECTBASEDIR
288 | fi
289 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
290 |
291 | # For Cygwin, switch paths to Windows format before running java
292 | if $cygwin; then
293 | [ -n "$M2_HOME" ] &&
294 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
295 | [ -n "$JAVA_HOME" ] &&
296 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
297 | [ -n "$CLASSPATH" ] &&
298 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
299 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
300 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
301 | fi
302 |
303 | # Provide a "standardized" way to retrieve the CLI args that will
304 | # work with both Windows and non-Windows executions.
305 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
306 | export MAVEN_CMD_LINE_ARGS
307 |
308 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
309 |
310 | exec "$JAVACMD" \
311 | $MAVEN_OPTS \
312 | $MAVEN_DEBUG_OPTS \
313 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
314 | "-Dmaven.home=${M2_HOME}" \
315 | "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
316 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
317 |
--------------------------------------------------------------------------------
/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 Maven 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 keystroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM set title of command window
39 | title %0
40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
42 |
43 | @REM set %HOME% to equivalent of $HOME
44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45 |
46 | @REM Execute a user defined script before this one
47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
49 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
50 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
51 | :skipRcPre
52 |
53 | @setlocal
54 |
55 | set ERROR_CODE=0
56 |
57 | @REM To isolate internal variables from possible post scripts, we use another setlocal
58 | @setlocal
59 |
60 | @REM ==== START VALIDATION ====
61 | if not "%JAVA_HOME%" == "" goto OkJHome
62 |
63 | echo.
64 | echo Error: JAVA_HOME not found in your environment. >&2
65 | echo Please set the JAVA_HOME variable in your environment to match the >&2
66 | echo location of your Java installation. >&2
67 | echo.
68 | goto error
69 |
70 | :OkJHome
71 | if exist "%JAVA_HOME%\bin\java.exe" goto init
72 |
73 | echo.
74 | echo Error: JAVA_HOME is set to an invalid directory. >&2
75 | echo JAVA_HOME = "%JAVA_HOME%" >&2
76 | echo Please set the JAVA_HOME variable in your environment to match the >&2
77 | echo location of your Java installation. >&2
78 | echo.
79 | goto error
80 |
81 | @REM ==== END VALIDATION ====
82 |
83 | :init
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122 |
123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
124 |
125 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127 | )
128 |
129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131 | if exist %WRAPPER_JAR% (
132 | if "%MVNW_VERBOSE%" == "true" (
133 | echo Found %WRAPPER_JAR%
134 | )
135 | ) else (
136 | if not "%MVNW_REPOURL%" == "" (
137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
138 | )
139 | if "%MVNW_VERBOSE%" == "true" (
140 | echo Couldn't find %WRAPPER_JAR%, downloading it ...
141 | echo Downloading from: %DOWNLOAD_URL%
142 | )
143 |
144 | powershell -Command "&{"^
145 | "$webclient = new-object System.Net.WebClient;"^
146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148 | "}"^
149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150 | "}"
151 | if "%MVNW_VERBOSE%" == "true" (
152 | echo Finished downloading %WRAPPER_JAR%
153 | )
154 | )
155 | @REM End of extension
156 |
157 | @REM Provide a "standardized" way to retrieve the CLI args that will
158 | @REM work with both Windows and non-Windows executions.
159 | set MAVEN_CMD_LINE_ARGS=%*
160 |
161 | %MAVEN_JAVA_EXE% ^
162 | %JVM_CONFIG_MAVEN_PROPS% ^
163 | %MAVEN_OPTS% ^
164 | %MAVEN_DEBUG_OPTS% ^
165 | -classpath %WRAPPER_JAR% ^
166 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
167 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
168 | if ERRORLEVEL 1 goto error
169 | goto end
170 |
171 | :error
172 | set ERROR_CODE=1
173 |
174 | :end
175 | @endlocal & set ERROR_CODE=%ERROR_CODE%
176 |
177 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
178 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
179 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
180 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
181 | :skipRcPost
182 |
183 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
184 | if "%MAVEN_BATCH_PAUSE%"=="on" pause
185 |
186 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
187 |
188 | cmd /C exit /B %ERROR_CODE%
189 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 3.4.3
9 |
10 |
11 | dev.dashaun.shell.initializr
12 | plusplus
13 | 0
14 | ${project.groupId}:${project.artifactId}
15 |
16 | 3.4.0
17 | 21
18 |
19 |
20 |
21 |
22 | org.springframework.shell
23 | spring-shell-dependencies
24 | ${spring-shell.version}
25 | pom
26 | import
27 |
28 |
29 |
30 |
31 |
32 | org.apache.maven
33 | maven-model
34 | 3.9.9
35 |
36 |
37 | org.springframework.shell
38 | spring-shell-starter
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-starter-test
43 | test
44 |
45 |
46 |
47 |
48 |
49 | org.graalvm.buildtools
50 | native-maven-plugin
51 |
52 | initializr-plusplus-${os.detected.classifier}
53 |
54 |
55 |
56 | org.springframework.boot
57 | spring-boot-maven-plugin
58 |
59 |
60 | build-info
61 |
62 | build-info
63 |
64 |
65 |
66 |
67 |
68 | io.spring.javaformat
69 | spring-javaformat-maven-plugin
70 | 0.0.41
71 |
72 |
73 |
74 | validate
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/src/main/java/dev/dashaun/shell/initializr/plusplus/Application.java:
--------------------------------------------------------------------------------
1 | package dev.dashaun.shell.initializr.plusplus;
2 |
3 | import org.jline.utils.AttributedString;
4 | import org.jline.utils.AttributedStyle;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
7 | import org.springframework.shell.jline.PromptProvider;
8 | import org.springframework.stereotype.Component;
9 |
10 | import java.io.BufferedWriter;
11 | import java.io.File;
12 | import java.io.FileWriter;
13 | import java.io.IOException;
14 |
15 | @SpringBootApplication
16 | public class Application {
17 |
18 | public static void main(String[] args) {
19 | SpringApplication.run(Application.class, args);
20 | }
21 |
22 | static void writeStringToFile(String data, File file) throws IOException {
23 | FileWriter fileWriter = new FileWriter(file, false);
24 | BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
25 | bufferedWriter.write(data);
26 | bufferedWriter.flush();
27 | bufferedWriter.close();
28 | fileWriter.close();
29 | }
30 |
31 | }
32 |
33 | @Component
34 | class CustomPromptProvider implements PromptProvider {
35 |
36 | @Override
37 | public AttributedString getPrompt() {
38 | return new AttributedString("initializr-plusplus:>", AttributedStyle.DEFAULT.foreground(AttributedStyle.GREEN));
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/dev/dashaun/shell/initializr/plusplus/ApplicationConfigCommands.java:
--------------------------------------------------------------------------------
1 | package dev.dashaun.shell.initializr.plusplus;
2 |
3 | import org.springframework.shell.standard.ShellComponent;
4 | import org.springframework.shell.standard.ShellMethod;
5 |
6 | import java.io.File;
7 | import java.io.IOException;
8 |
9 | import static dev.dashaun.shell.initializr.plusplus.Application.writeStringToFile;
10 |
11 | @ShellComponent
12 | // @ShellCommandGroup("./src/main/resources/application.yaml")
13 | public class ApplicationConfigCommands {
14 |
15 | private final static File APPLICATION_YAML = new File("./src/main/resources/application.yaml");
16 |
17 | private final static File APPLICATION_PROPS = new File("./src/main/resources/application.properties");
18 |
19 | private final static File SRC_ASSEMBLY_JAVA = new File("./src/assembly/java.xml");
20 |
21 | private final static File SRC_ASSEMBLY_NATIVE = new File("./src/assembly/native.xml");
22 |
23 | private final static File SRC_SHELL_JAVA = new File("./src/shell/java/bootstrap");
24 |
25 | private final static File SRC_SHELL_NATIVE = new File("./src/shell/native/bootstrap");
26 |
27 | @ShellMethod("expose all management endpoints via web")
28 | public String exposeMgmt() {
29 | try {
30 | mgmtEndpoints();
31 | }
32 | catch (IOException ioException) {
33 | return "There was a problem editing the application.yaml";
34 | }
35 | return "Successfully setup application.yaml with management endpoints";
36 | }
37 |
38 | public static void writeNativeAssembly() throws IOException {
39 | srcAssemblyDir();
40 | srcShellDir();
41 | writeStringToFile(nativeAssembly(), SRC_ASSEMBLY_NATIVE);
42 | writeStringToFile(nativeShell(), SRC_SHELL_NATIVE);
43 | }
44 |
45 | public static void writeJavaAssembly() throws IOException {
46 | srcAssemblyDir();
47 | srcShellDir();
48 | writeStringToFile(javaAssembly(), SRC_ASSEMBLY_JAVA);
49 | writeStringToFile(javaShell(), SRC_SHELL_JAVA);
50 | }
51 |
52 | private void mgmtEndpoints() throws IOException {
53 | if (APPLICATION_PROPS.exists()) {
54 | if (!APPLICATION_PROPS.delete()) {
55 | throw new IOException("Couldn't remove application.properties file");
56 | }
57 | }
58 |
59 | if (!APPLICATION_YAML.exists()) {
60 | writeStringToFile(applicationYaml(), APPLICATION_YAML);
61 | }
62 | }
63 |
64 | private String applicationYaml() {
65 | return """
66 | management:
67 | endpoints:
68 | enabled-by-default: true
69 | health:
70 | show-details: always
71 | web:
72 | exposure:
73 | include: '*'
74 | """;
75 | }
76 |
77 | private static String javaAssembly() {
78 | return """
79 |
82 | java-zip
83 |
84 | zip
85 |
86 |
87 |
88 |
89 | target/classes
90 | /
91 |
92 |
93 | src/shell/java
94 | /
95 | true
96 | 0775
97 |
98 | bootstrap
99 |
100 |
101 |
102 |
103 |
104 | /lib
105 | false
106 | runtime
107 |
108 |
109 |
110 | """;
111 | }
112 |
113 | private static String javaShell() {
114 | return """
115 | #!/bin/sh
116 |
117 | cd ${LAMBDA_TASK_ROOT:-.}
118 |
119 | java -Dspring.main.web-application-type=none -Dlogging.level.org.springframework=DEBUG \\
120 | -noverify -XX:TieredStopAtLevel=1 -Xss256K -XX:MaxMetaspaceSize=128M \\
121 | -cp .:`echo lib/*.jar | tr ' ' :` com.example.demo.DemoApplication
122 | """;
123 | }
124 |
125 | private static String nativeAssembly() {
126 | return """
127 |
130 | native-zip
131 |
132 | zip
133 |
134 |
135 |
136 |
137 | src/shell/native
138 | /
139 | true
140 | 0775
141 |
142 | bootstrap
143 |
144 |
145 |
146 | target
147 | /
148 | true
149 | 0775
150 |
151 | demo
152 |
153 |
154 |
155 |
156 | """;
157 | }
158 |
159 | private static String nativeShell() {
160 | return """
161 | #!/bin/sh
162 |
163 | cd ${LAMBDA_TASK_ROOT:-.}
164 |
165 | ./demo -Dlogging.level.org.springframework=DEBUG
166 | """;
167 | }
168 |
169 | private static void srcAssemblyDir() throws IOException {
170 | File file = new File("./src/assembly");
171 | if (!file.exists()) {
172 | if (!file.mkdir()) {
173 | throw new IOException("Could not create src/assembly");
174 | }
175 | }
176 | }
177 |
178 | private static void srcShellDir() throws IOException {
179 | File file = new File("./src/shell");
180 | if (!file.exists()) {
181 | if (!file.mkdir()) {
182 | throw new IOException("Could not create src/shell");
183 | }
184 | }
185 | File n = new File("./src/shell/native");
186 | if (!n.exists()) {
187 | if (!n.mkdir()) {
188 | throw new IOException("Could not create src/shell/native");
189 | }
190 | }
191 | File j = new File("./src/shell/java");
192 | if (!j.exists()) {
193 | if (!j.mkdir()) {
194 | throw new IOException("Could not create src/shell/java");
195 | }
196 | }
197 | }
198 |
199 | }
200 |
--------------------------------------------------------------------------------
/src/main/java/dev/dashaun/shell/initializr/plusplus/CloudFunctionExample.java:
--------------------------------------------------------------------------------
1 | package dev.dashaun.shell.initializr.plusplus;
2 |
3 | import org.springframework.shell.standard.ShellComponent;
4 | import org.springframework.shell.standard.ShellMethod;
5 |
6 | import java.io.File;
7 | import java.io.IOException;
8 |
9 | import static dev.dashaun.shell.initializr.plusplus.Application.writeStringToFile;
10 |
11 | @ShellComponent
12 | // @ShellCommandGroup("spring-cloud-functions")
13 | public class CloudFunctionExample {
14 |
15 | private final static File DEMO_APPLICATION_SRC = new File("./src/main/java/com/example/demo/DemoApplication.java");
16 |
17 | @ShellMethod("Update DemoApplication with 'Hello World' @Bean Function")
18 | public String helloWorldFunctionBean() {
19 | try {
20 | writeStringToFile(DemoApplicationWithFunctionBean(), DEMO_APPLICATION_SRC);
21 | }
22 | catch (IOException ioException) {
23 | return "There was a problem adding the function";
24 | }
25 | return "Successfully added the function";
26 | }
27 |
28 | private String DemoApplicationWithFooFunction() {
29 | return """
30 | package com.example.demo;
31 |
32 | import org.springframework.boot.SpringBootConfiguration;
33 | import org.springframework.cloud.function.context.FunctionRegistration;
34 | import org.springframework.cloud.function.context.FunctionType;
35 | import org.springframework.cloud.function.context.FunctionalSpringApplication;
36 | import org.springframework.context.ApplicationContextInitializer;
37 | import org.springframework.context.support.GenericApplicationContext;
38 |
39 | import java.util.function.Function;
40 |
41 | @SpringBootConfiguration
42 | public class DemoApplication implements ApplicationContextInitializer {
43 |
44 | public static void main(String[] args) {
45 | FunctionalSpringApplication.run(DemoApplication.class, args);
46 | }
47 |
48 | public Function hello() {
49 | return foo -> String.format("Hello, %s", foo);
50 | }
51 |
52 | @Override
53 | public void initialize(GenericApplicationContext context) {
54 | context.registerBean("hello", FunctionRegistration.class,
55 | () -> new FunctionRegistration<>(hello())
56 | .type(FunctionType.from(Foo.class).to(String.class).getType()));
57 | }
58 |
59 | }
60 |
61 | class Foo {
62 | private String value;
63 |
64 | public String getValue() {
65 | return value;
66 | }
67 |
68 | public void setValue(String value) {
69 | this.value = value;
70 | }
71 |
72 | @Override
73 | public String toString() {
74 | return value;
75 | }
76 | }
77 | """;
78 | }
79 |
80 | private String DemoApplicationWithFunctionalBeanDef() {
81 | return """
82 | package com.example.demo;
83 |
84 | import org.springframework.boot.SpringBootConfiguration;
85 | import org.springframework.cloud.function.context.FunctionRegistration;
86 | import org.springframework.cloud.function.context.FunctionType;
87 | import org.springframework.cloud.function.context.FunctionalSpringApplication;
88 | import org.springframework.context.ApplicationContextInitializer;
89 | import org.springframework.context.support.GenericApplicationContext;
90 |
91 | import java.util.function.Function;
92 |
93 | @SpringBootConfiguration
94 | public class DemoApplication implements ApplicationContextInitializer {
95 |
96 | public static void main(String[] args) {
97 | FunctionalSpringApplication.run(DemoApplication.class, args);
98 | }
99 |
100 | public Function hello() {
101 | return value -> String.format("Hello, %s", value);
102 | }
103 |
104 | @Override
105 | public void initialize(GenericApplicationContext context) {
106 | context.registerBean("hello", FunctionRegistration.class,
107 | () -> new FunctionRegistration<>(hello())
108 | .type(FunctionType.from(String.class).to(String.class).getType()));
109 | }
110 |
111 | }
112 | """;
113 | }
114 |
115 | private String DemoApplicationWithFunctionBean() {
116 | return """
117 | package com.example.demo;
118 |
119 | import org.springframework.boot.SpringApplication;
120 | import org.springframework.boot.autoconfigure.SpringBootApplication;
121 | import org.springframework.context.annotation.Bean;
122 |
123 | import java.nio.charset.StandardCharsets;
124 | import java.util.function.Function;
125 |
126 | @SpringBootApplication
127 | public class DemoApplication {
128 |
129 | @Bean
130 | public Function hello() {
131 | return value -> value.length>0 ? String.format("Hello, %s", new String(value, StandardCharsets.UTF_8)) : "Hello, World";
132 | }
133 |
134 | public static void main(String[] args) {
135 | SpringApplication.run(DemoApplication.class, args);
136 | }
137 |
138 | }
139 | """;
140 | }
141 |
142 | }
143 |
--------------------------------------------------------------------------------
/src/main/java/dev/dashaun/shell/initializr/plusplus/MavenExtensionCommands.java:
--------------------------------------------------------------------------------
1 | package dev.dashaun.shell.initializr.plusplus;
2 |
3 | import org.springframework.shell.standard.ShellComponent;
4 | import org.springframework.shell.standard.ShellMethod;
5 |
6 | import java.io.File;
7 | import java.io.IOException;
8 |
9 | import static dev.dashaun.shell.initializr.plusplus.Application.writeStringToFile;
10 |
11 | @ShellComponent
12 | public class MavenExtensionCommands {
13 |
14 | @ShellMethod("add mvn extensions and config")
15 | public String extensions() {
16 | try {
17 | mavenConfigDir();
18 | extensionsConfig();
19 | jgitverConfig();
20 | }
21 | catch (IOException ioException) {
22 | return "There was a problem adding jgitver extension and config";
23 | }
24 | return "Successfully added jgitver extension and config in ./.mvn";
25 | }
26 |
27 | private void extensionsConfig() throws IOException {
28 | File file = new File("./.mvn/extensions.xml");
29 | if (!file.exists()) {
30 | writeStringToFile(extensionsFile(), file);
31 | }
32 | }
33 |
34 | private void jgitverConfig() throws IOException {
35 | File file = new File("./.mvn/jgitver.config.xml");
36 | if (!file.exists()) {
37 | writeStringToFile(jgitverConfigFile(), file);
38 | }
39 | }
40 |
41 | private String extensionsFile() {
42 | return """
43 |
45 |
46 | fr.brouillard.oss
47 | jgitver-maven-plugin
48 | 1.9.0
49 |
50 |
51 | kr.motd.maven
52 | os-maven-plugin
53 | 1.7.1
54 |
55 |
56 | """;
57 | }
58 |
59 | private String jgitverConfigFile() {
60 | return """
61 |
64 | CONFIGURABLE
65 | MAX
66 | true
67 | false
68 | false
69 | false
70 | 8
71 | main
72 | true
73 |
74 | .m2
75 |
76 |
77 | """;
78 | }
79 |
80 | private void mavenConfigDir() throws IOException {
81 | File file = new File("./.mvn");
82 | if (!file.exists()) {
83 | if (!file.mkdir()) {
84 | throw new IOException("Couldn't create directory");
85 | }
86 | }
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/src/main/java/dev/dashaun/shell/initializr/plusplus/PipelineCommands.java:
--------------------------------------------------------------------------------
1 | package dev.dashaun.shell.initializr.plusplus;
2 |
3 | import org.springframework.shell.standard.ShellComponent;
4 | import org.springframework.shell.standard.ShellMethod;
5 |
6 | import java.io.File;
7 | import java.io.IOException;
8 |
9 | import static dev.dashaun.shell.initializr.plusplus.Application.writeStringToFile;
10 |
11 | @ShellComponent
12 | public class PipelineCommands {
13 |
14 | @ShellMethod("pipelines to create multi-architecture manifests")
15 | public String multiArchManifests() {
16 | try {
17 | circleciDir();
18 | githubDir();
19 | addCircleCIConfig();
20 | addGithubWorkflow();
21 | }
22 | catch (IOException ioException) {
23 | return "There was a problem adding pipeline configs";
24 | }
25 | return "Successfully added pipeline configs";
26 | }
27 |
28 | private void addCircleCIConfig() throws IOException {
29 | File file = new File("./.circleci/config.yml");
30 | if (!file.exists()) {
31 | writeStringToFile(circleCIConfigFile(), file);
32 | }
33 | else {
34 | throw new IOException("File already exists");
35 | }
36 | }
37 |
38 | private void addGithubWorkflow() throws IOException {
39 | File file = new File("./.github/workflows/main.yml");
40 | if (!file.exists()) {
41 | writeStringToFile(githubWorkflowFile(), file);
42 | }
43 | else {
44 | throw new IOException("File already exists");
45 | }
46 | }
47 |
48 | private String circleCIConfigFile() {
49 | return """
50 | version: 2.1
51 |
52 | orbs:
53 | docker: circleci/docker@2.4.0
54 | sdkman: joshdholtz/sdkman@0.2.0
55 |
56 | jobs:
57 | arm64-native:
58 | machine:
59 | image: ubuntu-2004:current
60 | resource_class: arm.medium
61 | steps:
62 | - checkout
63 | - sdkman/setup-sdkman
64 | - sdkman/sdkman-install:
65 | candidate: java
66 | version: 22.3.r17-grl
67 | - run:
68 | name: "mvnw -Pnative spring-boot:build-image"
69 | command: "./mvnw -Pnative spring-boot:build-image"
70 | - docker/check:
71 | docker-username: DOCKER_LOGIN
72 | docker-password: DOCKERHUB_PASSWORD
73 | - docker/push:
74 | image: dashaun/$CIRCLE_PROJECT_REPONAME
75 | tag: $CIRCLE_TAG-aarch_64
76 |
77 | workflows:
78 | arm64-native-workflow:
79 | jobs:
80 | - arm64-native:
81 | context:
82 | - dashaun-dockerhub
83 | filters:
84 | tags:
85 | only: /^v.*/
86 | branches:
87 | ignore: /.*/
88 | """;
89 | }
90 |
91 | private String githubWorkflowFile() {
92 | return """
93 | name: Native-AMD64
94 |
95 | on:
96 | push:
97 | tags:
98 | - "v*"
99 |
100 | env:
101 | IMAGE_NAME: dashaun/${GITHUB_REPOSITORY#*/}
102 |
103 | jobs:
104 | build:
105 |
106 | runs-on: ubuntu-latest
107 |
108 | steps:
109 | #Login to DockerHub
110 | - name: Login to DockerHub
111 | uses: docker/login-action@v2
112 | with:
113 | username: dashaun
114 | password: ${{ secrets.DOCKERHUB_TOKEN }}
115 | - uses: actions/setup-java@v2
116 | with:
117 | distribution: 'liberica' # See 'Supported distributions' for available options
118 | java-version: '17'
119 | - name: Checkout master
120 | uses: actions/checkout@v3
121 | with:
122 | submodules: true
123 | #Build Image
124 | - name: Build Image
125 | run: ./mvnw -Pnative spring-boot:build-image
126 | #Deploy the image to the Docker registry
127 | - name: Push Images to Docker Registry
128 | run: docker push -a $IMAGE_NAME
129 |
130 |
131 | manifest:
132 | needs: build
133 | runs-on: ubuntu-latest
134 | steps:
135 | - name: Login to DockerHub
136 | uses: docker/login-action@v2
137 | with:
138 | username: dashaun
139 | password: ${{ secrets.DOCKERHUB_TOKEN }}
140 | - name: pull-arm64
141 | uses: nick-fields/retry@v2
142 | with:
143 | timeout_minutes: 5
144 | retry_wait_seconds: 60
145 | max_attempts: 6
146 | command: docker pull $IMAGE_NAME:$GITHUB_REF_NAME-aarch_64
147 | - name: create-manifest
148 | run: |
149 | docker manifest create $IMAGE_NAME:$GITHUB_REF_NAME --amend $IMAGE_NAME:$GITHUB_REF_NAME-x86_64 --amend $IMAGE_NAME:$GITHUB_REF_NAME-aarch_64
150 | docker manifest push $IMAGE_NAME:$GITHUB_REF_NAME
151 | docker manifest create $IMAGE_NAME:latest --amend $IMAGE_NAME:$GITHUB_REF_NAME-x86_64 --amend $IMAGE_NAME:$GITHUB_REF_NAME-aarch_64
152 | docker manifest push $IMAGE_NAME:latest
153 | """;
154 | }
155 |
156 | private void circleciDir() throws IOException {
157 | File file = new File("./.circleci");
158 | if (!file.exists()) {
159 | if (!file.mkdir()) {
160 | throw new IOException("Couldn't create directory");
161 | }
162 | }
163 | }
164 |
165 | private void githubDir() throws IOException {
166 | File file = new File("./.github/workflows");
167 | if (!file.exists()) {
168 | if (!file.mkdirs()) {
169 | throw new IOException("Couldn't create directory");
170 | }
171 | }
172 | }
173 |
174 | }
175 |
--------------------------------------------------------------------------------
/src/main/java/dev/dashaun/shell/initializr/plusplus/PomFileCommands.java:
--------------------------------------------------------------------------------
1 | package dev.dashaun.shell.initializr.plusplus;
2 |
3 | import dev.dashaun.shell.initializr.plusplus.models.*;
4 | import org.apache.maven.model.Model;
5 | import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
6 | import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
7 | import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
8 | import org.springframework.shell.Availability;
9 | import org.springframework.shell.command.annotation.Command;
10 | import org.springframework.shell.standard.*;
11 |
12 | import java.io.*;
13 |
14 | @ShellComponent
15 | public class PomFileCommands {
16 |
17 | private final MavenXpp3Reader reader;
18 |
19 | public PomFileCommands() {
20 | this.reader = new MavenXpp3Reader();
21 | }
22 |
23 | private final static File POM_FILE = new File("./pom.xml");
24 |
25 | @ShellMethod("Update the project version")
26 | public String projectVersion(@ShellOption(defaultValue = "0") String version) {
27 | try {
28 | Model model = reader.read(new FileReader(POM_FILE));
29 | model.setVersion(version);
30 | MavenXpp3Writer writer = new MavenXpp3Writer();
31 | writer.write(new FileWriter(POM_FILE), model);
32 | }
33 | catch (XmlPullParserException | IOException e) {
34 | return "There was a problem updating the project version.";
35 | }
36 | return "Successfully set project version to '%s'".formatted(version);
37 | }
38 |
39 | @ShellMethod("Update the project description")
40 | public String projectDescription(@ShellOption(defaultValue = "") String description) {
41 | try {
42 | Model model = reader.read(new FileReader(POM_FILE));
43 | if ("".equals(description)) {
44 | model.setDescription(null);
45 | }
46 | else {
47 | model.setDescription(description);
48 | }
49 | MavenXpp3Writer writer = new MavenXpp3Writer();
50 | writer.write(new FileWriter(POM_FILE), model);
51 | }
52 | catch (XmlPullParserException | IOException e) {
53 | return "There was a problem updating the project description.";
54 | }
55 | return "".equals(description) ? "Successfully removed the project description."
56 | : "Successfully set project name to '%s'".formatted(description);
57 | }
58 |
59 | @Command
60 | @ShellMethod("Update the project name")
61 | public String projectName(@ShellOption(defaultValue = "${project.groupId}.${project.artifactId}") String name) {
62 | try {
63 | Model model = reader.read(new FileReader(POM_FILE));
64 | model.setName(name);
65 | MavenXpp3Writer writer = new MavenXpp3Writer();
66 | writer.write(new FileWriter(POM_FILE), model);
67 | }
68 | catch (XmlPullParserException | IOException e) {
69 | return "There was a problem updating the project name.";
70 | }
71 | return "Successfully set project name to '%s'".formatted(name);
72 | }
73 |
74 | @ShellMethod("Add AWS Lambda profile for Spring Cloud Functions")
75 | public String lambdaProfile() {
76 | try {
77 | Model model = reader.read(new FileReader(POM_FILE));
78 |
79 | Profiles.removeLambdaProfile(model);
80 | model.getProfiles().add(Profiles.lambdaProfile());
81 |
82 | // Write updated model to file
83 | MavenXpp3Writer writer = new MavenXpp3Writer();
84 | writer.write(new FileWriter(POM_FILE), model);
85 |
86 | // Create assembly configs
87 | ApplicationConfigCommands.writeJavaAssembly();
88 | ApplicationConfigCommands.writeNativeAssembly();
89 |
90 | }
91 | catch (XmlPullParserException | IOException e) {
92 | return "There was a problem configuring Lambda use.";
93 | }
94 | return "Successfully configure for Lambda use.";
95 | }
96 |
97 | @ShellMethod("Add a 'webflux' profile for Spring Cloud Functions")
98 | public String webfluxProfile() {
99 | try {
100 | Model model = reader.read(new FileReader(POM_FILE));
101 |
102 | // Update starters
103 | Profiles.removeWebfluxProfile(model);
104 | model.getProfiles().add(Profiles.webfluxProfile());
105 |
106 | // Write updated model to file
107 | MavenXpp3Writer writer = new MavenXpp3Writer();
108 | writer.write(new FileWriter(POM_FILE), model);
109 | }
110 | catch (XmlPullParserException | IOException e) {
111 | return "There was a problem updating for webflux functions.";
112 | }
113 | return "Successfully configured to use webflux functions";
114 | }
115 |
116 | @ShellMethod("Support for GraalVM native-image compiler.")
117 | public String nativeMavenPlugin() {
118 | try {
119 | Model model = reader.read(new FileReader(POM_FILE));
120 |
121 | // Update plugins
122 | Plugins.addNativeMavenPlugin(model);
123 |
124 | // Write updated model to file
125 | MavenXpp3Writer writer = new MavenXpp3Writer();
126 | writer.write(new FileWriter(POM_FILE), model);
127 |
128 | }
129 | catch (XmlPullParserException | IOException e) {
130 | return "There was a problem adding native-maven-plugin.";
131 | }
132 | return "Successfully added native-maven-plugin.";
133 | }
134 |
135 | @ShellMethod("Add multi-architecture builder support.")
136 | public String multiArchBuilder() {
137 | try {
138 | Model model = reader.read(new FileReader(POM_FILE));
139 |
140 | // Update plugins
141 | Plugins.addMultiArchBuilder(model);
142 |
143 | // Write updated model to file
144 | MavenXpp3Writer writer = new MavenXpp3Writer();
145 | writer.write(new FileWriter(POM_FILE), model);
146 |
147 | }
148 | catch (XmlPullParserException | IOException e) {
149 | return "There was a problem adding multi-architecture builder support.";
150 | }
151 | return "Successfully added multi-architecture builder support.";
152 | }
153 |
154 | @ShellMethod("Use Zulu JDK for spring-boot:build-image with JVM args")
155 | public String zuluBuilder() {
156 | try {
157 | Model model = reader.read(new FileReader(POM_FILE));
158 |
159 | // Update plugins
160 | Plugins.addZuluBuilder(model);
161 |
162 | // Write updated model to file
163 | MavenXpp3Writer writer = new MavenXpp3Writer();
164 | writer.write(new FileWriter(POM_FILE), model);
165 |
166 | }
167 | catch (XmlPullParserException | IOException e) {
168 | return "There was a problem adding multi-architecture builder support.";
169 | }
170 | return "Successfully added multi-architecture builder support.";
171 | }
172 |
173 | @ShellMethod("Add Spring Java Format Maven Plugin and validate goal.")
174 | public String springFormat() {
175 | try {
176 | Model model = reader.read(new FileReader(POM_FILE));
177 |
178 | // Update plugins
179 | Plugins.addSpringFormat(model);
180 |
181 | // Write updated model to file
182 | MavenXpp3Writer writer = new MavenXpp3Writer();
183 | writer.write(new FileWriter(POM_FILE), model);
184 | }
185 | catch (XmlPullParserException | IOException e) {
186 | return "There was a problem adding Spring Java Format Maven Plugin.";
187 | }
188 | return "Successfully added Spring Java Format Maven Plugin.";
189 | }
190 |
191 | @ShellMethod("Add Spring REST Docs")
192 | public String springRestDocs() {
193 | try {
194 | Model model = reader.read(new FileReader(POM_FILE));
195 |
196 | // Update plugins
197 | Plugins.addSpringRESTDocs(model);
198 |
199 | // Write updated model to file
200 | MavenXpp3Writer writer = new MavenXpp3Writer();
201 | writer.write(new FileWriter(POM_FILE), model);
202 | }
203 | catch (XmlPullParserException | IOException e) {
204 | return "There was a problem adding Spring REST docs.";
205 | }
206 | return "Successfully added Spring REST docs";
207 | }
208 |
209 | }
--------------------------------------------------------------------------------
/src/main/java/dev/dashaun/shell/initializr/plusplus/ReadMeCommands.java:
--------------------------------------------------------------------------------
1 | package dev.dashaun.shell.initializr.plusplus;
2 |
3 | import org.springframework.shell.standard.ShellComponent;
4 | import org.springframework.shell.standard.ShellMethod;
5 |
6 | import java.io.File;
7 | import java.io.IOException;
8 |
9 | import static dev.dashaun.shell.initializr.plusplus.Application.writeStringToFile;
10 |
11 | @ShellComponent
12 | public class ReadMeCommands {
13 |
14 | @ShellMethod("add ReadMe.md file")
15 | public String addReadMe() {
16 | try {
17 | writeFile();
18 | }
19 | catch (IOException ioException) {
20 | return "There was a problem adding pipeline configs";
21 | }
22 | return "Successfully added pipeline configs";
23 | }
24 |
25 | private void writeFile() throws IOException {
26 | File file = new File("./README.md");
27 | if (!file.exists()) {
28 | writeStringToFile(readMeDotMD(), file);
29 | }
30 | else {
31 | throw new IOException("File already exists");
32 | }
33 | }
34 |
35 | private String readMeDotMD() {
36 | return """
37 | [![Forks][forks-shield]][forks-url]
38 | [![Stargazers][stars-shield]][stars-url]
39 | [![Issues][issues-shield]][issues-url]
40 | # Project Name
41 | ## Prerequisites
42 | ## Quick Start
43 | ## Attributions
44 | ## Related Videos
45 |
46 |
47 | [forks-shield]: https://img.shields.io/github/forks/[org]/[repository-name].svg?style=for-the-badge
48 | [forks-url]: https://github.com/[org]/[repository-name]/forks
49 | [stars-shield]: https://img.shields.io/github/stars/[org]/[repository-name].svg?style=for-the-badge
50 | [stars-url]: https://github.com/[org]/[repository-name]/stargazers
51 | [issues-shield]: https://img.shields.io/github/issues/[org]/[repository-name].svg?style=for-the-badge
52 | [issues-url]: https://github.com/[org]/[repository-name]/issues
53 | [org]: dashaun
54 | [repository]: initializr-plusplus
55 | """;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/dev/dashaun/shell/initializr/plusplus/models/Dependencies.java:
--------------------------------------------------------------------------------
1 | package dev.dashaun.shell.initializr.plusplus.models;
2 |
3 | import org.apache.maven.model.Dependency;
4 | import org.apache.maven.model.Model;
5 |
6 | public class Dependencies {
7 |
8 | private final static String AWS_LAMBDA_JAVA_CORE = "aws-lambda-java-core";
9 |
10 | private final static String AWS_LAMBDA_JAVA_EVENTS = "aws-lambda-java-events";
11 |
12 | private final static String COM_DOT_AMAZONAWS = "com.amazonaws";
13 |
14 | private final static String SPRING_EXPERIMENTAL = "org.springframework.experimental";
15 |
16 | private final static String SPRING_NATIVE = "spring-native";
17 |
18 | private final static String SPRING_CLOUD_GROUP_ID = "org.springframework.cloud";
19 |
20 | private final static String SPRING_CLOUD_FUNCTION_AWS = "spring-cloud-function-adapter-aws";
21 |
22 | private final static String SPRING_CLOUD_FUNCTION_WEBFLUX = "spring-cloud-starter-function-webflux";
23 |
24 | private final static String SPRING_CLOUD_FUNCTION_CONTEXT = "spring-cloud-function-context";
25 |
26 | private final static String SPRING_NATIVE_VERSION_HOLDER = "${spring-native.version}";
27 |
28 | public static void removeFunctionStarters(Model model) {
29 | model.getDependencies()
30 | .removeIf(d -> (d.getGroupId().equalsIgnoreCase(SPRING_CLOUD_GROUP_ID)
31 | && d.getArtifactId().equalsIgnoreCase(SPRING_CLOUD_FUNCTION_CONTEXT)));
32 | model.getDependencies()
33 | .removeIf(d -> (d.getGroupId().equalsIgnoreCase(SPRING_CLOUD_GROUP_ID)
34 | && d.getArtifactId().equalsIgnoreCase(SPRING_CLOUD_FUNCTION_WEBFLUX)));
35 | model.getDependencies()
36 | .removeIf(d -> (d.getGroupId().equalsIgnoreCase(SPRING_CLOUD_GROUP_ID)
37 | && d.getArtifactId().equalsIgnoreCase(SPRING_CLOUD_FUNCTION_AWS)));
38 | }
39 |
40 | public static Dependency springNative() {
41 | Dependency u = new Dependency();
42 | u.setGroupId(SPRING_EXPERIMENTAL);
43 | u.setArtifactId(SPRING_NATIVE);
44 | u.setVersion(SPRING_NATIVE_VERSION_HOLDER);
45 | return u;
46 | }
47 |
48 | public static Dependency springRestdocsAsciidoctor() {
49 | Dependency u = new Dependency();
50 | u.setGroupId("org.springframework.restdocs");
51 | u.setArtifactId("spring-restdocs-asciidoctor");
52 | u.setVersion("${spring-restdocs.version}");
53 | return u;
54 | }
55 |
56 | public static Dependency awsJavaEvents() {
57 | Dependency u = new Dependency();
58 | u.setGroupId(COM_DOT_AMAZONAWS);
59 | u.setArtifactId(AWS_LAMBDA_JAVA_EVENTS);
60 | u.setVersion("3.11.0");
61 | u.setScope("provided");
62 | return u;
63 | }
64 |
65 | public static Dependency awsJavaCore() {
66 | Dependency u = new Dependency();
67 | u.setGroupId(COM_DOT_AMAZONAWS);
68 | u.setArtifactId(AWS_LAMBDA_JAVA_CORE);
69 | u.setVersion("1.1.0");
70 | u.setScope("provided");
71 | return u;
72 | }
73 |
74 | public static Dependency webfluxStarter() {
75 | Dependency u = new Dependency();
76 | u.setGroupId(SPRING_CLOUD_GROUP_ID);
77 | u.setArtifactId(SPRING_CLOUD_FUNCTION_WEBFLUX);
78 | return u;
79 | }
80 |
81 | public static Dependency awsStarter() {
82 | Dependency u = new Dependency();
83 | u.setGroupId(SPRING_CLOUD_GROUP_ID);
84 | u.setArtifactId(SPRING_CLOUD_FUNCTION_AWS);
85 | return u;
86 | }
87 |
88 | public static Dependency junitPlatformLauncher() {
89 | Dependency d = new Dependency();
90 | d.setGroupId("org.junit.platform");
91 | d.setArtifactId("junit-platform-launcher");
92 | d.setScope("test");
93 | return d;
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/dev/dashaun/shell/initializr/plusplus/models/Plugins.java:
--------------------------------------------------------------------------------
1 | package dev.dashaun.shell.initializr.plusplus.models;
2 |
3 | import org.apache.maven.model.Model;
4 | import org.apache.maven.model.Plugin;
5 | import org.apache.maven.model.PluginExecution;
6 | import org.codehaus.plexus.util.xml.Xpp3Dom;
7 |
8 | import java.util.List;
9 |
10 | public class Plugins {
11 |
12 | private static final String MAVEN_ASSEMBLY_PLUGIN = "maven-assembly-plugin";
13 |
14 | private static final String SPRING_BOOT_GROUP_ID = "org.springframework.boot";
15 |
16 | private final static String SPRING_EXPERIMENTAL_GROUP_ID = "org.springframework.experimental";
17 |
18 | private final static String SPRING_AOT_MAVEN_PLUGIN = "spring-aot-maven-plugin";
19 |
20 | private final static String SPRING_BOOT_MAVEN_PLUGIN = "spring-boot-maven-plugin";
21 |
22 | private final static String GRAALVM_BUILDTOOLS_GROUP_ID = "org.graalvm.buildtools";
23 |
24 | private final static String NATIVE_MAVEN_PLUGIN = "native-maven-plugin";
25 |
26 | private final static String ORG_ASCIIDOCTOR = "org.asciidoctor";
27 |
28 | private final static String ASCIIDOCTOR_MAVEN_PLUGIN = "asciidoctor-maven-plugin";
29 |
30 | @Deprecated
31 | public static void removeNativePlugins(Model model) {
32 | model.getBuild()
33 | .getPlugins()
34 | .removeIf(p -> p.getGroupId().equalsIgnoreCase(SPRING_BOOT_GROUP_ID)
35 | && p.getArtifactId().equalsIgnoreCase(SPRING_BOOT_MAVEN_PLUGIN));
36 | model.getBuild()
37 | .getPlugins()
38 | .removeIf(p -> p.getGroupId().equalsIgnoreCase(SPRING_EXPERIMENTAL_GROUP_ID)
39 | && p.getArtifactId().equalsIgnoreCase(SPRING_AOT_MAVEN_PLUGIN));
40 | model.getBuild().getPlugins().removeIf(p -> p.getArtifactId().equalsIgnoreCase(MAVEN_ASSEMBLY_PLUGIN));
41 | }
42 |
43 | public static boolean hasSpringBootMavenPlugin(Model model) {
44 | return model.getBuild()
45 | .getPlugins()
46 | .stream()
47 | .anyMatch(p -> p.getGroupId().equalsIgnoreCase(SPRING_BOOT_GROUP_ID)
48 | && p.getArtifactId().equalsIgnoreCase(SPRING_BOOT_MAVEN_PLUGIN));
49 | }
50 |
51 | public static void addNativeMavenPlugin(Model model) {
52 | model.getBuild()
53 | .getPlugins()
54 | .removeIf(p -> p.getGroupId().equalsIgnoreCase(GRAALVM_BUILDTOOLS_GROUP_ID)
55 | && p.getArtifactId().equalsIgnoreCase(NATIVE_MAVEN_PLUGIN));
56 | model.getBuild().getPlugins().add(Plugins.nativeMavenPlugin());
57 | }
58 |
59 | public static void addMultiArchBuilder(Model model) {
60 | model.getBuild()
61 | .getPlugins()
62 | .removeIf(p -> p.getGroupId().equalsIgnoreCase(SPRING_BOOT_GROUP_ID)
63 | && p.getArtifactId().equalsIgnoreCase(SPRING_BOOT_MAVEN_PLUGIN));
64 | model.getBuild().getPlugins().add(Plugins.multiArchBuilder());
65 | }
66 |
67 | public static void addZuluBuilder(Model model) {
68 | model.getBuild()
69 | .getPlugins()
70 | .removeIf(p -> p.getGroupId().equalsIgnoreCase(SPRING_BOOT_GROUP_ID)
71 | && p.getArtifactId().equalsIgnoreCase(SPRING_BOOT_MAVEN_PLUGIN));
72 | model.getBuild().getPlugins().add(Plugins.zuluBuilder());
73 | }
74 |
75 | public static void addSpringFormat(Model model) {
76 | model.getBuild()
77 | .getPlugins()
78 | .removeIf(p -> p.getGroupId().equalsIgnoreCase("io.spring.javaformat")
79 | && p.getArtifactId().equalsIgnoreCase("spring-javaformat-maven-plugin"));
80 | model.getBuild().getPlugins().add(Plugins.springFormat());
81 | }
82 |
83 | public static void addSpringRESTDocs(Model model) {
84 | model.getBuild()
85 | .getPlugins()
86 | .removeIf(p -> p.getGroupId().equalsIgnoreCase(ORG_ASCIIDOCTOR)
87 | && p.getArtifactId().equalsIgnoreCase(ASCIIDOCTOR_MAVEN_PLUGIN));
88 | model.getBuild().getPlugins().add(Plugins.springRestDocs());
89 | }
90 |
91 | public static Plugin springBootMavenPlugin() {
92 | Plugin p = new Plugin();
93 | p.setGroupId(SPRING_BOOT_GROUP_ID);
94 | p.setArtifactId(SPRING_BOOT_MAVEN_PLUGIN);
95 | Xpp3Dom c = new Xpp3Dom("configuration");
96 | Xpp3Dom classifier = new Xpp3Dom("classifier");
97 | classifier.setValue("${repackage.classifier}");
98 | c.addChild(classifier);
99 | p.setConfiguration(c);
100 | return p;
101 | }
102 |
103 | public static Plugin springBootMavenPluginTinyBuildpack() {
104 | Plugin p = new Plugin();
105 | p.setGroupId(SPRING_BOOT_GROUP_ID);
106 | p.setArtifactId(SPRING_BOOT_MAVEN_PLUGIN);
107 | Xpp3Dom c = new Xpp3Dom("configuration");
108 | Xpp3Dom classifier = new Xpp3Dom("classifier");
109 | c.addChild(classifier);
110 | Xpp3Dom image = new Xpp3Dom("image");
111 | Xpp3Dom builder = new Xpp3Dom("builder");
112 | builder.setValue("paketobuildpacks/builder:tiny");
113 | image.addChild(builder);
114 | Xpp3Dom env = new Xpp3Dom("env");
115 | Xpp3Dom bpNativeImage = new Xpp3Dom("BP_NATIVE_IMAGE");
116 | bpNativeImage.setValue("true");
117 | env.addChild(bpNativeImage);
118 | image.addChild(env);
119 | c.addChild(image);
120 | p.setConfiguration(c);
121 | return p;
122 | }
123 |
124 | @Deprecated
125 | public static Plugin springBootAotPlugin() {
126 | Plugin p = new Plugin();
127 | p.setGroupId(SPRING_EXPERIMENTAL_GROUP_ID);
128 | p.setArtifactId(SPRING_AOT_MAVEN_PLUGIN);
129 | p.setVersion("${spring-native.version}");
130 |
131 | p.getExecutions().add(generate());
132 | p.getExecutions().add(testGenerate());
133 |
134 | Xpp3Dom configuration = new Xpp3Dom("configuration");
135 | Xpp3Dom removeYamlSupport = new Xpp3Dom("removeYamlSupport");
136 | removeYamlSupport.setValue("true");
137 | configuration.addChild(removeYamlSupport);
138 | p.setConfiguration(configuration);
139 |
140 | return p;
141 | }
142 |
143 | public static Plugin multiArchBuilder() {
144 | Plugin p = new Plugin();
145 | p.setGroupId(SPRING_BOOT_GROUP_ID);
146 | p.setArtifactId(SPRING_BOOT_MAVEN_PLUGIN);
147 |
148 | Xpp3Dom configuration = new Xpp3Dom("configuration");
149 | Xpp3Dom image = new Xpp3Dom("image");
150 | Xpp3Dom builder = new Xpp3Dom("builder");
151 | Xpp3Dom buildpacks = new Xpp3Dom("buildpacks");
152 | Xpp3Dom buildpack = new Xpp3Dom("buildpack");
153 | Xpp3Dom createdDate = new Xpp3Dom("createdDate");
154 | Xpp3Dom name = new Xpp3Dom("name");
155 | builder.setValue("paketobuildpacks/builder-jammy-buildpackless-tiny");
156 | buildpack.setValue("paketobuildpacks/java-native-image");
157 | buildpacks.addChild(buildpack);
158 | createdDate.setValue("now");
159 | name.setValue("dashaun/${project.name}:v${project.version}-${os.detected.arch}");
160 | image.addChild(builder);
161 | image.addChild(buildpacks);
162 | image.addChild(createdDate);
163 | image.addChild(name);
164 | configuration.addChild(image);
165 |
166 | p.setConfiguration(configuration);
167 |
168 | PluginExecution execution = new PluginExecution();
169 | execution.setId("build-info");
170 | execution.addGoal("build-info");
171 | p.setExecutions(List.of(execution));
172 | return p;
173 | }
174 |
175 | public static Plugin zuluBuilder() {
176 | Plugin p = new Plugin();
177 | p.setGroupId(SPRING_BOOT_GROUP_ID);
178 | p.setArtifactId(SPRING_BOOT_MAVEN_PLUGIN);
179 |
180 | Xpp3Dom configuration = new Xpp3Dom("configuration");
181 | Xpp3Dom image = new Xpp3Dom("image");
182 | Xpp3Dom buildpacks = new Xpp3Dom("buildpacks");
183 | Xpp3Dom zuluBuildpack = new Xpp3Dom("buildpack");
184 | zuluBuildpack.setValue("paketobuildpacks/azul-zulu");
185 | Xpp3Dom javaBuildpack = new Xpp3Dom("buildpack");
186 | javaBuildpack.setValue("paketobuildpacks/java");
187 | buildpacks.addChild(zuluBuildpack);
188 | buildpacks.addChild(javaBuildpack);
189 | image.addChild(buildpacks);
190 |
191 | Xpp3Dom env = new Xpp3Dom("env");
192 | Xpp3Dom xmlSpace = new Xpp3Dom("BPE_DELIM_JAVA_TOOL_OPTIONS");
193 | xmlSpace.setAttribute("xml:space", "preserve");
194 | xmlSpace.setValue(" ");
195 | Xpp3Dom javaOptions = new Xpp3Dom("BPE_APPEND_JAVA_TOOL_OPTIONS");
196 | javaOptions.setValue("-Xlog:gc:gc.log");
197 | env.addChild(xmlSpace);
198 | env.addChild(javaOptions);
199 | image.addChild(env);
200 |
201 | configuration.addChild(image);
202 |
203 | p.setConfiguration(configuration);
204 | return p;
205 | }
206 |
207 | public static Plugin springFormat() {
208 | Plugin p = new Plugin();
209 | p.setGroupId("io.spring.javaformat");
210 | p.setArtifactId("spring-javaformat-maven-plugin");
211 | p.setVersion("0.0.40");
212 | p.getExecutions().add(validate());
213 | return p;
214 | }
215 |
216 | public static Plugin springRestDocs() {
217 | Plugin p = new Plugin();
218 | p.setGroupId(ORG_ASCIIDOCTOR);
219 | p.setArtifactId(ASCIIDOCTOR_MAVEN_PLUGIN);
220 | p.setVersion("2.2.1");
221 | p.getExecutions().add(generateDocs());
222 |
223 | p.getDependencies().add(Dependencies.springRestdocsAsciidoctor());
224 |
225 | return p;
226 |
227 | }
228 |
229 | public static Plugin nativeMavenPlugin() {
230 | Plugin p = new Plugin();
231 | p.setGroupId("org.graalvm.buildtools");
232 | p.setArtifactId("native-maven-plugin");
233 | return p;
234 | }
235 |
236 | public static Plugin mavenAssemblyPluginJava() {
237 | Plugin p = new Plugin();
238 | p.setArtifactId("maven-assembly-plugin");
239 | p.getExecutions().add(javaZip());
240 |
241 | Xpp3Dom configuration = new Xpp3Dom("configuration");
242 | Xpp3Dom descriptors = new Xpp3Dom("descriptors");
243 | Xpp3Dom descriptor = new Xpp3Dom("descriptor");
244 | descriptor.setValue("src/assembly/java.xml");
245 | descriptors.addChild(descriptor);
246 | configuration.addChild(descriptors);
247 |
248 | p.setConfiguration(configuration);
249 | return p;
250 | }
251 |
252 | public static Plugin mavenAssemblyPluginNative() {
253 | Plugin p = new Plugin();
254 | p.setArtifactId(MAVEN_ASSEMBLY_PLUGIN);
255 | p.getExecutions().add(nativeZip());
256 |
257 | Xpp3Dom configuration = new Xpp3Dom("configuration");
258 | Xpp3Dom descriptors = new Xpp3Dom("descriptors");
259 | Xpp3Dom descriptor = new Xpp3Dom("descriptor");
260 | descriptor.setValue("src/assembly/native.xml");
261 | descriptors.addChild(descriptor);
262 | configuration.addChild(descriptors);
263 |
264 | p.setConfiguration(configuration);
265 | return p;
266 | }
267 |
268 | private static PluginExecution validate() {
269 | PluginExecution validate = new PluginExecution();
270 | validate.setId("validate");
271 | validate.setPhase("validate");
272 | validate.setInherited(true);
273 | validate.getGoals().add("validate");
274 | return validate;
275 | }
276 |
277 | private static PluginExecution generate() {
278 | PluginExecution generate = new PluginExecution();
279 | generate.setId("generate");
280 | generate.getGoals().add("generate");
281 | return generate;
282 | }
283 |
284 | private static PluginExecution generateDocs() {
285 | PluginExecution generateDocs = new PluginExecution();
286 | generateDocs.setId("generate-docs");
287 | generateDocs.setPhase("prepare-package");
288 | generateDocs.getGoals().add("process-asciidoc");
289 |
290 | Xpp3Dom configuration = new Xpp3Dom("configuration");
291 | Xpp3Dom backend = new Xpp3Dom("backend");
292 | backend.setValue("html");
293 | Xpp3Dom doctype = new Xpp3Dom("doctype");
294 | doctype.setValue("book");
295 | configuration.addChild(backend);
296 | configuration.addChild(doctype);
297 |
298 | generateDocs.setConfiguration(configuration);
299 | return generateDocs;
300 | }
301 |
302 | private static PluginExecution testGenerate() {
303 | PluginExecution testGenerate = new PluginExecution();
304 | testGenerate.setId("test-generate");
305 | testGenerate.getGoals().add("test-generate");
306 | return testGenerate;
307 | }
308 |
309 | @Deprecated
310 | private static PluginExecution buildNative() {
311 | PluginExecution tn = new PluginExecution();
312 | tn.setId("build-native");
313 | tn.setPhase("package");
314 | tn.getGoals().add("build");
315 | return tn;
316 | }
317 |
318 | @Deprecated
319 | private static PluginExecution testNative() {
320 | PluginExecution tn = new PluginExecution();
321 | tn.setId("test-native");
322 | tn.setPhase("test");
323 | tn.getGoals().add("test");
324 | return tn;
325 | }
326 |
327 | private static PluginExecution javaZip() {
328 | PluginExecution javaZip = new PluginExecution();
329 | javaZip.setId("java-zip");
330 | javaZip.setPhase("package");
331 | javaZip.setInherited(false);
332 | javaZip.getGoals().add("single");
333 | return javaZip;
334 | }
335 |
336 | private static PluginExecution nativeZip() {
337 | PluginExecution nativeZip = new PluginExecution();
338 | nativeZip.setId("native-zip");
339 | nativeZip.setPhase("package");
340 | nativeZip.setInherited(false);
341 | nativeZip.getGoals().add("single");
342 | return nativeZip;
343 | }
344 |
345 | }
346 |
--------------------------------------------------------------------------------
/src/main/java/dev/dashaun/shell/initializr/plusplus/models/Profiles.java:
--------------------------------------------------------------------------------
1 | package dev.dashaun.shell.initializr.plusplus.models;
2 |
3 | import org.apache.maven.model.BuildBase;
4 | import org.apache.maven.model.Model;
5 | import org.apache.maven.model.Profile;
6 |
7 | public class Profiles {
8 |
9 | private static final String LAMBDA_PROFILE_ID = "lambda";
10 |
11 | private static final String NATIVE_PROFILE_ID = "native";
12 |
13 | private static final String WEBFLUX_PROFILE_ID = "webflux";
14 |
15 | private static final String TINY_BUILDPACK_ID = "tiny-buildpack";
16 |
17 | @Deprecated
18 | public static void removeNativeProfile(Model model) {
19 | // Remove existing profile
20 | model.getProfiles().removeIf(p -> p.getId().equalsIgnoreCase(NATIVE_PROFILE_ID));
21 | }
22 |
23 | @Deprecated
24 | public static Profile nativeProfile() {
25 | Profile p = new Profile();
26 | p.setId(NATIVE_PROFILE_ID);
27 |
28 | // Set properties
29 | Properties.nativeProfileProperties(p);
30 |
31 | p.getRepositories().add(Repositories.springReleases());
32 | p.getPluginRepositories().add(Repositories.springReleases());
33 |
34 | // Add dependencies
35 | p.getDependencies().add(Dependencies.junitPlatformLauncher());
36 | p.getDependencies().add(Dependencies.springNative());
37 |
38 | // Add Build section
39 | p.setBuild(new BuildBase());
40 | // Add Build Plugins
41 | p.getBuild().addPlugin(Plugins.springBootMavenPlugin());
42 | p.getBuild().addPlugin(Plugins.springBootAotPlugin());
43 | p.getBuild().getPlugins().add(Plugins.nativeMavenPlugin());
44 | return p;
45 | }
46 |
47 | public static void removeLambdaProfile(Model model) {
48 | model.getProfiles().removeIf(p -> p.getId().equalsIgnoreCase(LAMBDA_PROFILE_ID));
49 | }
50 |
51 | public static Profile lambdaProfile() {
52 | Profile p = new Profile();
53 | p.setId(LAMBDA_PROFILE_ID);
54 |
55 | // Update starters
56 | p.getDependencies().add(Dependencies.awsStarter());
57 | p.getDependencies().add(Dependencies.awsJavaCore());
58 | p.getDependencies().add(Dependencies.awsJavaEvents());
59 |
60 | // Build section
61 | p.setBuild(new BuildBase());
62 | // Add Build Plugins
63 | p.getBuild().addPlugin(Plugins.mavenAssemblyPluginNative());
64 |
65 | return p;
66 | }
67 |
68 | public static void removeWebfluxProfile(Model model) {
69 | model.getProfiles().removeIf(p -> p.getId().equalsIgnoreCase(WEBFLUX_PROFILE_ID));
70 | }
71 |
72 | public static Profile webfluxProfile() {
73 | Profile p = new Profile();
74 | p.setId(WEBFLUX_PROFILE_ID);
75 |
76 | // Add dependencies
77 | p.getDependencies().add(Dependencies.webfluxStarter());
78 | return p;
79 | }
80 |
81 | public static void removeTinyBuildpackProfile(Model model) {
82 | model.getProfiles().removeIf(p -> p.getId().equalsIgnoreCase(TINY_BUILDPACK_ID));
83 | }
84 |
85 | public static Profile tinyBuildpackProfile() {
86 | Profile p = new Profile();
87 | p.setId(TINY_BUILDPACK_ID);
88 |
89 | Properties.buildpackProperties(p);
90 |
91 | // Add Build section
92 | p.setBuild(new BuildBase());
93 | // Add Build Plugins
94 | p.getBuild().addPlugin(Plugins.springBootMavenPluginTinyBuildpack());
95 |
96 | return p;
97 | }
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/src/main/java/dev/dashaun/shell/initializr/plusplus/models/Properties.java:
--------------------------------------------------------------------------------
1 | package dev.dashaun.shell.initializr.plusplus.models;
2 |
3 | import org.apache.maven.model.Model;
4 | import org.apache.maven.model.Profile;
5 |
6 | public class Properties {
7 |
8 | private final static String MAVEN_TEST_SKIP = "maven.test.skip";
9 |
10 | private final static String EXEC = "exec";
11 |
12 | private final static String REPACKAGE_CLASSIFIER = "repackage.classifier";
13 |
14 | private final static String SPRING_NATIVE_VERSION = "spring-native.version";
15 |
16 | private final static String SPRING_NATIVE_VERSION_VAL = "0.11.5";
17 |
18 | private final static String NATIVE_BUILDTOOLS_VERSION = "native-buildtools.version";
19 |
20 | private final static String NATIVE_BUILDTOOLS_VERSION_VAL = "0.9.11";
21 |
22 | private final static String SPRING_CLOUD_FUNCTION_VERSION = "spring-cloud-function.version";
23 |
24 | private final static String SPRING_CLOUD_FUNCTION_VERSION_VAL = "3.2.4";
25 |
26 | private final static String WRAPPER_VERSION = "wrapper.version";
27 |
28 | private final static String WRAPPER_VERSION_VAL = "1.0.27.RELEASE";
29 |
30 | private final static String AWS_LAMBDA_EVENTS = "aws-lambda-events.version";
31 |
32 | private final static String AWS_LAMBDA_EVENTS_VAL = "3.9.0";
33 |
34 | public static void awsProperties(Model model) {
35 | model.getProperties().setProperty(WRAPPER_VERSION, WRAPPER_VERSION_VAL);
36 | model.getProperties().setProperty(AWS_LAMBDA_EVENTS, AWS_LAMBDA_EVENTS_VAL);
37 | model.getProperties().setProperty(SPRING_CLOUD_FUNCTION_VERSION, SPRING_CLOUD_FUNCTION_VERSION_VAL);
38 | }
39 |
40 | public static void nativeProfileProperties(Profile p) {
41 | p.getProperties().setProperty(MAVEN_TEST_SKIP, "true");
42 | p.getProperties().setProperty(REPACKAGE_CLASSIFIER, EXEC);
43 | p.getProperties().setProperty(SPRING_NATIVE_VERSION, SPRING_NATIVE_VERSION_VAL);
44 | p.getProperties().setProperty(NATIVE_BUILDTOOLS_VERSION, NATIVE_BUILDTOOLS_VERSION_VAL);
45 | }
46 |
47 | public static void buildpackProperties(Profile p) {
48 | p.getProperties().setProperty(MAVEN_TEST_SKIP, "true");
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/dev/dashaun/shell/initializr/plusplus/models/Repositories.java:
--------------------------------------------------------------------------------
1 | package dev.dashaun.shell.initializr.plusplus.models;
2 |
3 | import org.apache.maven.model.Model;
4 | import org.apache.maven.model.Repository;
5 | import org.apache.maven.model.RepositoryPolicy;
6 |
7 | public class Repositories {
8 |
9 | private static final String SPRING_RELEASES = "spring-releases";
10 |
11 | private static final String SPRING_RELEASES_NAME = "Spring Releases";
12 |
13 | private static final String SPRING_RELEASES_URL = "https://repo.spring.io/release";
14 |
15 | public static void removeSpringReleases(Model model) {
16 | model.getRepositories().removeIf(r -> r.getId().equalsIgnoreCase(SPRING_RELEASES));
17 | model.getPluginRepositories().removeIf(pr -> pr.getId().equalsIgnoreCase(SPRING_RELEASES));
18 | }
19 |
20 | public static Repository springReleases() {
21 | Repository springReleases = new Repository();
22 | springReleases.setId(SPRING_RELEASES);
23 | springReleases.setName(SPRING_RELEASES_NAME);
24 | springReleases.setUrl(SPRING_RELEASES_URL);
25 | RepositoryPolicy rp = new RepositoryPolicy();
26 | rp.setEnabled(false);
27 | springReleases.setSnapshots(rp);
28 | return springReleases;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | logging:
2 | level:
3 | root: 'off'
4 |
5 | spring:
6 | main:
7 | banner-mode: 'off'
8 | web-application-type: 'NONE'
9 | shell:
10 | history:
11 | enabled: 'false'
--------------------------------------------------------------------------------
/src/test/java/dev/dashaun/shell/initializr/plusplus/ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package dev.dashaun.shell.initializr.plusplus;
2 |
3 | import org.springframework.boot.test.context.SpringBootTest;
4 |
5 | @SpringBootTest(properties = { "spring.shell.interactive.enabled=false" })
6 | public class ApplicationTests {
7 |
8 | //
9 | // @Autowired
10 | // private CommandRegistry commandRegistry;
11 | //
12 | // @Test
13 | // public void jgitver() {
14 | // final String command = "jgitver";
15 | // final MethodTarget commandTarget = lookupCommand(commandRegistry, command);
16 | // assertThat(commandTarget).isNotNull();
17 | // }
18 | //
19 | // @Test
20 | // public void projectDescription() {
21 | // final String command = "project-description";
22 | // final MethodTarget commandTarget = lookupCommand(commandRegistry, command);
23 | // assertThat(commandTarget).isNotNull();
24 | // }
25 | //
26 | // @Test
27 | // public void projectName() {
28 | // final String command = "project-name";
29 | // final MethodTarget commandTarget = lookupCommand(commandRegistry, command);
30 | // assertThat(commandTarget).isNotNull();
31 | // }
32 | //
33 | // @Test
34 | // public void projectVersion() {
35 | // final String command = "project-version";
36 | // final MethodTarget commandTarget = lookupCommand(commandRegistry, command);
37 | // assertThat(commandTarget).isNotNull();
38 | // }
39 | //
40 | // protected MethodTarget lookupCommand(@NotNull final CommandRegistry registry,
41 | // @NotNull final String command) {
42 | // return registry.listCommands().get(command);
43 | // }
44 |
45 | }
--------------------------------------------------------------------------------