├── .github ├── dependabot.yml └── workflows │ ├── add-to-projects.yml │ ├── test.yml │ └── triggerConversion.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.adoc ├── finish ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── openliberty │ │ │ └── guides │ │ │ └── hello │ │ │ └── HelloServlet.java │ ├── liberty │ │ └── config │ │ │ └── server.xml │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── index.html │ └── test │ └── java │ └── io │ └── openliberty │ └── guides │ └── hello │ └── it │ └── EndpointIT.java ├── scripts ├── dailyBuild.sh └── testApp.sh └── start ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd └── src ├── main ├── java │ └── io │ │ └── openliberty │ │ └── guides │ │ └── hello │ │ └── HelloServlet.java ├── liberty │ └── config │ │ └── server.xml └── webapp │ ├── WEB-INF │ └── web.xml │ └── index.html └── test └── java └── io └── openliberty └── guides └── hello └── it └── .gitkeep /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: maven 4 | directory: "/finish" 5 | schedule: 6 | interval: monthly 7 | open-pull-requests-limit: 50 8 | - package-ecosystem: maven 9 | directory: "/start" 10 | schedule: 11 | interval: monthly 12 | open-pull-requests-limit: 50 13 | -------------------------------------------------------------------------------- /.github/workflows/add-to-projects.yml: -------------------------------------------------------------------------------- 1 | name: Add issues to Liberty guides backlog project 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | - transferred 8 | 9 | jobs: 10 | add-to-project: 11 | name: Add issue to backlog 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/add-to-project@v0.4.0 15 | with: 16 | project-url: https://github.com/orgs/OpenLiberty/projects/11 17 | github-token: ${{ secrets.ADMIN_BACKLOG }} 18 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test application 2 | 3 | on: 4 | pull_request: 5 | branches: [ prod, staging ] 6 | 7 | jobs: 8 | check-files: 9 | if: ${{ github.event_name == 'pull_request' }} 10 | runs-on: ubuntu-latest 11 | outputs: 12 | canSkip: ${{ steps.Checker.outputs.canSkip }} 13 | steps: 14 | - name: Get files 15 | uses: actions/checkout@v4 16 | - name: Get tools 17 | uses: actions/checkout@v4 18 | with: 19 | path: tools/ 20 | repository: openliberty/guides-common 21 | - id: Checker 22 | shell: bash 23 | run: bash ./tools/pr-checker/checker.sh ${{ github.repository }} ${{ github.event.pull_request.number }} | tee checker.log 24 | - id: Lint-Code-Base 25 | if: "! github.event.pull_request.head.repo.fork" 26 | uses: github/super-linter@latest 27 | env: 28 | VALIDATE_ALL_CODEBASE: false 29 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 30 | FILTER_REGEX_EXCLUDE: mvnw* 31 | LINTER_RULES_PATH: ./tools/pr-checker/linters/ 32 | DEFAULT_BRANCH: prod 33 | - name: Summary 34 | if: "! github.event.pull_request.head.repo.fork" 35 | run: | 36 | < ./checker.log tail -n +2; echo "====== Super Linter ======" 37 | < ./super-linter.log sed -n '/.*The script has completed.*/,$p' | tail -n +4 | sed 's/.*\(\[[A-Z]\+\]\)/\1/' 38 | echo "====== Examine logs in Checker and Super-Linter steps for more details ======" 39 | if [ '${{ steps.Checker.outcome }}' != 'success' ] || [ '${{ steps.Lint-Code-Base.outcome }}' != 'success' ]; then exit 1; fi 40 | test-app: 41 | runs-on: ubuntu-latest 42 | needs: [check-files] 43 | if: "!contains(needs.check-files.outputs.canSkip, 'true')" 44 | defaults: 45 | run: 46 | working-directory: finish 47 | steps: 48 | - uses: actions/checkout@v4 49 | - name: Set up JDK 11 50 | uses: actions/setup-java@v4 51 | with: 52 | distribution: 'semeru' 53 | java-version: 11 54 | - run: unset _JAVA_OPTIONS 55 | - name: Run tests 56 | run: ../scripts/testApp.sh 57 | - name: Post tests 58 | if: always() 59 | run: | 60 | logsPath=$(sudo find . -name "console.log"); 61 | sudo cat "$logsPath" | grep Launching 62 | - name: Archive server logs if failed 63 | if: failure() 64 | uses: actions/upload-artifact@v4 65 | with: 66 | name: server-logs 67 | path: finish/target/liberty/wlp/usr/servers/guideServer/logs/ 68 | -------------------------------------------------------------------------------- /.github/workflows/triggerConversion.yml: -------------------------------------------------------------------------------- 1 | name: Rebuild cloud-hosted guide 2 | 3 | # Controls when the action will run. Triggers the workflow on push 4 | # events but only for the main branch 5 | on: 6 | push: 7 | branches: 8 | - 'prod' 9 | - 'staging' 10 | 11 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 12 | jobs: 13 | # This workflow contains a single job called "post" 14 | post: 15 | # The type of runner that the job will run on 16 | runs-on: ubuntu-latest 17 | 18 | # Steps represent a sequence of tasks that will be executed as part of the job 19 | steps: 20 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 21 | # Uses the secrets from the organisation for credentials 22 | - uses: actions/checkout@v2 23 | 24 | - name: Invoke workflow in another repo with inputs 25 | uses: benc-uk/workflow-dispatch@v1 26 | with: 27 | workflow: GuideConverter 28 | repo: OpenLiberty/cloud-hosted-guides 29 | token: ${{ secrets.GUIDECONVERSIONTOOL_PASSWORD }} 30 | inputs: '{ "branch": "${{ github.ref }}", "guide_name": "${{ github.event.repository.name }}" }' 31 | ref: "refs/heads/prod" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | 3 | # Eclipse generated 4 | .apt_generated/ 5 | .settings/ 6 | .project 7 | .classpath 8 | .factorypath 9 | MANIFEST.MF 10 | 11 | # MacOS system files 12 | .DS_Store 13 | 14 | # Asciidoc rendered 15 | README.html -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Open Liberty guides 2 | 3 | Anyone can contribute to the Open Liberty guides and we welcome your contributions! 4 | 5 | There are multiple ways to contribute: report bugs, fix bugs, contribute code, improve upon documentation, etc. 6 | 7 | ## Raising issues 8 | 9 | Please raise any bug reports in this [guide repository](../../issues). For new topics, large updates to existing guides, or general suggestions and ideas, report your issue in the [Open Liberty common guides repository](https://github.com/OpenLiberty/guides-common/issues). Be sure to search the list of open issues to see if your issue has already been raised. 10 | 11 | A good bug report makes it easy for everyone to understand what you were trying to do and what went wrong. Provide as much context as possible so we can try to recreate the issue. 12 | 13 | ## Contributions 14 | 15 | Contributing to an Open Liberty guide is simple. Each guide is maintained in its own GitHub repository. To contribute, just fork from the `prod` branch for your chosen guide. Then create a branch in your forked repository to include your contribution and open a pull request to the `staging` branch for the guide. 16 | Certify the originality of your work by following the [Developer Certificate of Origin (DCO)](https://developercertificate.org) approach and adding a line to the end of the Git commit message to sign your work: 17 | 18 | ```text 19 | Signed-off-by: Jane Williams 20 | ``` 21 | 22 | The sign-off is just a line at the end of the commit message that certifies that you wrote it or otherwise have the right to pass it on as an open source patch. 23 | 24 | Use your real name when you sign. We can't accept pseudonyms or anonymous contributions. 25 | 26 | Many Git UI tools have support for adding the `Signed-off-by` line to the end of your commit message. This line can be automatically added by the `git commit` command by using the `-s` option. 27 | 28 | The team is then notified and your contribution is reviewed according to the following process: 29 | 30 | 1. The team will review your change(s). 31 | - If there are further changes to be made, the team will request changes on the pull request. 32 | - If the team does not agree with the change, the PR will be closed with an explanation and suggestion for follow-up. 33 | 2. If the team approves, the team will merge your PR. A full Open Liberty staging site build will be run. 34 | 3. Based on the results of the build: 35 | - If further review is needed, we will let you know about a pending review from our team and discuss any necessary improvements that need to be made to your change(s). 36 | - If everything is successful, the team will publish your change(s) to the `prod` branch and update the Open Liberty production site, if necessary. 37 | 38 | ## Questions and concerns 39 | 40 | If you have any questions or concerns about the guides or about Open Liberty, you can visit [Gitter for Open Liberty](https://gitter.im/OpenLiberty/) and post your questions in the relevant rooms. You can also join the Open Liberty group on [Groups.io](https://groups.io/g/openliberty) to discuss any issues you have. 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Code and build scripts are licensed under the Eclipse Public License v2 2 | 3 | Documentation files (e.g. files with an adoc file extension) are licensed under 4 | Creative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0) 5 | 6 | Eclipse Public License - v 2.0 7 | 8 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE 9 | PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION 10 | OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 11 | 12 | 1. DEFINITIONS 13 | 14 | "Contribution" means: 15 | 16 | a) in the case of the initial Contributor, the initial content 17 | Distributed under this Agreement, and 18 | 19 | b) in the case of each subsequent Contributor: 20 | i) changes to the Program, and 21 | ii) additions to the Program; 22 | where such changes and/or additions to the Program originate from 23 | and are Distributed by that particular Contributor. A Contribution 24 | "originates" from a Contributor if it was added to the Program by 25 | such Contributor itself or anyone acting on such Contributor's behalf. 26 | Contributions do not include changes or additions to the Program that 27 | are not Modified Works. 28 | 29 | "Contributor" means any person or entity that Distributes the Program. 30 | 31 | "Licensed Patents" mean patent claims licensable by a Contributor which 32 | are necessarily infringed by the use or sale of its Contribution alone 33 | or when combined with the Program. 34 | 35 | "Program" means the Contributions Distributed in accordance with this 36 | Agreement. 37 | 38 | "Recipient" means anyone who receives the Program under this Agreement 39 | or any Secondary License (as applicable), including Contributors. 40 | 41 | "Derivative Works" shall mean any work, whether in Source Code or other 42 | form, that is based on (or derived from) the Program and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. 45 | 46 | "Modified Works" shall mean any work in Source Code or other form that 47 | results from an addition to, deletion from, or modification of the 48 | contents of the Program, including, for purposes of clarity any new file 49 | in Source Code form that contains any contents of the Program. Modified 50 | Works shall not include works that contain only declarations, 51 | interfaces, types, classes, structures, or files of the Program solely 52 | in each case in order to link to, bind by name, or subclass the Program 53 | or Modified Works thereof. 54 | 55 | "Distribute" means the acts of a) distributing or b) making available 56 | in any manner that enables the transfer of a copy. 57 | 58 | "Source Code" means the form of a Program preferred for making 59 | modifications, including but not limited to software source code, 60 | documentation source, and configuration files. 61 | 62 | "Secondary License" means either the GNU General Public License, 63 | Version 2.0, or any later versions of that license, including any 64 | exceptions or additional permissions as identified by the initial 65 | Contributor. 66 | 67 | 2. GRANT OF RIGHTS 68 | 69 | a) Subject to the terms of this Agreement, each Contributor hereby 70 | grants Recipient a non-exclusive, worldwide, royalty-free copyright 71 | license to reproduce, prepare Derivative Works of, publicly display, 72 | publicly perform, Distribute and sublicense the Contribution of such 73 | Contributor, if any, and such Derivative Works. 74 | 75 | b) Subject to the terms of this Agreement, each Contributor hereby 76 | grants Recipient a non-exclusive, worldwide, royalty-free patent 77 | license under Licensed Patents to make, use, sell, offer to sell, 78 | import and otherwise transfer the Contribution of such Contributor, 79 | if any, in Source Code or other form. This patent license shall 80 | apply to the combination of the Contribution and the Program if, at 81 | the time the Contribution is added by the Contributor, such addition 82 | of the Contribution causes such combination to be covered by the 83 | Licensed Patents. The patent license shall not apply to any other 84 | combinations which include the Contribution. No hardware per se is 85 | licensed hereunder. 86 | 87 | c) Recipient understands that although each Contributor grants the 88 | licenses to its Contributions set forth herein, no assurances are 89 | provided by any Contributor that the Program does not infringe the 90 | patent or other intellectual property rights of any other entity. 91 | Each Contributor disclaims any liability to Recipient for claims 92 | brought by any other entity based on infringement of intellectual 93 | property rights or otherwise. As a condition to exercising the 94 | rights and licenses granted hereunder, each Recipient hereby 95 | assumes sole responsibility to secure any other intellectual 96 | property rights needed, if any. For example, if a third party 97 | patent license is required to allow Recipient to Distribute the 98 | Program, it is Recipient's responsibility to acquire that license 99 | before distributing the Program. 100 | 101 | d) Each Contributor represents that to its knowledge it has 102 | sufficient copyright rights in its Contribution, if any, to grant 103 | the copyright license set forth in this Agreement. 104 | 105 | e) Notwithstanding the terms of any Secondary License, no 106 | Contributor makes additional grants to any Recipient (other than 107 | those set forth in this Agreement) as a result of such Recipient's 108 | receipt of the Program under the terms of a Secondary License 109 | (if permitted under the terms of Section 3). 110 | 111 | 3. REQUIREMENTS 112 | 113 | 3.1 If a Contributor Distributes the Program in any form, then: 114 | 115 | a) the Program must also be made available as Source Code, in 116 | accordance with section 3.2, and the Contributor must accompany 117 | the Program with a statement that the Source Code for the Program 118 | is available under this Agreement, and informs Recipients how to 119 | obtain it in a reasonable manner on or through a medium customarily 120 | used for software exchange; and 121 | 122 | b) the Contributor may Distribute the Program under a license 123 | different than this Agreement, provided that such license: 124 | i) effectively disclaims on behalf of all other Contributors all 125 | warranties and conditions, express and implied, including 126 | warranties or conditions of title and non-infringement, and 127 | implied warranties or conditions of merchantability and fitness 128 | for a particular purpose; 129 | 130 | ii) effectively excludes on behalf of all other Contributors all 131 | liability for damages, including direct, indirect, special, 132 | incidental and consequential damages, such as lost profits; 133 | 134 | iii) does not attempt to limit or alter the recipients' rights 135 | in the Source Code under section 3.2; and 136 | 137 | iv) requires any subsequent distribution of the Program by any 138 | party to be under a license that satisfies the requirements 139 | of this section 3. 140 | 141 | 3.2 When the Program is Distributed as Source Code: 142 | 143 | a) it must be made available under this Agreement, or if the 144 | Program (i) is combined with other material in a separate file or 145 | files made available under a Secondary License, and (ii) the initial 146 | Contributor attached to the Source Code the notice described in 147 | Exhibit A of this Agreement, then the Program may be made available 148 | under the terms of such Secondary Licenses, and 149 | 150 | b) a copy of this Agreement must be included with each copy of 151 | the Program. 152 | 153 | 3.3 Contributors may not remove or alter any copyright, patent, 154 | trademark, attribution notices, disclaimers of warranty, or limitations 155 | of liability ("notices") contained within the Program from any copy of 156 | the Program which they Distribute, provided that Contributors may add 157 | their own appropriate notices. 158 | 159 | 4. COMMERCIAL DISTRIBUTION 160 | 161 | Commercial distributors of software may accept certain responsibilities 162 | with respect to end users, business partners and the like. While this 163 | license is intended to facilitate the commercial use of the Program, 164 | the Contributor who includes the Program in a commercial product 165 | offering should do so in a manner which does not create potential 166 | liability for other Contributors. Therefore, if a Contributor includes 167 | the Program in a commercial product offering, such Contributor 168 | ("Commercial Contributor") hereby agrees to defend and indemnify every 169 | other Contributor ("Indemnified Contributor") against any losses, 170 | damages and costs (collectively "Losses") arising from claims, lawsuits 171 | and other legal actions brought by a third party against the Indemnified 172 | Contributor to the extent caused by the acts or omissions of such 173 | Commercial Contributor in connection with its distribution of the Program 174 | in a commercial product offering. The obligations in this section do not 175 | apply to any claims or Losses relating to any actual or alleged 176 | intellectual property infringement. In order to qualify, an Indemnified 177 | Contributor must: a) promptly notify the Commercial Contributor in 178 | writing of such claim, and b) allow the Commercial Contributor to control, 179 | and cooperate with the Commercial Contributor in, the defense and any 180 | related settlement negotiations. The Indemnified Contributor may 181 | participate in any such claim at its own expense. 182 | 183 | For example, a Contributor might include the Program in a commercial 184 | product offering, Product X. That Contributor is then a Commercial 185 | Contributor. If that Commercial Contributor then makes performance 186 | claims, or offers warranties related to Product X, those performance 187 | claims and warranties are such Commercial Contributor's responsibility 188 | alone. Under this section, the Commercial Contributor would have to 189 | defend claims against the other Contributors related to those performance 190 | claims and warranties, and if a court requires any other Contributor to 191 | pay any damages as a result, the Commercial Contributor must pay 192 | those damages. 193 | 194 | 5. NO WARRANTY 195 | 196 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT 197 | PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" 198 | BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR 199 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF 200 | TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR 201 | PURPOSE. Each Recipient is solely responsible for determining the 202 | appropriateness of using and distributing the Program and assumes all 203 | risks associated with its exercise of rights under this Agreement, 204 | including but not limited to the risks and costs of program errors, 205 | compliance with applicable laws, damage to or loss of data, programs 206 | or equipment, and unavailability or interruption of operations. 207 | 208 | 6. DISCLAIMER OF LIABILITY 209 | 210 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT 211 | PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS 212 | SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 213 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST 214 | PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 215 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 216 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 217 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE 218 | POSSIBILITY OF SUCH DAMAGES. 219 | 220 | 7. GENERAL 221 | 222 | If any provision of this Agreement is invalid or unenforceable under 223 | applicable law, it shall not affect the validity or enforceability of 224 | the remainder of the terms of this Agreement, and without further 225 | action by the parties hereto, such provision shall be reformed to the 226 | minimum extent necessary to make such provision valid and enforceable. 227 | 228 | If Recipient institutes patent litigation against any entity 229 | (including a cross-claim or counterclaim in a lawsuit) alleging that the 230 | Program itself (excluding combinations of the Program with other software 231 | or hardware) infringes such Recipient's patent(s), then such Recipient's 232 | rights granted under Section 2(b) shall terminate as of the date such 233 | litigation is filed. 234 | 235 | All Recipient's rights under this Agreement shall terminate if it 236 | fails to comply with any of the material terms or conditions of this 237 | Agreement and does not cure such failure in a reasonable period of 238 | time after becoming aware of such noncompliance. If all Recipient's 239 | rights under this Agreement terminate, Recipient agrees to cease use 240 | and distribution of the Program as soon as reasonably practicable. 241 | However, Recipient's obligations under this Agreement and any licenses 242 | granted by Recipient relating to the Program shall continue and survive. 243 | 244 | Everyone is permitted to copy and distribute copies of this Agreement, 245 | but in order to avoid inconsistency the Agreement is copyrighted and 246 | may only be modified in the following manner. The Agreement Steward 247 | reserves the right to publish new versions (including revisions) of 248 | this Agreement from time to time. No one other than the Agreement 249 | Steward has the right to modify this Agreement. The Eclipse Foundation 250 | is the initial Agreement Steward. The Eclipse Foundation may assign the 251 | responsibility to serve as the Agreement Steward to a suitable separate 252 | entity. Each new version of the Agreement will be given a distinguishing 253 | version number. The Program (including Contributions) may always be 254 | Distributed subject to the version of the Agreement under which it was 255 | received. In addition, after a new version of the Agreement is published, 256 | Contributor may elect to Distribute the Program (including its 257 | Contributions) under the new version. 258 | 259 | Except as expressly stated in Sections 2(a) and 2(b) above, Recipient 260 | receives no rights or licenses to the intellectual property of any 261 | Contributor under this Agreement, whether expressly, by implication, 262 | estoppel or otherwise. All rights in the Program not expressly granted 263 | under this Agreement are reserved. Nothing in this Agreement is intended 264 | to be enforceable by any entity that is not a Contributor or Recipient. 265 | No third-party beneficiary rights are created under this Agreement. 266 | 267 | Exhibit A - Form of Secondary Licenses Notice 268 | 269 | "This Source Code may also be made available under the following 270 | Secondary Licenses when the conditions for such availability set forth 271 | in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), 272 | version(s), and exceptions or additional permissions here}." 273 | 274 | Simply including a copy of this Agreement, including this Exhibit A 275 | is not sufficient to license the Source Code under Secondary Licenses. 276 | 277 | If it is not possible or desirable to put the notice in a particular 278 | file, then You may include the notice in a location (such as a LICENSE 279 | file in a relevant directory) where a recipient would be likely to 280 | look for such a notice. 281 | 282 | You may add additional accurate notices of copyright ownership. 283 | 284 | -------------------------------------------------------------------------------- 285 | 286 | Attribution-NoDerivatives 4.0 International 287 | 288 | ======================================================================= 289 | 290 | Creative Commons Corporation ("Creative Commons") is not a law firm and 291 | does not provide legal services or legal advice. Distribution of 292 | Creative Commons public licenses does not create a lawyer-client or 293 | other relationship. Creative Commons makes its licenses and related 294 | information available on an "as-is" basis. Creative Commons gives no 295 | warranties regarding its licenses, any material licensed under their 296 | terms and conditions, or any related information. Creative Commons 297 | disclaims all liability for damages resulting from their use to the 298 | fullest extent possible. 299 | 300 | Using Creative Commons Public Licenses 301 | 302 | Creative Commons public licenses provide a standard set of terms and 303 | conditions that creators and other rights holders may use to share 304 | original works of authorship and other material subject to copyright 305 | and certain other rights specified in the public license below. The 306 | following considerations are for informational purposes only, are not 307 | exhaustive, and do not form part of our licenses. 308 | 309 | Considerations for licensors: Our public licenses are 310 | intended for use by those authorized to give the public 311 | permission to use material in ways otherwise restricted by 312 | copyright and certain other rights. Our licenses are 313 | irrevocable. Licensors should read and understand the terms 314 | and conditions of the license they choose before applying it. 315 | Licensors should also secure all rights necessary before 316 | applying our licenses so that the public can reuse the 317 | material as expected. Licensors should clearly mark any 318 | material not subject to the license. This includes other CC- 319 | licensed material, or material used under an exception or 320 | limitation to copyright. More considerations for licensors: 321 | wiki.creativecommons.org/Considerations_for_licensors 322 | 323 | Considerations for the public: By using one of our public 324 | licenses, a licensor grants the public permission to use the 325 | licensed material under specified terms and conditions. If 326 | the licensor's permission is not necessary for any reason--for 327 | example, because of any applicable exception or limitation to 328 | copyright--then that use is not regulated by the license. Our 329 | licenses grant only permissions under copyright and certain 330 | other rights that a licensor has authority to grant. Use of 331 | the licensed material may still be restricted for other 332 | reasons, including because others have copyright or other 333 | rights in the material. A licensor may make special requests, 334 | such as asking that all changes be marked or described. 335 | Although not required by our licenses, you are encouraged to 336 | respect those requests where reasonable. More_considerations 337 | for the public: 338 | wiki.creativecommons.org/Considerations_for_licensees 339 | 340 | 341 | ======================================================================= 342 | 343 | Creative Commons Attribution-NoDerivatives 4.0 International Public 344 | License 345 | 346 | By exercising the Licensed Rights (defined below), You accept and agree 347 | to be bound by the terms and conditions of this Creative Commons 348 | Attribution-NoDerivatives 4.0 International Public License ("Public 349 | License"). To the extent this Public License may be interpreted as a 350 | contract, You are granted the Licensed Rights in consideration of Your 351 | acceptance of these terms and conditions, and the Licensor grants You 352 | such rights in consideration of benefits the Licensor receives from 353 | making the Licensed Material available under these terms and 354 | conditions. 355 | 356 | 357 | Section 1 -- Definitions. 358 | 359 | a. Adapted Material means material subject to Copyright and Similar 360 | Rights that is derived from or based upon the Licensed Material 361 | and in which the Licensed Material is translated, altered, 362 | arranged, transformed, or otherwise modified in a manner requiring 363 | permission under the Copyright and Similar Rights held by the 364 | Licensor. For purposes of this Public License, where the Licensed 365 | Material is a musical work, performance, or sound recording, 366 | Adapted Material is always produced where the Licensed Material is 367 | synched in timed relation with a moving image. 368 | 369 | b. Copyright and Similar Rights means copyright and/or similar rights 370 | closely related to copyright including, without limitation, 371 | performance, broadcast, sound recording, and Sui Generis Database 372 | Rights, without regard to how the rights are labeled or 373 | categorized. For purposes of this Public License, the rights 374 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 375 | Rights. 376 | 377 | c. Effective Technological Measures means those measures that, in the 378 | absence of proper authority, may not be circumvented under laws 379 | fulfilling obligations under Article 11 of the WIPO Copyright 380 | Treaty adopted on December 20, 1996, and/or similar international 381 | agreements. 382 | 383 | d. Exceptions and Limitations means fair use, fair dealing, and/or 384 | any other exception or limitation to Copyright and Similar Rights 385 | that applies to Your use of the Licensed Material. 386 | 387 | e. Licensed Material means the artistic or literary work, database, 388 | or other material to which the Licensor applied this Public 389 | License. 390 | 391 | f. Licensed Rights means the rights granted to You subject to the 392 | terms and conditions of this Public License, which are limited to 393 | all Copyright and Similar Rights that apply to Your use of the 394 | Licensed Material and that the Licensor has authority to license. 395 | 396 | g. Licensor means the individual(s) or entity(ies) granting rights 397 | under this Public License. 398 | 399 | h. Share means to provide material to the public by any means or 400 | process that requires permission under the Licensed Rights, such 401 | as reproduction, public display, public performance, distribution, 402 | dissemination, communication, or importation, and to make material 403 | available to the public including in ways that members of the 404 | public may access the material from a place and at a time 405 | individually chosen by them. 406 | 407 | i. Sui Generis Database Rights means rights other than copyright 408 | resulting from Directive 96/9/EC of the European Parliament and of 409 | the Council of 11 March 1996 on the legal protection of databases, 410 | as amended and/or succeeded, as well as other essentially 411 | equivalent rights anywhere in the world. 412 | 413 | j. You means the individual or entity exercising the Licensed Rights 414 | under this Public License. Your has a corresponding meaning. 415 | 416 | 417 | Section 2 -- Scope. 418 | 419 | a. License grant. 420 | 421 | 1. Subject to the terms and conditions of this Public License, 422 | the Licensor hereby grants You a worldwide, royalty-free, 423 | non-sublicensable, non-exclusive, irrevocable license to 424 | exercise the Licensed Rights in the Licensed Material to: 425 | 426 | a. reproduce and Share the Licensed Material, in whole or 427 | in part; and 428 | 429 | b. produce and reproduce, but not Share, Adapted Material. 430 | 431 | 2. Exceptions and Limitations. For the avoidance of doubt, where 432 | Exceptions and Limitations apply to Your use, this Public 433 | License does not apply, and You do not need to comply with 434 | its terms and conditions. 435 | 436 | 3. Term. The term of this Public License is specified in Section 437 | 6(a). 438 | 439 | 4. Media and formats; technical modifications allowed. The 440 | Licensor authorizes You to exercise the Licensed Rights in 441 | all media and formats whether now known or hereafter created, 442 | and to make technical modifications necessary to do so. The 443 | Licensor waives and/or agrees not to assert any right or 444 | authority to forbid You from making technical modifications 445 | necessary to exercise the Licensed Rights, including 446 | technical modifications necessary to circumvent Effective 447 | Technological Measures. For purposes of this Public License, 448 | simply making modifications authorized by this Section 2(a) 449 | (4) never produces Adapted Material. 450 | 451 | 5. Downstream recipients. 452 | 453 | a. Offer from the Licensor -- Licensed Material. Every 454 | recipient of the Licensed Material automatically 455 | receives an offer from the Licensor to exercise the 456 | Licensed Rights under the terms and conditions of this 457 | Public License. 458 | 459 | b. No downstream restrictions. You may not offer or impose 460 | any additional or different terms or conditions on, or 461 | apply any Effective Technological Measures to, the 462 | Licensed Material if doing so restricts exercise of the 463 | Licensed Rights by any recipient of the Licensed 464 | Material. 465 | 466 | 6. No endorsement. Nothing in this Public License constitutes or 467 | may be construed as permission to assert or imply that You 468 | are, or that Your use of the Licensed Material is, connected 469 | with, or sponsored, endorsed, or granted official status by, 470 | the Licensor or others designated to receive attribution as 471 | provided in Section 3(a)(1)(A)(i). 472 | 473 | b. Other rights. 474 | 475 | 1. Moral rights, such as the right of integrity, are not 476 | licensed under this Public License, nor are publicity, 477 | privacy, and/or other similar personality rights; however, to 478 | the extent possible, the Licensor waives and/or agrees not to 479 | assert any such rights held by the Licensor to the limited 480 | extent necessary to allow You to exercise the Licensed 481 | Rights, but not otherwise. 482 | 483 | 2. Patent and trademark rights are not licensed under this 484 | Public License. 485 | 486 | 3. To the extent possible, the Licensor waives any right to 487 | collect royalties from You for the exercise of the Licensed 488 | Rights, whether directly or through a collecting society 489 | under any voluntary or waivable statutory or compulsory 490 | licensing scheme. In all other cases the Licensor expressly 491 | reserves any right to collect such royalties. 492 | 493 | 494 | Section 3 -- License Conditions. 495 | 496 | Your exercise of the Licensed Rights is expressly made subject to the 497 | following conditions. 498 | 499 | a. Attribution. 500 | 501 | 1. If You Share the Licensed Material, You must: 502 | 503 | a. retain the following if it is supplied by the Licensor 504 | with the Licensed Material: 505 | 506 | i. identification of the creator(s) of the Licensed 507 | Material and any others designated to receive 508 | attribution, in any reasonable manner requested by 509 | the Licensor (including by pseudonym if 510 | designated); 511 | 512 | ii. a copyright notice; 513 | 514 | iii. a notice that refers to this Public License; 515 | 516 | iv. a notice that refers to the disclaimer of 517 | warranties; 518 | 519 | v. a URI or hyperlink to the Licensed Material to the 520 | extent reasonably practicable; 521 | 522 | b. indicate if You modified the Licensed Material and 523 | retain an indication of any previous modifications; and 524 | 525 | c. indicate the Licensed Material is licensed under this 526 | Public License, and include the text of, or the URI or 527 | hyperlink to, this Public License. 528 | 529 | For the avoidance of doubt, You do not have permission under 530 | this Public License to Share Adapted Material. 531 | 532 | 2. You may satisfy the conditions in Section 3(a)(1) in any 533 | reasonable manner based on the medium, means, and context in 534 | which You Share the Licensed Material. For example, it may be 535 | reasonable to satisfy the conditions by providing a URI or 536 | hyperlink to a resource that includes the required 537 | information. 538 | 539 | 3. If requested by the Licensor, You must remove any of the 540 | information required by Section 3(a)(1)(A) to the extent 541 | reasonably practicable. 542 | 543 | 544 | Section 4 -- Sui Generis Database Rights. 545 | 546 | Where the Licensed Rights include Sui Generis Database Rights that 547 | apply to Your use of the Licensed Material: 548 | 549 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 550 | to extract, reuse, reproduce, and Share all or a substantial 551 | portion of the contents of the database, provided You do not Share 552 | Adapted Material; 553 | b. if You include all or a substantial portion of the database 554 | contents in a database in which You have Sui Generis Database 555 | Rights, then the database in which You have Sui Generis Database 556 | Rights (but not its individual contents) is Adapted Material; and 557 | c. You must comply with the conditions in Section 3(a) if You Share 558 | all or a substantial portion of the contents of the database. 559 | 560 | For the avoidance of doubt, this Section 4 supplements and does not 561 | replace Your obligations under this Public License where the Licensed 562 | Rights include other Copyright and Similar Rights. 563 | 564 | 565 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 566 | 567 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 568 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 569 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 570 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 571 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 572 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 573 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 574 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 575 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 576 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 577 | 578 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 579 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 580 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 581 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 582 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 583 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 584 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 585 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 586 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 587 | 588 | c. The disclaimer of warranties and limitation of liability provided 589 | above shall be interpreted in a manner that, to the extent 590 | possible, most closely approximates an absolute disclaimer and 591 | waiver of all liability. 592 | 593 | 594 | Section 6 -- Term and Termination. 595 | 596 | a. This Public License applies for the term of the Copyright and 597 | Similar Rights licensed here. However, if You fail to comply with 598 | this Public License, then Your rights under this Public License 599 | terminate automatically. 600 | 601 | b. Where Your right to use the Licensed Material has terminated under 602 | Section 6(a), it reinstates: 603 | 604 | 1. automatically as of the date the violation is cured, provided 605 | it is cured within 30 days of Your discovery of the 606 | violation; or 607 | 608 | 2. upon express reinstatement by the Licensor. 609 | 610 | For the avoidance of doubt, this Section 6(b) does not affect any 611 | right the Licensor may have to seek remedies for Your violations 612 | of this Public License. 613 | 614 | c. For the avoidance of doubt, the Licensor may also offer the 615 | Licensed Material under separate terms or conditions or stop 616 | distributing the Licensed Material at any time; however, doing so 617 | will not terminate this Public License. 618 | 619 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 620 | License. 621 | 622 | 623 | Section 7 -- Other Terms and Conditions. 624 | 625 | a. The Licensor shall not be bound by any additional or different 626 | terms or conditions communicated by You unless expressly agreed. 627 | 628 | b. Any arrangements, understandings, or agreements regarding the 629 | Licensed Material not stated herein are separate from and 630 | independent of the terms and conditions of this Public License. 631 | 632 | 633 | Section 8 -- Interpretation. 634 | 635 | a. For the avoidance of doubt, this Public License does not, and 636 | shall not be interpreted to, reduce, limit, restrict, or impose 637 | conditions on any use of the Licensed Material that could lawfully 638 | be made without permission under this Public License. 639 | 640 | b. To the extent possible, if any provision of this Public License is 641 | deemed unenforceable, it shall be automatically reformed to the 642 | minimum extent necessary to make it enforceable. If the provision 643 | cannot be reformed, it shall be severed from this Public License 644 | without affecting the enforceability of the remaining terms and 645 | conditions. 646 | 647 | c. No term or condition of this Public License will be waived and no 648 | failure to comply consented to unless expressly agreed to by the 649 | Licensor. 650 | 651 | d. Nothing in this Public License constitutes or may be interpreted 652 | as a limitation upon, or waiver of, any privileges and immunities 653 | that apply to the Licensor or You, including from the legal 654 | processes of any jurisdiction or authority. 655 | 656 | ======================================================================= 657 | 658 | Creative Commons is not a party to its public 659 | licenses. Notwithstanding, Creative Commons may elect to apply one of 660 | its public licenses to material it publishes and in those instances 661 | will be considered the “Licensor.” The text of the Creative Commons 662 | public licenses is dedicated to the public domain under the CC0 Public 663 | Domain Dedication. Except for the limited purpose of indicating that 664 | material is shared under a Creative Commons public license or as 665 | otherwise permitted by the Creative Commons policies published at 666 | creativecommons.org/policies, Creative Commons does not authorize the 667 | use of the trademark "Creative Commons" or any other trademark or logo 668 | of Creative Commons without its prior written consent including, 669 | without limitation, in connection with any unauthorized modifications 670 | to any of its public licenses or any other arrangements, 671 | understandings, or agreements concerning use of licensed material. For 672 | the avoidance of doubt, this paragraph does not form part of the 673 | public licenses. 674 | 675 | Creative Commons may be contacted at creativecommons.org. 676 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, 2025 IBM Corporation and others. 2 | // Licensed under Creative Commons Attribution-NoDerivatives 3 | // 4.0 International (CC BY-ND 4.0) 4 | // https://creativecommons.org/licenses/by-nd/4.0/ 5 | // 6 | // Contributors: 7 | // IBM Corporation 8 | // 9 | :projectid: maven-intro 10 | :page-layout: guide-multipane 11 | :page-duration: 15 minutes 12 | :page-releasedate: 2017-09-19 13 | :page-guide-category: basic 14 | :page-essential: true 15 | :page-essential-order: 3 16 | :page-description: Learn how to build and test a simple web application using Maven and Open Liberty 17 | :page-related-guides: ['maven-multimodules', 'gradle-intro'] 18 | :page-tags: ['maven'] 19 | :page-permalink: /guides/{projectid} 20 | :common-includes: https://raw.githubusercontent.com/OpenLiberty/guides-common/prod 21 | :page-seo-title: Building and testing a Java web application with Maven and Open Liberty 22 | :page-seo-description: A getting started tutorial with examples of how to build and test a simple Java EE or Jakarta EE web application using a Maven Project Object Model (POM) file. 23 | :guide-author: Open Liberty 24 | = Building a web application with Maven 25 | 26 | [.hidden] 27 | NOTE: This repository contains the guide documentation source. To view the guide in published form, view it on the https://openliberty.io/guides/{projectid}.html[Open Liberty website]. 28 | 29 | Learn how to build and test a simple web application using Maven and Open Liberty. 30 | 31 | // ================================================================================================= 32 | // What you'll learn 33 | // ================================================================================================= 34 | 35 | == What you'll learn 36 | 37 | You will learn how to configure a simple web servlet application using https://maven.apache.org/what-is-maven.html[Maven^] and the https://github.com/OpenLiberty/ci.maven/blob/main/README.md[Liberty Maven plugin^]. When you compile and build the application code, Maven downloads and installs Open Liberty. If you run the application, Maven creates an Open Liberty instance and runs the application on it. The application displays a simple web page with a link that, when clicked, calls the servlet to return a simple response of `Hello! How are you today?`. 38 | 39 | One benefit of using a build tool like Maven is that you can define the details of the project and any dependencies it has, and Maven automatically downloads and installs the dependencies. Another benefit of using Maven is that it can run repeatable, automated tests on the application. You can, of course, test your application manually by starting a Liberty instance and pointing a web browser at the application URL. However, automated tests are a much better approach because you can easily rerun the same tests each time the application is built. If the tests don't pass after you change the application, the build fails, and you know that you introduced a regression that requires a fix to your code. 40 | 41 | Choosing a build tool often comes down to personal or organizational preference, but you might choose to use Maven for several reasons. Maven defines its builds by using XML, which is probably familiar to you already. As a mature, commonly used build tool, Maven probably integrates with whichever IDE you prefer to use. Maven also has an extensive plug-in library that offers various ways to quickly customize your build. Maven can be a good choice if your team is already familiar with it. 42 | 43 | You will create a Maven build definition file that's called a `pom.xml` file, which stands for Project Object Model, and use it to build your web application. You will then create a simple, automated test and configure Maven to automatically run the test. 44 | 45 | ifndef::cloud-hosted[] 46 | // ================================================================================================= 47 | // Installing Maven 48 | // ================================================================================================= 49 | 50 | == Installing Maven 51 | 52 | Maven Wrapper is provided in this guide. You have no need to install Maven. 53 | 54 | If you use Maven and it isn't already installed, https://maven.apache.org/download.cgi[download the binary zip or tar.gz file^]. Then, follow the https://maven.apache.org/install.html[installation instructions for your operating system^] to extract the `.zip` file and add the `bin` directory, which contains the `mvn` command to the `PATH` on your computer. 55 | 56 | endif::[] 57 | 58 | // ================================================================================================= 59 | // Getting Started 60 | // ================================================================================================= 61 | [role='command'] 62 | include::{common-includes}/gitclone.adoc[] 63 | 64 | // ================================================================================================= 65 | // Try what you'll build 66 | // ================================================================================================= 67 | 68 | === Try what you'll build 69 | 70 | The `finish` directory in the root of this guide contains the finished application. Give it a try before you proceed. 71 | Run the following command to test that Maven Wrapper works: 72 | 73 | include::{common-includes}/os-tabs.adoc[] 74 | 75 | [.tab_content.windows_section] 76 | -- 77 | [role='command'] 78 | ``` 79 | mvnw.cmd -v 80 | ``` 81 | -- 82 | 83 | [.tab_content.mac_section] 84 | -- 85 | [role='command'] 86 | ``` 87 | ./mvnw -v 88 | ``` 89 | -- 90 | 91 | [.tab_content.linux_section] 92 | -- 93 | [role='command'] 94 | ``` 95 | ./mvnw -v 96 | ``` 97 | -- 98 | 99 | If Maven Wrapper is installed properly, you see information about the Maven installation similar to the following example: 100 | 101 | [source, role="no_copy"] 102 | ---- 103 | Apache Maven 3.9.9 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d) 104 | Maven home: /Applications/Maven/apache-maven-3.9.9 105 | Java version: 11.0.12, vendor: International Business Machines Corporation, runtime: /Library/Java/JavaVirtualMachines/ibm-semeru-open-11.jdk/Contents/Home 106 | Default locale: en_US, platform encoding: UTF-8 107 | OS name: "mac os x", version: "11.6", arch: "x86_64", family: "mac" 108 | ---- 109 | 110 | // tag::runCommand[] 111 | To try out the application, first go to the `finish` directory and run Maven with the `liberty:run` goal to build the application and deploy it to Open Liberty: 112 | include::{common-includes}/os-tabs.adoc[] 113 | 114 | [.tab_content.windows_section] 115 | -- 116 | [role='command'] 117 | ``` 118 | mvnw.cmd liberty:run 119 | ``` 120 | -- 121 | 122 | [.tab_content.mac_section] 123 | -- 124 | [role='command'] 125 | ``` 126 | ./mvnw liberty:run 127 | ``` 128 | -- 129 | 130 | [.tab_content.linux_section] 131 | -- 132 | [role='command'] 133 | ``` 134 | ./mvnw liberty:run 135 | ``` 136 | -- 137 | 138 | After you see the following message, your Liberty instance is ready. 139 | 140 | [role="no_copy"] 141 | ---- 142 | The guideServer server is ready to run a smarter planet. 143 | ---- 144 | // end::runCommand[] 145 | 146 | ifndef::cloud-hosted[] 147 | Navigate your browser to the http://localhost:9080/ServletSample/servlet[^] URL to access the application. The servlet returns a simple response of `Hello! How are you today?`. 148 | endif::[] 149 | 150 | ifdef::cloud-hosted[] 151 | Select **Terminal** > **New Terminal** from the menu of the IDE to open another command-line session. Run the following curl command to view the output of the application: 152 | ```bash 153 | curl -s http://localhost:9080/ServletSample/servlet 154 | ``` 155 | 156 | The servlet returns a simple response of ***Hello! How are you today?***. 157 | endif::[] 158 | 159 | [role='command'] 160 | include::{common-includes}/twyb-end-mvnw.adoc[] 161 | 162 | // ================================================================================================= 163 | // Creating a simple application 164 | // ================================================================================================= 165 | 166 | == Creating a simple application 167 | 168 | The simple web application that you will build using Maven and Open Liberty is provided for you in the `start` directory so that you can focus on learning about Maven. This application uses a standard Maven directory structure, eliminating the need to customize the `pom.xml` file so that Maven understands your project layout. 169 | 170 | All the application source code, including the Open Liberty `server.xml` configuration file, is in the `src/main/liberty/config` directory: 171 | 172 | [source, role="no_copy"] 173 | ---- 174 | └── src 175 | └── main 176 | └── java 177 | └── resources 178 | └── webapp 179 | └── liberty 180 | └── config 181 | ---- 182 | 183 | // ================================================================================================= 184 | // Creating the project POM file 185 | // ================================================================================================= 186 | 187 | == Creating the project POM file 188 | Navigate to the `start` directory to begin. 189 | // cloud hosted instructions 190 | ifdef::cloud-hosted[] 191 | ```bash 192 | cd /home/project/guide-maven-intro/start 193 | ``` 194 | endif::[] 195 | 196 | Before you can build the project, define the Maven Project Object Model (POM) file, the `pom.xml`. 197 | 198 | [role="code_command hotspot", subs="quotes"] 199 | ---- 200 | #Create the pom.xml file in the `start` directory.# 201 | `pom.xml` 202 | ---- 203 | 204 | pom.xml 205 | [source, xml, linenums, role='code_column'] 206 | ---- 207 | include::finish/pom.xml[] 208 | ---- 209 | 210 | The [hotspot file=0]`pom.xml` file starts with a root [hotspot=project file=0]`project` element and a [hotspot=modelVersion file=0]`modelversion` element, which is always set to `4.0.0`. 211 | 212 | A typical POM for a Liberty application contains the following sections: 213 | 214 | * **Project coordinates**: The identifiers for this application. 215 | * **Properties** ([hotspot=properties file=0]`properties`): Any properties for the project go here, including compilation details and any values that are referenced during compilation of the Java source code and generating the application. 216 | * **Dependencies** ([hotspot=dependencies file=0]`dependencies`): Any Java dependencies that are required for compiling, testing, and running the application are listed here. 217 | * **Build plugins** ([hotspot=build file=0]`build`): Maven is modular and each of its capabilities is provided by a separate plugin. This is where you specify which Maven plugins should be used to build this project and any configuration information needed by those plugins. 218 | 219 | The project coordinates describe the name and version of the application. The [hotspot=artifactID file=0]`artifactId` gives a name to the web application project, which is used to name the output files that are generated by the build (e.g. the WAR file) and the Open Liberty instance that is created. You'll notice that other fields in the [hotspot file=0]`pom.xml` file use variables that are resolved by the [hotspot=artifactID file=0]`artifactId` field. This is so that you can update the name of the sample application, including files generated by Maven, in a single place in the [hotspot file=0]`pom.xml` file. The value of the [hotspot=packaging file=0]`packaging` field is `war` so that the project output artifact is a WAR file. 220 | 221 | The first four properties in the properties section of the project, just define the encoding ([hotspot=encoding file=0]`UTF-8`) and version of Java ([hotspot=java-version file=0]`Java 11`) that Maven uses to compile the application source code. 222 | 223 | Open Liberty configuration properties provide you with a single place to specify values that are used in multiple places throughout the application. For example, the [hotspot=http.port file=0]`http.port` value is used in both the Liberty [hotspot=httpEndpoint file=2]`server.xml` configuration file and will be used in the test class that you will add (`EndpointIT.java`) to the application. Because the [hotspot=http.port file=0]`http.port` value is specified in the [hotspot file=0]`pom.xml` file, you can easily change the port number that the Liberty instance runs on without updating the application code in multiple places. 224 | 225 | HelloServlet.java 226 | [source, java, linenums, role='code_column hide_tags=comment,javadoc1,javadoc2'] 227 | ---- 228 | include::finish/src/main/java/io/openliberty/guides/hello/HelloServlet.java[] 229 | ---- 230 | 231 | The [hotspot file=1]`HelloServlet.java` class depends on [hotspot=jakarta.jakartaee-api file=0]`jakarta.jakartaee-api` to compile. Maven will download this dependency from the Maven Central repository using the [hotspot=groupID-api file=0]`groupId`, [hotspot=artifactID-api file=0]`artifactId`, and [hotspot=version-api file=0]`version` details that you provide here. The dependency is set to [hotspot=scope-api file=0]`provided`, which means that the API is in the Liberty runtime and doesn't need to be packaged by the application. 232 | 233 | The [hotspot=build file=0]`build` section gives details of the two plugins that Maven uses to build this project. 234 | 235 | * The Maven plugin for generating a WAR file as one of the output files. 236 | * The Liberty Maven plug-in, which allows you to install applications into Open Liberty and manage the associated Liberty instances. 237 | 238 | In the [hotspot=liberty-maven-plugin file=0]`liberty-maven-plugin` plug-in section, you can add a [hotspot=configuration file=0]`configuration` element to specify Open Liberty configuration details. For example, the [hotspot=serverName file=0]`serverName` field defines the name of the Open Liberty instance that Maven creates. You specified `guideServer` as the value for [hotspot=serverName file=0]`serverName`. If the [hotspot=serverName file=0]`serverName` field is not included, the default value is `defaultServer`. 239 | 240 | server.xml 241 | [source, xml, linenums, role='code_column hide_tags=comment'] 242 | ---- 243 | include::finish/src/main/liberty/config/server.xml[] 244 | ---- 245 | 246 | // ================================================================================================= 247 | // Running the application 248 | // ================================================================================================= 249 | 250 | == Running the application 251 | 252 | [role='command'] 253 | include::{common-includes}/devmode-mvnw-start.adoc[] 254 | 255 | ifndef::cloud-hosted[] 256 | Navigate your browser to the http://localhost:9080/ServletSample/servlet[^] URL to access the application. The servlet returns a simple response of `Hello! How are you today?`. 257 | endif::[] 258 | 259 | ifdef::cloud-hosted[] 260 | Select **Terminal** > **New Terminal** from the menu of the IDE to open another command-line session. Run the following curl command to view the output of the application: 261 | ```bash 262 | curl -s http://localhost:9080/ServletSample/servlet 263 | ``` 264 | 265 | The servlet returns a simple response of ***Hello! How are you today?***. 266 | endif::[] 267 | // ================================================================================================= 268 | // Testing the web application 269 | // ================================================================================================= 270 | 271 | == Testing the web application 272 | 273 | One of the benefits of building an application with Maven is that Maven can be configured to run a set of tests. You can write tests for the individual units of code outside of a running Liberty instance (unit tests), or you can write them to call the Liberty instance directly (integration tests). In this example you will create a simple integration test that checks that the web page opens and that the correct response is returned when the link is clicked. 274 | 275 | [role="code_command hotspot", subs="quotes"] 276 | ---- 277 | #Create the `EndpointIT` class.# 278 | `src/test/java/io/openliberty/guides/hello/it/EndpointIT.java` 279 | ---- 280 | 281 | EndpointIT.java 282 | [source, Java, linenums, role='code_column hide_tags=copyright'] 283 | ---- 284 | include::finish/src/test/java/io/openliberty/guides/hello/it/EndpointIT.java[] 285 | ---- 286 | 287 | The test class name ends in `IT` to indicate that it contains an integration test. 288 | 289 | Maven is configured to run the integration test using the [hotspot=maven-failsafe-plugin file=1]`maven-failsafe-plugin`. The [hotspot=system-property-variables file=1]`systemPropertyVariables` section defines some variables that the test class uses. The test code needs to know where to find the application that it is testing. While the port number and context root information can be hardcoded in the test class, it is better to specify it in a single place like the Maven [hotspot file=1]`pom.xml` file because this information is also used by other files in the project. The [hotspot=system-property-variables file=1]`systemPropertyVariables` section passes these details to the Java test program as a series of system properties, resolving the [hotspot=http-port file=1]`http.port` and [hotspot=war-name file=1]`war.name` variables. 290 | 291 | pom.xml 292 | [source, xml, linenums, role='code_column'] 293 | ---- 294 | include::finish/pom.xml[] 295 | ---- 296 | 297 | The following lines in the [hotspot=URL file=0]`EndpointIT` test class uses these system variables to build up the URL of the application. 298 | 299 | In the test class, after defining how to build the application URL, the [hotspot=Test file=0]`@Test` annotation indicates the start of the test method. 300 | 301 | In the [hotspot=link file=0]`try block` of the test method, an HTTP `GET` request to the URL of the application returns a status code. If the response to the request includes the string `Hello! How are you today?`, the test passes. If that string is not in the response, the test fails. The HTTP client then disconnects from the application. 302 | 303 | In the [hotspot=import file=0]`import` statements of this test class, you'll notice that the test has some new dependencies. Before the test can be compiled by Maven, you need to update the [hotspot file=1]`pom.xml` to include these dependencies. 304 | 305 | The Apache [hotspot=commons-httpclient file=1]`httpclient` and [hotspot=junit file=1]`junit-jupiter-engine` dependencies are needed to compile and run the integration test [hotspot=EndpointIT file=0]`EndpointIT` class. The scope for each of the dependencies is set to [hotspot=test1 hotspot=test2 file=1]`test` because the libraries are needed only during the Maven build and do not needed to be packaged with the application. 306 | 307 | Now, the created WAR file contains the web application, and dev mode can run any integration test classes that it finds. Integration test classes are classes with names that end in `IT`. 308 | 309 | The directory structure of the project should now look like this: 310 | 311 | [source, role="no_copy"] 312 | ---- 313 | └── src 314 | ├── main 315 | │ └── java 316 | │ └── resources 317 | │ └── webapp 318 | │ └── liberty 319 | │ └── config 320 | └── test 321 | └── java 322 | ---- 323 | 324 | // ================================================================================================= 325 | // Running the tests 326 | // ================================================================================================= 327 | 328 | [role='command'] 329 | include::{common-includes}/devmode-test.adoc[] 330 | 331 | You see the following output: 332 | 333 | [source, role="no_copy"] 334 | ---- 335 | ------------------------------------------------------- 336 | T E S T S 337 | ------------------------------------------------------- 338 | Running io.openliberty.guides.hello.it.EndpointIT 339 | Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.255 sec - in io.openliberty.guides.hello.it.EndpointIT 340 | 341 | Results : 342 | 343 | Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 344 | ---- 345 | 346 | To see whether the test detects a failure, change the [hotspot=responseString file=0]`response string` in the servlet [hotspot]`src/main/java/io/openliberty/guides/hello/HelloServlet.java` so that it doesn't match the string that the test is looking for. Then re-run the tests and check that the test fails. 347 | 348 | HelloServlet.java 349 | [source, java, linenums, role='code_column hide_tags=comment,javadoc1,javadoc2'] 350 | ---- 351 | include::finish/src/main/java/io/openliberty/guides/hello/HelloServlet.java[] 352 | ---- 353 | 354 | [role='command'] 355 | include::{common-includes}/devmode-quit-ctrlc.adoc[] 356 | 357 | == Great work! You're done! 358 | 359 | You built and tested a web application project with an Open Liberty instance using Maven. 360 | 361 | include::{common-includes}/attribution.adoc[subs="attributes"] 362 | -------------------------------------------------------------------------------- /finish/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/guide-maven-intro/75ec74bac2a270fb9113385b8fdef78e4a0bfea4/finish/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /finish/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar 3 | -------------------------------------------------------------------------------- /finish/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Apache Maven Wrapper startup batch script, version 3.3.2 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | # e.g. to debug Maven itself, use 32 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | # ---------------------------------------------------------------------------- 35 | 36 | if [ -z "$MAVEN_SKIP_RC" ]; then 37 | 38 | if [ -f /usr/local/etc/mavenrc ]; then 39 | . /usr/local/etc/mavenrc 40 | fi 41 | 42 | if [ -f /etc/mavenrc ]; then 43 | . /etc/mavenrc 44 | fi 45 | 46 | if [ -f "$HOME/.mavenrc" ]; then 47 | . "$HOME/.mavenrc" 48 | fi 49 | 50 | fi 51 | 52 | # OS specific support. $var _must_ be set to either true or false. 53 | cygwin=false 54 | darwin=false 55 | mingw=false 56 | case "$(uname)" in 57 | CYGWIN*) cygwin=true ;; 58 | MINGW*) mingw=true ;; 59 | Darwin*) 60 | 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 | JAVA_HOME="$(/usr/libexec/java_home)" 66 | export JAVA_HOME 67 | else 68 | JAVA_HOME="/Library/Java/Home" 69 | export JAVA_HOME 70 | fi 71 | fi 72 | ;; 73 | esac 74 | 75 | if [ -z "$JAVA_HOME" ]; then 76 | if [ -r /etc/gentoo-release ]; then 77 | JAVA_HOME=$(java-config --jre-home) 78 | fi 79 | fi 80 | 81 | # For Cygwin, ensure paths are in UNIX format before anything is touched 82 | if $cygwin; then 83 | [ -n "$JAVA_HOME" ] \ 84 | && JAVA_HOME=$(cygpath --unix "$JAVA_HOME") 85 | [ -n "$CLASSPATH" ] \ 86 | && CLASSPATH=$(cygpath --path --unix "$CLASSPATH") 87 | fi 88 | 89 | # For Mingw, ensure paths are in UNIX format before anything is touched 90 | if $mingw; then 91 | [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] \ 92 | && JAVA_HOME="$( 93 | cd "$JAVA_HOME" || ( 94 | echo "cannot cd into $JAVA_HOME." >&2 95 | exit 1 96 | ) 97 | pwd 98 | )" 99 | fi 100 | 101 | if [ -z "$JAVA_HOME" ]; then 102 | javaExecutable="$(which javac)" 103 | if [ -n "$javaExecutable" ] && ! [ "$(expr "$javaExecutable" : '\([^ ]*\)')" = "no" ]; then 104 | # readlink(1) is not available as standard on Solaris 10. 105 | readLink=$(which readlink) 106 | if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then 107 | if $darwin; then 108 | javaHome="$(dirname "$javaExecutable")" 109 | javaExecutable="$(cd "$javaHome" && pwd -P)/javac" 110 | else 111 | javaExecutable="$(readlink -f "$javaExecutable")" 112 | fi 113 | javaHome="$(dirname "$javaExecutable")" 114 | javaHome=$(expr "$javaHome" : '\(.*\)/bin') 115 | JAVA_HOME="$javaHome" 116 | export JAVA_HOME 117 | fi 118 | fi 119 | fi 120 | 121 | if [ -z "$JAVACMD" ]; then 122 | if [ -n "$JAVA_HOME" ]; then 123 | if [ -x "$JAVA_HOME/jre/sh/java" ]; then 124 | # IBM's JDK on AIX uses strange locations for the executables 125 | JAVACMD="$JAVA_HOME/jre/sh/java" 126 | else 127 | JAVACMD="$JAVA_HOME/bin/java" 128 | fi 129 | else 130 | JAVACMD="$( 131 | \unset -f command 2>/dev/null 132 | \command -v java 133 | )" 134 | fi 135 | fi 136 | 137 | if [ ! -x "$JAVACMD" ]; then 138 | echo "Error: JAVA_HOME is not defined correctly." >&2 139 | echo " We cannot execute $JAVACMD" >&2 140 | exit 1 141 | fi 142 | 143 | if [ -z "$JAVA_HOME" ]; then 144 | echo "Warning: JAVA_HOME environment variable is not set." >&2 145 | fi 146 | 147 | # traverses directory structure from process work directory to filesystem root 148 | # first directory with .mvn subdirectory is considered project base directory 149 | find_maven_basedir() { 150 | if [ -z "$1" ]; then 151 | echo "Path not specified to find_maven_basedir" >&2 152 | return 1 153 | fi 154 | 155 | basedir="$1" 156 | wdir="$1" 157 | while [ "$wdir" != '/' ]; do 158 | if [ -d "$wdir"/.mvn ]; then 159 | basedir=$wdir 160 | break 161 | fi 162 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 163 | if [ -d "${wdir}" ]; then 164 | wdir=$( 165 | cd "$wdir/.." || exit 1 166 | pwd 167 | ) 168 | fi 169 | # end of workaround 170 | done 171 | printf '%s' "$( 172 | cd "$basedir" || exit 1 173 | pwd 174 | )" 175 | } 176 | 177 | # concatenates all lines of a file 178 | concat_lines() { 179 | if [ -f "$1" ]; then 180 | # Remove \r in case we run on Windows within Git Bash 181 | # and check out the repository with auto CRLF management 182 | # enabled. Otherwise, we may read lines that are delimited with 183 | # \r\n and produce $'-Xarg\r' rather than -Xarg due to word 184 | # splitting rules. 185 | tr -s '\r\n' ' ' <"$1" 186 | fi 187 | } 188 | 189 | log() { 190 | if [ "$MVNW_VERBOSE" = true ]; then 191 | printf '%s\n' "$1" 192 | fi 193 | } 194 | 195 | BASE_DIR=$(find_maven_basedir "$(dirname "$0")") 196 | if [ -z "$BASE_DIR" ]; then 197 | exit 1 198 | fi 199 | 200 | MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 201 | export MAVEN_PROJECTBASEDIR 202 | log "$MAVEN_PROJECTBASEDIR" 203 | 204 | ########################################################################################## 205 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 206 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 207 | ########################################################################################## 208 | wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" 209 | if [ -r "$wrapperJarPath" ]; then 210 | log "Found $wrapperJarPath" 211 | else 212 | log "Couldn't find $wrapperJarPath, downloading it ..." 213 | 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" 216 | else 217 | wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" 218 | fi 219 | while IFS="=" read -r key value; do 220 | # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) 221 | safeValue=$(echo "$value" | tr -d '\r') 222 | case "$key" in wrapperUrl) 223 | wrapperUrl="$safeValue" 224 | break 225 | ;; 226 | esac 227 | done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" 228 | log "Downloading from: $wrapperUrl" 229 | 230 | if $cygwin; then 231 | wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") 232 | fi 233 | 234 | if command -v wget >/dev/null; then 235 | log "Found wget ... using wget" 236 | [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" 237 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 238 | wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 239 | else 240 | wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 241 | fi 242 | elif command -v curl >/dev/null; then 243 | log "Found curl ... using curl" 244 | [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" 245 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 246 | curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" 247 | else 248 | curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" 249 | fi 250 | else 251 | log "Falling back to using Java to download" 252 | javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" 253 | javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" 254 | # For Cygwin, switch paths to Windows format before running javac 255 | if $cygwin; then 256 | javaSource=$(cygpath --path --windows "$javaSource") 257 | javaClass=$(cygpath --path --windows "$javaClass") 258 | fi 259 | if [ -e "$javaSource" ]; then 260 | if [ ! -e "$javaClass" ]; then 261 | log " - Compiling MavenWrapperDownloader.java ..." 262 | ("$JAVA_HOME/bin/javac" "$javaSource") 263 | fi 264 | if [ -e "$javaClass" ]; then 265 | log " - Running MavenWrapperDownloader.java ..." 266 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" 267 | fi 268 | fi 269 | fi 270 | fi 271 | ########################################################################################## 272 | # End of extension 273 | ########################################################################################## 274 | 275 | # If specified, validate the SHA-256 sum of the Maven wrapper jar file 276 | wrapperSha256Sum="" 277 | while IFS="=" read -r key value; do 278 | case "$key" in wrapperSha256Sum) 279 | wrapperSha256Sum=$value 280 | break 281 | ;; 282 | esac 283 | done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" 284 | if [ -n "$wrapperSha256Sum" ]; then 285 | wrapperSha256Result=false 286 | if command -v sha256sum >/dev/null; then 287 | if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c >/dev/null 2>&1; then 288 | wrapperSha256Result=true 289 | fi 290 | elif command -v shasum >/dev/null; then 291 | if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c >/dev/null 2>&1; then 292 | wrapperSha256Result=true 293 | fi 294 | else 295 | echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 296 | echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." >&2 297 | exit 1 298 | fi 299 | if [ $wrapperSha256Result = false ]; then 300 | echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 301 | echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 302 | echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 303 | exit 1 304 | fi 305 | fi 306 | 307 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 308 | 309 | # For Cygwin, switch paths to Windows format before running java 310 | if $cygwin; then 311 | [ -n "$JAVA_HOME" ] \ 312 | && JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") 313 | [ -n "$CLASSPATH" ] \ 314 | && CLASSPATH=$(cygpath --path --windows "$CLASSPATH") 315 | [ -n "$MAVEN_PROJECTBASEDIR" ] \ 316 | && MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") 317 | fi 318 | 319 | # Provide a "standardized" way to retrieve the CLI args that will 320 | # work with both Windows and non-Windows executions. 321 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" 322 | export MAVEN_CMD_LINE_ARGS 323 | 324 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 325 | 326 | # shellcheck disable=SC2086 # safe args 327 | exec "$JAVACMD" \ 328 | $MAVEN_OPTS \ 329 | $MAVEN_DEBUG_OPTS \ 330 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 331 | "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 332 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 333 | -------------------------------------------------------------------------------- /finish/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Apache Maven Wrapper startup batch script, version 3.3.2 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 MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 28 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 29 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 30 | @REM e.g. to debug Maven itself, use 31 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 32 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 33 | @REM ---------------------------------------------------------------------------- 34 | 35 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 36 | @echo off 37 | @REM set title of command window 38 | title %0 39 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 40 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 41 | 42 | @REM set %HOME% to equivalent of $HOME 43 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 44 | 45 | @REM Execute a user defined script before this one 46 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 47 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 48 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 49 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 50 | :skipRcPre 51 | 52 | @setlocal 53 | 54 | set ERROR_CODE=0 55 | 56 | @REM To isolate internal variables from possible post scripts, we use another setlocal 57 | @setlocal 58 | 59 | @REM ==== START VALIDATION ==== 60 | if not "%JAVA_HOME%" == "" goto OkJHome 61 | 62 | echo. >&2 63 | echo Error: JAVA_HOME not found in your environment. >&2 64 | echo Please set the JAVA_HOME variable in your environment to match the >&2 65 | echo location of your Java installation. >&2 66 | echo. >&2 67 | goto error 68 | 69 | :OkJHome 70 | if exist "%JAVA_HOME%\bin\java.exe" goto init 71 | 72 | echo. >&2 73 | echo Error: JAVA_HOME is set to an invalid directory. >&2 74 | echo JAVA_HOME = "%JAVA_HOME%" >&2 75 | echo Please set the JAVA_HOME variable in your environment to match the >&2 76 | echo location of your Java installation. >&2 77 | echo. >&2 78 | goto error 79 | 80 | @REM ==== END VALIDATION ==== 81 | 82 | :init 83 | 84 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 85 | @REM Fallback to current working directory if not found. 86 | 87 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 88 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 89 | 90 | set EXEC_DIR=%CD% 91 | set WDIR=%EXEC_DIR% 92 | :findBaseDir 93 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 94 | cd .. 95 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 96 | set WDIR=%CD% 97 | goto findBaseDir 98 | 99 | :baseDirFound 100 | set MAVEN_PROJECTBASEDIR=%WDIR% 101 | cd "%EXEC_DIR%" 102 | goto endDetectBaseDir 103 | 104 | :baseDirNotFound 105 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 106 | cd "%EXEC_DIR%" 107 | 108 | :endDetectBaseDir 109 | 110 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 111 | 112 | @setlocal EnableExtensions EnableDelayedExpansion 113 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 114 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 115 | 116 | :endReadAdditionalConfig 117 | 118 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" 123 | 124 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 125 | IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | if "%MVNW_VERBOSE%" == "true" ( 132 | echo Found %WRAPPER_JAR% 133 | ) 134 | ) else ( 135 | if not "%MVNW_REPOURL%" == "" ( 136 | SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" 137 | ) 138 | if "%MVNW_VERBOSE%" == "true" ( 139 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 140 | echo Downloading from: %WRAPPER_URL% 141 | ) 142 | 143 | powershell -Command "&{"^ 144 | "$webclient = new-object System.Net.WebClient;"^ 145 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 146 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 147 | "}"^ 148 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ 149 | "}" 150 | if "%MVNW_VERBOSE%" == "true" ( 151 | echo Finished downloading %WRAPPER_JAR% 152 | ) 153 | ) 154 | @REM End of extension 155 | 156 | @REM If specified, validate the SHA-256 sum of the Maven wrapper jar file 157 | SET WRAPPER_SHA_256_SUM="" 158 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 159 | IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B 160 | ) 161 | IF NOT %WRAPPER_SHA_256_SUM%=="" ( 162 | powershell -Command "&{"^ 163 | "Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash;"^ 164 | "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ 165 | "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ 166 | " Write-Error 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ 167 | " Write-Error 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ 168 | " Write-Error 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ 169 | " exit 1;"^ 170 | "}"^ 171 | "}" 172 | if ERRORLEVEL 1 goto error 173 | ) 174 | 175 | @REM Provide a "standardized" way to retrieve the CLI args that will 176 | @REM work with both Windows and non-Windows executions. 177 | set MAVEN_CMD_LINE_ARGS=%* 178 | 179 | %MAVEN_JAVA_EXE% ^ 180 | %JVM_CONFIG_MAVEN_PROPS% ^ 181 | %MAVEN_OPTS% ^ 182 | %MAVEN_DEBUG_OPTS% ^ 183 | -classpath %WRAPPER_JAR% ^ 184 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 185 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 186 | if ERRORLEVEL 1 goto error 187 | goto end 188 | 189 | :error 190 | set ERROR_CODE=1 191 | 192 | :end 193 | @endlocal & set ERROR_CODE=%ERROR_CODE% 194 | 195 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 196 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 197 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 198 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 199 | :skipRcPost 200 | 201 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 202 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 203 | 204 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 205 | 206 | cmd /C exit /B %ERROR_CODE% 207 | -------------------------------------------------------------------------------- /finish/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 4.0.0 7 | 8 | 9 | io.openliberty.guides 10 | 11 | ServletSample 12 | 13 | 14 | war 15 | 16 | 1.0-SNAPSHOT 17 | 18 | 19 | 20 | 21 | UTF-8 22 | UTF-8 23 | 24 | 25 | 11 26 | 11 27 | 28 | 29 | 30 | 9080 31 | 32 | 9443 33 | ${project.artifactId} 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | jakarta.platform 44 | 45 | 46 | jakarta.jakartaee-api 47 | 48 | 49 | 10.0.0 50 | 51 | 52 | provided 53 | 54 | 55 | 56 | 57 | org.eclipse.microprofile 58 | microprofile 59 | 7.0 60 | pom 61 | provided 62 | 63 | 64 | 65 | 66 | org.apache.httpcomponents 67 | httpclient 68 | 4.5.14 69 | 70 | test 71 | 72 | 73 | 74 | 75 | 76 | org.junit.jupiter 77 | junit-jupiter 78 | 5.13.0 79 | 80 | test 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | ${project.artifactId} 90 | 91 | 92 | org.apache.maven.plugins 93 | maven-war-plugin 94 | 3.4.0 95 | 96 | 97 | 98 | io.openliberty.tools 99 | liberty-maven-plugin 100 | 3.11.3 101 | 102 | 103 | 104 | guideServer 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | org.apache.maven.plugins 113 | maven-failsafe-plugin 114 | 3.5.3 115 | 116 | 117 | 118 | 119 | ${liberty.var.http.port} 120 | 121 | 122 | ${liberty.var.app.context.root} 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /finish/src/main/java/io/openliberty/guides/hello/HelloServlet.java: -------------------------------------------------------------------------------- 1 | // tag::copyright[] 2 | /******************************************************************************* 3 | * Copyright (c) 2017, 2022 IBM Corporation and others. 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | *******************************************************************************/ 11 | // end::copyright[] 12 | package io.openliberty.guides.hello; 13 | 14 | import java.io.IOException; 15 | 16 | import jakarta.servlet.ServletException; 17 | import jakarta.servlet.annotation.WebServlet; 18 | import jakarta.servlet.http.HttpServlet; 19 | import jakarta.servlet.http.HttpServletRequest; 20 | import jakarta.servlet.http.HttpServletResponse; 21 | 22 | @WebServlet(urlPatterns = "/servlet") 23 | public class HelloServlet extends HttpServlet { 24 | private static final long serialVersionUID = 1L; 25 | 26 | // tag::javadoc1[] 27 | /** 28 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) 29 | */ 30 | // end::javadoc1[] 31 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 32 | throws ServletException, IOException { 33 | // tag::responseString[] 34 | response.getWriter().append("Hello! How are you today?\n"); 35 | // end::responseString[] 36 | } 37 | 38 | // tag::javadoc2[] 39 | /** 40 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) 41 | */ 42 | // end::javadoc2[] 43 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 44 | throws ServletException, IOException { 45 | doGet(request, response); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /finish/src/main/liberty/config/server.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | jakartaee-10.0 4 | servlet 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /finish/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | Hello Servlet 6 | 7 | 8 | index.html 9 | 10 | 11 | -------------------------------------------------------------------------------- /finish/src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 |

