├── .github ├── dependabot.yml ├── release-drafter.yml └── workflows │ ├── maven.yml │ └── release-drafter.yml ├── .gitignore ├── LICENSE.txt ├── README.md ├── pom.xml └── src ├── it ├── check-fails │ ├── invoker.properties │ └── pom.xml ├── check-separate-fails │ ├── invalid-pom.xml │ ├── invoker.properties │ └── pom.xml ├── check-separate-succeeds │ ├── invoker.properties │ ├── pom.xml │ └── valid-pom.xml ├── check-succeeds │ ├── invoker.properties │ └── pom.xml ├── pom │ ├── invoker.properties │ ├── pom-expected.xml │ ├── pom.xml │ └── verify.groovy ├── separate-pom │ ├── invoker.properties │ ├── pom.xml │ ├── separate-pom-expected.xml │ ├── separate-pom.xml │ └── verify.groovy └── settings.xml ├── main └── java │ └── org │ └── codehaus │ └── mojo │ └── tidy │ ├── CheckMojo.java │ ├── PomMojo.java │ ├── TidyMojo.java │ └── task │ ├── EnsureOrderAndIndent.java │ ├── EnsureSingleLineProjectStartTag.java │ ├── EnsureTrailingNewLine.java │ ├── EnsureXmlHeader.java │ ├── Format.java │ ├── FormatIdentifier.java │ ├── PomTidy.java │ ├── TidyTask.java │ └── XMLEventReaderFactory.java ├── site ├── markdown │ ├── index.md │ └── usage.md.vm └── site.xml └── test ├── java └── org │ └── codehaus │ └── mojo │ └── tidy │ └── task │ ├── EnsureSingleLineProjectStartTagTest.java │ ├── PomTidyFixesTest.java │ └── PomTidyTest.java └── resources └── org └── codehaus └── mojo └── tidy └── task ├── EnsureSingleLineProjectStartTagTest ├── project-single-line │ ├── pom-expected.xml │ └── pom.xml ├── project-support-4-1-0-attributes-with-unordered-nodes │ ├── pom-expected.xml │ └── pom.xml ├── project-support-4-1-0-attributes │ ├── pom-expected.xml │ └── pom.xml └── project-support-4-1-0-model-version │ ├── pom-expected.xml │ └── pom.xml ├── add-xml-declaration ├── pom-expected.xml └── pom.xml ├── complete-pom ├── pom-expected.xml └── pom.xml ├── do-not-mix-tab-and-spaces ├── pom-expected.xml └── pom.xml ├── fixes └── order-and-indent-start-element-of-scope │ ├── property-ending-with-dependency.pom.xml │ └── property-ending-with-plugin.pom.xml ├── groupid-artifactid-version ├── pom-expected.xml └── pom.xml ├── plugin-config-with-maven-element-names ├── pom-expected.xml └── pom.xml ├── pom-space-indent ├── pom-expected.xml └── pom.xml ├── pom-tab-indent ├── pom-expected.xml └── pom.xml ├── pom-with-comments ├── pom-expected.xml └── pom.xml ├── pom-with-crlf ├── pom-expected.xml └── pom.xml ├── pom-with-line-without-indent ├── pom-expected.xml └── pom.xml ├── pom-with-profiles ├── pom-expected.xml └── pom.xml ├── pom-with-reporting ├── pom-expected.xml └── pom.xml ├── project-single-line ├── pom-expected.xml └── pom.xml ├── project-support-4-1-0-attributes-with-unordered-nodes ├── pom-expected.xml └── pom.xml ├── project-support-4-1-0-attributes ├── pom-expected.xml └── pom.xml └── project-support-4-1-0-model-version ├── pom-expected.xml └── pom.xml /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | updates: 4 | - package-ecosystem: maven 5 | directory: "/" 6 | schedule: 7 | interval: daily 8 | 9 | - package-ecosystem: github-actions 10 | directory: "/" 11 | schedule: 12 | interval: daily 13 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | _extends: .github 2 | -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | name: Java CI 19 | 20 | on: [push, pull_request] 21 | 22 | jobs: 23 | build: 24 | name: Verify 25 | uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4 26 | with: 27 | maven4-enabled: true 28 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | name: Release Drafter 19 | on: 20 | push: 21 | branches: 22 | - master 23 | jobs: 24 | update_release_draft: 25 | uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v4 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .settings 3 | .project 4 | .classpath 5 | *.iml 6 | *.ipr 7 | *.iws 8 | .idea 9 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MojoHaus Tidy Maven Plugin 2 | 3 | This is the [tidy-maven-plugin](http://www.mojohaus.org/tidy-maven-plugin/). 4 | 5 | [![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/mojohaus/tidy-maven-plugin.svg?label=License)](http://www.apache.org/licenses/) 6 | [![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.mojo/tidy-maven-plugin.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.codehaus.mojo/tidy-maven-plugin) 7 | [![Build Status](https://github.com/mojohaus/tidy-maven-plugin/actions/workflows/maven.yml/badge.svg)](https://github.com/mojohaus/tidy-maven-plugin/actions/workflows/maven.yml) 8 | 9 | ## Releasing 10 | 11 | * Make sure `gpg-agent` is running. 12 | * Execute `mvn -B release:prepare release:perform` 13 | 14 | For publishing the site do the following: 15 | 16 | ``` 17 | cd target/checkout 18 | mvn verify site site:stage scm-publish:publish-scm 19 | ``` 20 | 21 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 4.0.0 22 | 23 | 24 | org.codehaus.mojo 25 | mojo-parent 26 | 87 27 | 28 | 29 | 30 | tidy-maven-plugin 31 | 1.4.1-SNAPSHOT 32 | maven-plugin 33 | 34 | Tidy Maven Plugin 35 | Tidy Plugin for Maven. The Tidy plugin provides goals for tidying up 36 | your source code. 37 | https://www.mojohaus.org/tidy-maven-plugin/ 38 | 2011 39 | 40 | 41 | The Apache Software License, Version 2.0 42 | https://www.apache.org/licenses/LICENSE-2.0.txt 43 | repo 44 | 45 | 46 | 47 | 48 | 49 | Stephen Connolly 50 | stephen.alan.connolly@gmail.com 51 | 52 | Lead Developer 53 | 54 | 0 55 | 56 | 57 | Slawomir Jaranowski 58 | sjaranowski@apache.org 59 | 60 | Developer 61 | 62 | Europe/Warsaw 63 | 64 | 65 | 66 | 67 | ${mavenVersion} 68 | 69 | 70 | 71 | scm:git:https://github.com/mojohaus/tidy-maven-plugin.git 72 | scm:git:ssh://git@github.com/mojohaus/tidy-maven-plugin.git 73 | HEAD 74 | https://github.com/mojohaus/tidy-maven-plugin/tree/master 75 | 76 | 77 | 78 | 2025-03-08T07:55:57Z 79 | 80 | 81 | 82 | 83 | 84 | org.codehaus.plexus 85 | plexus-utils 86 | 4.0.2 87 | 88 | 89 | 90 | 91 | 92 | 93 | org.apache.maven 94 | maven-plugin-api 95 | ${mavenVersion} 96 | provided 97 | 98 | 99 | org.apache.maven 100 | maven-core 101 | ${mavenVersion} 102 | provided 103 | 104 | 105 | org.apache.maven.plugin-tools 106 | maven-plugin-annotations 107 | provided 108 | 109 | 110 | 111 | org.codehaus.plexus 112 | plexus-utils 113 | 114 | 115 | 116 | com.fasterxml.woodstox 117 | woodstox-core 118 | 7.1.1 119 | 120 | 121 | 122 | 123 | org.junit.jupiter 124 | junit-jupiter-api 125 | test 126 | 127 | 128 | org.junit.jupiter 129 | junit-jupiter-params 130 | test 131 | 132 | 133 | 134 | 135 | 136 | run-its 137 | 138 | 139 | 140 | org.apache.maven.plugins 141 | maven-invoker-plugin 142 | 143 | true 144 | ${project.build.directory}/it 145 | verify 146 | ${project.build.directory}/local-repo 147 | src/it/settings.xml 148 | 149 | 150 | 151 | integration-test 152 | 153 | install 154 | run 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /src/it/check-fails/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = verify 2 | invoker.buildResult = failure 3 | -------------------------------------------------------------------------------- /src/it/check-fails/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | pom-check-fails 5 | org.codehaus.mojo.tidy.its 6 | 4.0.0 7 | 1.0-SNAPSHOT 8 | 9 | Test that check fails for a POM that is not tidy. 10 | 11 | 12 | 13 | 14 | org.codehaus.mojo 15 | tidy-maven-plugin 16 | @project.version@ 17 | 18 | 19 | validate 20 | validate 21 | 22 | check 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/it/check-separate-fails/invalid-pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | pom-check-fails 5 | org.codehaus.mojo.tidy.its 6 | 7 | org.codehaus 8 | codehaus-parent 9 | 4 10 | 11 | 4.0.0 12 | 1.0-SNAPSHOT 13 | 14 | Test that check fails for a POM that is not tidy. 15 | 16 | -------------------------------------------------------------------------------- /src/it/check-separate-fails/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = verify 2 | invoker.buildResult = failure 3 | -------------------------------------------------------------------------------- /src/it/check-separate-fails/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | pom-check-separate-fails 7 | 1.0-SNAPSHOT 8 | 9 | Test that check fails for an external invalid POM 10 | 11 | 12 | 13 | 14 | org.codehaus.mojo 15 | tidy-maven-plugin 16 | @project.version@ 17 | 18 | 19 | validate 20 | validate 21 | 22 | check 23 | 24 | 25 | ${project.basedir}/invalid-pom.xml 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/it/check-separate-succeeds/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = verify 2 | -------------------------------------------------------------------------------- /src/it/check-separate-succeeds/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | pom-check-fails 5 | org.codehaus.mojo.tidy.its 6 | 4.0.0 7 | 1.0-SNAPSHOT 8 | 9 | Test that check passes for a separate POM that is tidy. 10 | 11 | 12 | 13 | 14 | org.codehaus.mojo 15 | tidy-maven-plugin 16 | @project.version@ 17 | 18 | 19 | validate 20 | validate 21 | 22 | check 23 | 24 | 25 | ${project.basedir}/valid-pom.xml 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/it/check-separate-succeeds/valid-pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | pom-check-succeeds 7 | 1.0-SNAPSHOT 8 | 9 | Test that check doesn't fail for a tidy separate POM 10 | 11 | -------------------------------------------------------------------------------- /src/it/check-succeeds/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = verify 2 | -------------------------------------------------------------------------------- /src/it/check-succeeds/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | pom-check-succeeds 7 | 1.0-SNAPSHOT 8 | 9 | Test that check doesn't fail for a tidy POM 10 | 11 | 12 | 13 | 14 | org.codehaus.mojo 15 | tidy-maven-plugin 16 | @project.version@ 17 | 18 | 19 | validate 20 | validate 21 | 22 | check 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/it/pom/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = org.codehaus.mojo:tidy-maven-plugin:${project.version}:pom 2 | -------------------------------------------------------------------------------- /src/it/pom/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | pom-space-indent 7 | 1.0-SNAPSHOT 8 | pom 9 | 10 | Complete POM test 11 | Test of tidy:pom on a pom with all elements. 12 | http://maven.apache.org 13 | 2011 14 | 15 | MojoHaus 16 | http://www.mojohaus.org 17 | 18 | 19 | 20 | The Apache Software License, Version 2.0 21 | http://www.apache.org/licenses/LICENSE-2.0.txt 22 | repo 23 | 24 | 25 | 26 | 27 | 28 | John Doe 29 | john.doe@acme.org 30 | 31 | Lead Developer 32 | 33 | 0 34 | 35 | 36 | 37 | 38 | Jane Doe 39 | jone.doe@acme.org 40 | 41 | 42 | 43 | 44 | 45 | MojoHaus Development List 46 | mojohaus-dev+subscribe@googlegroups.com 47 | mojohaus-dev+unsubscribe@googlegroups.com 48 | mojohaus-dev@googlegroups.com 49 | https://groups.google.com/forum/#!forum/mojohaus-dev 50 | 51 | 52 | Maven Users List 53 | users-subscribe@maven.apache.org 54 | users-unsubscribe@maven.apache.org 55 | users@maven.apache.org 56 | http://mail-archives.apache.org/mod_mbox/maven-users/ 57 | 58 | http://maven.40175.n5.nabble.com/Maven-Users-f40176.html 59 | 60 | 61 | 62 | 63 | 64 | 2.2.1 65 | 66 | 67 | 68 | scm:git:https://github.com/mojohaus/tidy-maven-plugin.git 69 | scm:git:ssh://git@github.com/mojohaus/tidy-maven-plugin.git 70 | https://github.com/mojohaus/tidy-maven-plugin 71 | 72 | 73 | GitHub 74 | https://github.com/mojohaus/tidy-maven-plugin/issues 75 | 76 | 77 | travis 78 | https://travis-ci.org/mojohaus/tidy-maven-plugin 79 | 80 | 81 | 82 | ossrh-staging 83 | https://oss.sonatype.org/service/local/staging/deploy/maven2 84 | 85 | 86 | ossrh-snapshots 87 | https://oss.sonatype.org/content/repositories/snapshots 88 | 89 | 90 | github 91 | scm:git:git@github.com:mojohaus/tidy-maven-plugin.git 92 | 93 | 94 | 95 | 96 | UTF-8 97 | 5.7.2 98 | 99 | 100 | 101 | 102 | 103 | org.codehaus.plexus 104 | plexus-utils 105 | 3.0.24 106 | jar 107 | compile 108 | 109 | 110 | 111 | 112 | 113 | org.junit.jupiter 114 | junit-jupiter-engine 115 | ${junit.version} 116 | test 117 | 118 | 119 | org.junit.vintage 120 | junit-vintage-engine 121 | ${junit.version} 122 | test 123 | 124 | 125 | org.apache.logging.log4j 126 | log4j-api 127 | 2.19.0 128 | bundle 129 | 130 | 131 | 132 | 133 | 134 | ossrh-snapshots 135 | ossrh-snapshots 136 | https://oss.sonatype.org/content/repositories/snapshots 137 | 138 | false 139 | 140 | 141 | true 142 | 143 | 144 | 145 | 146 | 147 | ossrh-snapshots 148 | ossrh-snapshots 149 | https://oss.sonatype.org/content/repositories/snapshots 150 | 151 | false 152 | 153 | 154 | true 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | org.apache.maven.plugins 164 | maven-compiler-plugin 165 | 2.5.1 166 | 167 | 168 | 169 | 170 | org.apache.maven.plugins 171 | maven-surefire-plugin 172 | 2.16 173 | 174 | 175 | 176 | 177 | 178 | org.codehaus.mojo 179 | build-helper-maven-plugin 180 | 1.8 181 | 182 | 183 | build-helper 184 | generate-sources 185 | 186 | add-source 187 | 188 | 189 | 190 | 191 | dummy 192 | 193 | 194 | 195 | 196 | 197 | org.apache.maven.wagon 198 | wagon-ssh-external 199 | 1.0-beta-6 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | org.apache.maven.plugins 208 | maven-project-info-reports-plugin 209 | 2.7 210 | 211 | 212 | 213 | 214 | 215 | 216 | run-its 217 | 218 | 219 | skipTests 220 | !true 221 | 222 | 223 | 224 | 225 | 226 | -------------------------------------------------------------------------------- /src/it/pom/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | pom 5 | 6 | pom-space-indent 7 | org.codehaus.mojo.tidy.its 8 | 4.0.0 9 | 1.0-SNAPSHOT 10 | Test of tidy:pom on a pom with all elements. 11 | 12 | 13 | 14 | The Apache Software License, Version 2.0 15 | http://www.apache.org/licenses/LICENSE-2.0.txt 16 | repo 17 | 18 | 19 | 20 | Complete POM test 21 | 2011 22 | http://maven.apache.org 23 | 24 | 25 | UTF-8 26 | 5.7.2 27 | 28 | 29 | 30 | ossrh-snapshots 31 | ossrh-snapshots 32 | https://oss.sonatype.org/content/repositories/snapshots 33 | 34 | false 35 | 36 | 37 | true 38 | 39 | 40 | 41 | 42 | MojoHaus 43 | http://www.mojohaus.org 44 | 45 | 46 | 47 | 48 | ossrh-snapshots 49 | ossrh-snapshots 50 | https://oss.sonatype.org/content/repositories/snapshots 51 | 52 | false 53 | 54 | 55 | true 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | MojoHaus Development List 64 | mojohaus-dev+subscribe@googlegroups.com 65 | mojohaus-dev+unsubscribe@googlegroups.com 66 | mojohaus-dev@googlegroups.com 67 | https://groups.google.com/forum/#!forum/mojohaus-dev 68 | 69 | 70 | Maven Users List 71 | users-subscribe@maven.apache.org 72 | users-unsubscribe@maven.apache.org 73 | users@maven.apache.org 74 | http://mail-archives.apache.org/mod_mbox/maven-users/ 75 | 76 | http://maven.40175.n5.nabble.com/Maven-Users-f40176.html 77 | 78 | 79 | 80 | 81 | scm:git:https://github.com/mojohaus/tidy-maven-plugin.git 82 | scm:git:ssh://git@github.com/mojohaus/tidy-maven-plugin.git 83 | https://github.com/mojohaus/tidy-maven-plugin 84 | 85 | 86 | 87 | 2.2.1 88 | 89 | 90 | 91 | GitHub 92 | https://github.com/mojohaus/tidy-maven-plugin/issues 93 | 94 | 95 | 96 | Jane Doe 97 | jone.doe@acme.org 98 | 99 | 100 | 101 | 102 | John Doe 103 | john.doe@acme.org 104 | 105 | Lead Developer 106 | 107 | 0 108 | 109 | 110 | 111 | 112 | 113 | ossrh-staging 114 | https://oss.sonatype.org/service/local/staging/deploy/maven2 115 | 116 | 117 | ossrh-snapshots 118 | https://oss.sonatype.org/content/repositories/snapshots 119 | 120 | 121 | github 122 | scm:git:git@github.com:mojohaus/tidy-maven-plugin.git 123 | 124 | 125 | 126 | 127 | 128 | 129 | org.codehaus.plexus 130 | plexus-utils 131 | 3.0.24 132 | jar 133 | compile 134 | 135 | 136 | 137 | 138 | 139 | 140 | org.apache.maven.wagon 141 | wagon-ssh-external 142 | 1.0-beta-6 143 | 144 | 145 | 146 | 147 | 148 | 149 | org.apache.maven.plugins 150 | maven-compiler-plugin 151 | 2.5.1 152 | 153 | 154 | 155 | 156 | org.apache.maven.plugins 157 | maven-surefire-plugin 158 | 2.16 159 | 160 | 161 | 162 | 163 | 164 | org.codehaus.mojo 165 | build-helper-maven-plugin 166 | 1.8 167 | 168 | 169 | build-helper 170 | generate-sources 171 | 172 | add-source 173 | 174 | 175 | 176 | 177 | dummy 178 | 179 | 180 | 181 | 182 | 183 | travis 184 | https://travis-ci.org/mojohaus/tidy-maven-plugin 185 | 186 | 187 | 188 | org.junit.jupiter 189 | junit-jupiter-engine 190 | ${junit.version} 191 | test 192 | 193 | 194 | org.junit.vintage 195 | junit-vintage-engine 196 | ${junit.version} 197 | test 198 | 199 | 200 | org.apache.logging.log4j 201 | log4j-api 202 | 2.19.0 203 | bundle 204 | 205 | 206 | 207 | 208 | 209 | 210 | org.apache.maven.plugins 211 | maven-project-info-reports-plugin 212 | 2.7 213 | 214 | 215 | 216 | 217 | 218 | run-its 219 | 220 | 221 | skipTests 222 | !true 223 | 224 | 225 | 226 | 227 | 228 | -------------------------------------------------------------------------------- /src/it/pom/verify.groovy: -------------------------------------------------------------------------------- 1 | File pomFile = new File( basedir, 'pom.xml' ) 2 | File expectedPomFile = new File( basedir, 'pom-expected.xml' ) 3 | 4 | assert pomFile.getText() == expectedPomFile.getText() 5 | -------------------------------------------------------------------------------- /src/it/separate-pom/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = org.codehaus.mojo:tidy-maven-plugin:${project.version}:pom -Dtidy.pomFile=separate-pom.xml 2 | -------------------------------------------------------------------------------- /src/it/separate-pom/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | pom 5 | 6 | pom-space-indent 7 | org.codehaus.mojo.tidy.its 8 | 4.0.0 9 | 1.0-SNAPSHOT 10 | Test of tidy:pom on a separate pom with all elements. 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/it/separate-pom/separate-pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | pom-space-indent 7 | 1.0-SNAPSHOT 8 | pom 9 | 10 | Complete POM test 11 | Test of tidy:pom on a separate pom with all elements. 12 | http://maven.apache.org 13 | 2011 14 | 15 | MojoHaus 16 | http://www.mojohaus.org 17 | 18 | 19 | 20 | The Apache Software License, Version 2.0 21 | http://www.apache.org/licenses/LICENSE-2.0.txt 22 | repo 23 | 24 | 25 | 26 | 27 | 28 | John Doe 29 | john.doe@acme.org 30 | 31 | Lead Developer 32 | 33 | 0 34 | 35 | 36 | 37 | 38 | Jane Doe 39 | jone.doe@acme.org 40 | 41 | 42 | 43 | 44 | 45 | MojoHaus Development List 46 | mojohaus-dev+subscribe@googlegroups.com 47 | mojohaus-dev+unsubscribe@googlegroups.com 48 | mojohaus-dev@googlegroups.com 49 | https://groups.google.com/forum/#!forum/mojohaus-dev 50 | 51 | 52 | Maven Users List 53 | users-subscribe@maven.apache.org 54 | users-unsubscribe@maven.apache.org 55 | users@maven.apache.org 56 | http://mail-archives.apache.org/mod_mbox/maven-users/ 57 | 58 | http://maven.40175.n5.nabble.com/Maven-Users-f40176.html 59 | 60 | 61 | 62 | 63 | 64 | 2.2.1 65 | 66 | 67 | 68 | scm:git:https://github.com/mojohaus/tidy-maven-plugin.git 69 | scm:git:ssh://git@github.com/mojohaus/tidy-maven-plugin.git 70 | https://github.com/mojohaus/tidy-maven-plugin 71 | 72 | 73 | GitHub 74 | https://github.com/mojohaus/tidy-maven-plugin/issues 75 | 76 | 77 | travis 78 | https://travis-ci.org/mojohaus/tidy-maven-plugin 79 | 80 | 81 | 82 | ossrh-staging 83 | https://oss.sonatype.org/service/local/staging/deploy/maven2 84 | 85 | 86 | ossrh-snapshots 87 | https://oss.sonatype.org/content/repositories/snapshots 88 | 89 | 90 | github 91 | scm:git:git@github.com:mojohaus/tidy-maven-plugin.git 92 | 93 | 94 | 95 | 96 | UTF-8 97 | 5.7.2 98 | 99 | 100 | 101 | 102 | 103 | org.codehaus.plexus 104 | plexus-utils 105 | 3.0.24 106 | jar 107 | compile 108 | 109 | 110 | 111 | 112 | 113 | org.junit.jupiter 114 | junit-jupiter-engine 115 | ${junit.version} 116 | test 117 | 118 | 119 | org.junit.vintage 120 | junit-vintage-engine 121 | ${junit.version} 122 | test 123 | 124 | 125 | org.apache.logging.log4j 126 | log4j-api 127 | 2.19.0 128 | bundle 129 | 130 | 131 | 132 | 133 | 134 | ossrh-snapshots 135 | ossrh-snapshots 136 | https://oss.sonatype.org/content/repositories/snapshots 137 | 138 | false 139 | 140 | 141 | true 142 | 143 | 144 | 145 | 146 | 147 | ossrh-snapshots 148 | ossrh-snapshots 149 | https://oss.sonatype.org/content/repositories/snapshots 150 | 151 | false 152 | 153 | 154 | true 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | org.apache.maven.plugins 164 | maven-compiler-plugin 165 | 2.5.1 166 | 167 | 168 | 169 | 170 | org.apache.maven.plugins 171 | maven-surefire-plugin 172 | 2.16 173 | 174 | 175 | 176 | 177 | 178 | org.codehaus.mojo 179 | build-helper-maven-plugin 180 | 1.8 181 | 182 | 183 | build-helper 184 | generate-sources 185 | 186 | add-source 187 | 188 | 189 | 190 | 191 | dummy 192 | 193 | 194 | 195 | 196 | 197 | org.apache.maven.wagon 198 | wagon-ssh-external 199 | 1.0-beta-6 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | org.apache.maven.plugins 208 | maven-project-info-reports-plugin 209 | 2.7 210 | 211 | 212 | 213 | 214 | 215 | 216 | run-its 217 | 218 | 219 | skipTests 220 | !true 221 | 222 | 223 | 224 | 225 | 226 | -------------------------------------------------------------------------------- /src/it/separate-pom/separate-pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | pom 5 | 6 | pom-space-indent 7 | org.codehaus.mojo.tidy.its 8 | 4.0.0 9 | 1.0-SNAPSHOT 10 | Test of tidy:pom on a separate pom with all elements. 11 | 12 | 13 | 14 | The Apache Software License, Version 2.0 15 | http://www.apache.org/licenses/LICENSE-2.0.txt 16 | repo 17 | 18 | 19 | 20 | Complete POM test 21 | 2011 22 | http://maven.apache.org 23 | 24 | 25 | UTF-8 26 | 5.7.2 27 | 28 | 29 | 30 | ossrh-snapshots 31 | ossrh-snapshots 32 | https://oss.sonatype.org/content/repositories/snapshots 33 | 34 | false 35 | 36 | 37 | true 38 | 39 | 40 | 41 | 42 | MojoHaus 43 | http://www.mojohaus.org 44 | 45 | 46 | 47 | 48 | ossrh-snapshots 49 | ossrh-snapshots 50 | https://oss.sonatype.org/content/repositories/snapshots 51 | 52 | false 53 | 54 | 55 | true 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | MojoHaus Development List 64 | mojohaus-dev+subscribe@googlegroups.com 65 | mojohaus-dev+unsubscribe@googlegroups.com 66 | mojohaus-dev@googlegroups.com 67 | https://groups.google.com/forum/#!forum/mojohaus-dev 68 | 69 | 70 | Maven Users List 71 | users-subscribe@maven.apache.org 72 | users-unsubscribe@maven.apache.org 73 | users@maven.apache.org 74 | http://mail-archives.apache.org/mod_mbox/maven-users/ 75 | 76 | http://maven.40175.n5.nabble.com/Maven-Users-f40176.html 77 | 78 | 79 | 80 | 81 | scm:git:https://github.com/mojohaus/tidy-maven-plugin.git 82 | scm:git:ssh://git@github.com/mojohaus/tidy-maven-plugin.git 83 | https://github.com/mojohaus/tidy-maven-plugin 84 | 85 | 86 | 87 | 2.2.1 88 | 89 | 90 | 91 | GitHub 92 | https://github.com/mojohaus/tidy-maven-plugin/issues 93 | 94 | 95 | 96 | Jane Doe 97 | jone.doe@acme.org 98 | 99 | 100 | 101 | 102 | John Doe 103 | john.doe@acme.org 104 | 105 | Lead Developer 106 | 107 | 0 108 | 109 | 110 | 111 | 112 | 113 | ossrh-staging 114 | https://oss.sonatype.org/service/local/staging/deploy/maven2 115 | 116 | 117 | ossrh-snapshots 118 | https://oss.sonatype.org/content/repositories/snapshots 119 | 120 | 121 | github 122 | scm:git:git@github.com:mojohaus/tidy-maven-plugin.git 123 | 124 | 125 | 126 | 127 | 128 | 129 | org.codehaus.plexus 130 | plexus-utils 131 | 3.0.24 132 | jar 133 | compile 134 | 135 | 136 | 137 | 138 | 139 | 140 | org.apache.maven.wagon 141 | wagon-ssh-external 142 | 1.0-beta-6 143 | 144 | 145 | 146 | 147 | 148 | 149 | org.apache.maven.plugins 150 | maven-compiler-plugin 151 | 2.5.1 152 | 153 | 154 | 155 | 156 | org.apache.maven.plugins 157 | maven-surefire-plugin 158 | 2.16 159 | 160 | 161 | 162 | 163 | 164 | org.codehaus.mojo 165 | build-helper-maven-plugin 166 | 1.8 167 | 168 | 169 | build-helper 170 | generate-sources 171 | 172 | add-source 173 | 174 | 175 | 176 | 177 | dummy 178 | 179 | 180 | 181 | 182 | 183 | travis 184 | https://travis-ci.org/mojohaus/tidy-maven-plugin 185 | 186 | 187 | 188 | org.junit.jupiter 189 | junit-jupiter-engine 190 | ${junit.version} 191 | test 192 | 193 | 194 | org.junit.vintage 195 | junit-vintage-engine 196 | ${junit.version} 197 | test 198 | 199 | 200 | org.apache.logging.log4j 201 | log4j-api 202 | 2.19.0 203 | bundle 204 | 205 | 206 | 207 | 208 | 209 | 210 | org.apache.maven.plugins 211 | maven-project-info-reports-plugin 212 | 2.7 213 | 214 | 215 | 216 | 217 | 218 | run-its 219 | 220 | 221 | skipTests 222 | !true 223 | 224 | 225 | 226 | 227 | 228 | -------------------------------------------------------------------------------- /src/it/separate-pom/verify.groovy: -------------------------------------------------------------------------------- 1 | File pomFile = new File( basedir, 'separate-pom.xml' ) 2 | File expectedPomFile = new File( basedir, 'separate-pom-expected.xml' ) 3 | 4 | assert pomFile.getText() == expectedPomFile.getText() 5 | -------------------------------------------------------------------------------- /src/it/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | it-repo 6 | 7 | true 8 | 9 | 10 | 11 | local.central 12 | @localRepositoryUrl@ 13 | 14 | true 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | 23 | local.central 24 | @localRepositoryUrl@ 25 | 26 | true 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/tidy/CheckMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.tidy; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import org.apache.maven.plugin.MojoExecutionException; 23 | import org.apache.maven.plugin.MojoFailureException; 24 | import org.apache.maven.plugins.annotations.LifecyclePhase; 25 | import org.apache.maven.plugins.annotations.Mojo; 26 | 27 | /** 28 | * Checks that the pom.xml is tidy. Fails the build if mvn tidy:pom would 29 | * create a different pom.xml than the current one. 30 | */ 31 | @Mojo(name = "check", defaultPhase = LifecyclePhase.VERIFY, threadSafe = true) 32 | public class CheckMojo extends TidyMojo { 33 | @Override 34 | protected void executeForPom(String pom) throws MojoExecutionException, MojoFailureException { 35 | String tidyPom = tidy(pom); 36 | if (!pom.equals(tidyPom)) { 37 | throw new MojoFailureException( 38 | "The POM violates the code style. Please format it by running `mvn tidy:pom`."); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/tidy/PomMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.tidy; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.io.IOException; 23 | 24 | import org.apache.maven.plugin.MojoExecutionException; 25 | import org.apache.maven.plugin.MojoFailureException; 26 | import org.apache.maven.plugins.annotations.Mojo; 27 | 28 | import static org.codehaus.plexus.util.FileUtils.fileWrite; 29 | 30 | /** 31 | * Tidy up the pom.xml into the canonical order. 32 | */ 33 | @Mojo(name = "pom") 34 | public class PomMojo extends TidyMojo { 35 | @Override 36 | protected void executeForPom(String pom) throws MojoExecutionException, MojoFailureException { 37 | try { 38 | String tidyPom = tidy(pom); 39 | fileWrite(getPomFile(), tidyPom); 40 | } catch (IOException e) { 41 | throw new MojoExecutionException("Failed to write the tidy POM.", e); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/tidy/TidyMojo.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.tidy; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import javax.xml.stream.XMLStreamException; 23 | 24 | import java.io.File; 25 | import java.io.IOException; 26 | 27 | import org.apache.maven.plugin.AbstractMojo; 28 | import org.apache.maven.plugin.MojoExecutionException; 29 | import org.apache.maven.plugin.MojoFailureException; 30 | import org.apache.maven.plugins.annotations.Parameter; 31 | import org.apache.maven.project.MavenProject; 32 | import org.codehaus.mojo.tidy.task.PomTidy; 33 | 34 | import static org.codehaus.plexus.util.FileUtils.fileRead; 35 | 36 | /** 37 | * An abstract base class for Mojos of the Tidy plugin. Handles common 38 | * configuration issues and provides the POM as String. 39 | */ 40 | public abstract class TidyMojo extends AbstractMojo { 41 | private static final PomTidy POM_TIDY = new PomTidy(); 42 | 43 | /** 44 | * The Maven Project. 45 | */ 46 | @Parameter(defaultValue = "${project}", required = true, readonly = true) 47 | protected MavenProject project; 48 | 49 | /** 50 | * The path of the pom file to process. 51 | * 52 | * @since 1.3.0 53 | */ 54 | @Parameter(property = "tidy.pomFile", defaultValue = "${project.file}") 55 | private File pomFile; 56 | 57 | /** 58 | * Set this to 'true' to skip execution. 59 | */ 60 | @Parameter(property = "tidy.skip", defaultValue = "false") 61 | protected boolean skip; 62 | 63 | /** 64 | * Perform whatever build-process behavior this Mojo implements using the specified POM. 65 | * 66 | * @param pom the project's POM. 67 | * @throws MojoExecutionException if an unexpected problem occurs. 68 | * Throwing this exception causes a "BUILD ERROR" message to be displayed. 69 | * @throws MojoFailureException if an expected problem (such as a compilation failure) occurs. 70 | * Throwing this exception causes a "BUILD FAILURE" message to be displayed. 71 | */ 72 | protected abstract void executeForPom(String pom) throws MojoExecutionException, MojoFailureException; 73 | 74 | @Override 75 | public void execute() throws MojoExecutionException, MojoFailureException { 76 | if (skip) { 77 | getLog().info("Tidy is skipped."); 78 | return; 79 | } 80 | String pom = getProjectPom(); 81 | executeForPom(pom); 82 | } 83 | 84 | /** 85 | * Returns the project's POM. 86 | */ 87 | private String getProjectPom() throws MojoExecutionException { 88 | try { 89 | return fileRead(getPomFile()); 90 | } catch (IOException e) { 91 | throw new MojoExecutionException("Failed to read the POM.", e); 92 | } 93 | } 94 | 95 | /** 96 | * Returns the file of the POM. 97 | */ 98 | protected File getPomFile() { 99 | return this.pomFile; 100 | } 101 | 102 | /** 103 | * Tidy the given POM. 104 | */ 105 | protected String tidy(String pom) throws MojoExecutionException { 106 | try { 107 | return POM_TIDY.tidy(pom); 108 | } catch (XMLStreamException e) { 109 | throw new MojoExecutionException(e.getMessage(), e); 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/tidy/task/EnsureOrderAndIndent.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.tidy.task; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import javax.xml.namespace.QName; 23 | import javax.xml.stream.XMLEventReader; 24 | import javax.xml.stream.XMLStreamException; 25 | import javax.xml.stream.events.XMLEvent; 26 | 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | 30 | import static java.lang.Math.max; 31 | import static java.lang.Math.min; 32 | import static java.util.Arrays.asList; 33 | import static java.util.Arrays.fill; 34 | import static org.codehaus.mojo.tidy.task.XMLEventReaderFactory.createEventReaderForPom; 35 | import static org.codehaus.plexus.util.StringUtils.countMatches; 36 | import static org.codehaus.plexus.util.StringUtils.isWhitespace; 37 | import static org.codehaus.plexus.util.StringUtils.repeat; 38 | 39 | class EnsureOrderAndIndent implements TidyTask { 40 | private static final List SECTION_SORTERS = asList( 41 | new SectionSorter( 42 | "/project", 43 | new NodeGroup("modelVersion"), 44 | new NodeGroup("parent"), 45 | new NodeGroup("groupId", "artifactId", "version", "packaging"), 46 | new NodeGroup("name", "description", "url", "inceptionYear", "organization", "licenses"), 47 | new NodeGroup("developers", "contributors"), 48 | new NodeGroup("mailingLists"), 49 | new NodeGroup("prerequisites"), 50 | new NodeGroup("modules"), 51 | new NodeGroup("scm", "issueManagement", "ciManagement", "distributionManagement"), 52 | new NodeGroup("properties"), 53 | new NodeGroup("dependencyManagement", "dependencies"), 54 | new NodeGroup("repositories", "pluginRepositories"), 55 | new NodeGroup("build"), 56 | new NodeGroup("reporting"), 57 | new NodeGroup("profiles")), 58 | new SectionSorter( 59 | "/project/build", 60 | new NodeGroup( 61 | "defaultGoal", 62 | "sourceDirectory", 63 | "scriptSourceDirectory", 64 | "testSourceDirectory", 65 | "directory", 66 | "outputDirectory", 67 | "testOutputDirectory", 68 | "finalName", 69 | "filters", 70 | "resources", 71 | "testResources", 72 | "pluginManagement", 73 | "plugins", 74 | "extensions")), 75 | new SectionSorter( 76 | "dependency", 77 | new NodeGroup( 78 | "groupId", 79 | "artifactId", 80 | "version", 81 | "type", 82 | "classifier", 83 | "scope", 84 | "systemPath", 85 | "exclusions", 86 | "optional")), 87 | new SectionSorter("dependency/exclusions/exclusion", new NodeGroup("groupId", "artifactId")), 88 | new SectionSorter("build/extensions/extension", new NodeGroup("groupId", "artifactId", "version")), 89 | new SectionSorter("/project/parent", new NodeGroup("groupId", "artifactId", "version", "relativePath")), 90 | new SectionSorter("plugin", new NodeGroup("groupId", "artifactId", "version")), 91 | new SectionSorter( 92 | "/project/distributionManagement/relocation", new NodeGroup("groupId", "artifactId", "version"))); 93 | 94 | @Override 95 | public String tidyPom(String pom, Format format) throws XMLStreamException { 96 | for (SectionSorter sorter : SECTION_SORTERS) { 97 | pom = sorter.sortSections(pom, format); 98 | } 99 | return pom; 100 | } 101 | 102 | private static class SectionSorter { 103 | final String scope; 104 | 105 | final NodeGroup[] groups; 106 | 107 | final List sequence; 108 | 109 | SectionSorter(String scope, NodeGroup... groups) { 110 | this.scope = scope; 111 | this.groups = groups; 112 | this.sequence = calculateSequence(groups); 113 | } 114 | 115 | List calculateSequence(NodeGroup[] groups) { 116 | List sequence = new ArrayList(); 117 | for (NodeGroup group : groups) { 118 | sequence.addAll(group.nodes); 119 | } 120 | return sequence; 121 | } 122 | 123 | String sortSections(String pom, Format format) throws XMLStreamException { 124 | XMLEventReader reader = createEventReaderForPom(pom); 125 | String path = ""; 126 | int posFirstUnformatted = 0; 127 | StringBuilder tidyPom = new StringBuilder(); 128 | while (reader.hasNext()) { 129 | XMLEvent event = reader.nextEvent(); 130 | if (event.isStartElement()) { 131 | path += "/" + event.asStartElement().getName().getLocalPart(); 132 | if (isStartElementOfScope(path)) { 133 | int pos = getPosOfNextEvent(reader); 134 | tidyPom.append(pom.substring(posFirstUnformatted, pos)); 135 | tidyPom.append(formatSection(reader, pom, format)); 136 | posFirstUnformatted = getPosOfNextEvent(reader); 137 | } 138 | } else if (event.isEndElement()) { 139 | path = substringBeforeLast(path, "/"); 140 | } 141 | } 142 | tidyPom.append(pom.substring(posFirstUnformatted)); 143 | return tidyPom.toString(); 144 | } 145 | 146 | private boolean isStartElementOfScope(String path) { 147 | if (scope.startsWith("/")) { 148 | return path.equals(scope); 149 | } else { 150 | return path.endsWith("/" + scope); 151 | } 152 | } 153 | 154 | private String formatSection(XMLEventReader reader, String pom, Format format) throws XMLStreamException { 155 | int startOfSection = getPosOfNextEvent(reader); 156 | int[] starts = new int[sequence.size()]; 157 | int[] ends = new int[sequence.size()]; 158 | XMLEvent endScope = calculateStartsAndEnds(reader, starts, ends); 159 | return formatSection(reader, pom, format, startOfSection, starts, ends, endScope); 160 | } 161 | 162 | private XMLEvent calculateStartsAndEnds(XMLEventReader reader, int[] starts, int[] ends) 163 | throws XMLStreamException { 164 | fill(starts, Integer.MAX_VALUE); 165 | fill(ends, -1); 166 | int level = 0; 167 | while (reader.hasNext()) { 168 | XMLEvent event = reader.nextEvent(); 169 | if (event.isStartElement()) { 170 | ++level; 171 | if (level == 1) { 172 | QName name = event.asStartElement().getName(); 173 | if (hasToBeSorted(name)) { 174 | int i = getSequenceIndex(name); 175 | starts[i] = event.getLocation().getCharacterOffset(); 176 | } 177 | } 178 | } else if (event.isEndElement()) { 179 | if (level == 0) { 180 | return event; 181 | } else if (level == 1) { 182 | QName name = event.asEndElement().getName(); 183 | if (hasToBeSorted(name)) { 184 | int i = getSequenceIndex(name); 185 | ends[i] = getPosOfNextEvent(reader); 186 | } 187 | } 188 | --level; 189 | } 190 | } 191 | throw new RuntimeException("End element missing."); 192 | } 193 | 194 | private boolean hasToBeSorted(QName nodeName) { 195 | String name = nodeName.getLocalPart(); 196 | return sequence.contains(name); 197 | } 198 | 199 | private int getSequenceIndex(QName nodeName) { 200 | String name = nodeName.getLocalPart(); 201 | if (sequence.contains(name)) { 202 | return sequence.indexOf(name); 203 | } else { 204 | throw new IllegalArgumentException( 205 | "The path '" + nodeName + " does not specify an element of the sequence " + sequence + "."); 206 | } 207 | } 208 | 209 | private String formatSection( 210 | XMLEventReader reader, 211 | String pom, 212 | Format format, 213 | int startOfSection, 214 | int[] starts, 215 | int[] ends, 216 | XMLEvent endScope) 217 | throws XMLStreamException { 218 | String outdent = calculateOutdent(pom, endScope); 219 | String indent = calculateIndent(pom, starts); 220 | int first = calculateFirst(starts, pom); 221 | StringBuilder output = new StringBuilder(); 222 | output.append(pom.substring(startOfSection, first).trim()); 223 | int i = 0; 224 | boolean firstGroupStarted = false; 225 | for (NodeGroup group : groups) { 226 | boolean groupStarted = false; 227 | for (String node : group.nodes) { 228 | if (starts[i] != Integer.MAX_VALUE) { 229 | if (firstGroupStarted && !groupStarted) { 230 | output.append(format.getLineSeparator()); 231 | } 232 | addTextIfNotEmpty(output, indent, getPrecedingText(pom, starts[i], ends), format); 233 | addTextIfNotEmpty(output, indent, pom.substring(starts[i], ends[i]), format); 234 | firstGroupStarted = true; 235 | groupStarted = true; 236 | } 237 | ++i; 238 | } 239 | } 240 | int last = calculateLast(ends); 241 | int afterSection = getPosOfNextEvent(reader); 242 | int offsetEndElement = endScope.getLocation().getCharacterOffset(); 243 | addTextIfNotEmpty(output, indent, pom.substring(last, offsetEndElement), format); 244 | addTextIfNotEmpty(output, outdent, pom.substring(offsetEndElement, afterSection), format); 245 | return output.toString(); 246 | } 247 | 248 | private String calculateOutdent(String pom, XMLEvent endScope) { 249 | String before = pom.substring(0, endScope.getLocation().getCharacterOffset()); 250 | return substringAfterLast(before, "\n"); 251 | } 252 | 253 | private int calculateFirst(int[] starts, String pom) { 254 | int first = pom.length(); 255 | for (int start : starts) { 256 | first = min(first, start); 257 | } 258 | return first; 259 | } 260 | 261 | private int calculateLast(int[] ends) { 262 | int last = 0; 263 | for (int end : ends) { 264 | last = max(last, end); 265 | } 266 | return last; 267 | } 268 | 269 | private String calculateIndent(String input, int[] starts) { 270 | int numNodesWithSpaceIndent = 0; 271 | int numNodesWithTabIndent = 0; 272 | int spaceIndentTotal = 0; 273 | int tabIndentTotal = 0; 274 | for (int start : starts) { 275 | if (start != Integer.MAX_VALUE) { 276 | String indent = calculateIndent(input, start); 277 | if (!indent.isEmpty()) { 278 | int numTabs = countMatches(indent, "\t"); 279 | if (numTabs == indent.length()) { 280 | ++numNodesWithTabIndent; 281 | tabIndentTotal += numTabs; 282 | } else if (!indent.contains("\t")) { 283 | ++numNodesWithSpaceIndent; 284 | spaceIndentTotal += indent.length(); 285 | } 286 | } 287 | } 288 | } 289 | if (numNodesWithSpaceIndent == 0 && numNodesWithTabIndent == 0) { 290 | return " "; 291 | } else if (numNodesWithSpaceIndent > numNodesWithTabIndent) { 292 | int averageIndent = spaceIndentTotal / numNodesWithSpaceIndent; 293 | return repeat(" ", averageIndent); 294 | } else { 295 | int averageIndent = tabIndentTotal / numNodesWithTabIndent; 296 | return repeat("\t", averageIndent); 297 | } 298 | } 299 | 300 | private String calculateIndent(String input, int startOfTag) { 301 | for (int i = startOfTag; i > 1; --i) { 302 | String character = input.substring(i - 1, i); 303 | if (!isWhitespace(character) || "\n".equals(character) || "\r".equals(character)) { 304 | return input.substring(i, startOfTag); 305 | } 306 | } 307 | return input; 308 | } 309 | 310 | private String getPrecedingText(String pom, int start, int[] ends) { 311 | int startPrecedingText = -1; 312 | for (int end : ends) { 313 | if (end < start) { 314 | startPrecedingText = max(startPrecedingText, end); 315 | } 316 | } 317 | if (startPrecedingText != -1) { 318 | return pom.substring(startPrecedingText, start); 319 | } else { 320 | return ""; 321 | } 322 | } 323 | 324 | private void addTextIfNotEmpty(StringBuilder output, String indent, String text, Format format) { 325 | String trimmedText = text.trim(); 326 | if (trimmedText.length() != 0) { 327 | output.append(format.getLineSeparator()); 328 | output.append(indent); 329 | output.append(trimmedText); 330 | } 331 | } 332 | 333 | private int getPosOfNextEvent(XMLEventReader reader) throws XMLStreamException { 334 | return reader.peek().getLocation().getCharacterOffset(); 335 | } 336 | 337 | private String substringBeforeLast(String str, String separator) { 338 | int endIndex = str.lastIndexOf(separator); 339 | return str.substring(0, endIndex); 340 | } 341 | 342 | private String substringAfterLast(String str, String separator) { 343 | int beginIndex = str.lastIndexOf(separator) + 1; 344 | return str.substring(beginIndex); 345 | } 346 | } 347 | 348 | private static class NodeGroup { 349 | final List nodes; 350 | 351 | NodeGroup(String... nodes) { 352 | this.nodes = asList(nodes); 353 | } 354 | } 355 | } 356 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/tidy/task/EnsureSingleLineProjectStartTag.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.tidy.task; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import javax.xml.XMLConstants; 23 | import javax.xml.namespace.QName; 24 | import javax.xml.stream.XMLEventReader; 25 | import javax.xml.stream.XMLStreamException; 26 | import javax.xml.stream.events.Attribute; 27 | import javax.xml.stream.events.XMLEvent; 28 | 29 | import java.util.Arrays; 30 | import java.util.Collection; 31 | import java.util.Collections; 32 | import java.util.HashMap; 33 | import java.util.HashSet; 34 | import java.util.Iterator; 35 | import java.util.Map; 36 | 37 | import org.codehaus.plexus.util.StringUtils; 38 | 39 | import static org.codehaus.mojo.tidy.task.XMLEventReaderFactory.createEventReaderForPom; 40 | 41 | class EnsureSingleLineProjectStartTag implements TidyTask { 42 | private static final String PROJECT_START_TAG = " PROJECT_4_0_ATTRIBUTES = 47 | Collections.singleton(new QName(null, "child.project.url.inherit.append.path")); 48 | 49 | private static final Collection PROJECT_4_1_ATTRIBUTES = 50 | Collections.unmodifiableSet(new HashSet<>(Arrays.asList( 51 | new QName(null, "child.project.url.inherit.append.path"), 52 | new QName(null, "root"), 53 | new QName(null, "preserve.model.version")))); 54 | 55 | private static final String PROJECT_4_1_START_TAG = 56 | " additionalProperties) 157 | throws XMLStreamException { 158 | while (eventReader.hasNext()) { 159 | XMLEvent event = eventReader.nextEvent(); 160 | if (event.isStartElement() 161 | && event.asStartElement().getName().getLocalPart().equals("project")) { 162 | return replaceProjectStartTag(pom, eventReader, event, projectStartTag, additionalProperties); 163 | } 164 | } 165 | throw new IllegalArgumentException("The POM has no project node."); 166 | } 167 | 168 | private String replaceProjectStartTag( 169 | String pom, 170 | XMLEventReader eventReader, 171 | XMLEvent event, 172 | String startTag, 173 | Collection additionalProperties) 174 | throws XMLStreamException { 175 | int start = event.getLocation().getCharacterOffset(); 176 | final Map additionalPropertiesMap; 177 | if (additionalProperties.isEmpty()) { 178 | additionalPropertiesMap = Collections.emptyMap(); 179 | } else { 180 | additionalPropertiesMap = new HashMap<>(additionalProperties.size()); 181 | final Iterator attributeIterator = event.asStartElement().getAttributes(); 182 | while (attributeIterator.hasNext()) { 183 | final Attribute currentAttribute = attributeIterator.next(); 184 | final QName attributeQualifiedName = currentAttribute.getName(); 185 | if (additionalProperties.contains(attributeQualifiedName)) { 186 | additionalPropertiesMap.put(attributeQualifiedName, currentAttribute.getValue()); 187 | } 188 | } 189 | } 190 | int nextChar = eventReader.nextEvent().getLocation().getCharacterOffset(); 191 | if (additionalPropertiesMap.isEmpty()) { 192 | return pom.substring(0, start) + startTag + ">" + pom.substring(nextChar); 193 | } 194 | StringBuilder result = new StringBuilder(pom.substring(0, start)).append(startTag); 195 | for (QName additionalProperty : additionalProperties) { 196 | final String value = additionalPropertiesMap.get(additionalProperty); 197 | if (value != null) { 198 | result.append(' '); 199 | if (additionalProperty.getPrefix().equals(XMLConstants.DEFAULT_NS_PREFIX)) { 200 | result.append(additionalProperty.getLocalPart()); 201 | } else { 202 | result.append(additionalProperty.getPrefix()).append(':').append(additionalProperty.getLocalPart()); 203 | } 204 | result.append('=').append(StringUtils.quoteAndEscape(value, '"', new char[] {'"', '\\'}, '\\', true)); 205 | } 206 | } 207 | return result.append('>').append(pom.substring(nextChar)).toString(); 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/tidy/task/EnsureTrailingNewLine.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.tidy.task; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import javax.xml.stream.XMLStreamException; 23 | 24 | class EnsureTrailingNewLine implements TidyTask { 25 | @Override 26 | public String tidyPom(String pom, Format format) throws XMLStreamException { 27 | return pom.trim() + format.getLineSeparator(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/tidy/task/EnsureXmlHeader.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.tidy.task; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import javax.xml.stream.XMLStreamException; 23 | 24 | class EnsureXmlHeader implements TidyTask { 25 | @Override 26 | public String tidyPom(String pom, Format format) throws XMLStreamException { 27 | if (pom.startsWith("" + format.getLineSeparator() + pom; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/tidy/task/Format.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.tidy.task; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * Specification of the output format used by the Tidy plugin. 24 | */ 25 | class Format { 26 | private final String lineSeparator; 27 | 28 | /** 29 | * Creates a new output format. 30 | * 31 | * @param lineSeparator the line separator. 32 | */ 33 | Format(String lineSeparator) { 34 | this.lineSeparator = lineSeparator; 35 | } 36 | 37 | /** 38 | * Returns the characters that should be used as line separator. 39 | * 40 | * @return the characters that should be used as line separator. 41 | */ 42 | String getLineSeparator() { 43 | return lineSeparator; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/tidy/task/FormatIdentifier.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.tidy.task; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.util.List; 23 | 24 | import static java.util.Arrays.asList; 25 | 26 | /** 27 | * Identifies the output format for a given POM. It tries to find a 28 | * format that is similar to the current format. 29 | */ 30 | class FormatIdentifier { 31 | private static final List LINE_SEPARATORS = asList("\r\n", "\n", "\r"); 32 | 33 | /** 34 | * Identifies the output format for the given POM. 35 | * 36 | * @param pom the POM. 37 | * @return the output format. 38 | */ 39 | Format identifyFormat(String pom) { 40 | for (String separator : LINE_SEPARATORS) { 41 | if (pom.contains(separator)) { 42 | return new Format(separator); 43 | } 44 | } 45 | 46 | throw new IllegalArgumentException("The pom.xml has no known line separator."); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/tidy/task/PomTidy.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.tidy.task; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import javax.xml.stream.XMLStreamException; 23 | 24 | import java.util.List; 25 | 26 | import static java.util.Arrays.asList; 27 | 28 | /** 29 | * Tidy up a POM into the canonical order. 30 | */ 31 | public class PomTidy { 32 | private static final FormatIdentifier FORMAT_IDENTIFIER = new FormatIdentifier(); 33 | 34 | private static final List TIDY_TASKS = asList( 35 | new EnsureXmlHeader(), 36 | new EnsureOrderAndIndent(), 37 | new EnsureSingleLineProjectStartTag(), 38 | new EnsureTrailingNewLine()); 39 | 40 | public String tidy(String pom) throws XMLStreamException { 41 | Format format = FORMAT_IDENTIFIER.identifyFormat(pom); 42 | for (TidyTask task : TIDY_TASKS) { 43 | pom = task.tidyPom(pom, format); 44 | } 45 | return pom; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/tidy/task/TidyTask.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.tidy.task; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import javax.xml.stream.XMLStreamException; 23 | 24 | /** 25 | * A single task that tidies a POM. 26 | */ 27 | interface TidyTask { 28 | /** 29 | * Tidies the POM. 30 | * 31 | * @param pom the POM as string. 32 | * @param format the expected format of the POM. 33 | * @return the tidy POM. 34 | * @throws XMLStreamException 35 | */ 36 | String tidyPom(String pom, Format format) throws XMLStreamException; 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/codehaus/mojo/tidy/task/XMLEventReaderFactory.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.tidy.task; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import javax.xml.stream.XMLEventReader; 23 | import javax.xml.stream.XMLInputFactory; 24 | import javax.xml.stream.XMLStreamException; 25 | 26 | import java.io.StringReader; 27 | 28 | import org.codehaus.stax2.XMLInputFactory2; 29 | 30 | class XMLEventReaderFactory { 31 | private static final XMLInputFactory XML_INPUT_FACTORY = createInputFactory(); 32 | 33 | static XMLEventReader createEventReaderForPom(String pom) throws XMLStreamException { 34 | return XML_INPUT_FACTORY.createXMLEventReader(new StringReader(pom)); 35 | } 36 | 37 | private static XMLInputFactory createInputFactory() { 38 | XMLInputFactory inputFactory = XMLInputFactory2.newInstance(); 39 | inputFactory.setProperty(XMLInputFactory2.P_PRESERVE_LOCATION, true); 40 | return inputFactory; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/site/markdown/index.md: -------------------------------------------------------------------------------- 1 | 17 | 18 | Tidy Maven Plugin 19 | ================= 20 | 21 | The Tidy Plugin tidies up a project's `pom.xml` and optionally verifies 22 | that it is tidy. 23 | 24 | Goals Overview 25 | -------------- 26 | 27 | The Tidy Plugin has two goals. 28 | 29 | * [tidy:pom](./pom-mojo.html) tidies up the project's `pom.xml`. 30 | * [tidy:check](./check-mojo.html) checks that the project's `pom.xml` is tidy. 31 | 32 | Usage 33 | ----- 34 | 35 | General instructions on how to use the different goals of the Tidy Plugin can 36 | be found on the [usage page](./usage.html). 37 | 38 | To tidy up the `pom.xml`, simply invoke it on your project, e.g. 39 | 40 | mvn tidy:pom 41 | 42 | The `pom.xml` file will 43 | 44 | * be rewritten according to the 45 | [POM Code Convention](http://maven.apache.org/developers/conventions/code.html#POM_Code_Convention) 46 | of the Maven team. 47 | * have the nodes `groupId`, `artifactId` and `version` always in this order. 48 | 49 | -------------------------------------------------------------------------------- /src/site/markdown/usage.md.vm: -------------------------------------------------------------------------------- 1 | 17 | 18 | Usage 19 | ===== 20 | 21 | The following examples describe the basic usage of the Tidy Plugin. 22 | 23 | Format the POM 24 | -------------- 25 | 26 | To format the `pom.xml` execute the `pom` goal manually. 27 | 28 | mvn tidy:pom 29 | 30 | The `pom.xml` file will 31 | 32 | * be rewritten according to the 33 | [POM Code Convention](http://maven.apache.org/developers/conventions/code.html#POM_Code_Convention) 34 | of the Maven team. 35 | * have the nodes `groupId`, `artifactId` and `version` always in this order. 36 | 37 | Note: It is recommended that you use your IDE or other formatting tools to 38 | ensure that your `pom.xml` is indented correctly. 39 | 40 | Note: The following sections can have their child elements reordered without affecting the build: 41 | 42 | * `/project/licenses` 43 | * `/project/developers` 44 | * `/project/contributors` 45 | * `/project/mailingLists` 46 | * `/project/properties` 47 | * `/project/build/pluginManagement/plugins` 48 | * `/project/profiles` 49 | 50 | Note: The following sections potentially can affect the build process if the child elements are reordered: 51 | 52 | * `/project/repositories` 53 | * `/project/pluginRepositories` 54 | * `/project/dependencyManagement/dependencies` 55 | * `/project/dependencies` 56 | * `/project/build/plugins` 57 | 58 | Checking for Tidy POM as Part of the Build 59 | ------------------------------------------ 60 | 61 | If you want to fail the build for a POM that is not formatted according to the 62 | `pom` goal, you must add an execution of `tidy:check` to the `build` element. 63 | 64 | 65 | org.codehaus.mojo 66 | tidy-maven-plugin 67 | ${project.version} 68 | 69 | 70 | validate 71 | validate 72 | 73 | check 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/tidy/task/EnsureSingleLineProjectStartTagTest.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.tidy.task; 2 | 3 | import javax.xml.stream.XMLStreamException; 4 | 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | 8 | import org.codehaus.plexus.util.IOUtil; 9 | import org.junit.jupiter.params.ParameterizedTest; 10 | import org.junit.jupiter.params.provider.ValueSource; 11 | 12 | import static org.junit.jupiter.api.Assertions.*; 13 | 14 | /** 15 | * Unit test class dedicated to the validation of {@link EnsureSingleLineProjectStartTag}. 16 | * 17 | * @author Antoine Malliarakis 18 | */ 19 | class EnsureSingleLineProjectStartTagTest { 20 | @ParameterizedTest(name = "{0}") 21 | @ValueSource( 22 | strings = { 23 | "project-single-line", 24 | "project-support-4-1-0-attributes", 25 | "project-support-4-1-0-attributes-with-unordered-nodes", 26 | "project-support-4-1-0-model-version" 27 | }) 28 | void applyTidying(String name) throws IOException, XMLStreamException { 29 | String pom = readPom(name, "pom.xml"); 30 | String tidyPom = new EnsureSingleLineProjectStartTag().tidyPom(pom, new FormatIdentifier().identifyFormat(pom)); 31 | assertEquals(readPom(name, "pom-expected.xml"), tidyPom); 32 | } 33 | 34 | private String readPom(String test, String filename) throws IOException { 35 | InputStream is = getClass().getResourceAsStream(getClass().getSimpleName() + "/" + test + "/" + filename); 36 | return IOUtil.toString(is); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/tidy/task/PomTidyFixesTest.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.tidy.task; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.util.Objects; 23 | 24 | import org.codehaus.plexus.util.IOUtil; 25 | import org.junit.jupiter.params.ParameterizedTest; 26 | import org.junit.jupiter.params.provider.ValueSource; 27 | 28 | import static org.junit.jupiter.api.Assertions.assertEquals; 29 | 30 | class PomTidyFixesTest { 31 | 32 | protected static final String PATH = "fixes/order-and-indent-start-element-of-scope/"; 33 | 34 | @ValueSource(strings = {"property-ending-with-plugin.pom.xml", "property-ending-with-dependency.pom.xml"}) 35 | @ParameterizedTest(name = "{0}") 36 | void shouldThrowNoError(String name) throws Exception { 37 | String pom = IOUtil.toString(Objects.requireNonNull(getClass().getResourceAsStream(PATH + name))); 38 | String tidyPom = new PomTidy().tidy(pom); 39 | assertEquals(pom, tidyPom, "nothing to tidy here"); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/org/codehaus/mojo/tidy/task/PomTidyTest.java: -------------------------------------------------------------------------------- 1 | package org.codehaus.mojo.tidy.task; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import javax.xml.stream.XMLStreamException; 23 | 24 | import java.io.IOException; 25 | import java.io.InputStream; 26 | 27 | import org.codehaus.plexus.util.IOUtil; 28 | import org.junit.jupiter.params.ParameterizedTest; 29 | import org.junit.jupiter.params.provider.ValueSource; 30 | 31 | import static org.junit.jupiter.api.Assertions.assertEquals; 32 | 33 | class PomTidyTest { 34 | 35 | @ParameterizedTest(name = "{0}") 36 | @ValueSource( 37 | strings = { 38 | "add-xml-declaration", 39 | "complete-pom", 40 | "do-not-mix-tab-and-spaces", 41 | "groupid-artifactid-version", 42 | "plugin-config-with-maven-element-names", 43 | "pom-space-indent", 44 | "pom-tab-indent", 45 | "pom-with-comments", 46 | "pom-with-crlf", 47 | "pom-with-line-without-indent", 48 | "pom-with-profiles", 49 | "pom-with-reporting", 50 | "project-single-line", 51 | "project-support-4-1-0-attributes", 52 | "project-support-4-1-0-attributes-with-unordered-nodes", 53 | "project-support-4-1-0-model-version" 54 | }) 55 | void generatesTidyPom(String name) throws IOException, XMLStreamException { 56 | String pom = readPom(name, "pom.xml"); 57 | String tidyPom = new PomTidy().tidy(pom); 58 | assertEquals(readPom(name, "pom-expected.xml"), tidyPom); 59 | } 60 | 61 | private String readPom(String test, String filename) throws IOException { 62 | InputStream is = getClass().getResourceAsStream(test + "/" + filename); 63 | return IOUtil.toString(is); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/EnsureSingleLineProjectStartTagTest/project-single-line/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | add-xml-declaration 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom ensuring project element on a single row in a pom. 10 | 11 | 12 | UTF-8 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/EnsureSingleLineProjectStartTagTest/project-single-line/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.codehaus.mojo.tidy.its 8 | add-xml-declaration 9 | 1.0-SNAPSHOT 10 | 11 | Test of tidy:pom ensuring project element on a single row in a pom. 12 | 13 | 14 | UTF-8 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/EnsureSingleLineProjectStartTagTest/project-support-4-1-0-attributes-with-unordered-nodes/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.codehaus.mojo.tidy.its 4 | add-xml-declaration 5 | 1.0-SNAPSHOT 6 | 7 | Test of tidy:pom ensuring project element on a single row in a pom and supports 4.1.0 attributes even though ordering is not satisfied 8 | 9 | 10 | UTF-8 11 | 12 | 13 | 4.1.0 14 | 15 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/EnsureSingleLineProjectStartTagTest/project-support-4-1-0-attributes-with-unordered-nodes/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | org.codehaus.mojo.tidy.its 10 | add-xml-declaration 11 | 1.0-SNAPSHOT 12 | 13 | Test of tidy:pom ensuring project element on a single row in a pom and supports 4.1.0 attributes even though ordering is not satisfied 14 | 15 | 16 | UTF-8 17 | 18 | 19 | 4.1.0 20 | 21 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/EnsureSingleLineProjectStartTagTest/project-support-4-1-0-attributes/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.1.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | add-xml-declaration 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom ensuring project element on a single row in a pom and supports 4.1.0 attributes. 10 | 11 | 12 | UTF-8 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/EnsureSingleLineProjectStartTagTest/project-support-4-1-0-attributes/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 4.1.0 10 | 11 | org.codehaus.mojo.tidy.its 12 | add-xml-declaration 13 | 1.0-SNAPSHOT 14 | 15 | Test of tidy:pom ensuring project element on a single row in a pom and supports 4.1.0 attributes. 16 | 17 | 18 | UTF-8 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/EnsureSingleLineProjectStartTagTest/project-support-4-1-0-model-version/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.1.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | add-xml-declaration 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom ensuring project element on a single row in a pom and supports 4.1.0 model version 10 | 11 | 12 | UTF-8 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/EnsureSingleLineProjectStartTagTest/project-support-4-1-0-model-version/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.1.0 7 | 8 | org.codehaus.mojo.tidy.its 9 | add-xml-declaration 10 | 1.0-SNAPSHOT 11 | 12 | Test of tidy:pom ensuring project element on a single row in a pom and supports 4.1.0 model version 13 | 14 | 15 | UTF-8 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/add-xml-declaration/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | add-xml-declaration 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom on a pom without an XML declaration 10 | 11 | 12 | UTF-8 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/add-xml-declaration/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.codehaus.mojo.tidy.its 5 | add-xml-declaration 6 | 1.0-SNAPSHOT 7 | 8 | Test of tidy:pom on a pom without an XML declaration 9 | 10 | 11 | UTF-8 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/complete-pom/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.codehaus 7 | codehaus-parent 8 | 4 9 | 10 | 11 | org.codehaus.mojo.tidy.its 12 | pom-space-indent 13 | 1.0-SNAPSHOT 14 | pom 15 | 16 | Complete POM test 17 | Test of tidy:pom on a pom with all elements. 18 | https://maven.apache.org 19 | 2011 20 | 21 | MojoHaus 22 | https://www.mojohaus.org 23 | 24 | 25 | 26 | The Apache Software License, Version 2.0 27 | https://www.apache.org/licenses/LICENSE-2.0.txt 28 | repo 29 | 30 | 31 | 32 | 33 | 34 | John Doe 35 | john.doe@acme.org 36 | 37 | Lead Developer 38 | 39 | 0 40 | 41 | 42 | 43 | 44 | Jane Doe 45 | jone.doe@acme.org 46 | 47 | 48 | 49 | 50 | 51 | MojoHaus Development List 52 | mojohaus-dev+subscribe@googlegroups.com 53 | mojohaus-dev+unsubscribe@googlegroups.com 54 | mojohaus-dev@googlegroups.com 55 | https://groups.google.com/forum/#!forum/mojohaus-dev 56 | 57 | 58 | Maven Users List 59 | users-subscribe@maven.apache.org 60 | users-unsubscribe@maven.apache.org 61 | users@maven.apache.org 62 | https://mail-archives.apache.org/mod_mbox/maven-users/ 63 | 64 | https://maven.40175.n5.nabble.com/Maven-Users-f40176.html 65 | 66 | 67 | 68 | 69 | 70 | 2.2.1 71 | 72 | 73 | 74 | module1 75 | module2 76 | 77 | 78 | 79 | scm:git:https://github.com/mojohaus/tidy-maven-plugin.git 80 | scm:git:ssh://git@github.com/mojohaus/tidy-maven-plugin.git 81 | https://github.com/mojohaus/tidy-maven-plugin 82 | 83 | 84 | GitHub 85 | https://github.com/mojohaus/tidy-maven-plugin/issues 86 | 87 | 88 | travis 89 | https://travis-ci.org/mojohaus/tidy-maven-plugin 90 | 91 | 92 | 93 | ossrh-staging 94 | https://oss.sonatype.org/service/local/staging/deploy/maven2 95 | 96 | 97 | ossrh-snapshots 98 | https://oss.sonatype.org/content/repositories/snapshots 99 | 100 | 101 | github 102 | scm:git:git@github.com:mojohaus/tidy-maven-plugin.git 103 | 104 | 105 | 106 | 107 | UTF-8 108 | 5.7.2 109 | 110 | 111 | 112 | 113 | 114 | org.codehaus.plexus 115 | plexus-utils 116 | 3.4.2 117 | jar 118 | compile 119 | 120 | 121 | 122 | 123 | 124 | org.junit.jupiter 125 | junit-jupiter-engine 126 | ${junit.version} 127 | test 128 | 129 | 130 | org.junit.vintage 131 | junit-vintage-engine 132 | ${junit.version} 133 | test 134 | 135 | 136 | org.apache.logging.log4j 137 | log4j-api 138 | 2.19.0 139 | bundle 140 | 141 | 142 | 143 | 144 | 145 | ossrh-snapshots 146 | ossrh-snapshots 147 | https://oss.sonatype.org/content/repositories/snapshots 148 | 149 | false 150 | 151 | 152 | true 153 | 154 | 155 | 156 | 157 | 158 | ossrh-snapshots 159 | ossrh-snapshots 160 | https://oss.sonatype.org/content/repositories/snapshots 161 | 162 | false 163 | 164 | 165 | true 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | org.apache.maven.plugins 175 | maven-compiler-plugin 176 | 2.5.1 177 | 178 | 179 | 180 | 181 | org.apache.maven.plugins 182 | maven-surefire-plugin 183 | 2.16 184 | 185 | 186 | 187 | 188 | 189 | org.codehaus.mojo 190 | build-helper-maven-plugin 191 | 1.8 192 | 193 | 194 | build-helper 195 | generate-sources 196 | 197 | add-source 198 | 199 | 200 | 201 | 202 | dummy 203 | 204 | 205 | 206 | 207 | 208 | org.apache.maven.wagon 209 | wagon-ssh-external 210 | 1.0-beta-6 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | org.apache.maven.plugins 219 | maven-project-info-reports-plugin 220 | 2.7 221 | 222 | 223 | 224 | 225 | 226 | 227 | run-its 228 | 229 | 230 | skipTests 231 | !true 232 | 233 | 234 | 235 | 236 | 237 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/complete-pom/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | pom 5 | 6 | pom-space-indent 7 | org.codehaus.mojo.tidy.its 8 | 9 | org.codehaus 10 | codehaus-parent 11 | 4 12 | 13 | 4.0.0 14 | 1.0-SNAPSHOT 15 | Test of tidy:pom on a pom with all elements. 16 | 17 | 18 | 19 | The Apache Software License, Version 2.0 20 | https://www.apache.org/licenses/LICENSE-2.0.txt 21 | repo 22 | 23 | 24 | 25 | Complete POM test 26 | 2011 27 | https://maven.apache.org 28 | 29 | 30 | UTF-8 31 | 5.7.2 32 | 33 | 34 | 35 | ossrh-snapshots 36 | ossrh-snapshots 37 | https://oss.sonatype.org/content/repositories/snapshots 38 | 39 | false 40 | 41 | 42 | true 43 | 44 | 45 | 46 | 47 | MojoHaus 48 | https://www.mojohaus.org 49 | 50 | 51 | 52 | 53 | ossrh-snapshots 54 | ossrh-snapshots 55 | https://oss.sonatype.org/content/repositories/snapshots 56 | 57 | false 58 | 59 | 60 | true 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | MojoHaus Development List 69 | mojohaus-dev+subscribe@googlegroups.com 70 | mojohaus-dev+unsubscribe@googlegroups.com 71 | mojohaus-dev@googlegroups.com 72 | https://groups.google.com/forum/#!forum/mojohaus-dev 73 | 74 | 75 | Maven Users List 76 | users-subscribe@maven.apache.org 77 | users-unsubscribe@maven.apache.org 78 | users@maven.apache.org 79 | https://mail-archives.apache.org/mod_mbox/maven-users/ 80 | 81 | https://maven.40175.n5.nabble.com/Maven-Users-f40176.html 82 | 83 | 84 | 85 | 86 | scm:git:https://github.com/mojohaus/tidy-maven-plugin.git 87 | scm:git:ssh://git@github.com/mojohaus/tidy-maven-plugin.git 88 | https://github.com/mojohaus/tidy-maven-plugin 89 | 90 | 91 | 92 | 2.2.1 93 | 94 | 95 | 96 | GitHub 97 | https://github.com/mojohaus/tidy-maven-plugin/issues 98 | 99 | 100 | 101 | Jane Doe 102 | jone.doe@acme.org 103 | 104 | 105 | 106 | 107 | John Doe 108 | john.doe@acme.org 109 | 110 | Lead Developer 111 | 112 | 0 113 | 114 | 115 | 116 | 117 | 118 | ossrh-staging 119 | https://oss.sonatype.org/service/local/staging/deploy/maven2 120 | 121 | 122 | ossrh-snapshots 123 | https://oss.sonatype.org/content/repositories/snapshots 124 | 125 | 126 | github 127 | scm:git:git@github.com:mojohaus/tidy-maven-plugin.git 128 | 129 | 130 | 131 | 132 | 133 | 134 | org.codehaus.plexus 135 | plexus-utils 136 | 3.4.2 137 | jar 138 | compile 139 | 140 | 141 | 142 | 143 | 144 | 145 | org.apache.maven.wagon 146 | wagon-ssh-external 147 | 1.0-beta-6 148 | 149 | 150 | 151 | 152 | 153 | 154 | org.apache.maven.plugins 155 | maven-compiler-plugin 156 | 2.5.1 157 | 158 | 159 | 160 | 161 | org.apache.maven.plugins 162 | maven-surefire-plugin 163 | 2.16 164 | 165 | 166 | 167 | 168 | 169 | org.codehaus.mojo 170 | build-helper-maven-plugin 171 | 1.8 172 | 173 | 174 | build-helper 175 | generate-sources 176 | 177 | add-source 178 | 179 | 180 | 181 | 182 | dummy 183 | 184 | 185 | 186 | 187 | 188 | travis 189 | https://travis-ci.org/mojohaus/tidy-maven-plugin 190 | 191 | 192 | 193 | org.junit.jupiter 194 | junit-jupiter-engine 195 | ${junit.version} 196 | test 197 | 198 | 199 | org.junit.vintage 200 | junit-vintage-engine 201 | ${junit.version} 202 | test 203 | 204 | 205 | org.apache.logging.log4j 206 | log4j-api 207 | 2.19.0 208 | bundle 209 | 210 | 211 | 212 | 213 | 214 | 215 | org.apache.maven.plugins 216 | maven-project-info-reports-plugin 217 | 2.7 218 | 219 | 220 | 221 | 222 | 223 | run-its 224 | 225 | 226 | skipTests 227 | !true 228 | 229 | 230 | 231 | 232 | 233 | module1 234 | module2 235 | 236 | 237 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/do-not-mix-tab-and-spaces/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | foo.bar 6 | hello-world 7 | 1.0.0 8 | jar 9 | 10 | Test of tidy:pom on a pom with mixed tab and spaces indentation. 11 | 12 | 13 | bar 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/do-not-mix-tab-and-spaces/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | foo.bar 6 | hello-world 7 | 1.0.0 8 | jar 9 | 10 | Test of tidy:pom on a pom with mixed tab and spaces indentation. 11 | 12 | 13 | bar 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/fixes/order-and-indent-start-element-of-scope/property-ending-with-dependency.pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | add-xml-declaration 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom on a pom with properties ending on keywords 10 | 11 | 12 | This has been throwing errors in the past. 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/fixes/order-and-indent-start-element-of-scope/property-ending-with-plugin.pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | add-xml-declaration 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom on a pom with properties ending on keywords 10 | 11 | 12 | This has been throwing errors in the past. 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/groupid-artifactid-version/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | dummy.group.id 7 | dummy-parent 8 | 1.0.0 9 | ../dummy/path 10 | 11 | 12 | org.codehaus.mojo.tidy.its 13 | pom-space-indent 14 | 1.0-SNAPSHOT 15 | 16 | Test of tidy:pom sorting all GAV elements in a pom. 17 | 18 | 19 | 20 | dummy.group.id 21 | dummy-artifact 22 | 1.0.0 23 | 24 | 25 | 26 | 27 | 28 | UTF-8 29 | 30 | 31 | 32 | 33 | junit 34 | junit 35 | 4.12 36 | jar 37 | shaded 38 | test 39 | ../foo/bar 40 | 41 | 42 | org.hamcrest 43 | hamcrest-core 44 | 45 | 46 | true 47 | 48 | 49 | 50 | 51 | 52 | 53 | dummy.group.id 54 | dummy-plugin 55 | 1.0.0 56 | 57 | 58 | 59 | 60 | org.apache.maven.wagon 61 | wagon-ssh-external 62 | 1.0-beta-6 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/groupid-artifactid-version/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | dummy-parent 7 | ../dummy/path 8 | 1.0.0 9 | dummy.group.id 10 | 11 | 12 | org.codehaus.mojo.tidy.its 13 | pom-space-indent 14 | 1.0-SNAPSHOT 15 | 16 | Test of tidy:pom sorting all GAV elements in a pom. 17 | 18 | 19 | 20 | dummy-artifact 21 | 1.0.0 22 | dummy.group.id 23 | 24 | 25 | 26 | 27 | 28 | UTF-8 29 | 30 | 31 | 32 | 33 | jar 34 | true 35 | ../foo/bar 36 | shaded 37 | test 38 | junit 39 | 4.12 40 | junit 41 | 42 | 43 | hamcrest-core 44 | org.hamcrest 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | dummy-plugin 54 | 1.0.0 55 | dummy.group.id 56 | 57 | 58 | 59 | 60 | wagon-ssh-external 61 | 1.0-beta-6 62 | org.apache.maven.wagon 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/plugin-config-with-maven-element-names/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | plugin-config-with-maven-element-names 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom on a pom with plugin configurations containing elements with the same 10 | name as sorted elements in the Maven project. 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | 18 | 19 | 20 | org.apache.cxf 21 | cxf-xjc-plugin 22 | 3.0.5 23 | 24 | 25 | org.apache.cxf.xjcplugins:cxf-xjc-dv:3.0.5 26 | 27 | 28 | 29 | 30 | org.acme 31 | dummy-plugin 32 | 1.0.0 33 | 34 | test 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-shade-plugin 43 | 2.3 44 | 45 | 46 | package 47 | 48 | shade 49 | 50 | 51 | 52 | 53 | com.foo.bar 54 | somewhereelse.com.foo.bar 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/plugin-config-with-maven-element-names/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.codehaus.mojo.tidy.its 7 | plugin-config-with-maven-element-names 8 | 1.0-SNAPSHOT 9 | 10 | Test of tidy:pom on a pom with plugin configurations containing elements with the same 11 | name as sorted elements in the Maven project. 12 | 13 | 14 | UTF-8 15 | 16 | 17 | 18 | 19 | 20 | 21 | org.apache.cxf 22 | cxf-xjc-plugin 23 | 3.0.5 24 | 25 | 26 | org.apache.cxf.xjcplugins:cxf-xjc-dv:3.0.5 27 | 28 | 29 | 30 | 31 | org.acme 32 | dummy-plugin 33 | 1.0.0 34 | 35 | test 36 | 37 | 38 | 39 | 40 | 41 | 42 | org.apache.maven.plugins 43 | maven-shade-plugin 44 | 2.3 45 | 46 | 47 | package 48 | 49 | shade 50 | 51 | 52 | 53 | 54 | com.foo.bar 55 | somewhereelse.com.foo.bar 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/pom-space-indent/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | pom-space-indent 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom on a pom with space indents. 10 | 11 | 12 | UTF-8 13 | 5.7.2 14 | 15 | 16 | 17 | 18 | org.junit.jupiter 19 | junit-jupiter-engine 20 | ${junit.version} 21 | test 22 | 23 | 24 | org.junit.vintage 25 | junit-vintage-engine 26 | ${junit.version} 27 | test 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.apache.maven.plugins 36 | maven-compiler-plugin 37 | 2.5.1 38 | 39 | 40 | 41 | 42 | 43 | org.codehaus.mojo 44 | build-helper-maven-plugin 45 | 1.8 46 | 47 | 48 | build-helper 49 | generate-sources 50 | 51 | add-source 52 | 53 | 54 | 55 | 56 | dummy 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/pom-space-indent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | pom-space-indent 6 | org.codehaus.mojo.tidy.its 7 | 8 | 1.0-SNAPSHOT 9 | Test of tidy:pom on a pom with space indents. 10 | 11 | 12 | UTF-8 13 | 5.7.2 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | org.apache.maven.plugins 22 | maven-compiler-plugin 23 | 2.5.1 24 | 25 | 26 | 27 | 28 | 29 | org.codehaus.mojo 30 | build-helper-maven-plugin 31 | 1.8 32 | 33 | 34 | build-helper 35 | generate-sources 36 | 37 | add-source 38 | 39 | 40 | 41 | 42 | dummy 43 | 44 | 45 | 46 | 47 | 48 | 49 | org.junit.jupiter 50 | junit-jupiter-engine 51 | ${junit.version} 52 | test 53 | 54 | 55 | org.junit.vintage 56 | junit-vintage-engine 57 | ${junit.version} 58 | test 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/pom-tab-indent/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | pom-space-indent 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom on a pom with tab indents. 10 | 11 | 12 | UTF-8 13 | 5.7.2 14 | 15 | 16 | 17 | 18 | org.junit.jupiter 19 | junit-jupiter-engine 20 | ${junit.version} 21 | test 22 | 23 | 24 | org.junit.vintage 25 | junit-vintage-engine 26 | ${junit.version} 27 | test 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.apache.maven.plugins 36 | maven-compiler-plugin 37 | 2.5.1 38 | 39 | 40 | 41 | 42 | 43 | org.codehaus.mojo 44 | build-helper-maven-plugin 45 | 1.8 46 | 47 | 48 | build-helper 49 | generate-sources 50 | 51 | add-source 52 | 53 | 54 | 55 | 56 | dummy 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/pom-tab-indent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | pom-space-indent 6 | org.codehaus.mojo.tidy.its 7 | 8 | 1.0-SNAPSHOT 9 | Test of tidy:pom on a pom with tab indents. 10 | 11 | 12 | UTF-8 13 | 5.7.2 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | org.apache.maven.plugins 22 | maven-compiler-plugin 23 | 2.5.1 24 | 25 | 26 | 27 | 28 | 29 | org.codehaus.mojo 30 | build-helper-maven-plugin 31 | 1.8 32 | 33 | 34 | build-helper 35 | generate-sources 36 | 37 | add-source 38 | 39 | 40 | 41 | 42 | dummy 43 | 44 | 45 | 46 | 47 | 48 | 49 | org.junit.jupiter 50 | junit-jupiter-engine 51 | ${junit.version} 52 | test 53 | 54 | 55 | org.junit.vintage 56 | junit-vintage-engine 57 | ${junit.version} 58 | test 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/pom-with-comments/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | pom-space-indent 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom on a pom with XML comments. 10 | 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | 18 | 19 | 20 | org.apache.maven.plugins 21 | maven-compiler-plugin 22 | 2.5.1 23 | 24 | 25 | 26 | 27 | 28 | org.codehaus.mojo 29 | build-helper-maven-plugin 30 | 1.8 31 | 32 | 33 | build-helper 34 | generate-sources 35 | 36 | add-source 37 | 38 | 39 | 40 | 41 | dummy 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/pom-with-comments/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | pom-space-indent 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom on a pom with XML comments. 10 | 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | 18 | 19 | 20 | org.apache.maven.plugins 21 | maven-compiler-plugin 22 | 2.5.1 23 | 24 | 25 | 26 | 27 | 28 | org.codehaus.mojo 29 | build-helper-maven-plugin 30 | 1.8 31 | 32 | 33 | build-helper 34 | generate-sources 35 | 36 | add-source 37 | 38 | 39 | 40 | 41 | dummy 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/pom-with-crlf/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.test 6 | pom-with-crlf 7 | 1.0-SNAPSHOT 8 | 9 | Test of PomTidy with CRLF 10 | 11 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/pom-with-crlf/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.test 6 | pom-with-crlf 7 | 1.0-SNAPSHOT 8 | 9 | Test of PomTidy with CRLF 10 | 11 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/pom-with-line-without-indent/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.eclipse.recommenders.privacy 7 | plugins 8 | 0.1.0 9 | ../pom.xml 10 | 11 | 12 | org.eclipse.recommenders.privacy.rcp 13 | 0.1.0-SNAPSHOT 14 | eclipse-plugin 15 | 16 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/pom-with-line-without-indent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.eclipse.recommenders.privacy 7 | plugins 8 | 0.1.0 9 | ../pom.xml 10 | 11 | 12 | org.eclipse.recommenders.privacy.rcp 13 | 0.1.0-SNAPSHOT 14 | eclipse-plugin 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/pom-with-profiles/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | add-xml-declaration 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom on a pom with profiles 10 | 11 | 12 | UTF-8 13 | 14 | 15 | 16 | 17 | run-its 18 | 19 | 20 | skipTests 21 | !true 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/pom-with-profiles/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | add-xml-declaration 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom on a pom with profiles 10 | 11 | 12 | 13 | 14 | run-its 15 | 16 | 17 | skipTests 18 | !true 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | UTF-8 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/pom-with-reporting/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | add-xml-declaration 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom on a pom with reporting section 10 | 11 | 12 | UTF-8 13 | 14 | 15 | 16 | 17 | 18 | maven-project-info-reports-plugin 19 | ${maven-project-info-reports-plugin.version} 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/pom-with-reporting/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | add-xml-declaration 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom on a pom with reporting section 10 | 11 | 12 | 13 | 14 | maven-project-info-reports-plugin 15 | ${maven-project-info-reports-plugin.version} 16 | 17 | 18 | 19 | 20 | 21 | 22 | UTF-8 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/project-single-line/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | add-xml-declaration 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom ensuring project element on a single row in a pom. 10 | 11 | 12 | UTF-8 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/project-single-line/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.codehaus.mojo.tidy.its 8 | add-xml-declaration 9 | 1.0-SNAPSHOT 10 | 11 | Test of tidy:pom ensuring project element on a single row in a pom. 12 | 13 | 14 | UTF-8 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/project-support-4-1-0-attributes-with-unordered-nodes/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.1.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | add-xml-declaration 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom ensuring project element on a single row in a pom and supports 4.1.0 attributes even though ordering is not satisfied 10 | 11 | 12 | UTF-8 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/project-support-4-1-0-attributes-with-unordered-nodes/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | org.codehaus.mojo.tidy.its 10 | add-xml-declaration 11 | 1.0-SNAPSHOT 12 | 13 | Test of tidy:pom ensuring project element on a single row in a pom and supports 4.1.0 attributes even though ordering is not satisfied 14 | 15 | 16 | UTF-8 17 | 18 | 19 | 4.1.0 20 | 21 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/project-support-4-1-0-attributes/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.1.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | add-xml-declaration 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom ensuring project element on a single row in a pom and supports 4.1.0 attributes. 10 | 11 | 12 | UTF-8 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/project-support-4-1-0-attributes/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 4.1.0 10 | 11 | org.codehaus.mojo.tidy.its 12 | add-xml-declaration 13 | 1.0-SNAPSHOT 14 | 15 | Test of tidy:pom ensuring project element on a single row in a pom and supports 4.1.0 attributes. 16 | 17 | 18 | UTF-8 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/project-support-4-1-0-model-version/pom-expected.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.1.0 4 | 5 | org.codehaus.mojo.tidy.its 6 | add-xml-declaration 7 | 1.0-SNAPSHOT 8 | 9 | Test of tidy:pom ensuring project element on a single row in a pom and supports 4.1.0 model version 10 | 11 | 12 | UTF-8 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/test/resources/org/codehaus/mojo/tidy/task/project-support-4-1-0-model-version/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.1.0 7 | 8 | org.codehaus.mojo.tidy.its 9 | add-xml-declaration 10 | 1.0-SNAPSHOT 11 | 12 | Test of tidy:pom ensuring project element on a single row in a pom and supports 4.1.0 model version 13 | 14 | 15 | UTF-8 16 | 17 | 18 | 19 | --------------------------------------------------------------------------------