├── .gitignore ├── LICENSE.txt ├── README.md ├── pom.xml └── src ├── it ├── classifiers-fail-match │ ├── invoker.properties │ ├── pom.xml │ └── src │ │ ├── conflict-javadoc.jar │ │ ├── conflict-sources.jar │ │ ├── conflict.jar │ │ ├── smokes-javadoc.jar │ │ ├── smokes-sources.jar │ │ └── smokes.jar ├── classifiers-with-confusion │ ├── invoker.properties │ ├── pom.xml │ └── src │ │ ├── confusion.jar │ │ ├── smokes-javadoc.jar │ │ ├── smokes-sources.jar │ │ └── smokes.jar ├── classifiers │ ├── invoker.properties │ ├── pom.xml │ └── src │ │ ├── smokes-javadoc.jar │ │ ├── smokes-sources.jar │ │ └── smokes.jar ├── missing-jar │ ├── invoker.properties │ └── pom.xml ├── multi-module-advanced │ ├── invoker.properties │ ├── maven │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ └── java │ │ │ └── localhost │ │ │ └── HaveNonMavenDependencyTest.java │ ├── non-maven │ │ ├── pom.xml │ │ └── src │ │ │ └── smokes.jar │ ├── pom.xml │ └── src │ │ └── smokes.jar ├── multi-module │ ├── invoker.properties │ ├── maven │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ └── java │ │ │ └── localhost │ │ │ └── HaveNonMavenDependencyTest.java │ ├── non-maven │ │ ├── pom.xml │ │ └── src │ │ │ └── smokes.jar │ ├── pom.xml │ └── src │ │ └── smokes.jar ├── multiple-matches │ ├── invoker.properties │ ├── pom.xml │ └── src │ │ ├── confuses.jar │ │ └── smokes.jar ├── settings.xml ├── smokes │ ├── invoker.properties │ ├── pom.xml │ └── src │ │ └── smokes.jar └── specify-file │ ├── invoker.properties │ ├── pom.xml │ └── smokes.jar └── main ├── java └── com │ └── github │ └── stephenc │ └── nonmavenjar │ └── JarMojo.java └── resources └── META-INF └── plexus └── components.xml /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .classpath 3 | .settings 4 | *.iml 5 | *.ipr 6 | *.iws 7 | .idea/ 8 | target/ 9 | 10 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Non-Maven Jar Maven Plugin 2 | ========================== 3 | 4 | [![Build Status](https://buildhive.cloudbees.com/job/stephenc/job/non-maven-jar-maven-plugin/badge/icon)](https://buildhive.cloudbees.com/job/stephenc/job/non-maven-jar-maven-plugin/) 5 | 6 | There is a rare situation that this plugin aims to address. Here is the use case: 7 | 8 | * You have a dependency on a third-party JAR 9 | * You cannot convince the authors of that third-party JAR to publish the JAR file to a Maven repository 10 | (either an internal repository if the authors are within your organization or a repository like 11 | [Central](http://repo.maven.apache.org/maven2/) where they are outside your organization) 12 | * You are unwilling to either have an internal Maven repository or take part in the process for uploading 13 | their dependencies to a repository like [Central](http://repo.maven.apache.org/maven2/) 14 | 15 | Now good citizens would solve this issue by changing their stance to the last point in that use-case, but if you wish 16 | to insist on being a bad citizen, the Non-Maven Jar Maven Plugin is here to help you get your build done... 17 | 18 | - - - 19 | 20 | __BY USING THIS PLUGIN YOU ACKNOWLEDGE THAT YOU ARE A BAD CITIZEN OF THE MAVEN ECOSYSTEM.__ 21 | 22 | - - - 23 | 24 | How to use this plugin 25 | ---------------------- 26 | 27 | Firstly, you will be using a multi-module build. For each non-maven dependency you will need a `pom.xml` file and a 28 | directory to hold that file. In that directory you can either have a `src` sub-directory and put the `.jar` file in 29 | that `src` directory, or you can type a little more in your `pom.xml` and put the `.jar` file beside the `pom.xml`. 30 | So the directory tree could look something like 31 | 32 | pom.xml 33 | dep1/ 34 | pom.xml 35 | src/ 36 | dep1.jar 37 | dep2/ 38 | pom.xml 39 | dep2.jar 40 | main/ 41 | pom.xml 42 | src/ 43 | main/ 44 | java/ 45 | ... 46 | 47 | If all your `pom.xml` files inherit from the root `pom.xml` (this is the simplest for you) then you will need to 48 | add the following to your root `pom` 49 | 50 | 51 | ... 52 | 53 | ... 54 | 55 | ... 56 | 57 | com.github.stephenc.nonmavenjar 58 | non-maven-jar-maven-plugin 59 | ... 60 | true 61 | ... 62 | 63 | ... 64 | 65 | ... 66 | 67 | ... 68 | 69 | 70 | So that Maven is aware of the `non-maven-jar` packaging type. If you don't or cannot add that to your root `pom.xml` 71 | (for example in the case where the child `pom.xml` files do not use the root `pom.xml` as their parent) then 72 | you will need to flag the extension in each of the child `pom.xml` files that have 73 | `non-maven-jar` 74 | 75 | Continuing the above example, the `dep1/pom.xml` would look something like this: 76 | 77 | 79 | 4.0.0 80 | 81 | com.bar.foo 82 | manchu-parent 83 | 1.0-SNAPSHOT 84 | 85 | 86 | manchu-dep1 87 | non-maven-jar 88 | 89 | 90 | 91 | Where the auto-magic will be used to pick up the one and only JAR file from `dep1/src` and bind that into the reactor. 92 | If there was `dep1/src/dep1-javadoc.jar` and `dep1/src/dep1-sources.jar` then they will be picked up as secondary 93 | artifacts and attached with the corresponding classifiers. 94 | 95 | The `dep2/pom.xml` needs some configuration to specify where the JAR file is, as it is not using the defaults, so 96 | would look something like this: 97 | 98 | 100 | 4.0.0 101 | 102 | com.bar.foo 103 | manchu-parent 104 | 1.0-SNAPSHOT 105 | 106 | 107 | manchu-dep2 108 | non-maven-jar 109 | 110 | 111 | 112 | 113 | com.bar.foo 114 | manchu-dep1 115 | 1.0-SNAPSHOT 116 | 117 | 118 | 119 | 120 | 121 | 122 | com.github.stephenc.nonmavenjar 123 | non-maven-jar-maven-plugin 124 | 125 | ${basedir}/dep2.jar 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | If there was `dep2/dep2-javadoc.jar` and `dep2/dep2-sources.jar` then they will be picked up as secondary 134 | artifacts and attached with the corresponding classifiers. 135 | 136 | And finally the `main/pom.xml` can just list the dependencies as if they were ordinary dependencies: 137 | 138 | 140 | 4.0.0 141 | 142 | com.bar.foo 143 | manchu-parent 144 | 1.0-SNAPSHOT 145 | 146 | 147 | manchu-main 148 | 149 | 150 | 151 | com.bar.foo 152 | manchu-dep2 153 | 1.0-SNAPSHOT 154 | 155 | 156 | 157 | 158 | 159 | 160 | Rational for releasing this plugin 161 | ---------------------------------- 162 | 163 | While this is a bad way to do things, it is less evil than the other hacks such as abusing `system` scope or 164 | adding a `` which is pointing to a `file:///` URI. Also if used correctly this plugin can make 165 | transitioning from a bad citizen to a good citizen a lot easier as one needs only remove the 166 | `non-maven-jar` and submit the JAR and `pom.xml` as part of an upload bundle for 167 | [Central](http://repo.maven.apache.org/maven2/) (in other words those upload bundles are less work than you fear) 168 | 169 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 | 20 | 4.0.0 21 | 22 | 23 | org.sonatype.oss 24 | oss-parent 25 | 9 26 | 27 | 28 | com.github.stephenc.nonmavenjar 29 | non-maven-jar-maven-plugin 30 | 1.3-SNAPSHOT 31 | maven-plugin 32 | 33 | Non-Maven Jar Maven Plugin 34 | A plugin for making it easier to pull a non-maven jar into your build. 35 | http://stephenc.github.com/non-maven-jar-maven-plugin 36 | 2013 37 | 38 | 39 | The Apache Software License, Version 2.0 40 | http://www.apache.org/licenses/LICENSE-2.0.txt 41 | repo 42 | 43 | 44 | 45 | 2.2.1 46 | 47 | 48 | 49 | 50 | stephenc 51 | Stephen Connolly 52 | 53 | Developer 54 | 55 | 56 | 57 | 58 | 59 | scm:git:git://github.com/stephenc/non-maven-jar-maven-plugin.git 60 | scm:git:git@github.com:stephenc/non-maven-jar-maven-plugin.git 61 | http://github.com/stephenc/non-maven-jar-maven-plugin/tree/master/ 62 | HEAD 63 | 64 | 65 | github 66 | http://github.com/stephenc/non-maven-jar-maven-plugin/issues 67 | 68 | 69 | 70 | UTF-8 71 | UTF-8 72 | UTF-8 73 | 2.2.1 74 | 75 | 76 | 77 | 78 | org.apache.maven 79 | maven-project 80 | ${mavenVersion} 81 | 82 | 83 | org.apache.maven.shared 84 | maven-filtering 85 | 1.0-beta-4 86 | 87 | 88 | org.apache.maven 89 | maven-model 90 | ${mavenVersion} 91 | 92 | 93 | org.apache.maven 94 | maven-artifact 95 | ${mavenVersion} 96 | 97 | 98 | org.apache.maven 99 | maven-artifact-manager 100 | ${mavenVersion} 101 | 102 | 103 | org.apache.maven 104 | maven-core 105 | ${mavenVersion} 106 | 107 | 108 | org.apache.maven 109 | maven-plugin-api 110 | ${mavenVersion} 111 | 112 | 113 | org.codehaus.plexus 114 | plexus-utils 115 | 2.0.5 116 | 117 | 118 | org.codehaus.plexus 119 | plexus-container-default 120 | 1.0-alpha-9 121 | 122 | 123 | 124 | org.apache.maven.plugin-tools 125 | maven-plugin-annotations 126 | 3.0 127 | compile 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | maven-clean-plugin 136 | 2.6.1 137 | 138 | 139 | maven-compiler-plugin 140 | 3.3 141 | 142 | 143 | maven-deploy-plugin 144 | 2.8.2 145 | 146 | 147 | maven-gpg-plugin 148 | 1.6 149 | 150 | 151 | maven-install-plugin 152 | 2.5.2 153 | 154 | 155 | maven-invoker-plugin 156 | 2.0.0 157 | 158 | 159 | maven-jar-plugin 160 | 2.6 161 | 162 | 163 | maven-plugin-plugin 164 | 3.4 165 | 166 | true 167 | 168 | 169 | 170 | mojo-descriptor 171 | 172 | descriptor 173 | 174 | 175 | 176 | help-mojo 177 | 178 | helpmojo 179 | 180 | 181 | 182 | 183 | 184 | maven-release-plugin 185 | 2.5.2 186 | 187 | 188 | maven-resources-plugin 189 | 2.7 190 | 191 | 192 | maven-site-plugin 193 | 3.4 194 | 195 | 196 | maven-surefire-plugin 197 | 2.20 198 | 199 | 200 | org.codehaus.mojo 201 | mrm-maven-plugin 202 | 1.0-beta-2 203 | 204 | repository.proxy.url 205 | 206 | 207 | 208 | 209 | 210 | 211 | maven-compiler-plugin 212 | 213 | 1.5 214 | 1.5 215 | -g 216 | 217 | 218 | 219 | org.codehaus.mojo 220 | mrm-maven-plugin 221 | 222 | 223 | 224 | start 225 | stop 226 | 227 | 228 | 229 | 230 | 231 | org.apache.maven.plugins 232 | maven-invoker-plugin 233 | 234 | 235 | integration-test 236 | 237 | install 238 | run 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | src/it 248 | ${project.build.directory}/it 249 | ${project.build.directory}/local-repo 250 | src/it/settings.xml 251 | true 252 | true 253 | 254 | */pom.xml 255 | 256 | verify.bsh 257 | 258 | ${repository.proxy.url} 259 | 260 | -Xmx256m 261 | 262 | 263 | 264 | 265 | 266 | 267 | -------------------------------------------------------------------------------- /src/it/classifiers-fail-match/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011-2012 Stephen Connolly. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | invoker.goals=install 18 | 19 | # the jar file is non-unique, so expect to fail 20 | invoker.buildResult = failure 21 | -------------------------------------------------------------------------------- /src/it/classifiers-fail-match/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | localhost 21 | smokes 22 | 1.0-SNAPSHOT 23 | non-maven-jar 24 | classifiers-fail-match 25 | Basic smoke test of custom packaging with classifiers and multiple best matches 26 | 27 | 28 | UTF-8 29 | UTF-8 30 | UTF-8 31 | 32 | 33 | 34 | 35 | 36 | @project.groupId@ 37 | @project.artifactId@ 38 | @project.version@ 39 | true 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/it/classifiers-fail-match/src/conflict-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/classifiers-fail-match/src/conflict-javadoc.jar -------------------------------------------------------------------------------- /src/it/classifiers-fail-match/src/conflict-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/classifiers-fail-match/src/conflict-sources.jar -------------------------------------------------------------------------------- /src/it/classifiers-fail-match/src/conflict.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/classifiers-fail-match/src/conflict.jar -------------------------------------------------------------------------------- /src/it/classifiers-fail-match/src/smokes-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/classifiers-fail-match/src/smokes-javadoc.jar -------------------------------------------------------------------------------- /src/it/classifiers-fail-match/src/smokes-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/classifiers-fail-match/src/smokes-sources.jar -------------------------------------------------------------------------------- /src/it/classifiers-fail-match/src/smokes.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/classifiers-fail-match/src/smokes.jar -------------------------------------------------------------------------------- /src/it/classifiers-with-confusion/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011-2012 Stephen Connolly. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | invoker.goals=install 18 | -------------------------------------------------------------------------------- /src/it/classifiers-with-confusion/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | localhost 21 | smokes 22 | 1.0-SNAPSHOT 23 | non-maven-jar 24 | classifiers-with-confusion 25 | A good match with multiple classifiers and a poor match 26 | 27 | 28 | UTF-8 29 | UTF-8 30 | UTF-8 31 | 32 | 33 | 34 | 35 | 36 | @project.groupId@ 37 | @project.artifactId@ 38 | @project.version@ 39 | true 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/it/classifiers-with-confusion/src/confusion.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/classifiers-with-confusion/src/confusion.jar -------------------------------------------------------------------------------- /src/it/classifiers-with-confusion/src/smokes-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/classifiers-with-confusion/src/smokes-javadoc.jar -------------------------------------------------------------------------------- /src/it/classifiers-with-confusion/src/smokes-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/classifiers-with-confusion/src/smokes-sources.jar -------------------------------------------------------------------------------- /src/it/classifiers-with-confusion/src/smokes.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/classifiers-with-confusion/src/smokes.jar -------------------------------------------------------------------------------- /src/it/classifiers/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011-2012 Stephen Connolly. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | invoker.goals=install 18 | -------------------------------------------------------------------------------- /src/it/classifiers/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | localhost 21 | smokes 22 | 1.0-SNAPSHOT 23 | non-maven-jar 24 | classifiers 25 | Basic smoke test of custom packaging with classifiers 26 | 27 | 28 | UTF-8 29 | UTF-8 30 | UTF-8 31 | 32 | 33 | 34 | 35 | 36 | @project.groupId@ 37 | @project.artifactId@ 38 | @project.version@ 39 | true 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/it/classifiers/src/smokes-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/classifiers/src/smokes-javadoc.jar -------------------------------------------------------------------------------- /src/it/classifiers/src/smokes-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/classifiers/src/smokes-sources.jar -------------------------------------------------------------------------------- /src/it/classifiers/src/smokes.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/classifiers/src/smokes.jar -------------------------------------------------------------------------------- /src/it/missing-jar/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011-2012 Stephen Connolly. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | invoker.goals=install 18 | 19 | # the jar file is missing, so expect to fail 20 | invoker.buildResult = failure -------------------------------------------------------------------------------- /src/it/missing-jar/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | localhost 21 | smokes 22 | 1.0-SNAPSHOT 23 | non-maven-jar 24 | smokes 25 | Basic smoke test of custom packaging 26 | 27 | 28 | UTF-8 29 | UTF-8 30 | UTF-8 31 | 32 | 33 | 34 | 35 | 36 | @project.groupId@ 37 | @project.artifactId@ 38 | @project.version@ 39 | true 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/it/multi-module-advanced/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011-2012 Stephen Connolly. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | invoker.goals=test 18 | -------------------------------------------------------------------------------- /src/it/multi-module-advanced/maven/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | 21 | localhost.advanced 22 | mult-module 23 | 1.0-SNAPSHOT 24 | 25 | 26 | maven 27 | 28 | 29 | 30 | localhost.advanced 31 | non-maven 32 | 1.0-SNAPSHOT 33 | non-maven-jar 34 | 35 | 36 | junit 37 | junit 38 | 4.11 39 | test 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/it/multi-module-advanced/maven/src/test/java/localhost/HaveNonMavenDependencyTest.java: -------------------------------------------------------------------------------- 1 | package localhost; 2 | 3 | import junit.framework.Assert; 4 | import org.junit.*; 5 | 6 | import java.lang.Exception; 7 | 8 | public class HaveNonMavenDependencyTest { 9 | 10 | @Test 11 | public void haveLicenseDotTxt() throws Exception { 12 | Assert.assertNotNull("The '/LICENSE.txt' resource is on the classpath via the non-maven dependency", 13 | getClass().getResource("/LICENSE.txt")); 14 | } 15 | } -------------------------------------------------------------------------------- /src/it/multi-module-advanced/non-maven/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | 21 | localhost.advanced 22 | mult-module 23 | 1.0-SNAPSHOT 24 | 25 | 26 | non-maven 27 | non-maven-jar 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/it/multi-module-advanced/non-maven/src/smokes.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/multi-module-advanced/non-maven/src/smokes.jar -------------------------------------------------------------------------------- /src/it/multi-module-advanced/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | localhost.advanced 21 | mult-module 22 | 1.0-SNAPSHOT 23 | pom 24 | multi-module 25 | Tests using from a multi-module build 26 | 27 | 28 | maven 29 | non-maven 30 | 31 | 32 | 33 | 34 | UTF-8 35 | UTF-8 36 | UTF-8 37 | 38 | 39 | 40 | 41 | 42 | 43 | maven-compiler-plugin 44 | 3.0 45 | 46 | 47 | maven-surefire-plugin 48 | 2.14 49 | 50 | 51 | 52 | 53 | 54 | @project.groupId@ 55 | @project.artifactId@ 56 | @project.version@ 57 | true 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/it/multi-module-advanced/src/smokes.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/multi-module-advanced/src/smokes.jar -------------------------------------------------------------------------------- /src/it/multi-module/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011-2012 Stephen Connolly. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | invoker.goals=test 18 | -------------------------------------------------------------------------------- /src/it/multi-module/maven/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | 21 | localhost 22 | mult-module 23 | 1.0-SNAPSHOT 24 | 25 | 26 | maven 27 | 28 | 29 | 30 | localhost 31 | non-maven 32 | 1.0-SNAPSHOT 33 | 34 | 35 | junit 36 | junit 37 | 4.11 38 | test 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/it/multi-module/maven/src/test/java/localhost/HaveNonMavenDependencyTest.java: -------------------------------------------------------------------------------- 1 | package localhost; 2 | 3 | import junit.framework.Assert; 4 | import org.junit.*; 5 | 6 | import java.lang.Exception; 7 | 8 | public class HaveNonMavenDependencyTest { 9 | 10 | @Test 11 | public void haveLicenseDotTxt() throws Exception { 12 | Assert.assertNotNull("The '/LICENSE.txt' resource is on the classpath via the non-maven dependency", 13 | getClass().getResource("/LICENSE.txt")); 14 | } 15 | } -------------------------------------------------------------------------------- /src/it/multi-module/non-maven/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | 21 | localhost 22 | mult-module 23 | 1.0-SNAPSHOT 24 | 25 | 26 | non-maven 27 | non-maven-jar 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/it/multi-module/non-maven/src/smokes.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/multi-module/non-maven/src/smokes.jar -------------------------------------------------------------------------------- /src/it/multi-module/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | localhost 21 | mult-module 22 | 1.0-SNAPSHOT 23 | pom 24 | multi-module 25 | Tests using from a multi-module build 26 | 27 | 28 | maven 29 | non-maven 30 | 31 | 32 | 33 | 34 | UTF-8 35 | UTF-8 36 | UTF-8 37 | 38 | 39 | 40 | 41 | 42 | 43 | maven-compiler-plugin 44 | 3.0 45 | 46 | 47 | maven-surefire-plugin 48 | 2.14 49 | 50 | 51 | 52 | 53 | 54 | @project.groupId@ 55 | @project.artifactId@ 56 | @project.version@ 57 | true 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/it/multi-module/src/smokes.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/multi-module/src/smokes.jar -------------------------------------------------------------------------------- /src/it/multiple-matches/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011-2012 Stephen Connolly. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | invoker.goals=install 18 | 19 | # the jar file is non-unique, so expect to fail 20 | invoker.buildResult = failure 21 | -------------------------------------------------------------------------------- /src/it/multiple-matches/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | localhost 21 | smokes 22 | 1.0-SNAPSHOT 23 | non-maven-jar 24 | multiple-matches 25 | Basic smoke test of custom packaging 26 | 27 | 28 | UTF-8 29 | UTF-8 30 | UTF-8 31 | 32 | 33 | 34 | 35 | 36 | @project.groupId@ 37 | @project.artifactId@ 38 | @project.version@ 39 | true 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/it/multiple-matches/src/confuses.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/multiple-matches/src/confuses.jar -------------------------------------------------------------------------------- /src/it/multiple-matches/src/smokes.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/multiple-matches/src/smokes.jar -------------------------------------------------------------------------------- /src/it/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | mrm-maven-plugin 21 | Mock Repository Manager 22 | @repository.proxy.url@ 23 | * 24 | 25 | 26 | 27 | 28 | it-repo 29 | 30 | true 31 | 32 | 33 | 34 | snapshots 35 | @repository.proxy.url@ 36 | 37 | true 38 | ignore 39 | never 40 | 41 | 42 | true 43 | ignore 44 | always 45 | 46 | 47 | 48 | 49 | 50 | snapshots 51 | @repository.proxy.url@ 52 | 53 | true 54 | ignore 55 | never 56 | 57 | 58 | true 59 | ignore 60 | always 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/it/smokes/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011-2012 Stephen Connolly. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | invoker.goals=install 18 | -------------------------------------------------------------------------------- /src/it/smokes/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | localhost 21 | smokes 22 | 1.0-SNAPSHOT 23 | non-maven-jar 24 | smokes 25 | Basic smoke test of custom packaging 26 | 27 | 28 | UTF-8 29 | UTF-8 30 | UTF-8 31 | 32 | 33 | 34 | 35 | 36 | @project.groupId@ 37 | @project.artifactId@ 38 | @project.version@ 39 | true 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/it/smokes/src/smokes.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/smokes/src/smokes.jar -------------------------------------------------------------------------------- /src/it/specify-file/invoker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011-2012 Stephen Connolly. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | invoker.goals=install 18 | -------------------------------------------------------------------------------- /src/it/specify-file/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 4.0.0 20 | localhost 21 | specify-file 22 | 1.0-SNAPSHOT 23 | non-maven-jar 24 | specify-file 25 | Tests calling out the jar file explicitly 26 | 27 | 28 | UTF-8 29 | UTF-8 30 | UTF-8 31 | 32 | 33 | 34 | 35 | 36 | @project.groupId@ 37 | @project.artifactId@ 38 | @project.version@ 39 | true 40 | 41 | ${basedir}/smokes.jar 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/it/specify-file/smokes.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephenc/non-maven-jar-maven-plugin/70b990ed6dac53c49410cd451e8d8ca3258c1dd4/src/it/specify-file/smokes.jar -------------------------------------------------------------------------------- /src/main/java/com/github/stephenc/nonmavenjar/JarMojo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Stephen Connolly. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.github.stephenc.nonmavenjar; 17 | 18 | import java.io.File; 19 | import java.io.FilenameFilter; 20 | import java.util.ArrayList; 21 | import java.util.Collections; 22 | import java.util.Comparator; 23 | import java.util.Iterator; 24 | import java.util.List; 25 | import java.util.Map; 26 | import java.util.TreeMap; 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.Component; 31 | import org.apache.maven.plugins.annotations.LifecyclePhase; 32 | import org.apache.maven.plugins.annotations.Mojo; 33 | import org.apache.maven.plugins.annotations.Parameter; 34 | import org.apache.maven.project.MavenProject; 35 | import org.apache.maven.project.MavenProjectHelper; 36 | import org.codehaus.plexus.util.FileUtils; 37 | import org.codehaus.plexus.util.StringUtils; 38 | 39 | /** 40 | * A helper mojo for when you have 3rd party non-maven jars to integrate into a maven project. 41 | * 42 | * @author stephenc 43 | * @since 1.0 44 | */ 45 | @Mojo(name = "jar", 46 | aggregator = false, 47 | defaultPhase = LifecyclePhase.COMPILE, // needs to be compile to lest the test phase work 48 | requiresProject = true, 49 | threadSafe = true) 50 | public class JarMojo extends AbstractMojo { 51 | 52 | /** 53 | * The non-maven jar file or the directory to find the file in. 54 | */ 55 | @Parameter(property = "non-maven-jar.file", defaultValue = "${basedir}/src") 56 | private File jarFile; 57 | 58 | /** 59 | * The classifiers to look for secondary artifacts to attach to the build. 60 | * Defaults to javadoc, sources. 61 | * Where there are multiple candidates for {@link #jarFile} the one that matches the most secondary artifacts 62 | * will win. 63 | */ 64 | @Parameter 65 | private String[] classifiers; 66 | 67 | @Component 68 | private MavenProject project; 69 | 70 | @Component 71 | private MavenProjectHelper projectHelper; 72 | 73 | public void execute() throws MojoExecutionException, MojoFailureException { 74 | if (classifiers == null) { 75 | classifiers = new String[]{"javadoc", "sources"}; 76 | } 77 | Map selection; 78 | if (jarFile.isDirectory()) { 79 | File[] files = jarFile.listFiles(new FilenameFilter() { 80 | public boolean accept(File dir, String name) { 81 | return name.toLowerCase().endsWith(".jar"); 82 | } 83 | }); 84 | List> selections = new ArrayList>(); 85 | for (File file : files) { 86 | selections.add(matchArtifacts(file)); 87 | } 88 | Collections.sort(selections, new Comparator>() { 89 | public int compare(Map o1, Map o2) { 90 | long diff = ((long) o2.size()) - o1.size(); 91 | return diff < 0 ? -1 : diff == 0 ? 0 : +1; 92 | } 93 | }); 94 | if (selections.size() > 1) { 95 | // if more than one selection, remove all the less optimal selections 96 | Iterator> i = selections.iterator(); 97 | int bestSize = i.next().size(); 98 | while (i.hasNext()) { 99 | if (i.next().size() < bestSize) { 100 | i.remove(); 101 | } 102 | } 103 | } 104 | if (selections.size() == 1) { 105 | selection = selections.get(0); 106 | getLog().info("Found unique best match in " + jarFile); 107 | logSelection(selection); 108 | } else if (selections.isEmpty()) { 109 | throw new MojoExecutionException( 110 | "Expected exactly one main .jar file in the " + jarFile + " directory, found none"); 111 | } else { 112 | throw new MojoExecutionException( 113 | "Expected exactly one best match in the " + jarFile + " directory, found " + selections.size() 114 | + ":\n" 115 | + formatSelections(selections)); 116 | } 117 | } else if (jarFile.isFile()) { 118 | selection = matchArtifacts(jarFile); 119 | } else { 120 | throw new MojoExecutionException("Expected either a single .jar file in the " + jarFile 121 | + " directory or else that the 'jarFile' parameter would point to a jar file"); 122 | } 123 | for (Map.Entry entry : selection.entrySet()) { 124 | if (StringUtils.isEmpty(entry.getKey())) { 125 | if (project.getArtifact().getFile() != null && project.getArtifact().getFile().isFile()) { 126 | throw new MojoExecutionException("You have to use a classifier " 127 | + "to attach supplemental artifacts to the project. Expected to set " + entry.getValue() 128 | + " as the project artifact but found it already set to " + project.getArtifact().getFile() 129 | ); 130 | } 131 | project.getArtifact().setFile(entry.getValue()); 132 | } else { 133 | projectHelper.attachArtifact(project, "jar", entry.getKey(), entry.getValue()); 134 | } 135 | } 136 | } 137 | 138 | private Map matchArtifacts(File mainFile) { 139 | Map selection = new TreeMap(); 140 | if (mainFile.isFile()) { 141 | selection.put("", mainFile); 142 | for (String classifier : classifiers) { 143 | String filename = mainFile.getName(); 144 | File sideFile = new File(mainFile.getParentFile(), 145 | FileUtils.basename(filename, "." + FileUtils.extension(filename)) 146 | + "-" + classifier + "." 147 | + FileUtils.extension(filename)); 148 | if (sideFile.isFile()) { 149 | selection.put(classifier, sideFile); 150 | } 151 | } 152 | } 153 | return selection; 154 | } 155 | 156 | private void logSelection(Map selection) { 157 | getLog().info("Primary artifact: " + selection.get("")); 158 | for (Map.Entry entry : selection.entrySet()) { 159 | if (StringUtils.isBlank(entry.getKey())) { 160 | continue; 161 | } 162 | getLog().info("Secondary artifact, classifier " + entry.getKey() + ": " + entry.getValue()); 163 | } 164 | } 165 | 166 | private String formatSelection(Map selection) { 167 | StringBuilder buf = new StringBuilder(); 168 | buf.append("Primary artifact: ").append(selection.get("")); 169 | for (Map.Entry entry : selection.entrySet()) { 170 | if (StringUtils.isBlank(entry.getKey())) { 171 | continue; 172 | } 173 | buf.append("\nSecondary artifact, classifier ") 174 | .append(entry.getKey()) 175 | .append(": ") 176 | .append(entry.getValue()); 177 | } 178 | return buf.toString(); 179 | } 180 | 181 | private String formatSelections(List> selections) { 182 | StringBuilder buf = new StringBuilder(); 183 | for (Map selection : selections) { 184 | buf.append("- ").append(formatSelection(selection).replace("\n", "\n ")).append("\n"); 185 | } 186 | return buf.toString(); 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/plexus/components.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | org.apache.maven.lifecycle.mapping.LifecycleMapping 21 | non-maven-jar 22 | org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping 23 | 24 | 25 | com.github.stephenc.nonmavenjar:non-maven-jar-maven-plugin:jar 26 | org.apache.maven.plugins:maven-install-plugin:install 27 | org.apache.maven.plugins:maven-deploy-plugin:deploy 28 | 29 | 30 | 31 | 32 | org.apache.maven.artifact.handler.ArtifactHandler 33 | non-maven-jar 34 | org.apache.maven.artifact.handler.DefaultArtifactHandler 35 | 36 | jar 37 | java 38 | jar 39 | true 40 | 41 | 42 | 43 | --------------------------------------------------------------------------------