Welcome to Hello Servlet

16 |

17 | Click here to get a greeting from the Hello Servlet. 18 |

19 | 20 | 21 | -------------------------------------------------------------------------------- /finish/src/test/java/io/openliberty/guides/hello/it/EndpointIT.java: -------------------------------------------------------------------------------- 1 | // tag::copyright[] 2 | /******************************************************************************* 3 | * Copyright (c) 2017, 2023 IBM Corporation and others. 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | *******************************************************************************/ 11 | // end::copyright[] 12 | package io.openliberty.guides.hello.it; 13 | 14 | //tag::import[] 15 | import static org.junit.jupiter.api.Assertions.assertEquals; 16 | import static org.junit.jupiter.api.Assertions.assertTrue; 17 | 18 | import java.io.BufferedReader; 19 | import java.io.InputStreamReader; 20 | 21 | import org.apache.http.HttpStatus; 22 | import org.apache.http.client.methods.CloseableHttpResponse; 23 | import org.apache.http.client.methods.HttpGet; 24 | import org.apache.http.impl.client.CloseableHttpClient; 25 | import org.apache.http.impl.client.HttpClientBuilder; 26 | import org.junit.jupiter.api.BeforeAll; 27 | import org.junit.jupiter.api.Test; 28 | //end::import[] 29 | 30 | // tag::EndpointIT[] 31 | public class EndpointIT { 32 | private static String siteURL; 33 | 34 | @BeforeAll 35 | public static void init() { 36 | // tag::URL[] 37 | String port = System.getProperty("http.port"); 38 | String war = System.getProperty("war.name"); 39 | siteURL = "http://localhost:" + port + "/" + war + "/" + "servlet"; 40 | // end::URL[] 41 | } 42 | 43 | // tag::Test[] 44 | @Test 45 | // end::Test[] 46 | public void testServlet() throws Exception { 47 | 48 | CloseableHttpClient client = HttpClientBuilder.create().build(); 49 | HttpGet httpGet = new HttpGet(siteURL); 50 | CloseableHttpResponse response = null; 51 | 52 | // tag::link[] 53 | try { 54 | response = client.execute(httpGet); 55 | 56 | int statusCode = response.getStatusLine().getStatusCode(); 57 | assertEquals(HttpStatus.SC_OK, statusCode, "HTTP GET failed"); 58 | 59 | BufferedReader reader = new BufferedReader(new InputStreamReader( 60 | response.getEntity().getContent())); 61 | String line; 62 | StringBuffer buffer = new StringBuffer(); 63 | while ((line = reader.readLine()) != null) { 64 | buffer.append(line); 65 | } 66 | reader.close(); 67 | assertTrue(buffer.toString().contains("Hello! How are you today?"), 68 | "Unexpected response body: " + buffer.toString()); 69 | } finally { 70 | response.close(); 71 | httpGet.releaseConnection(); 72 | } 73 | // end::link[] 74 | } 75 | } 76 | // end::EndpointIT[] 77 | -------------------------------------------------------------------------------- /scripts/dailyBuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | while getopts t:d: flag; 3 | do 4 | case "${flag}" in 5 | t) DATE="${OPTARG}";; 6 | d) DRIVER="${OPTARG}";; 7 | *) echo "Invalid option";; 8 | esac 9 | done 10 | 11 | sed -i "\#liberty-maven-plugin#,\##cliberty-maven-plugin3.11.3https://public.dhe.ibm.com/ibmdl/export/pub/software/openliberty/runtime/nightly/$DATE/$DRIVER" pom.xml 12 | cat pom.xml 13 | 14 | ../scripts/testApp.sh 15 | -------------------------------------------------------------------------------- /scripts/testApp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euxo pipefail 3 | ./mvnw -version 4 | 5 | # LMP 3.0+ goals are listed here: https://github.com/OpenLiberty/ci.maven#goals 6 | 7 | ## Rebuild the application 8 | # package - Take the compiled code and package it in its distributable format. 9 | # liberty:create - Create a Liberty server. 10 | # liberty:install-feature - Install a feature packaged as a Subsystem Archive (esa) to the Liberty runtime. 11 | # liberty:deploy - Copy applications to the Liberty server's dropins or apps directory. 12 | ./mvnw -Dhttp.keepAlive=false \ 13 | -Dmaven.wagon.http.pool=false \ 14 | -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 \ 15 | -q clean package liberty:create liberty:install-feature liberty:deploy 16 | 17 | 18 | ## Run the tests 19 | # These commands are separated because if one of the commands fail, the test script will fail and exit. 20 | # e.g if liberty:start fails, then there is no need to run the failsafe commands. 21 | # liberty:start - Start a Liberty server in the background. 22 | # failsafe:integration-test - Runs the integration tests of an application. 23 | # liberty:stop - Stop a Liberty server. 24 | # failsafe:verify - Verifies that the integration tests of an application passed. 25 | ./mvnw liberty:start 26 | ./mvnw failsafe:integration-test liberty:stop 27 | ./mvnw failsafe:verify 28 | -------------------------------------------------------------------------------- /start/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/guide-maven-intro/75ec74bac2a270fb9113385b8fdef78e4a0bfea4/start/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /start/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar 3 | -------------------------------------------------------------------------------- /start/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Apache Maven Wrapper startup batch script, version 3.3.2 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | # e.g. to debug Maven itself, use 32 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | # ---------------------------------------------------------------------------- 35 | 36 | if [ -z "$MAVEN_SKIP_RC" ]; then 37 | 38 | if [ -f /usr/local/etc/mavenrc ]; then 39 | . /usr/local/etc/mavenrc 40 | fi 41 | 42 | if [ -f /etc/mavenrc ]; then 43 | . /etc/mavenrc 44 | fi 45 | 46 | if [ -f "$HOME/.mavenrc" ]; then 47 | . "$HOME/.mavenrc" 48 | fi 49 | 50 | fi 51 | 52 | # OS specific support. $var _must_ be set to either true or false. 53 | cygwin=false 54 | darwin=false 55 | mingw=false 56 | case "$(uname)" in 57 | CYGWIN*) cygwin=true ;; 58 | MINGW*) mingw=true ;; 59 | Darwin*) 60 | 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 | JAVA_HOME="$(/usr/libexec/java_home)" 66 | export JAVA_HOME 67 | else 68 | JAVA_HOME="/Library/Java/Home" 69 | export JAVA_HOME 70 | fi 71 | fi 72 | ;; 73 | esac 74 | 75 | if [ -z "$JAVA_HOME" ]; then 76 | if [ -r /etc/gentoo-release ]; then 77 | JAVA_HOME=$(java-config --jre-home) 78 | fi 79 | fi 80 | 81 | # For Cygwin, ensure paths are in UNIX format before anything is touched 82 | if $cygwin; then 83 | [ -n "$JAVA_HOME" ] \ 84 | && JAVA_HOME=$(cygpath --unix "$JAVA_HOME") 85 | [ -n "$CLASSPATH" ] \ 86 | && CLASSPATH=$(cygpath --path --unix "$CLASSPATH") 87 | fi 88 | 89 | # For Mingw, ensure paths are in UNIX format before anything is touched 90 | if $mingw; then 91 | [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] \ 92 | && JAVA_HOME="$( 93 | cd "$JAVA_HOME" || ( 94 | echo "cannot cd into $JAVA_HOME." >&2 95 | exit 1 96 | ) 97 | pwd 98 | )" 99 | fi 100 | 101 | if [ -z "$JAVA_HOME" ]; then 102 | javaExecutable="$(which javac)" 103 | if [ -n "$javaExecutable" ] && ! [ "$(expr "$javaExecutable" : '\([^ ]*\)')" = "no" ]; then 104 | # readlink(1) is not available as standard on Solaris 10. 105 | readLink=$(which readlink) 106 | if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then 107 | if $darwin; then 108 | javaHome="$(dirname "$javaExecutable")" 109 | javaExecutable="$(cd "$javaHome" && pwd -P)/javac" 110 | else 111 | javaExecutable="$(readlink -f "$javaExecutable")" 112 | fi 113 | javaHome="$(dirname "$javaExecutable")" 114 | javaHome=$(expr "$javaHome" : '\(.*\)/bin') 115 | JAVA_HOME="$javaHome" 116 | export JAVA_HOME 117 | fi 118 | fi 119 | fi 120 | 121 | if [ -z "$JAVACMD" ]; then 122 | if [ -n "$JAVA_HOME" ]; then 123 | if [ -x "$JAVA_HOME/jre/sh/java" ]; then 124 | # IBM's JDK on AIX uses strange locations for the executables 125 | JAVACMD="$JAVA_HOME/jre/sh/java" 126 | else 127 | JAVACMD="$JAVA_HOME/bin/java" 128 | fi 129 | else 130 | JAVACMD="$( 131 | \unset -f command 2>/dev/null 132 | \command -v java 133 | )" 134 | fi 135 | fi 136 | 137 | if [ ! -x "$JAVACMD" ]; then 138 | echo "Error: JAVA_HOME is not defined correctly." >&2 139 | echo " We cannot execute $JAVACMD" >&2 140 | exit 1 141 | fi 142 | 143 | if [ -z "$JAVA_HOME" ]; then 144 | echo "Warning: JAVA_HOME environment variable is not set." >&2 145 | fi 146 | 147 | # traverses directory structure from process work directory to filesystem root 148 | # first directory with .mvn subdirectory is considered project base directory 149 | find_maven_basedir() { 150 | if [ -z "$1" ]; then 151 | echo "Path not specified to find_maven_basedir" >&2 152 | return 1 153 | fi 154 | 155 | basedir="$1" 156 | wdir="$1" 157 | while [ "$wdir" != '/' ]; do 158 | if [ -d "$wdir"/.mvn ]; then 159 | basedir=$wdir 160 | break 161 | fi 162 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 163 | if [ -d "${wdir}" ]; then 164 | wdir=$( 165 | cd "$wdir/.." || exit 1 166 | pwd 167 | ) 168 | fi 169 | # end of workaround 170 | done 171 | printf '%s' "$( 172 | cd "$basedir" || exit 1 173 | pwd 174 | )" 175 | } 176 | 177 | # concatenates all lines of a file 178 | concat_lines() { 179 | if [ -f "$1" ]; then 180 | # Remove \r in case we run on Windows within Git Bash 181 | # and check out the repository with auto CRLF management 182 | # enabled. Otherwise, we may read lines that are delimited with 183 | # \r\n and produce $'-Xarg\r' rather than -Xarg due to word 184 | # splitting rules. 185 | tr -s '\r\n' ' ' <"$1" 186 | fi 187 | } 188 | 189 | log() { 190 | if [ "$MVNW_VERBOSE" = true ]; then 191 | printf '%s\n' "$1" 192 | fi 193 | } 194 | 195 | BASE_DIR=$(find_maven_basedir "$(dirname "$0")") 196 | if [ -z "$BASE_DIR" ]; then 197 | exit 1 198 | fi 199 | 200 | MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 201 | export MAVEN_PROJECTBASEDIR 202 | log "$MAVEN_PROJECTBASEDIR" 203 | 204 | ########################################################################################## 205 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 206 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 207 | ########################################################################################## 208 | wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" 209 | if [ -r "$wrapperJarPath" ]; then 210 | log "Found $wrapperJarPath" 211 | else 212 | log "Couldn't find $wrapperJarPath, downloading it ..." 213 | 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" 216 | else 217 | wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" 218 | fi 219 | while IFS="=" read -r key value; do 220 | # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) 221 | safeValue=$(echo "$value" | tr -d '\r') 222 | case "$key" in wrapperUrl) 223 | wrapperUrl="$safeValue" 224 | break 225 | ;; 226 | esac 227 | done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" 228 | log "Downloading from: $wrapperUrl" 229 | 230 | if $cygwin; then 231 | wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") 232 | fi 233 | 234 | if command -v wget >/dev/null; then 235 | log "Found wget ... using wget" 236 | [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" 237 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 238 | wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 239 | else 240 | wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 241 | fi 242 | elif command -v curl >/dev/null; then 243 | log "Found curl ... using curl" 244 | [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" 245 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 246 | curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" 247 | else 248 | curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" 249 | fi 250 | else 251 | log "Falling back to using Java to download" 252 | javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" 253 | javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" 254 | # For Cygwin, switch paths to Windows format before running javac 255 | if $cygwin; then 256 | javaSource=$(cygpath --path --windows "$javaSource") 257 | javaClass=$(cygpath --path --windows "$javaClass") 258 | fi 259 | if [ -e "$javaSource" ]; then 260 | if [ ! -e "$javaClass" ]; then 261 | log " - Compiling MavenWrapperDownloader.java ..." 262 | ("$JAVA_HOME/bin/javac" "$javaSource") 263 | fi 264 | if [ -e "$javaClass" ]; then 265 | log " - Running MavenWrapperDownloader.java ..." 266 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" 267 | fi 268 | fi 269 | fi 270 | fi 271 | ########################################################################################## 272 | # End of extension 273 | ########################################################################################## 274 | 275 | # If specified, validate the SHA-256 sum of the Maven wrapper jar file 276 | wrapperSha256Sum="" 277 | while IFS="=" read -r key value; do 278 | case "$key" in wrapperSha256Sum) 279 | wrapperSha256Sum=$value 280 | break 281 | ;; 282 | esac 283 | done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" 284 | if [ -n "$wrapperSha256Sum" ]; then 285 | wrapperSha256Result=false 286 | if command -v sha256sum >/dev/null; then 287 | if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c >/dev/null 2>&1; then 288 | wrapperSha256Result=true 289 | fi 290 | elif command -v shasum >/dev/null; then 291 | if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c >/dev/null 2>&1; then 292 | wrapperSha256Result=true 293 | fi 294 | else 295 | echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 296 | echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." >&2 297 | exit 1 298 | fi 299 | if [ $wrapperSha256Result = false ]; then 300 | echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 301 | echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 302 | echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 303 | exit 1 304 | fi 305 | fi 306 | 307 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 308 | 309 | # For Cygwin, switch paths to Windows format before running java 310 | if $cygwin; then 311 | [ -n "$JAVA_HOME" ] \ 312 | && JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") 313 | [ -n "$CLASSPATH" ] \ 314 | && CLASSPATH=$(cygpath --path --windows "$CLASSPATH") 315 | [ -n "$MAVEN_PROJECTBASEDIR" ] \ 316 | && MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") 317 | fi 318 | 319 | # Provide a "standardized" way to retrieve the CLI args that will 320 | # work with both Windows and non-Windows executions. 321 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" 322 | export MAVEN_CMD_LINE_ARGS 323 | 324 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 325 | 326 | # shellcheck disable=SC2086 # safe args 327 | exec "$JAVACMD" \ 328 | $MAVEN_OPTS \ 329 | $MAVEN_DEBUG_OPTS \ 330 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 331 | "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 332 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 333 | -------------------------------------------------------------------------------- /start/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Apache Maven Wrapper startup batch script, version 3.3.2 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 MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 28 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 29 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 30 | @REM e.g. to debug Maven itself, use 31 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 32 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 33 | @REM ---------------------------------------------------------------------------- 34 | 35 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 36 | @echo off 37 | @REM set title of command window 38 | title %0 39 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 40 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 41 | 42 | @REM set %HOME% to equivalent of $HOME 43 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 44 | 45 | @REM Execute a user defined script before this one 46 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 47 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 48 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 49 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 50 | :skipRcPre 51 | 52 | @setlocal 53 | 54 | set ERROR_CODE=0 55 | 56 | @REM To isolate internal variables from possible post scripts, we use another setlocal 57 | @setlocal 58 | 59 | @REM ==== START VALIDATION ==== 60 | if not "%JAVA_HOME%" == "" goto OkJHome 61 | 62 | echo. >&2 63 | echo Error: JAVA_HOME not found in your environment. >&2 64 | echo Please set the JAVA_HOME variable in your environment to match the >&2 65 | echo location of your Java installation. >&2 66 | echo. >&2 67 | goto error 68 | 69 | :OkJHome 70 | if exist "%JAVA_HOME%\bin\java.exe" goto init 71 | 72 | echo. >&2 73 | echo Error: JAVA_HOME is set to an invalid directory. >&2 74 | echo JAVA_HOME = "%JAVA_HOME%" >&2 75 | echo Please set the JAVA_HOME variable in your environment to match the >&2 76 | echo location of your Java installation. >&2 77 | echo. >&2 78 | goto error 79 | 80 | @REM ==== END VALIDATION ==== 81 | 82 | :init 83 | 84 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 85 | @REM Fallback to current working directory if not found. 86 | 87 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 88 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 89 | 90 | set EXEC_DIR=%CD% 91 | set WDIR=%EXEC_DIR% 92 | :findBaseDir 93 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 94 | cd .. 95 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 96 | set WDIR=%CD% 97 | goto findBaseDir 98 | 99 | :baseDirFound 100 | set MAVEN_PROJECTBASEDIR=%WDIR% 101 | cd "%EXEC_DIR%" 102 | goto endDetectBaseDir 103 | 104 | :baseDirNotFound 105 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 106 | cd "%EXEC_DIR%" 107 | 108 | :endDetectBaseDir 109 | 110 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 111 | 112 | @setlocal EnableExtensions EnableDelayedExpansion 113 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 114 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 115 | 116 | :endReadAdditionalConfig 117 | 118 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" 123 | 124 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 125 | IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | if "%MVNW_VERBOSE%" == "true" ( 132 | echo Found %WRAPPER_JAR% 133 | ) 134 | ) else ( 135 | if not "%MVNW_REPOURL%" == "" ( 136 | SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" 137 | ) 138 | if "%MVNW_VERBOSE%" == "true" ( 139 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 140 | echo Downloading from: %WRAPPER_URL% 141 | ) 142 | 143 | powershell -Command "&{"^ 144 | "$webclient = new-object System.Net.WebClient;"^ 145 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 146 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 147 | "}"^ 148 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ 149 | "}" 150 | if "%MVNW_VERBOSE%" == "true" ( 151 | echo Finished downloading %WRAPPER_JAR% 152 | ) 153 | ) 154 | @REM End of extension 155 | 156 | @REM If specified, validate the SHA-256 sum of the Maven wrapper jar file 157 | SET WRAPPER_SHA_256_SUM="" 158 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 159 | IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B 160 | ) 161 | IF NOT %WRAPPER_SHA_256_SUM%=="" ( 162 | powershell -Command "&{"^ 163 | "Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash;"^ 164 | "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ 165 | "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ 166 | " Write-Error 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ 167 | " Write-Error 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ 168 | " Write-Error 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ 169 | " exit 1;"^ 170 | "}"^ 171 | "}" 172 | if ERRORLEVEL 1 goto error 173 | ) 174 | 175 | @REM Provide a "standardized" way to retrieve the CLI args that will 176 | @REM work with both Windows and non-Windows executions. 177 | set MAVEN_CMD_LINE_ARGS=%* 178 | 179 | %MAVEN_JAVA_EXE% ^ 180 | %JVM_CONFIG_MAVEN_PROPS% ^ 181 | %MAVEN_OPTS% ^ 182 | %MAVEN_DEBUG_OPTS% ^ 183 | -classpath %WRAPPER_JAR% ^ 184 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 185 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 186 | if ERRORLEVEL 1 goto error 187 | goto end 188 | 189 | :error 190 | set ERROR_CODE=1 191 | 192 | :end 193 | @endlocal & set ERROR_CODE=%ERROR_CODE% 194 | 195 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 196 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 197 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 198 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 199 | :skipRcPost 200 | 201 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 202 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 203 | 204 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 205 | 206 | cmd /C exit /B %ERROR_CODE% 207 | -------------------------------------------------------------------------------- /start/src/main/java/io/openliberty/guides/hello/HelloServlet.java: -------------------------------------------------------------------------------- 1 | // tag::copyright[] 2 | /******************************************************************************* 3 | * Copyright (c) 2017, 2022 IBM Corporation and others. 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License 2.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-2.0/ 8 | * 9 | * SPDX-License-Identifier: EPL-2.0 10 | *******************************************************************************/ 11 | // end::copyright[] 12 | package io.openliberty.guides.hello; 13 | 14 | import java.io.IOException; 15 | 16 | import jakarta.servlet.ServletException; 17 | import jakarta.servlet.annotation.WebServlet; 18 | import jakarta.servlet.http.HttpServlet; 19 | import jakarta.servlet.http.HttpServletRequest; 20 | import jakarta.servlet.http.HttpServletResponse; 21 | 22 | @WebServlet(urlPatterns = "/servlet") 23 | public class HelloServlet extends HttpServlet { 24 | private static final long serialVersionUID = 1L; 25 | 26 | /** 27 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) 28 | */ 29 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 30 | throws ServletException, IOException { 31 | response.getWriter().append("Hello! How are you today?\n"); 32 | } 33 | 34 | /** 35 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) 36 | */ 37 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 38 | throws ServletException, IOException { 39 | doGet(request, response); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /start/src/main/liberty/config/server.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | jakartaee-10.0 4 | servlet 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /start/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | Hello Servlet 6 | 7 | 8 | index.html 9 | 10 | 11 | -------------------------------------------------------------------------------- /start/src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | 15 |

Welcome to Hello Servlet

16 |

17 | Click here to get a greeting from the Hello Servlet. 18 |

19 | 20 | 21 | -------------------------------------------------------------------------------- /start/src/test/java/io/openliberty/guides/hello/it/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenLiberty/guide-maven-intro/75ec74bac2a270fb9113385b8fdef78e4a0bfea4/start/src/test/java/io/openliberty/guides/hello/it/.gitkeep --------------------------------------------------------------------------------