├── .fixtures.yml ├── .gitignore ├── .sync.yml ├── .travis.yml ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── Puppetfile ├── Puppetfile.lock ├── README.md ├── Rakefile ├── lib ├── facter │ └── maven_version.rb └── puppet │ ├── parser │ └── functions │ │ └── snapshotbaseversion.rb │ ├── provider │ └── maven │ │ └── mvn.rb │ └── type │ └── maven.rb ├── manifests ├── buildr.pp ├── configure.pp ├── environment.pp ├── init.pp ├── install_gem.pp ├── maven.pp └── settings.pp ├── metadata.json ├── spec ├── acceptance │ ├── maven_system_spec.rb │ └── nodesets │ │ ├── centos-65-x64-docker.yml │ │ ├── centos-65-x64.yml │ │ ├── debian-73-x64.yml │ │ ├── default.yml │ │ ├── ubuntu-server-1404-x64-docker.yml │ │ └── ubuntu-server-1404-x64.yml ├── classes │ └── maven_spec.rb ├── defines │ ├── active-profiles-settings.xml │ ├── complete-settings.xml │ ├── default-mavenrc │ ├── default-repo-only-url-settings.xml │ ├── default-repo-settings.xml │ ├── default-settings-security.xml │ ├── default-settings.xml │ ├── environment_spec.rb │ ├── local-repo-settings.xml │ ├── mirror-servers-settings.xml │ ├── populated-mavenrc │ ├── profiles-settings.xml │ ├── properties-settings.xml │ ├── proxy-settings.xml │ └── settings_spec.rb ├── fixtures │ └── acceptance │ │ └── maven │ │ ├── repo-1 │ │ └── org │ │ │ └── foo │ │ │ └── hello │ │ │ ├── 0.0.1-SNAPSHOT │ │ │ ├── hello-0.0.1-20131008.014634-1.jar │ │ │ ├── hello-0.0.1-20131008.014634-1.jar.md5 │ │ │ ├── hello-0.0.1-20131008.014634-1.jar.sha1 │ │ │ ├── hello-0.0.1-20131008.014634-1.pom │ │ │ ├── hello-0.0.1-20131008.014634-1.pom.md5 │ │ │ ├── hello-0.0.1-20131008.014634-1.pom.sha1 │ │ │ ├── maven-metadata.xml │ │ │ ├── maven-metadata.xml.md5 │ │ │ └── maven-metadata.xml.sha1 │ │ │ ├── maven-metadata.xml │ │ │ ├── maven-metadata.xml.md5 │ │ │ └── maven-metadata.xml.sha1 │ │ └── repo-2 │ │ └── org │ │ └── foo │ │ └── hello │ │ ├── 0.0.1-SNAPSHOT │ │ ├── hello-0.0.1-20131008.014634-1.jar │ │ ├── hello-0.0.1-20131008.014634-1.jar.md5 │ │ ├── hello-0.0.1-20131008.014634-1.jar.sha1 │ │ ├── hello-0.0.1-20131008.014634-1.pom │ │ ├── hello-0.0.1-20131008.014634-1.pom.md5 │ │ ├── hello-0.0.1-20131008.014634-1.pom.sha1 │ │ ├── hello-0.0.1-20131008.025235-2.jar │ │ ├── hello-0.0.1-20131008.025235-2.jar.md5 │ │ ├── hello-0.0.1-20131008.025235-2.jar.sha1 │ │ ├── hello-0.0.1-20131008.025235-2.pom │ │ ├── hello-0.0.1-20131008.025235-2.pom.md5 │ │ ├── hello-0.0.1-20131008.025235-2.pom.sha1 │ │ ├── maven-metadata.xml │ │ ├── maven-metadata.xml.md5 │ │ └── maven-metadata.xml.sha1 │ │ ├── maven-metadata.xml │ │ ├── maven-metadata.xml.md5 │ │ └── maven-metadata.xml.sha1 ├── spec_helper.rb ├── spec_helper_acceptance.rb └── unit │ └── puppet │ ├── provider │ └── maven │ │ └── mvn_spec.rb │ └── type │ └── maven_spec.rb ├── templates ├── mavenrc.erb ├── settings-security.xml.erb └── settings.xml.erb └── tests └── init.pp /.fixtures.yml: -------------------------------------------------------------------------------- 1 | fixtures: 2 | symlinks: 3 | maven: "#{source_dir}" 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This file is managed centrally by modulesync 2 | # https://github.com/maestrodev/puppet-modulesync 3 | 4 | ## MAC OS 5 | .DS_Store 6 | 7 | ## TEXTMATE 8 | *.tmproj 9 | tmtags 10 | 11 | ## EMACS 12 | *~ 13 | \#* 14 | .\#* 15 | 16 | ## VIM 17 | *.swp 18 | *.swo 19 | tags 20 | 21 | ## Bundler 22 | .bundle 23 | vendor/ 24 | 25 | ## rbenv / rvm 26 | .rbenv* 27 | .rvmrc* 28 | .ruby-* 29 | 30 | ## rspec 31 | spec/fixtures/ 32 | 33 | ## Puppet module 34 | pkg/ 35 | coverage/ 36 | 37 | ## Librarian-puppet 38 | .tmp/ 39 | .librarian/ 40 | 41 | -------------------------------------------------------------------------------- /.sync.yml: -------------------------------------------------------------------------------- 1 | Gemfile: 2 | puppet_version: '>= 3.0' 3 | spec/spec_helper_acceptance.rb: 4 | modules: 5 | - name: maestrodev-wget 6 | version: 1.0.0 7 | osfamily: RedHat 8 | - name: puppetlabs-java 9 | version: 1.0.1 10 | .travis.yml: 11 | exclude_puppet: 12 | - 3.3.0 13 | - 3.2.0 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This file is managed centrally by modulesync 3 | # https://github.com/maestrodev/puppet-modulesync 4 | 5 | before_install: 6 | - rm -f Gemfile.lock 7 | 8 | rvm: 9 | - "2.0.0" 10 | 11 | env: 12 | - PUPPET_VERSION="~> 3.7.0" 13 | - PUPPET_VERSION="~> 3.6.0" 14 | - PUPPET_VERSION="~> 3.5.0" 15 | - PUPPET_VERSION="~> 3.4.0" 16 | 17 | matrix: 18 | exclude: 19 | # No support for Ruby 2.0 before Puppet 3.2 20 | - rvm: 2.0.0 21 | env: PUPPET_VERSION="~> 2.7.0" 22 | - rvm: 2.0.0 23 | env: PUPPET_VERSION="~> 3.0.0" 24 | - rvm: 2.0.0 25 | env: PUPPET_VERSION="~> 3.1.0" 26 | # Puppet < 3.5.0 is broken under ruby 2.1 https://tickets.puppetlabs.com/browse/PUP-1243 27 | - rvm: 2.1.0 28 | env: PUPPET_VERSION="~> 2.7.0" 29 | - rvm: 2.1.0 30 | env: PUPPET_VERSION="~> 3.0.0" 31 | - rvm: 2.1.0 32 | env: PUPPET_VERSION="~> 3.1.0" 33 | - rvm: 2.1.0 34 | env: PUPPET_VERSION="~> 3.2.0" 35 | - rvm: 2.1.0 36 | env: PUPPET_VERSION="~> 3.3.0" 37 | - rvm: 2.1.0 38 | env: PUPPET_VERSION="~> 3.4.0" 39 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # This file is managed centrally by modulesync 2 | # https://github.com/maestrodev/puppet-modulesync 3 | 4 | source 'https://rubygems.org' 5 | 6 | gem 'puppet', ENV['PUPPET_VERSION'] || '>= 3.0', :require => false 7 | 8 | gem 'rake', :require => false 9 | gem 'rspec-puppet', '>= 1.0.0', :require => false 10 | gem 'puppetlabs_spec_helper', '>= 0.8.0', :require => false 11 | gem 'puppet-lint', '>= 1.1.0', :require => false 12 | gem 'simplecov', :require => false 13 | gem 'puppet-blacksmith', '>= 3.0.0', :require => false 14 | gem 'librarian-puppet', '>= 2.0.0', :require => false 15 | gem 'beaker-rspec', '>= 3.0.0', :require => false 16 | 17 | # vim:ft=ruby 18 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | CFPropertyList (2.2.8) 5 | activemodel (4.2.0) 6 | activesupport (= 4.2.0) 7 | builder (~> 3.1) 8 | activesupport (4.2.0) 9 | i18n (~> 0.7) 10 | json (~> 1.7, >= 1.7.7) 11 | minitest (~> 5.1) 12 | thread_safe (~> 0.3, >= 0.3.4) 13 | tzinfo (~> 1.1) 14 | addressable (2.3.6) 15 | archive-tar-minitar (0.5.2) 16 | autoparse (0.3.3) 17 | addressable (>= 2.3.1) 18 | extlib (>= 0.9.15) 19 | multi_json (>= 1.0.0) 20 | aws-sdk (1.61.0) 21 | aws-sdk-v1 (= 1.61.0) 22 | aws-sdk-v1 (1.61.0) 23 | json (~> 1.4) 24 | nokogiri (>= 1.4.4) 25 | beaker (2.2.0) 26 | aws-sdk (~> 1.57) 27 | docker-api 28 | fission (~> 0.4) 29 | fog (~> 1.25) 30 | google-api-client (~> 0.7) 31 | hocon (~> 0.0.4) 32 | inifile (~> 2.0) 33 | json (~> 1.8) 34 | minitest (~> 5.4) 35 | net-scp (~> 1.2) 36 | net-ssh (~> 2.9) 37 | rbvmomi (~> 1.8) 38 | unf (~> 0.1) 39 | beaker-rspec (5.0.0) 40 | beaker (~> 2.0) 41 | rspec 42 | serverspec (~> 2) 43 | specinfra (~> 2) 44 | builder (3.2.2) 45 | diff-lcs (1.2.5) 46 | docile (1.1.5) 47 | docker-api (1.17.0) 48 | archive-tar-minitar 49 | excon (>= 0.38.0) 50 | json 51 | excon (0.43.0) 52 | extlib (0.9.16) 53 | facter (2.3.0) 54 | CFPropertyList (~> 2.2.6) 55 | faraday (0.9.1) 56 | multipart-post (>= 1.2, < 3) 57 | fission (0.5.0) 58 | CFPropertyList (~> 2.2) 59 | fog (1.27.0) 60 | fog-atmos 61 | fog-aws (~> 0.0) 62 | fog-brightbox (~> 0.4) 63 | fog-core (~> 1.27, >= 1.27.3) 64 | fog-ecloud 65 | fog-json 66 | fog-profitbricks 67 | fog-radosgw (>= 0.0.2) 68 | fog-sakuracloud (>= 0.0.4) 69 | fog-serverlove 70 | fog-softlayer 71 | fog-storm_on_demand 72 | fog-terremark 73 | fog-vmfusion 74 | fog-voxel 75 | fog-xml (~> 0.1.1) 76 | ipaddress (~> 0.5) 77 | nokogiri (~> 1.5, >= 1.5.11) 78 | fog-atmos (0.1.0) 79 | fog-core 80 | fog-xml 81 | fog-aws (0.0.6) 82 | fog-core (~> 1.27) 83 | fog-json (~> 1.0) 84 | fog-xml (~> 0.1) 85 | ipaddress (~> 0.8) 86 | fog-brightbox (0.7.1) 87 | fog-core (~> 1.22) 88 | fog-json 89 | inflecto (~> 0.0.2) 90 | fog-core (1.27.3) 91 | builder 92 | excon (~> 0.38) 93 | formatador (~> 0.2) 94 | mime-types 95 | net-scp (~> 1.1) 96 | net-ssh (>= 2.1.3) 97 | fog-ecloud (0.0.2) 98 | fog-core 99 | fog-xml 100 | fog-json (1.0.0) 101 | multi_json (~> 1.0) 102 | fog-profitbricks (0.0.1) 103 | fog-core 104 | fog-xml 105 | nokogiri 106 | fog-radosgw (0.0.3) 107 | fog-core (>= 1.21.0) 108 | fog-json 109 | fog-xml (>= 0.0.1) 110 | fog-sakuracloud (0.1.1) 111 | fog-core 112 | fog-json 113 | fog-serverlove (0.1.1) 114 | fog-core 115 | fog-json 116 | fog-softlayer (0.3.30) 117 | fog-core 118 | fog-json 119 | fog-storm_on_demand (0.1.0) 120 | fog-core 121 | fog-json 122 | fog-terremark (0.0.3) 123 | fog-core 124 | fog-xml 125 | fog-vmfusion (0.0.1) 126 | fission 127 | fog-core 128 | fog-voxel (0.0.2) 129 | fog-core 130 | fog-xml 131 | fog-xml (0.1.1) 132 | fog-core 133 | nokogiri (~> 1.5, >= 1.5.11) 134 | formatador (0.2.5) 135 | google-api-client (0.8.2) 136 | activesupport (>= 3.2) 137 | addressable (~> 2.3) 138 | autoparse (~> 0.3) 139 | extlib (~> 0.9) 140 | faraday (~> 0.9) 141 | launchy (~> 2.4) 142 | multi_json (~> 1.10) 143 | retriable (~> 1.4) 144 | signet (~> 0.6) 145 | her (0.7.3) 146 | activemodel (>= 3.0.0, <= 4.2) 147 | activesupport (>= 3.0.0, <= 4.2) 148 | faraday (>= 0.8, < 1.0) 149 | multi_json (~> 1.7) 150 | hiera (1.3.4) 151 | json_pure 152 | highline (1.6.21) 153 | hocon (0.0.6) 154 | i18n (0.7.0) 155 | inflecto (0.0.2) 156 | inifile (2.0.2) 157 | ipaddress (0.8.0) 158 | json (1.8.2) 159 | json_pure (1.8.2) 160 | jwt (1.2.0) 161 | launchy (2.4.3) 162 | addressable (~> 2.3) 163 | librarian (0.1.2) 164 | highline 165 | thor (~> 0.15) 166 | librarian-puppet (2.0.1) 167 | librarian (>= 0.1.2) 168 | puppet_forge 169 | rsync 170 | metaclass (0.0.4) 171 | mime-types (2.4.3) 172 | mini_portile (0.6.2) 173 | minitest (5.5.1) 174 | mocha (1.1.0) 175 | metaclass (~> 0.0.1) 176 | multi_json (1.10.1) 177 | multipart-post (2.0.0) 178 | net-scp (1.2.1) 179 | net-ssh (>= 2.6.5) 180 | net-ssh (2.9.2) 181 | netrc (0.10.2) 182 | nokogiri (1.6.5) 183 | mini_portile (~> 0.6.0) 184 | puppet (3.7.3) 185 | facter (> 1.6, < 3) 186 | hiera (~> 1.0) 187 | json_pure 188 | puppet-blacksmith (3.1.1) 189 | puppet (>= 2.7.16) 190 | rest-client 191 | puppet-lint (1.1.0) 192 | puppet-syntax (1.4.1) 193 | rake 194 | puppet_forge (1.0.4) 195 | her (~> 0.6) 196 | puppetlabs_spec_helper (0.8.2) 197 | mocha 198 | puppet-lint 199 | puppet-syntax 200 | rake 201 | rspec 202 | rspec-puppet 203 | rake (10.4.2) 204 | rbvmomi (1.8.2) 205 | builder 206 | nokogiri (>= 1.4.1) 207 | trollop 208 | rest-client (1.7.2) 209 | mime-types (>= 1.16, < 3.0) 210 | netrc (~> 0.7) 211 | retriable (1.4.1) 212 | rspec (3.1.0) 213 | rspec-core (~> 3.1.0) 214 | rspec-expectations (~> 3.1.0) 215 | rspec-mocks (~> 3.1.0) 216 | rspec-core (3.1.7) 217 | rspec-support (~> 3.1.0) 218 | rspec-expectations (3.1.2) 219 | diff-lcs (>= 1.2.0, < 2.0) 220 | rspec-support (~> 3.1.0) 221 | rspec-its (1.1.0) 222 | rspec-core (>= 3.0.0) 223 | rspec-expectations (>= 3.0.0) 224 | rspec-mocks (3.1.3) 225 | rspec-support (~> 3.1.0) 226 | rspec-puppet (1.0.1) 227 | rspec 228 | rspec-support (3.1.2) 229 | rsync (1.0.9) 230 | serverspec (2.7.1) 231 | multi_json 232 | rspec (~> 3.0) 233 | rspec-its 234 | specinfra (~> 2.10) 235 | signet (0.6.0) 236 | addressable (~> 2.3) 237 | extlib (~> 0.9) 238 | faraday (~> 0.9) 239 | jwt (~> 1.0) 240 | multi_json (~> 1.10) 241 | simplecov (0.9.1) 242 | docile (~> 1.1.0) 243 | multi_json (~> 1.0) 244 | simplecov-html (~> 0.8.0) 245 | simplecov-html (0.8.0) 246 | specinfra (2.11.5) 247 | net-scp 248 | net-ssh 249 | thor (0.19.1) 250 | thread_safe (0.3.4) 251 | trollop (2.1.1) 252 | tzinfo (1.2.2) 253 | thread_safe (~> 0.1) 254 | unf (0.1.4) 255 | unf_ext 256 | unf_ext (0.0.6) 257 | 258 | PLATFORMS 259 | ruby 260 | 261 | DEPENDENCIES 262 | beaker-rspec (>= 3.0.0) 263 | librarian-puppet (>= 2.0.0) 264 | puppet (>= 3.0) 265 | puppet-blacksmith (>= 3.0.0) 266 | puppet-lint (>= 1.1.0) 267 | puppetlabs_spec_helper (>= 0.8.0) 268 | rake 269 | rspec-puppet (>= 1.0.0) 270 | simplecov 271 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [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 | -------------------------------------------------------------------------------- /Puppetfile: -------------------------------------------------------------------------------- 1 | forge 'http://forge.puppetlabs.com' 2 | 3 | mod 'maestrodev/wget', '>=1.0.0' 4 | -------------------------------------------------------------------------------- /Puppetfile.lock: -------------------------------------------------------------------------------- 1 | FORGE 2 | remote: http://forge.puppetlabs.com 3 | specs: 4 | maestrodev/wget (1.1.0) 5 | 6 | DEPENDENCIES 7 | maestrodev/wget (>= 1.0.0) 8 | 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Puppet-Maven 2 | ============ 3 | 4 | A Puppet recipe for Apache Maven, to download artifacts from a Maven repository 5 | 6 | Uses [Apache Maven](http://maven.apache.org) command line to download the artifacts. 7 | 8 | Building and Installing the Module 9 | ---------------------------------- 10 | 11 | To build the module for installing in your Puppet master: 12 | 13 | ```sh 14 | gem install puppet-module 15 | git clone git://github.com/maestrodev/puppet-maven.git 16 | cd puppet-maven 17 | puppet module build 18 | puppet module install pkg/maestrodev-maven-1.0.1.tar.gz 19 | ``` 20 | 21 | Of course, you can also clone the repository straight into `/etc/puppet/modules/maven` as well. 22 | 23 | Developing and Testing the Module 24 | --------------------------------- 25 | 26 | If you are developing the module, it can be built using `rake`: 27 | 28 | ```sh 29 | gem install bundler 30 | bundle 31 | rake spec 32 | ``` 33 | 34 | ### Acceptance tests 35 | 36 | Using Puppetlabs Beaker. To run the default Vagrant box in CentOS 6.5 just do 37 | 38 | ``` 39 | rake beaker 40 | ``` 41 | 42 | To run any other box, check the definitions at `spec/acceptance/nodesets`. For instance to run the tests with Docker in CentOS 6.5 43 | 44 | ``` 45 | BEAKER_set=centos-65-x64-docker rake beaker 46 | ``` 47 | 48 | 49 | Usage 50 | ----- 51 | 52 | ```puppet 53 | maven { "/tmp/myfile": 54 | id => "groupId:artifactId:version:packaging:classifier", 55 | repos => ["id::layout::http://repo.acme.com","http://repo2.acme.com"], 56 | } 57 | ``` 58 | 59 | or 60 | 61 | ```puppet 62 | maven { "/tmp/myfile": 63 | groupid => "org.apache.maven", 64 | artifactid => "maven-core", 65 | version => "3.2.5", 66 | packaging => "jar", 67 | classifier => "sources", 68 | repos => ["id::layout::http://repo.acme.com","http://repo2.acme.com"], 69 | } 70 | ``` 71 | 72 | ### ensure 73 | 74 | `ensure` may be one of two values: 75 | * `present` (the default) -- the specified maven artifact is downloaded when no file exists 76 | at `path` (or `name` if no path is specified.) This is probably makes 77 | sense when the specified maven artifact refers to a released (non-SNAPSHOT) 78 | artifact. 79 | * `latest` -- if value of version is a specific version, `RELEASE`, `LATEST`, or a SNAPSHOT the repository 80 | is queried for an updated artifact. If an updated artifact is found the file 81 | at `path` is replaced. 82 | 83 | ### MAVEN_OPTS Precedence 84 | 85 | Values set in `maven_opts` will be _prepended_ to any existing 86 | `MAVEN_OPTS` value. This ensures that those already specified will win over 87 | those added in `mavenrc`. 88 | 89 | If you would prefer these options to win, instead use: 90 | 91 | ```puppet 92 | maven_opts => "", 93 | mavenrc_additions => 'MAVEN_OPTS="$MAVEN_OPTS -Xmx1024m" 94 | ``` 95 | 96 | Examples 97 | -------- 98 | 99 | ### Setup 100 | 101 | ```puppet 102 | $central = { 103 | id => "myrepo", 104 | username => "myuser", 105 | password => "mypassword", 106 | url => "http://repo.acme.com", 107 | mirrorof => "external:*", # if you want to use the repo as a mirror, see maven::settings below 108 | } 109 | 110 | $proxy = { 111 | active => true, #Defaults to true 112 | protocol => 'http', #Defaults to 'http' 113 | host => 'http://proxy.acme.com', 114 | username => 'myuser', #Optional if proxy does not require 115 | password => 'mypassword', #Optional if proxy does not require 116 | nonProxyHosts => 'www.acme.com', #Optional, provides exceptions to the proxy 117 | } 118 | 119 | # Install Maven 120 | class { "maven::maven": 121 | version => "3.2.5", # version to install 122 | # you can get Maven tarball from a Maven repository instead than from Apache servers, optionally with a user/password 123 | repo => { 124 | #url => "http://repo.maven.apache.org/maven2", 125 | #username => "", 126 | #password => "", 127 | } 128 | } -> 129 | 130 | # Setup a .mavenrc file for the specified user 131 | maven::environment { 'maven-env' : 132 | user => 'root', 133 | # anything to add to MAVEN_OPTS in ~/.mavenrc 134 | maven_opts => '-Xmx1384m', # anything to add to MAVEN_OPTS in ~/.mavenrc 135 | maven_path_additions => "", # anything to add to the PATH in ~/.mavenrc 136 | 137 | } -> 138 | 139 | # Create a settings.xml with the repo credentials 140 | maven::settings { 'maven-user-settings' : 141 | mirrors => [$central], # mirrors entry in settings.xml, uses id, url, mirrorof from the hash passed 142 | servers => [$central], # servers entry in settings.xml, uses id, username, password from the hash passed, privateKey 143 | proxies => [$proxy], # proxies entry in settings.xml, active, protocol, host, username, password, nonProxyHosts 144 | user => 'maven', 145 | } 146 | 147 | # defaults for all maven{} declarations 148 | Maven { 149 | user => "maven", # you can make puppet run Maven as a specific user instead of root, useful to share Maven settings and local repository 150 | group => "maven", # you can make puppet run Maven as a specific group 151 | repos => "http://repo.maven.apache.org/maven2" 152 | } 153 | ``` 154 | 155 | Downloading artifacts 156 | --------------------- 157 | 158 | ```puppet 159 | maven { "/tmp/maven-core-3.2.5.jar": 160 | id => "org.apache.maven:maven-core:3.2.5:jar", 161 | repos => ["central::default::http://repo.maven.apache.org/maven2","http://mirrors.ibiblio.org/pub/mirrors/maven2"], 162 | } 163 | 164 | maven { "/tmp/maven-core-3.2.5-sources.jar": 165 | groupid => "org.apache.maven", 166 | artifactid => "maven-core", 167 | version => "3.2.5", 168 | classifier => "sources", 169 | } 170 | ``` 171 | 172 | Buildr version 173 | -------------- 174 | 175 | Initially there was an [Apache Buildr](http://buildr.apache.org) version, but it required to have Buildr installed before running Puppet and you would need to [enable pluginsync](http://docs.puppetlabs.com/guides/plugins_in_modules.html#enabling-pluginsync) 176 | in both master and clients. 177 | 178 | License 179 | ------- 180 | ``` 181 | Copyright 2011-2012 MaestroDev 182 | 183 | Licensed under the Apache License, Version 2.0 (the "License"); 184 | you may not use this file except in compliance with the License. 185 | You may obtain a copy of the License at 186 | 187 | http://www.apache.org/licenses/LICENSE-2.0 188 | 189 | Unless required by applicable law or agreed to in writing, software 190 | distributed under the License is distributed on an "AS IS" BASIS, 191 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 192 | See the License for the specific language governing permissions and 193 | limitations under the License. 194 | ``` 195 | 196 | Author 197 | ------ 198 | 199 | Carlos Sanchez 200 | [MaestroDev](http://www.maestrodev.com) 201 | 2010-03-01 202 | 203 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # This file is managed centrally by modulesync 2 | # https://github.com/maestrodev/puppet-modulesync 3 | 4 | require 'rake/clean' 5 | require 'puppetlabs_spec_helper/rake_tasks' 6 | require 'puppet-lint/tasks/puppet-lint' 7 | require 'puppet_blacksmith/rake_tasks' 8 | 9 | CLEAN.include('spec/fixtures/manifests/', 'spec/fixtures/modules/', 'doc', 'pkg') 10 | CLOBBER.include('.tmp', '.librarian') 11 | 12 | ENV['STRICT_VARIABLES']='yes' unless Gem::Version.new(Puppet.version) < Gem::Version.new("3.5.0") 13 | 14 | task :librarian_spec_prep do 15 | sh "librarian-puppet install --path=spec/fixtures/modules/" 16 | end 17 | task :spec_prep => :librarian_spec_prep 18 | 19 | Rake::Task[:lint].clear # workaround https://github.com/rodjek/puppet-lint/issues/331 20 | PuppetLint.configuration.relative = true # https://github.com/rodjek/puppet-lint/pull/334 21 | PuppetLint::RakeTask.new :lint do |config| 22 | config.pattern = 'manifests/**/*.pp' 23 | config.disable_checks = ['80chars', 'class_inherits_from_params_class'] 24 | config.fail_on_warnings = true 25 | # config.relative = true 26 | end 27 | 28 | task :default => [:clean, :validate, :lint, :spec] 29 | -------------------------------------------------------------------------------- /lib/facter/maven_version.rb: -------------------------------------------------------------------------------- 1 | Facter.add("maven_version") do 2 | setcode do 3 | version = Facter::Util::Resolution.exec('mvn --version') 4 | version.chomp.split("\n")[0].split(" ")[2] if version 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /lib/puppet/parser/functions/snapshotbaseversion.rb: -------------------------------------------------------------------------------- 1 | module Puppet::Parser::Functions 2 | newfunction(:snapshotbaseversion, :type => :rvalue) do |args| 3 | version = args[0] 4 | # If the version is a Maven snapshot, transform the base version to it's 5 | # SNAPSHOT indicator 6 | regex = /^(.*)-[0-9]{8}\.[0-9]{6}-[0-9]+$/ 7 | if version =~ regex 8 | base_version = regex.match(version)[1] + "-SNAPSHOT" 9 | else 10 | base_version = version 11 | end 12 | base_version 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/puppet/provider/maven/mvn.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 MaestroDev 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require 'puppet/resource' 16 | require 'puppet/resource/catalog' 17 | require 'fileutils' 18 | require 'tempfile' 19 | 20 | Puppet::Type.type(:maven).provide(:mvn) do 21 | desc "Maven download using mvn command line." 22 | include Puppet::Util::Execution 23 | 24 | def ensure 25 | if !exists? 26 | value = :absent 27 | elsif @resource[:ensure] == :latest && !outdated? 28 | value = :latest 29 | else 30 | value = :present 31 | #value = Digest::MD5.file(@resource[:name]).hexdigest 32 | end 33 | debug "#{@resource[:name]} ensure #{value}" 34 | value 35 | end 36 | 37 | def ensure=(value) 38 | debug "#{@resource[:name]} ensure = #{value}" 39 | ([:present, :latest] & [value]).any? ? create(value) : destroy 40 | end 41 | 42 | private 43 | [:artifactid, 44 | :version, 45 | :packaging, 46 | :classifier, 47 | :options, 48 | :user, 49 | :group, 50 | :groupid, 51 | :repoid].each { |m| define_method(m) { @resource[m] } } 52 | 53 | def full_id 54 | @resource[:id] 55 | end 56 | 57 | def plugin_version 58 | @resource[:pluginversion].nil? ? "2.4" : @resource[:pluginversion] 59 | end 60 | 61 | def repos 62 | repos = @resource[:repos] 63 | if repos.nil? || repos.empty? 64 | ["http://repo1.maven.apache.org/maven2"] 65 | elsif !repos.kind_of?(Array) 66 | [repos] 67 | else 68 | repos 69 | end 70 | end 71 | 72 | def transitive 73 | @resource[:transitive].nil? ? false : @resource[:transitive] 74 | end 75 | 76 | # is it a version that automatically updates? (SNAPSHOT, LATEST, RELEASE) 77 | def updatable? 78 | if full_id.nil? 79 | ver = version 80 | else 81 | ver = full_id.split(':')[2] 82 | end 83 | 84 | value = ver =~ /SNAPSHOT$/ || ver == 'LATEST' || ver == 'RELEASE' 85 | debug "#{@resource[:name]} updatable? #{value}" 86 | value 87 | end 88 | 89 | def inlocalrepo? tempfile 90 | # try an "offline" maven download 91 | value = download tempfile, false, true 92 | debug "#{@resource[:name]} in local repo? #{value}" 93 | value 94 | end 95 | 96 | def create(value) 97 | download name, value == :latest 98 | end 99 | 100 | def download(dest, latest, offline = false) 101 | # Remote repositories to use 102 | debug "Repositories to use: #{repos.join(', ')}" 103 | 104 | # Download the artifact fom the repo 105 | command_string = "-Dartifact=#{full_id}" 106 | msg = full_id 107 | if (full_id.nil?) 108 | command_string = "-DgroupId=#{groupid} -DartifactId=#{artifactid} -Dversion=#{version} " 109 | command_string = command_string + "-Dpackaging=#{packaging} " unless packaging.nil? 110 | command_string = command_string + "-Dclassifier=#{classifier}" unless classifier.nil? 111 | msg = "#{groupid}:#{artifactid}:#{version}:" + (packaging.nil? ? "" : packaging) + ":" + (classifier.nil? ? "" : classifier) 112 | end 113 | 114 | if offline 115 | command_string = command_string + " -o " 116 | else 117 | command_string = command_string + " -U " if updatable? && latest 118 | end 119 | 120 | # set the repoId if specified 121 | command_string = command_string + " -DrepoId=#{repoid}" unless repoid.nil? 122 | 123 | if offline 124 | debug "mvn copying repo file #{msg} to #{dest} from local repo" 125 | else 126 | debug "mvn downloading (if needed) repo file #{msg} to #{dest} from #{repos.join(', ')}" 127 | end 128 | 129 | command = ["mvn -B org.apache.maven.plugins:maven-dependency-plugin:#{plugin_version}:get #{command_string} -DremoteRepositories=#{repos.join(',')} -Ddest=#{dest} -Dtransitive=#{transitive} -Ppuppet-maven #{options}"] 130 | 131 | timeout = @resource[:timeout].nil? ? 0 : @resource[:timeout].to_i 132 | output = nil 133 | status = nil 134 | 135 | begin 136 | Timeout::timeout(timeout) do 137 | output = Puppet::Util::Execution.execute(command, {:uid => user, :gid => group}) 138 | 139 | debug output if output.exitstatus == 0 140 | debug "Exit status = #{output.exitstatus}" 141 | end 142 | rescue Timeout::Error 143 | self.fail("Command timed out, increase timeout parameter if needed: #{command}") 144 | end 145 | 146 | if (output.exitstatus == 1) && (output == '') 147 | self.fail("mvn returned #{output.exitstatus}: Is Maven installed?") 148 | end 149 | 150 | # if we are offline, we check by this if the file is yet downloaded 151 | if output.exitstatus != 0 && !offline 152 | self.fail("#{command} returned #{output.exitstatus}: #{output}") 153 | end 154 | 155 | output.exitstatus == 0 156 | end 157 | 158 | def destroy 159 | # no going back 160 | # FileUtils.rm @resource[:dest] 161 | raise NotImplementedError 162 | end 163 | 164 | def exists? 165 | return File.exists?(@resource[:name]) 166 | end 167 | 168 | def outdated? 169 | tempfile = Tempfile.new 'mvn' 170 | FileUtils.chown(user, group, tempfile.path) 171 | if updatable? 172 | download tempfile.path, true 173 | !FileUtils.compare_file @resource[:name], tempfile.path 174 | else 175 | if inlocalrepo? tempfile.path 176 | !FileUtils.compare_file @resource[:name], tempfile.path 177 | else 178 | true 179 | end 180 | end 181 | end 182 | end 183 | -------------------------------------------------------------------------------- /lib/puppet/type/maven.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 MaestroDev 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require 'puppet/type' 16 | 17 | Puppet::Type.newtype(:maven) do 18 | require 'timeout' 19 | 20 | @doc = "Maven repository files." 21 | 22 | newproperty(:ensure) do 23 | desc <<-EOT 24 | May be one of two values: 'present' or 'latest'. When 'present' (the default) 25 | the specified maven artifact is downloaded when no file exists 26 | at 'path' (or 'name' if no path is specified.) This is approporate 27 | when the specified maven artifact refers to a released (non-SNAPSHOT) 28 | artifact. If 'latest' is specified and the value of version is 29 | 'RELEASE', 'LATEST', or a SNAPSHOT the repository is queried for the 30 | most recent version. 31 | EOT 32 | defaultto(:present) 33 | 34 | newvalue(:present) 35 | newvalue(:latest) 36 | end 37 | 38 | # required or puppet will fail with one of these errors 39 | # err: Could not render to pson: undefined method `merge' for []:Array 40 | # Could not evaluate: No ability to determine if maven exists 41 | def self.title_patterns 42 | [ [ /^(.*?)\/*\Z/m, [ [ :path, lambda{|x| x} ] ] ] ] 43 | end 44 | 45 | newparam(:path) do 46 | desc "The destination path of the downloaded file." 47 | isnamevar 48 | end 49 | 50 | newparam(:id) do 51 | desc "The Maven repository id, ie. 'org.apache.maven:maven-core:jar:3.0.5', 52 | 'org.apache.maven:maven-core:jar:sources:3.0.5'" 53 | end 54 | newparam(:groupid) do 55 | desc "The Maven arifact group id, ie. 'org.apache.maven'" 56 | end 57 | newparam(:artifactid) do 58 | desc "The Maven artifact id, ie. 'maven-core'" 59 | end 60 | newparam(:version) do 61 | desc "The Maven artifact version, ie. '3.0.5'" 62 | end 63 | newparam(:packaging) do 64 | desc "The Maven artifact packaging, ie. 'jar'" 65 | end 66 | newparam(:classifier) do 67 | desc "The Maven artifact classifier, ie. 'sources'" 68 | end 69 | 70 | newparam(:repoid) do 71 | desc "Id of the repository to use. Useful for mirroring, authentication,..." 72 | end 73 | newparam(:repos) do 74 | desc "Repositories to use for artifact downloading. Defaults to http://repo1.maven.apache.org/maven2" 75 | end 76 | newparam(:timeout) do 77 | desc "Download timeout." 78 | end 79 | newparam(:pluginversion) do 80 | desc "Version of the dependency plugin to use." 81 | end 82 | newparam(:options) do 83 | desc "Other options to pass to mvn." 84 | end 85 | 86 | newparam(:user) do 87 | desc "User to run Maven as. Useful to share a local repo and settings.xml. Defaults to user executing puppet." 88 | end 89 | newparam(:group) do 90 | desc "Group to run Maven as. Defaults to group of the user executing puppet." 91 | end 92 | newparam(:transitive) do 93 | desc "Whether to resolve transitive dependencies. Defaults to false." 94 | end 95 | 96 | validate do 97 | full_id = self[:id] 98 | groupid = self[:groupid] 99 | artifactid = self[:artifactid] 100 | version = self[:version] 101 | packaging = self[:packaging] 102 | classifier = self[:classifier] 103 | transitive = self[:transitive] 104 | 105 | using_detailed_parameters = !groupid.nil? || !artifactid.nil? || !version.nil? || !packaging.nil? || !classifier.nil? 106 | if (!full_id.nil? && using_detailed_parameters) 107 | self.fail "Can't define id and other groupid, artifactid, version, packaging, classifier parameters at the same time" 108 | end 109 | if (using_detailed_parameters && (groupid.nil? || artifactid.nil? || version.nil?)) 110 | self.fail "Missing required groupid, artifactid or version parameters" 111 | end 112 | 113 | end 114 | 115 | end 116 | -------------------------------------------------------------------------------- /manifests/buildr.pp: -------------------------------------------------------------------------------- 1 | # Copyright 2011 MaestroDev 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Class: buildr 16 | # 17 | # A puppet recipe to install Apache Buildr 18 | # 19 | # 20 | class maven::buildr( $java_home ) { 21 | 22 | # Can't use this as gem install buildr requires JAVA_HOME environment variable 23 | # package { "buildr": 24 | # ensure => "1.4.6", 25 | # provider => gem 26 | # } 27 | 28 | # a workaround using exec 29 | 30 | notice('Installing buildr') 31 | 32 | package { 'rake': 33 | ensure => '0.8.7', 34 | provider => gem, 35 | } 36 | maven::install_gem { 'buildr' : 37 | version => '1.4.5', 38 | require => Package['rake'], 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /manifests/configure.pp: -------------------------------------------------------------------------------- 1 | # Licensed under the Apache License, Version 2.0 (the "License"); 2 | # you may not use this file except in compliance with the License. 3 | # You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | # This is a helper class that wraps the settings and environment defines. 14 | # 15 | # settings = { 16 | # 'uselessName' => { 17 | # #see maven::settings for details 18 | # } 19 | # } 20 | # 21 | # environments = { 22 | # 'uselessName' => { 23 | # #see maven::environment for details 24 | # } 25 | # } 26 | class maven::configure( 27 | $settings = undef, 28 | $environments = undef, 29 | ) { 30 | 31 | if $settings != undef { 32 | create_resources('maven::settings', $settings) 33 | } 34 | 35 | if $environments != undef { 36 | create_resources('maven::environment', $environments) 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /manifests/environment.pp: -------------------------------------------------------------------------------- 1 | # Copyright 2011 MaestroDev 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Define: maven::environment 16 | # 17 | # A puppet recipe to set the contents of the .mavenrc file 18 | # 19 | define maven::environment( $user, $group = 'root', $home = undef, $maven_opts = '', $maven_path_additions = '', $mavenrc_additions = '' ) { 20 | 21 | if $home == undef { 22 | $home_real = $user ? { 23 | 'root' => '/root', 24 | default => "/home/${user}" 25 | } 26 | } 27 | else { 28 | $home_real = $home 29 | } 30 | 31 | file { "${home_real}/.mavenrc": 32 | mode => '0600', 33 | owner => $user, 34 | group => $group, 35 | content => template('maven/mavenrc.erb'), 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /manifests/init.pp: -------------------------------------------------------------------------------- 1 | # Copyright 2011 MaestroDev 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Class: maven 16 | # 17 | # A puppet recipe for Apache Maven, to download artifacts 18 | # from a Maven repository 19 | # 20 | # It uses Apache Maven command line to download the artifacts. 21 | # 22 | # Parameters: 23 | # - $version: 24 | # Maven version. 25 | # 26 | # Requires: 27 | # Java package installed. 28 | # 29 | # Sample Usage: 30 | # class {'maven': 31 | # version => "3.2.5", 32 | # } 33 | # 34 | class maven() { 35 | 36 | debug('Installing Maven module pre-requisites') 37 | 38 | class { 'maven::maven': } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /manifests/install_gem.pp: -------------------------------------------------------------------------------- 1 | # Copyright 2011 MaestroDev 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | define maven::install_gem ($version = '') { 16 | exec { "gem ${name} ${version}": 17 | path => '/usr/bin:/opt/ruby/bin', 18 | environment => "JAVA_HOME=${maven::java_home}", 19 | command => "gem install ${name} --version ${version} --no-rdoc --no-ri", 20 | unless => "gem query -i --name-matches ${name} --version ${version}", 21 | logoutput => true, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /manifests/maven.pp: -------------------------------------------------------------------------------- 1 | # Copyright 2011 MaestroDev 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Class: maven::maven 16 | # 17 | # A puppet recipe to install Apache Maven 18 | # 19 | # Parameters: 20 | # - $version: 21 | # Maven version. 22 | # 23 | # Requires: 24 | # Java package installed. 25 | # 26 | # Sample Usage: 27 | # class {'maven::maven': 28 | # version => "3.2.5", 29 | # } 30 | # 31 | class maven::maven( 32 | $version = '3.2.5', 33 | $repo = { 34 | #url => 'http://repo1.maven.org/maven2', 35 | #username => '', 36 | #password => '', 37 | } ) { 38 | 39 | $archive = "/tmp/apache-maven-${version}-bin.tar.gz" 40 | 41 | # prior to puppet 3.5.0, defined() couldn't test if a variable was defined. 42 | # strict_variables wasn't added until 3.5.0, so this should be fine. 43 | if $::puppetversion and versioncmp($::puppetversion, '3.5.0') < 0 { 44 | $xfacts = { 45 | 'maven_version' => $::maven_version, 46 | } 47 | } else { 48 | # Strict variables facts lookup compatibility 49 | $xfacts = { 50 | 'maven_version' => defined('$maven_version') ? { 51 | true => $::maven_version, 52 | default => undef, 53 | } 54 | } 55 | } 56 | 57 | # Avoid redownloading when tmp tar.gz is deleted 58 | if $xfacts['maven_version'] != $version { 59 | 60 | # we could use puppet-stdlib function !empty(repo) but avoiding adding a new 61 | # dependency for now 62 | if "x${repo['url']}x" != 'xx' { 63 | wget::authfetch { 'fetch-maven': 64 | source => "${repo['url']}/org/apache/maven/apache-maven/${version}/apache-maven-${version}-bin.tar.gz", 65 | destination => $archive, 66 | user => $repo['username'], 67 | password => $repo['password'], 68 | before => Exec['maven-untar'], 69 | } 70 | } else { 71 | wget::fetch { 'fetch-maven': 72 | source => "http://archive.apache.org/dist/maven/maven-3/${version}/binaries/apache-maven-${version}-bin.tar.gz", 73 | destination => $archive, 74 | before => Exec['maven-untar'], 75 | } 76 | } 77 | exec { 'maven-untar': 78 | command => "tar xf /tmp/apache-maven-${version}-bin.tar.gz", 79 | cwd => '/opt', 80 | creates => "/opt/apache-maven-${version}", 81 | path => ['/bin','/usr/bin'], 82 | } 83 | 84 | file { '/usr/bin/mvn': 85 | ensure => link, 86 | target => "/opt/apache-maven-${version}/bin/mvn", 87 | require => Exec['maven-untar'], 88 | } -> 89 | file { '/usr/local/bin/mvn': 90 | ensure => absent, 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /manifests/settings.pp: -------------------------------------------------------------------------------- 1 | # Copyright 2011 MaestroDev 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Define: maven::settings 16 | # 17 | # A puppet recipe to set the contents of the settings.xml file 18 | # 19 | # 20 | # servers => [{ 21 | # id, 22 | # username, 23 | # password 24 | # },...] 25 | # 26 | # mirrors => [{ 27 | # id, 28 | # url, 29 | # mirrorOf 30 | # },...] 31 | # 32 | # properties => { 33 | # key=>value 34 | # } 35 | # 36 | # repos => [{ 37 | # id, 38 | # name, #optional 39 | # url, 40 | # releases => { 41 | # key=>value 42 | # }, 43 | # snapshots=> { 44 | # key=>value 45 | # } 46 | # },...] 47 | # 48 | # # Provided for backwards compatibility 49 | # # A shortcut to essentially add the central repo to the above list of repos. 50 | # default_repo_config => { 51 | # url, 52 | # releases => { 53 | # key=>value 54 | # }, 55 | # snapshots=> { 56 | # key=>value 57 | # } 58 | # } 59 | # 60 | # proxies => [{ 61 | # active, #optional, default to true 62 | # protocol, #optional, defaults to http 63 | # host, 64 | # port, 65 | # username,#optional 66 | # password, #optional 67 | # nonProxyHosts #optional 68 | # },...] 69 | # 70 | # profiles => { 71 | # 'profile1' => { # <- this becomes the profile id 72 | # 'activation' => { 73 | # 'activeByDefault' => false, 74 | # 'jdk' => '1.5', 75 | # 'os' => { 76 | # 'name' => 'Windows XP', 77 | # 'family' => 'Windows', 78 | # 'arch' => 'x86', 79 | # 'version' => '5.1.2600' 80 | # }, 81 | # 'property' => { 82 | # 'name' => 'mavenVersion', 83 | # 'value' => '2.0.3' 84 | # }, 85 | # 'file' => { 86 | # 'exists' => '${basedir}/file2.properties', 87 | # 'missing' => '${basedir}/file1.properties' 88 | # } 89 | # }, 90 | # 'repositories' => { 91 | # 'codehausSnapshots' => { # <- this becomes the repository id 92 | # 'name' => 'Codehaus Snapshots', 93 | # 'releases' => { 94 | # 'enabled' => false, 95 | # 'updatePolicy' => 'always', 96 | # 'checksumPolicy' => 'warn' 97 | # }, 98 | # 'snapshots' => { 99 | # 'enabled' => true, 100 | # 'updatePolicy' => 'never', 101 | # 'checksumPolicy' => 'fail' 102 | # }, 103 | # 'url' => 'http://snapshots.maven.codehaus.org/maven2', 104 | # 'layout' => 'default' 105 | # } 106 | # }, 107 | # 'pluginRepositories' => { 108 | # 'codehausSnapshots' => { # <- this becomes the repository id 109 | # 'name' => 'Codehaus Snapshots', 110 | # 'releases' => { 111 | # 'enabled' => false, 112 | # 'update_policy' => 'always', 113 | # 'checksum_policy' => 'warn' 114 | # }, 115 | # 'snapshots' => { 116 | # 'enabled' => true, 117 | # 'updatePolicy' => 'never', 118 | # 'checksumPolicy' => 'fail' 119 | # }, 120 | # 'url' => 'http://snapshots.maven.codehaus.org/maven2', 121 | # 'layout' => 'default' 122 | # } 123 | # }, 124 | # 'properties' => { 125 | # 'key1' => 'value1' 126 | # } 127 | # } 128 | # 129 | # activeProfiles => [ 'profile1', 'profile2', ...] 130 | # 131 | define maven::settings($home = undef, $user = 'root', $group = 'root', 132 | $servers = [], $mirrors = [], $default_repo_config = undef, $repos = [], 133 | $properties = {}, $local_repo = '', $dir_mask = '700', $file_mask = '600', 134 | $proxies = [], $profiles = {}, $active_profiles = [], $master_password = undef) { 135 | 136 | if $home == undef { 137 | $home_real = $user ? { 138 | 'root' => '/root', 139 | default => "/home/${user}" 140 | } 141 | } 142 | else { 143 | $home_real = $home 144 | } 145 | 146 | file { "${home_real}/.m2": 147 | ensure => directory, 148 | owner => $user, 149 | group => $group, 150 | mode => $dir_mask, 151 | } -> 152 | file { "${home_real}/.m2/settings.xml": 153 | owner => $user, 154 | group => $group, 155 | mode => $file_mask, 156 | content => template('maven/settings.xml.erb'), 157 | } 158 | 159 | unless $master_password == undef { 160 | file { "${home_real}/.m2/settings-security.xml": 161 | owner => $user, 162 | group => $group, 163 | mode => $file_mask, 164 | content => template('maven/settings-security.xml.erb'), 165 | require => File["${home_real}/.m2"], 166 | } 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "maestrodev-maven", 3 | "version": "1.4.1", 4 | "author": "maestrodev", 5 | "summary": "Apache Maven module for Puppet", 6 | "license": "Apache License, Version 2.0", 7 | "source": "http://github.com/maestrodev/puppet-maven", 8 | "project_page": "http://github.com/maestrodev/puppet-maven", 9 | "issues_url": "https://github.com/maestrodev/puppet-maven/issues", 10 | "description": "A Puppet module to download artifacts from Maven repositories", 11 | "dependencies": [ 12 | { 13 | "name": "maestrodev/wget", 14 | "version_requirement": ">=1.0.0" 15 | } 16 | ], 17 | "operatingsystem_support": [ 18 | { 19 | "operatingsystem": "RedHat", 20 | "operatingsystemrelease": [ 21 | "4", 22 | "5", 23 | "6", 24 | "7" 25 | ] 26 | }, 27 | { 28 | "operatingsystem": "CentOS", 29 | "operatingsystemrelease": [ 30 | "4", 31 | "5", 32 | "6", 33 | "7" 34 | ] 35 | }, 36 | { 37 | "operatingsystem": "OracleLinux", 38 | "operatingsystemrelease": [ 39 | "4", 40 | "5", 41 | "6", 42 | "7" 43 | ] 44 | }, 45 | { 46 | "operatingsystem": "Scientific", 47 | "operatingsystemrelease": [ 48 | "4", 49 | "5", 50 | "6", 51 | "7" 52 | ] 53 | }, 54 | { 55 | "operatingsystem": "SLES", 56 | "operatingsystemrelease": [ 57 | "11 SP1" 58 | ] 59 | }, 60 | { 61 | "operatingsystem": "Debian", 62 | "operatingsystemrelease": [ 63 | "6", 64 | "7" 65 | ] 66 | }, 67 | { 68 | "operatingsystem": "Ubuntu", 69 | "operatingsystemrelease": [ 70 | "10.04", 71 | "12.04" 72 | ] 73 | }, 74 | { 75 | "operatingsystem": "Solaris", 76 | "operatingsystemrelease": [ 77 | "10", 78 | "11" 79 | ] 80 | }, 81 | { 82 | "operatingsystem": "Windows", 83 | "operatingsystemrelease": [ 84 | "Server 2003", 85 | "Server 2003 R2", 86 | "Server 2008", 87 | "Server 2008 R2", 88 | "Server 2012", 89 | "Server 2012 R2", 90 | "7", 91 | "8" 92 | ] 93 | }, 94 | { 95 | "operatingsystem": "AIX", 96 | "operatingsystemrelease": [ 97 | "5.3", 98 | "6.1", 99 | "7.1" 100 | ] 101 | }, 102 | { 103 | "operatingsystem": "Darwin", 104 | "operatingsystemrelease": [ 105 | "10", 106 | "11", 107 | "12", 108 | "13" 109 | ] 110 | } 111 | ], 112 | "requirements": [ 113 | { 114 | "name": "pe", 115 | "version_requirement": ">=3.2.0" 116 | }, 117 | { 118 | "name": "puppet", 119 | "version_requirement": ">=3.0.0" 120 | } 121 | ] 122 | } 123 | -------------------------------------------------------------------------------- /spec/acceptance/maven_system_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper_acceptance' 2 | 3 | describe 'maven type' do 4 | before(:all) do 5 | pp = %Q( 6 | class { 'java': } 7 | class { 'maven::maven': } 8 | ) 9 | apply_manifest(pp, :catch_failures => true) 10 | end 11 | 12 | it 'should be idempotent' do 13 | pp = %Q( 14 | maven { '/tmp/maven-core-3.0.5.jar': 15 | id => 'org.apache.maven:maven-core:3.0.5:jar', 16 | repos => [ 17 | 'central::default::http://repo1.maven.apache.org/maven2', 18 | 'http://mirrors.ibiblio.org/pub/mirrors/maven2'], 19 | } 20 | ) 21 | apply_manifest(pp, :catch_failures => true) 22 | apply_manifest(pp, :catch_changes => true) 23 | end 24 | 25 | context 'when changing the version' do 26 | describe file('/tmp/maven-core.jar') do 27 | 28 | before do 29 | apply_manifest(%Q( 30 | maven { '/tmp/maven-core.jar': 31 | id => 'org.apache.maven:maven-core:3.0.5:jar', 32 | } 33 | ), :catch_failures => true) 34 | on(hosts, 'rm -rf /tmp/touch-me-if-updated') 35 | end 36 | 37 | it 'should not update to the same version' do 38 | should match_md5checksum 'ee0bd82403231f5e268fd85044027221' 39 | apply_manifest(%Q( 40 | maven { '/tmp/maven-core.jar': 41 | id => 'org.apache.maven:maven-core:3.0.5:jar', 42 | } 43 | exec { 'touch-me': 44 | command => '/bin/touch /tmp/touch-me-if-updated', 45 | refreshonly => true, 46 | subscribe => Maven['/tmp/maven-core.jar'] 47 | } 48 | ), :catch_failures => true) 49 | should match_md5checksum 'ee0bd82403231f5e268fd85044027221' 50 | file('/tmp/touch-me-if-snapshot-updated').should_not be_file 51 | end 52 | 53 | it 'should update to a different version' do 54 | should match_md5checksum 'ee0bd82403231f5e268fd85044027221' 55 | apply_manifest(%Q( 56 | maven { '/tmp/maven-core.jar': 57 | ensure => 'latest', 58 | id => 'org.apache.maven:maven-core:3.1.0:jar', 59 | } 60 | ), :catch_failures => true) 61 | should match_md5checksum '67c1cd4fa81ff39826826f46e88f420f' 62 | end 63 | end 64 | end 65 | 66 | context 'an existing SNAPSHOT artifact' do 67 | let(:version) { '0.0.1-SNAPSHOT' } 68 | let(:ensure_param) { 'present' } 69 | let(:repo_version) { 1 } 70 | 71 | before(:each) do 72 | apply_manifest(%Q( 73 | package { 'httpd': ensure => 'present' } -> 74 | service { 'httpd': ensure => 'running' } 75 | ), :catch_failures => true) 76 | 77 | hosts.each do |host| 78 | on(host, 'rm -rf /var/www/html/repo /root/.m2/repository/org/foo /tmp/touch-me-if-snapshot-updated') 79 | fixture_rcp(host, "acceptance/maven/repo-#{repo_version}", '/var/www/html/repo') 80 | end 81 | 82 | apply_manifest(%Q( 83 | maven { '/tmp/hello.jar': 84 | ensure => '#{ensure_param}', 85 | id => 'org.foo:hello:#{version}', 86 | repos => 'http://localhost/repo' 87 | } 88 | 89 | exec { 'touch-me': 90 | command => '/bin/touch /tmp/touch-me-if-snapshot-updated', 91 | refreshonly => true, 92 | subscribe => Maven['/tmp/hello.jar'] 93 | } 94 | ), :catch_failures => true) 95 | end 96 | 97 | describe file('/tmp/hello.jar') do 98 | it 'should have have the original version' do 99 | should match_md5checksum '807f2fca0e279dbe48f695983141fd5c' 100 | end 101 | end 102 | 103 | context 'with the same SNAPSHOT in the repote repo' do 104 | let(:repo_version) { 1 } 105 | 106 | around(:each) do |example| 107 | #make sure the v1 verson of the SNAPSHOT is on the filesystem 108 | hosts.each do |host| 109 | fixture_rcp(host, 'acceptance/maven/repo-1/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.jar', '/tmp/hello.jar') 110 | end 111 | example.run 112 | end 113 | 114 | context 'and ensure => latest' do 115 | let(:ensure_param) { 'latest' } 116 | 117 | describe file('/tmp/hello.jar') do 118 | it 'should have the same snapshot' do 119 | should match_md5checksum '807f2fca0e279dbe48f695983141fd5c' 120 | end 121 | end 122 | 123 | describe file('/tmp/touch-me-if-snapshot-updated') do 124 | it 'should not have been created by subscribe relationship' do 125 | should_not be_file 126 | end 127 | end 128 | end 129 | end 130 | 131 | context 'with an updated SNAPSHOT in the remote repo' do 132 | let(:repo_version) { 2 } 133 | 134 | around(:each) do |example| 135 | #make sure the v1 verson of the SNAPSHOT is on the filesystem 136 | hosts.each do |host| 137 | fixture_rcp(host, 'acceptance/maven/repo-1/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.jar', '/tmp/hello.jar') 138 | end 139 | example.run 140 | end 141 | 142 | context 'and ensure => present' do 143 | let(:ensure_param) { 'present' } 144 | 145 | describe file('/tmp/hello.jar') do 146 | it 'should still have have the original version' do 147 | should match_md5checksum '807f2fca0e279dbe48f695983141fd5c' 148 | end 149 | end 150 | 151 | describe file('/tmp/touch-me-if-snapshot-updated') do 152 | it 'should not have been created by subscribe relationship' do 153 | should_not be_file 154 | end 155 | end 156 | end 157 | 158 | context 'and ensure => latest' do 159 | let(:ensure_param) { 'latest' } 160 | 161 | describe file('/tmp/hello.jar') do 162 | it 'should have the updated snapshot' do 163 | should match_md5checksum '67fce35a2a7227a53cdcde06b86d33bf' 164 | end 165 | end 166 | 167 | describe file('/tmp/touch-me-if-snapshot-updated') do 168 | it 'should have been created by subscribe relationship' do 169 | should be_file 170 | end 171 | end 172 | end 173 | end 174 | end 175 | end 176 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/centos-65-x64-docker.yml: -------------------------------------------------------------------------------- 1 | # This file is managed centrally by modulesync 2 | # https://github.com/maestrodev/puppet-modulesync 3 | 4 | HOSTS: 5 | centos-65-x64: 6 | roles: 7 | - master 8 | platform: el-6-x86_64 9 | image: devopsil/puppet:3.5.1 10 | # ip: localhost 11 | hypervisor : docker 12 | docker_image_commands: 13 | - yum -y install tar 14 | - useradd vagrant 15 | - "sed -ri 's/^#?PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config" 16 | - "sed -ri 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config" 17 | docker_cmd: 18 | - 'sh' 19 | - '-c' 20 | - 'service sshd start; tail -f /dev/null' 21 | CONFIG: 22 | log_level: debug 23 | type: git 24 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/centos-65-x64.yml: -------------------------------------------------------------------------------- 1 | # This file is managed centrally by modulesync 2 | # https://github.com/maestrodev/puppet-modulesync 3 | 4 | HOSTS: 5 | centos-65-x64: 6 | roles: 7 | - master 8 | platform: el-6-x86_64 9 | box : centos-65-x64-virtualbox-nocm 10 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box 11 | hypervisor : vagrant 12 | CONFIG: 13 | log_level: debug 14 | type: git 15 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/debian-73-x64.yml: -------------------------------------------------------------------------------- 1 | # This file is managed centrally by modulesync 2 | # https://github.com/maestrodev/puppet-modulesync 3 | 4 | HOSTS: 5 | debian-73-x64: 6 | roles: 7 | - master 8 | platform: debian-7-amd64 9 | box : debian-73-x64-virtualbox-nocm 10 | box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box 11 | hypervisor : vagrant 12 | CONFIG: 13 | log_level: debug 14 | type: git 15 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/default.yml: -------------------------------------------------------------------------------- 1 | # This file is managed centrally by modulesync 2 | # https://github.com/maestrodev/puppet-modulesync 3 | 4 | HOSTS: 5 | centos-65-x64: 6 | roles: 7 | - master 8 | platform: el-6-x86_64 9 | image: devopsil/puppet:3.5.1 10 | # ip: localhost 11 | hypervisor : docker 12 | docker_image_commands: 13 | - yum -y install tar 14 | - useradd vagrant 15 | - "sed -ri 's/^#?PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config" 16 | - "sed -ri 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config" 17 | docker_cmd: 18 | - 'sh' 19 | - '-c' 20 | - 'service sshd start; tail -f /dev/null' 21 | CONFIG: 22 | log_level: debug 23 | type: git 24 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/ubuntu-server-1404-x64-docker.yml: -------------------------------------------------------------------------------- 1 | # This file is managed centrally by modulesync 2 | # https://github.com/maestrodev/puppet-modulesync 3 | 4 | HOSTS: 5 | ubuntu-server-1404-x64: 6 | roles: 7 | - master 8 | platform: ubuntu-14.04-amd64 9 | image: ubuntu:trusty 10 | # ip: localhost 11 | hypervisor : docker 12 | docker_image_commands: 13 | - useradd vagrant 14 | - "sed -ri 's/^#?PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config" 15 | - "sed -ri 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config" 16 | docker_cmd: 17 | - 'sh' 18 | - '-c' 19 | - 'service ssh start; tail -f /dev/null' 20 | CONFIG: 21 | log_level: debug 22 | type: git 23 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/ubuntu-server-1404-x64.yml: -------------------------------------------------------------------------------- 1 | # This file is managed centrally by modulesync 2 | # https://github.com/maestrodev/puppet-modulesync 3 | 4 | HOSTS: 5 | ubuntu-server-1404-x64: 6 | roles: 7 | - master 8 | platform: ubuntu-14.04-amd64 9 | box : ubuntu-server-1404-x64-cloud 10 | box_url : https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box 11 | hypervisor : vagrant 12 | CONFIG: 13 | log_level: debug 14 | type: git 15 | -------------------------------------------------------------------------------- /spec/classes/maven_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'maven::maven' do 4 | let(:title) { 'maven' } 5 | let(:facts) {{ :http_proxy => '', :maven_version => '', :puppetversion => Puppet.version }} 6 | 7 | context "when downloading maven", :compile do 8 | it do should contain_wget__fetch('fetch-maven').with( 9 | 'source' => 'http://archive.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz', 10 | 'user' => nil, 11 | 'password' => nil 12 | ) end 13 | it { should contain_exec('maven-untar') } 14 | end 15 | 16 | context "when downloading maven from another repo", :compile do 17 | let(:params) { { :repo => { 18 | 'url' => 'http://repo1.maven.org/maven2', 19 | 'username' => 'u', 20 | 'password' => 'p' 21 | } 22 | } } 23 | 24 | it 'should fetch maven with username and password' do 25 | should contain_wget__authfetch('fetch-maven').with( 26 | 'source' => 'http://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.2.5/apache-maven-3.2.5-bin.tar.gz', 27 | 'user' => 'u', 28 | 'password' => 'p') 29 | end 30 | end 31 | 32 | context "when maven was already installed" do 33 | 34 | context "in the same version", :compile do 35 | let(:facts) {super().merge({ :maven_version => '3.2.5' })} 36 | it { should_not contain_wget__fetch('fetch-maven') } 37 | it { should_not contain_exec('maven-untar') } 38 | end 39 | 40 | context "in a different version", :compile do 41 | let(:facts) {super().merge({ :maven_version => '3.0.4' })} 42 | it { should contain_wget__fetch('fetch-maven') } 43 | it { should contain_exec('maven-untar') } 44 | end 45 | end 46 | 47 | end 48 | -------------------------------------------------------------------------------- /spec/defines/active-profiles-settings.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | profile1 6 | profile2 7 | 8 | 9 | -------------------------------------------------------------------------------- /spec/defines/complete-settings.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | /var/cache/maven/repository 5 | 6 | 7 | 8 | maestro-mirror 9 | http://localhost:8082/archiva/repository/all/ 10 | external:* 11 | 12 | 13 | 14 | 15 | 16 | maestro-mirror 17 | mirror_user 18 | mirror_pass 19 | 20 | 21 | maestro-deploy 22 | deploy_user 23 | deploy_pass 24 | 25 | 26 | maestro-deploy-ssh 27 | deploy_ssh_user 28 | ~/.ssh/id_rsa 29 | 30 | 31 | 32 | 33 | 34 | default-repo 35 | 36 | true 37 | 38 | 39 | 40 | central 41 | http://localhost:8082/archiva/repository/all/ 42 | 43 | fail 44 | true 45 | 46 | 47 | fail 48 | 49 | 50 | 51 | 52 | 53 | central 54 | http://localhost:8082/archiva/repository/all/ 55 | 56 | fail 57 | true 58 | 59 | 60 | fail 61 | 62 | 63 | 64 | 65 | 66 | properties 67 | 68 | true 69 | 70 | 71 | localhost 72 | http://localhost:8083/sonar 73 | org.postgresql.Driver 74 | password 75 | jdbc:postgresql://localhost:5432/sonar 76 | user 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /spec/defines/default-mavenrc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maestrodev/puppet-maven/b53fdc35e708f50fcf98254653fdeb3b20830276/spec/defines/default-mavenrc -------------------------------------------------------------------------------- /spec/defines/default-repo-only-url-settings.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | default-repo 7 | 8 | true 9 | 10 | 11 | 12 | central 13 | http://localhost:8082/archiva/repository/all/ 14 | 15 | 16 | 17 | 18 | central 19 | http://localhost:8082/archiva/repository/all/ 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /spec/defines/default-repo-settings.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | default-repo 7 | 8 | true 9 | 10 | 11 | 12 | central 13 | http://localhost:8082/archiva/repository/all/ 14 | 15 | fail 16 | true 17 | 18 | 19 | fail 20 | 21 | 22 | 23 | 24 | 25 | central 26 | http://localhost:8082/archiva/repository/all/ 27 | 28 | fail 29 | true 30 | 31 | 32 | fail 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /spec/defines/default-settings-security.xml: -------------------------------------------------------------------------------- 1 | 2 | {7837*#&$*i878283mkjdksf=} 3 | -------------------------------------------------------------------------------- /spec/defines/default-settings.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /spec/defines/environment_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe "maven::environment" do 4 | let(:title) { 'environment' } 5 | let(:params) { { 6 | :user => "u", 7 | } } 8 | 9 | let(:expected_filename) { '/home/u/.mavenrc' } 10 | 11 | context "default params", :compile do 12 | it { should contain_file(expected_filename).with_owner('u') } 13 | it { should contain_file(expected_filename).with_content(read_file("default-mavenrc")) } 14 | end 15 | 16 | context "provide options for mavenrc", :compile do 17 | let(:params) {{ 18 | :user => "u", 19 | :maven_opts => "-Xmx256m", 20 | :maven_path_additions => "/usr/local/bin", 21 | :mavenrc_additions => "echo Hello World!" 22 | }} 23 | 24 | it { should contain_file(expected_filename).with_content(read_file("populated-mavenrc")) } 25 | end 26 | 27 | end 28 | 29 | def read_file(filename) 30 | IO.read(File.expand_path(filename, File.dirname(__FILE__))) 31 | end 32 | -------------------------------------------------------------------------------- /spec/defines/local-repo-settings.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | /var/cache/maven/repository 5 | 6 | 7 | -------------------------------------------------------------------------------- /spec/defines/mirror-servers-settings.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | maestro-mirror 7 | http://localhost:8082/archiva/repository/all/ 8 | external:* 9 | 10 | 11 | 12 | 13 | 14 | maestro-mirror 15 | mirror_user 16 | mirror_pass 17 | 18 | 19 | maestro-deploy 20 | deploy_user 21 | deploy_pass 22 | 23 | 24 | maestro-deploy-ssh 25 | deploy_ssh_user 26 | ~/.ssh/id_rsa 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /spec/defines/populated-mavenrc: -------------------------------------------------------------------------------- 1 | export MAVEN_OPTS="-Xmx256m $MAVEN_OPTS" 2 | export PATH="/usr/local/bin:$PATH" 3 | echo Hello World! 4 | -------------------------------------------------------------------------------- /spec/defines/profiles-settings.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | profile1 7 | 8 | false 9 | 1.5 10 | 11 | Windows XP 12 | Windows 13 | x86 14 | 5.1.2600 15 | 16 | 17 | mavenVersion 18 | 2.0.3 19 | 20 | 21 | ${basedir}/file2.properties 22 | ${basedir}/file1.properties 23 | 24 | 25 | 26 | 27 | repo1 28 | First Repo 29 | 30 | warn 31 | true 32 | always 33 | 34 | 35 | fail 36 | false 37 | never 38 | 39 | http://repo1.example.com/maven2 40 | default 41 | 42 | 43 | 44 | 45 | repo2 46 | Second Repo 47 | 48 | fail 49 | false 50 | never 51 | 52 | 53 | warn 54 | true 55 | always 56 | 57 | http://repo2.example.com/maven2 58 | legacy 59 | 60 | 61 | 62 | value1 63 | 64 | 65 | 66 | minimal_profile 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /spec/defines/properties-settings.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | properties 7 | 8 | true 9 | 10 | 11 | localhost 12 | http://localhost:8083/sonar 13 | org.postgresql.Driver 14 | password 15 | jdbc:postgresql://localhost:5432/sonar 16 | user 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /spec/defines/proxy-settings.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | true 7 | http 8 | http://proxy.acme.com 9 | myuser 10 | mypassword 11 | www.acme.com 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /spec/defines/settings_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | shared_examples :maven_settings do |expected_file| 4 | 5 | def read_file(filename) 6 | IO.read(File.expand_path(filename, File.dirname(__FILE__))) 7 | end 8 | 9 | it { should contain_file(expected_filename).with_owner('u') } 10 | 11 | it 'should generate valid settings.xml' do 12 | should contain_file(expected_filename).with_content(read_file(expected_file)) 13 | end 14 | end 15 | 16 | shared_examples :maven_settings_security do |expected_file| 17 | 18 | def read_file(filename) 19 | IO.read(File.expand_path(filename, File.dirname(__FILE__))) 20 | end 21 | 22 | it { should contain_file(expected_filename).with_owner('u') } 23 | 24 | it 'should generate valid settings.xml' do 25 | should contain_file(expected_filename).with_content(read_file(expected_file)) 26 | end 27 | end 28 | 29 | describe "maven::settings" do 30 | let(:title) { 'settings' } 31 | let(:params) { { 32 | :user => "u", 33 | :home => "/home/u", 34 | } } 35 | 36 | let(:url) { 'http://localhost:8082/archiva/repository/all/' } 37 | let(:mirror) {{ 38 | 'id' => 'maestro-mirror', 39 | 'url' => url, 40 | 'mirrorof' => 'external:*', 41 | }} 42 | let(:mirror_server) {{ 43 | 'id' => 'maestro-mirror', 44 | 'username' => 'mirror_user', 45 | 'password' => 'mirror_pass', 46 | }} 47 | let(:deploy_server) {{ 48 | 'id' => 'maestro-deploy', 49 | 'username' => 'deploy_user', 50 | 'password' => 'deploy_pass', 51 | }} 52 | let(:deploy_server_with_ssh) {{ 53 | 'id' => 'maestro-deploy-ssh', 54 | 'username' => 'deploy_ssh_user', 55 | 'privateKey' => '~/.ssh/id_rsa', 56 | }} 57 | let(:default_repo_config) {{ 58 | 'url' => url, 59 | 'snapshots' => { 60 | 'enabled' => 'true', 61 | 'checksumPolicy' => 'fail', 62 | }, 63 | 'releases' => { 64 | 'checksumPolicy' => 'fail', 65 | } 66 | }} 67 | let(:profiles) {{ 68 | 'profile1' => { 69 | 'activation' => { 70 | 'activeByDefault' => false, 71 | 'jdk' => '1.5', 72 | 'os' => { 73 | 'name' => 'Windows XP', 74 | 'family' => 'Windows', 75 | 'arch' => 'x86', 76 | 'version' => '5.1.2600' 77 | }, 78 | 'property' => { 79 | 'name' => 'mavenVersion', 80 | 'value' => '2.0.3' 81 | }, 82 | 'file' => { 83 | 'exists' => '${basedir}/file2.properties', 84 | 'missing' => '${basedir}/file1.properties' 85 | } 86 | }, 87 | 'repositories' => { 88 | 'repo1' => { 89 | 'name' => 'First Repo', 90 | 'releases' => { 91 | 'enabled' => true, 92 | 'updatePolicy' => 'always', 93 | 'checksumPolicy' => 'warn' 94 | }, 95 | 'snapshots' => { 96 | 'enabled' => false, 97 | 'updatePolicy' => 'never', 98 | 'checksumPolicy' => 'fail' 99 | }, 100 | 'url' => 'http://repo1.example.com/maven2', 101 | 'layout' => 'default' 102 | } 103 | }, 104 | 'pluginRepositories' => { 105 | 'repo2' => { 106 | 'name' => 'Second Repo', 107 | 'releases' => { 108 | 'enabled' => false, 109 | 'updatePolicy' => 'never', 110 | 'checksumPolicy' => 'fail' 111 | }, 112 | 'snapshots' => { 113 | 'enabled' => true, 114 | 'updatePolicy' => 'always', 115 | 'checksumPolicy' => 'warn' 116 | }, 117 | 'url' => 'http://repo2.example.com/maven2', 118 | 'layout' => 'legacy' 119 | } 120 | }, 121 | 'properties' => { 122 | 'key1' => 'value1' 123 | } 124 | }, 125 | 'minimal_profile' => { 126 | } 127 | }} 128 | let(:active_profiles) { 129 | ['profile1', 'profile2'] 130 | } 131 | let(:proxy) {{ 132 | 'active' => true, 133 | 'protocol' => 'http', 134 | 'host' => 'http://proxy.acme.com', 135 | 'username' => 'myuser', 136 | 'password' => 'mypassword', 137 | 'nonProxyHosts' => 'www.acme.com', 138 | }} 139 | let(:properties) {{ 140 | 'sonar.jdbc.url' => 'jdbc:postgresql://localhost:5432/sonar', 141 | 'sonar.jdbc.driverClassName' => 'org.postgresql.Driver', 142 | 'sonar.jdbc.username' => 'user', 143 | 'sonar.jdbc.password' => 'password', 144 | 'sonar.host.url' => 'http://localhost:8083/sonar', 145 | 'selenium.host' => 'localhost', 146 | }} 147 | 148 | let(:expected_filename) { '/home/u/.m2/settings.xml' } 149 | 150 | context "default", :compile do 151 | it_behaves_like :maven_settings, "default-settings.xml" 152 | end 153 | 154 | context "with empty default_repo_config", :compile do 155 | let(:params) {{ 156 | :user => "u", 157 | :home => "/home/u", 158 | :default_repo_config => {}, 159 | }} 160 | 161 | it_behaves_like :maven_settings, "default-settings.xml" 162 | end 163 | 164 | context "with mirrors and settings", :compile do 165 | let(:params) {{ 166 | :user => "u", 167 | :home => "/home/u", 168 | :mirrors => [mirror], 169 | :servers => [mirror_server, deploy_server, deploy_server_with_ssh] 170 | }} 171 | 172 | it_behaves_like :maven_settings, "mirror-servers-settings.xml" 173 | end 174 | 175 | context "with default repository", :compile do 176 | let(:params) {{ 177 | :user => "u", 178 | :home => "/home/u", 179 | :default_repo_config => default_repo_config, 180 | }} 181 | 182 | it_behaves_like :maven_settings, "default-repo-settings.xml" 183 | end 184 | 185 | context "with default repository configuration url only", :compile do 186 | let(:params) {{ 187 | :user => "u", 188 | :home => "/home/u", 189 | :default_repo_config => { 190 | 'url' => default_repo_config['url'], 191 | }, 192 | }} 193 | 194 | it_behaves_like :maven_settings, "default-repo-only-url-settings.xml" 195 | end 196 | 197 | context "with properties", :compile do 198 | let(:params) {{ 199 | :user => "u", 200 | :home => "/home/u", 201 | :properties => properties, 202 | }} 203 | 204 | it_behaves_like :maven_settings, "properties-settings.xml" 205 | end 206 | 207 | context "with local repository", :compile do 208 | let(:params) {{ 209 | :user => "u", 210 | :home => "/home/u", 211 | :local_repo => "/var/cache/maven/repository", 212 | }} 213 | 214 | it_behaves_like :maven_settings, "local-repo-settings.xml" 215 | end 216 | 217 | context "with proxy", :compile do 218 | let(:params) {{ 219 | :user => "u", 220 | :home => "/home/u", 221 | :proxies => [proxy], 222 | }} 223 | 224 | it_behaves_like :maven_settings, "proxy-settings.xml" 225 | end 226 | 227 | context "with the lot", :compile do 228 | let(:params) {{ 229 | :user => "u", 230 | :home => "/home/u", 231 | :mirrors => [mirror], 232 | :servers => [mirror_server, deploy_server, deploy_server_with_ssh], 233 | :default_repo_config => default_repo_config, 234 | :properties => properties, 235 | :local_repo => "/var/cache/maven/repository", 236 | }} 237 | 238 | it_behaves_like :maven_settings, "complete-settings.xml" 239 | end 240 | 241 | context "with profiles", :compile do 242 | let(:params) {{ 243 | :user => "u", 244 | :home => "/home/u", 245 | :profiles => profiles 246 | }} 247 | 248 | it_behaves_like :maven_settings, "profiles-settings.xml" 249 | end 250 | 251 | context "with active_profiles", :compile do 252 | let(:params) {{ 253 | :user => "u", 254 | :home => "/home/u", 255 | :active_profiles => active_profiles 256 | }} 257 | 258 | it_behaves_like :maven_settings, "active-profiles-settings.xml" 259 | end 260 | 261 | context "with master password", :compile do 262 | let(:expected_filename) { '/home/u/.m2/settings-security.xml' } 263 | let(:params) {{ 264 | :user => "u", 265 | :home => "/home/u", 266 | :master_password => '{7837*#&$*i878283mkjdksf=}' 267 | }} 268 | 269 | it_behaves_like :maven_settings_security, "default-settings-security.xml" 270 | end 271 | end 272 | -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-1/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maestrodev/puppet-maven/b53fdc35e708f50fcf98254653fdeb3b20830276/spec/fixtures/acceptance/maven/repo-1/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.jar -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-1/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.jar.md5: -------------------------------------------------------------------------------- 1 | 807f2fca0e279dbe48f695983141fd5c -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-1/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.jar.sha1: -------------------------------------------------------------------------------- 1 | 9abe1fe1048c09c797a41e1c6e1220d266a67649 -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-1/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.pom: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.foo 5 | hello 6 | 0.0.1-SNAPSHOT 7 | 8 | 9 | 10 | releases 11 | http://p2-qanex101.ad.prodcc.net/content/repositories/releases/ 12 | 13 | 14 | false 15 | snapshots 16 | http://p2-qanex101.ad.prodcc.net/content/repositories/snapshots/ 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-1/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.pom.md5: -------------------------------------------------------------------------------- 1 | 6aad426b37bfcc332f431dea11986f56 2 | -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-1/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.pom.sha1: -------------------------------------------------------------------------------- 1 | 11a65f3820b9c405d7b7c07b4628d768daffa58e 2 | -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-1/org/foo/hello/0.0.1-SNAPSHOT/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.foo 4 | hello 5 | 0.0.1-SNAPSHOT 6 | 7 | 8 | 20131008.014634 9 | 1 10 | 11 | 20131008025235 12 | 13 | 14 | jar 15 | 0.0.1-20131008.014634-1 16 | 20131008025235 17 | 18 | 19 | pom 20 | 0.0.1-20131008.014634-1 21 | 20131008025235 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-1/org/foo/hello/0.0.1-SNAPSHOT/maven-metadata.xml.md5: -------------------------------------------------------------------------------- 1 | 8d802d21680c5b3ef27d7bbf2f46fea0 2 | -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-1/org/foo/hello/0.0.1-SNAPSHOT/maven-metadata.xml.sha1: -------------------------------------------------------------------------------- 1 | d2a689273ae74e15ebd6834805da39c1906dbf8d 2 | -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-1/org/foo/hello/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.foo 4 | hello 5 | 6 | 7 | 0.0.1-SNAPSHOT 8 | 9 | 20131008025236 10 | 11 | 12 | -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-1/org/foo/hello/maven-metadata.xml.md5: -------------------------------------------------------------------------------- 1 | 18f0fe5ecb5c26cc534e7087db9a10b8 -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-1/org/foo/hello/maven-metadata.xml.sha1: -------------------------------------------------------------------------------- 1 | 48db5cef43f828bd207aecf13e071e59902aeece -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maestrodev/puppet-maven/b53fdc35e708f50fcf98254653fdeb3b20830276/spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.jar -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.jar.md5: -------------------------------------------------------------------------------- 1 | 807f2fca0e279dbe48f695983141fd5c -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.jar.sha1: -------------------------------------------------------------------------------- 1 | 9abe1fe1048c09c797a41e1c6e1220d266a67649 -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.pom: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.foo 5 | hello 6 | 0.0.1-SNAPSHOT 7 | 8 | 9 | 10 | releases 11 | http://p2-qanex101.ad.prodcc.net/content/repositories/releases/ 12 | 13 | 14 | false 15 | snapshots 16 | http://p2-qanex101.ad.prodcc.net/content/repositories/snapshots/ 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.pom.md5: -------------------------------------------------------------------------------- 1 | 6aad426b37bfcc332f431dea11986f56 -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.014634-1.pom.sha1: -------------------------------------------------------------------------------- 1 | 11a65f3820b9c405d7b7c07b4628d768daffa58e -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.025235-2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maestrodev/puppet-maven/b53fdc35e708f50fcf98254653fdeb3b20830276/spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.025235-2.jar -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.025235-2.jar.md5: -------------------------------------------------------------------------------- 1 | 67fce35a2a7227a53cdcde06b86d33bf -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.025235-2.jar.sha1: -------------------------------------------------------------------------------- 1 | 10ce6f327d30938bed82fec7d5ddfa4146e349e3 -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.025235-2.pom: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.foo 5 | hello 6 | 0.0.1-SNAPSHOT 7 | 8 | 9 | 10 | releases 11 | http://p2-qanex101.ad.prodcc.net/content/repositories/releases/ 12 | 13 | 14 | false 15 | snapshots 16 | http://p2-qanex101.ad.prodcc.net/content/repositories/snapshots/ 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.025235-2.pom.md5: -------------------------------------------------------------------------------- 1 | 6aad426b37bfcc332f431dea11986f56 -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/hello-0.0.1-20131008.025235-2.pom.sha1: -------------------------------------------------------------------------------- 1 | 11a65f3820b9c405d7b7c07b4628d768daffa58e -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.foo 4 | hello 5 | 0.0.1-SNAPSHOT 6 | 7 | 8 | 20131008.025235 9 | 2 10 | 11 | 20131008025235 12 | 13 | 14 | jar 15 | 0.0.1-20131008.025235-2 16 | 20131008025235 17 | 18 | 19 | pom 20 | 0.0.1-20131008.025235-2 21 | 20131008025235 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/maven-metadata.xml.md5: -------------------------------------------------------------------------------- 1 | b879c7466ad00a5fadec890e1c4d84b2 -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/0.0.1-SNAPSHOT/maven-metadata.xml.sha1: -------------------------------------------------------------------------------- 1 | c5fcfc2d01ef7b35e2751c78f9b47952a73fda84 -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.foo 4 | hello 5 | 6 | 7 | 0.0.1-SNAPSHOT 8 | 9 | 20131008025236 10 | 11 | 12 | -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/maven-metadata.xml.md5: -------------------------------------------------------------------------------- 1 | 18f0fe5ecb5c26cc534e7087db9a10b8 -------------------------------------------------------------------------------- /spec/fixtures/acceptance/maven/repo-2/org/foo/hello/maven-metadata.xml.sha1: -------------------------------------------------------------------------------- 1 | 48db5cef43f828bd207aecf13e071e59902aeece -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file is managed centrally by modulesync 2 | # https://github.com/maestrodev/puppet-modulesync 3 | 4 | require 'puppetlabs_spec_helper/module_spec_helper' 5 | 6 | RSpec.configure do |c| 7 | c.treat_symbols_as_metadata_keys_with_true_values = true 8 | c.mock_with :rspec 9 | 10 | c.before(:each) do 11 | Puppet::Util::Log.level = :warning 12 | Puppet::Util::Log.newdestination(:console) 13 | end 14 | 15 | c.default_facts = { 16 | :operatingsystem => 'CentOS', 17 | :operatingsystemrelease => '6.6', 18 | :kernel => 'Linux', 19 | :osfamily => 'RedHat', 20 | :architecture => 'x86_64' 21 | } 22 | 23 | c.before do 24 | # avoid "Only root can execute commands as other users" 25 | Puppet.features.stubs(:root? => true) 26 | end 27 | end 28 | 29 | shared_examples :compile, :compile => true do 30 | it { should compile.with_all_deps } 31 | end 32 | 33 | -------------------------------------------------------------------------------- /spec/spec_helper_acceptance.rb: -------------------------------------------------------------------------------- 1 | require 'puppet' 2 | require 'beaker-rspec/spec_helper' 3 | require 'beaker-rspec/helpers/serverspec' 4 | 5 | # overriding puppet installation for the RedHat family distros due to 6 | # puppet breakage >= 3.5 7 | def install_puppet(host) 8 | host['platform'] =~ /(fedora|el)-(\d+)/ 9 | if host['platform'] =~ /(fedora|el)-(\d+)/ 10 | safeversion = '3.4.2' 11 | platform = $1 12 | relver = $2 13 | on host, "rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-#{platform}-#{relver}.noarch.rpm" 14 | on host, "yum install -y puppet-#{safeversion}" 15 | else 16 | super() 17 | end 18 | end 19 | 20 | RSpec.configure do |c| 21 | 22 | # Project root 23 | proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) 24 | 25 | c.before(:each) do 26 | Puppet::Util::Log.level = :warning 27 | Puppet::Util::Log.newdestination(:console) 28 | end 29 | 30 | c.before :suite do 31 | hosts.each do |host| 32 | unless (ENV['RS_PROVISION'] == 'no' || ENV['BEAKER_provision'] == 'no') 33 | begin 34 | on host, 'puppet --version' 35 | rescue 36 | if host.is_pe? 37 | install_pe 38 | else 39 | install_puppet(host) 40 | end 41 | end 42 | end 43 | 44 | # Install module and dependencies 45 | puppet_module_install(:source => proj_root, :module_name => File.basename(proj_root).gsub(/^puppet-/,'')) 46 | 47 | on host, puppet('module', 'install', 'maestrodev-wget', '--version=1.0.0'), { :acceptable_exit_codes => [0,1] } if fact('osfamily') == 'RedHat' 48 | on host, puppet('module', 'install', 'puppetlabs-java', '--version=1.0.1'), { :acceptable_exit_codes => [0,1] } 49 | end 50 | end 51 | 52 | end 53 | -------------------------------------------------------------------------------- /spec/unit/puppet/provider/maven/mvn_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | require 'rspec/its' 3 | require 'tempfile' 4 | 5 | type = Puppet::Type.type(:maven) 6 | provider_class = type.provider(:mvn) 7 | 8 | describe provider_class do 9 | subject { provider_class.new type.new({ path: path }.merge params) } 10 | let(:params) { { } } 11 | 12 | context 'if the file exists' do 13 | let(:path) do 14 | file = Tempfile.new 'tmp' 15 | file_path = file.path 16 | file.close! 17 | File.open(file_path, 'w') do |f| 18 | f.write 'blah' 19 | end 20 | 21 | file_path 22 | end 23 | 24 | its(:exists?) { should be true } 25 | 26 | example do 27 | expect { subject.ensure = :absent }.to raise_error NotImplementedError 28 | end 29 | end 30 | 31 | describe '#ensure' do 32 | subject { provider_class.new(type.new({ path: path, ensure: ensure_param }.merge params)).ensure } 33 | 34 | context 'with an existing file' do 35 | let(:path) do 36 | file = Tempfile.new 'tmp' 37 | file_path = file.path 38 | file.close! 39 | File.open(file_path, 'w') do |f| 40 | f.write 'foo' 41 | end 42 | 43 | file_path 44 | end 45 | 46 | context 'and ensure => latest' do 47 | let(:ensure_param) { 'latest' } 48 | 49 | context 'and a SNAPSHOT version' do 50 | let(:params) { { id: 'groupid:artifactid:1.2.3-SNAPSHOT' } } 51 | 52 | context 'and an updated snapshot' do 53 | before do 54 | expect(Puppet::Util::Execution).to receive(:execute) { |command| 55 | command[0] =~ /-Ddest=([^\s]+)/ 56 | File.open($1, 'w') do |f| 57 | f.write 'bar' 58 | end 59 | }.and_return OpenStruct.new({exitstatus: 0}) 60 | end 61 | 62 | it { should equal :present } 63 | end 64 | 65 | context 'and a current snapshot' do 66 | before do 67 | expect(Puppet::Util::Execution).to receive(:execute) { |command| 68 | command[0] =~ /-Ddest=([^\s]+)/ 69 | File.open($1, 'w') do |f| 70 | f.write 'foo' 71 | end 72 | }.and_return OpenStruct.new({exitstatus: 0}) 73 | end 74 | 75 | it { should equal :latest } 76 | end 77 | end 78 | end 79 | 80 | context 'and ensure => present' do 81 | let(:ensure_param) { 'present' } 82 | 83 | context 'and a SNAPSHOT version' do 84 | let(:params) { { id: 'groupid:artifactid:1.2.3-SNAPSHOT' } } 85 | 86 | context 'and an updated snapshot' do 87 | it { should equal :present } 88 | end 89 | 90 | context 'and a current snapshot' do 91 | it { should equal :present } 92 | end 93 | end 94 | end 95 | end 96 | end 97 | 98 | context 'if the file does not exist' do 99 | let(:path) do 100 | file = Tempfile.new 'tmp' 101 | file_path = file.path 102 | file.close! 103 | file_path 104 | end 105 | 106 | its(:exists?) { should be false } 107 | end 108 | 109 | describe '#ensure=' do 110 | subject { provider_class.new(type.new({ path: path }.merge params)).ensure = ensure_param } 111 | 112 | context 'with ensure => latest' do 113 | let(:ensure_param) { :latest } 114 | let(:exitstatus) { OpenStruct.new exitstatus: 0 } 115 | 116 | context 'given a valid path' do 117 | let(:path) { '/tmp/blah.txt' } 118 | 119 | describe 'maven command line' do 120 | subject do 121 | command_line = nil 122 | 123 | expect(Puppet::Util::Execution).to receive(:execute) { |command| 124 | command_line = command[0] 125 | }.and_return exitstatus 126 | provider_class.new(type.new({ path: path }.merge params)).ensure = ensure_param 127 | command_line 128 | end 129 | 130 | it 'should not pass -U' do 131 | should_not match /-U/ 132 | end 133 | 134 | context 'given a SNAPSHOT version' do 135 | let(:params) do 136 | { 137 | groupid: 'groupid_test', 138 | artifactid: 'artifactid_test', 139 | version: '1.2.3-SNAPSHOT' 140 | } 141 | end 142 | 143 | it 'should pass -U' do 144 | should match /-U/ 145 | end 146 | end 147 | 148 | context 'given a precise version' do 149 | let(:params) do 150 | { 151 | groupid: 'groupid_test', 152 | artifactid: 'artifactid_test', 153 | version: '1.2.3' 154 | } 155 | end 156 | 157 | it 'should not pass -U' do 158 | should_not match /-U/ 159 | end 160 | end 161 | 162 | context 'given the version LATEST' do 163 | let(:params) do 164 | { 165 | groupid: 'groupid_test', 166 | artifactid: 'artifactid_test', 167 | version: 'LATEST' 168 | } 169 | end 170 | 171 | it 'should pass -U' do 172 | should match /-U/ 173 | end 174 | end 175 | 176 | context 'given the version RELEASE' do 177 | let(:params) do 178 | { 179 | groupid: 'groupid_test', 180 | artifactid: 'artifactid_test', 181 | version: 'LATEST' 182 | } 183 | end 184 | 185 | it 'should pass -U' do 186 | should match /-U/ 187 | end 188 | end 189 | end 190 | end 191 | end 192 | 193 | context 'with ensure => present' do 194 | let(:ensure_param) { :present } 195 | let(:exitstatus) { OpenStruct.new exitstatus: 0 } 196 | 197 | context 'given a valid path' do 198 | let(:path) { '/tmp/blah.txt' } 199 | 200 | context 'when mvn returns 1' do 201 | #let(:exitstatus) { OpenStruct.new exitstatus: 1 } 202 | 203 | context 'with no output' do 204 | let(:output) { Puppet::Util::Execution::ProcessOutput.new '', 1 } 205 | example do 206 | expect(Puppet::Util::Execution).to receive(:execute) 207 | .and_return output 208 | expect { subject }.to raise_error Puppet::Error, /^mvn returned 1: Is Maven installed\?/ 209 | end 210 | end 211 | 212 | context 'with output "busted!"' do 213 | let(:output) { Puppet::Util::Execution::ProcessOutput. new 'busted!', 1 } 214 | 215 | example do 216 | expect(Puppet::Util::Execution).to receive(:execute) 217 | .and_return output 218 | expect { subject }.to raise_error Puppet::Error, /returned 1: busted\!/ 219 | end 220 | end 221 | end 222 | 223 | it 'should default to current user' do 224 | expect(Puppet::Util::Execution).to receive(:execute) 225 | .with(anything(), hash_including(:uid => nil)) 226 | .and_return exitstatus 227 | 228 | subject 229 | end 230 | 231 | it 'should default to current user group' do 232 | expect(Puppet::Util::Execution).to receive(:execute) 233 | .with(anything(), hash_including(:gid => nil)) 234 | .and_return exitstatus 235 | 236 | subject 237 | end 238 | 239 | it 'should use no timeout' do 240 | expect(Timeout).to receive(:timeout).with(0).and_call_original 241 | expect(Puppet::Util::Execution).to receive(:execute).and_return exitstatus 242 | 243 | subject 244 | end 245 | 246 | describe 'maven command line' do 247 | subject do 248 | command_line = nil 249 | 250 | expect(Puppet::Util::Execution).to receive(:execute) { |command| 251 | command_line = command[0] 252 | }.and_return exitstatus 253 | provider_class.new(type.new({ path: path }.merge params)).ensure = :present 254 | command_line 255 | end 256 | 257 | it 'should include path' do 258 | should match /-Ddest=\/tmp\/blah\.txt/ 259 | end 260 | 261 | it 'should default to plugin version 2.4' do 262 | should match /mvn -B org\.apache\.maven\.plugins:maven-dependency-plugin:2\.4:get/ 263 | end 264 | 265 | it 'should pass no repoId' do 266 | should_not match /-DrepoId=/ 267 | end 268 | 269 | it 'should pass no artifact coordinates' do 270 | should_not match /-Dartifact=/ 271 | end 272 | 273 | it 'should pass no packaging' do 274 | should_not match /-Dpackaging=/ 275 | end 276 | 277 | it 'should pass no classifier' do 278 | should_not match /-Dclassifier=/ 279 | end 280 | 281 | it 'should not pass -U' do 282 | should_not match /-U/ 283 | end 284 | 285 | context 'given a SNAPSHOT version' do 286 | let(:params) do 287 | { 288 | groupid: 'groupid_test', 289 | artifactid: 'artifactid_test', 290 | version: '1.2.3-SNAPSHOT' 291 | } 292 | end 293 | 294 | it 'should not pass -U' do 295 | should_not match /-U/ 296 | end 297 | end 298 | 299 | context 'and a groupId, artifactId, and version' do 300 | let(:params) do 301 | { 302 | groupid: 'groupid_test', 303 | artifactid: 'artifactid_test', 304 | version: 'version_test' 305 | } 306 | end 307 | 308 | it 'should pass the provided artifactid' do 309 | should match /-DartifactId=artifactid_test/ 310 | end 311 | 312 | it 'should pass the provided groupid' do 313 | should match /-DgroupId=groupid_test/ 314 | end 315 | 316 | it 'should pass the provided version' do 317 | should match /-Dversion=version_test/ 318 | end 319 | 320 | it 'should pass no packaging' do 321 | should_not match /-Dpackaging=/ 322 | end 323 | 324 | it 'should pass no classifier' do 325 | should_not match /-Dclassifier=/ 326 | end 327 | 328 | context 'and a classifier' do 329 | let(:params) do 330 | { 331 | groupid: 'groupid_test', 332 | artifactid: 'artifactid_test', 333 | version: 'version_test', 334 | classifier: 'classifier_test' 335 | } 336 | end 337 | 338 | it 'should pass the provided classifier' do 339 | should match /-Dclassifier=classifier_test/ 340 | end 341 | end 342 | 343 | context 'and a packaging' do 344 | let(:params) do 345 | { 346 | groupid: 'groupid_test', 347 | artifactid: 'artifactid_test', 348 | version: 'version_test', 349 | packaging: 'packaging_test' 350 | } 351 | end 352 | 353 | it 'should pass the provided packaging' do 354 | should match /-Dpackaging=packaging_test/ 355 | end 356 | end 357 | end 358 | 359 | context 'and an id' do 360 | let(:params) { { id: 'artifact_test' } } 361 | 362 | it 'should pass the provided id' do 363 | should match /-Dartifact=artifact_test/ 364 | end 365 | 366 | it 'should pass no groupid' do 367 | should_not match /-DgroupId=/ 368 | end 369 | 370 | it 'should pass no artifactid' do 371 | should_not match /-DartifactId=/ 372 | end 373 | 374 | it 'should pass no version' do 375 | should_not match /-Dversion=/ 376 | end 377 | 378 | it 'should not pass -U' do 379 | should_not match /-U/ 380 | end 381 | end 382 | 383 | context 'and an id with a SNAPSHOT version' do 384 | let(:params) { { id: 'groupid:artifactid:1.2.3-SNAPSHOT' } } 385 | 386 | it 'should not pass -U' do 387 | should_not match /-U/ 388 | end 389 | end 390 | 391 | context 'and a repoid' do 392 | let(:params) { { repoid: 'repoid_test' } } 393 | 394 | it 'should pass the provided repoid' do 395 | should match /-DrepoId=repoid_test/ 396 | end 397 | end 398 | 399 | context 'and an explicit pluginversion' do 400 | let(:params) { { pluginversion: '2.5' } } 401 | 402 | it 'should pass provided version' do 403 | should match /mvn -B org\.apache\.maven\.plugins:maven-dependency-plugin:2\.5:get/ 404 | end 405 | end 406 | 407 | context 'and an empty repo list' do 408 | let(:params) { { repos: [] } } 409 | 410 | it 'should default to http://repos1.maven.apache.org/maven2' do 411 | should match /-DremoteRepositories=http:\/\/repo1.maven.apache.org\/maven2/ 412 | end 413 | end 414 | 415 | context 'and a repo list' do 416 | let(:params) { { repos: ['http://repo1.com', 'http://repo2.com'] } } 417 | 418 | it 'should pass the provided repos' do 419 | should match /-DremoteRepositories=http:\/\/repo1.com,http:\/\/repo2.com/ 420 | end 421 | end 422 | 423 | context 'and a repo string' do 424 | let(:params) { { repos: 'http://repo1.com' } } 425 | 426 | it 'should pass the provided repos' do 427 | should match /-DremoteRepositories=http:\/\/repo1.com/ 428 | end 429 | end 430 | end 431 | 432 | 433 | context 'given a timeout' do 434 | let(:params) { { timeout: 1 } } 435 | 436 | it 'should use the given timeout' do 437 | expect(Timeout).to receive(:timeout).with(1).and_call_original 438 | expect(Puppet::Util::Execution).to receive(:execute).and_return exitstatus 439 | 440 | subject 441 | end 442 | 443 | it 'should timeout if mvn takes too long' do 444 | expect(Puppet::Util::Execution).to receive(:execute) do 445 | sleep 2 446 | end 447 | 448 | expect { subject }.to raise_error Puppet::Error, /^Command timed out/ 449 | end 450 | end 451 | 452 | context 'given a user' do 453 | let(:params) { { user: 'user_test' } } 454 | 455 | it 'should use the given user' do 456 | expect(Puppet::Util::Execution).to receive(:execute) 457 | .with(anything(), hash_including(:uid => 'user_test')) 458 | .and_return exitstatus 459 | 460 | subject 461 | end 462 | end 463 | 464 | context 'given a group' do 465 | let(:params) { { group: 'group_test' } } 466 | 467 | it 'should use the given group' do 468 | expect(Puppet::Util::Execution).to receive(:execute) 469 | .with(anything(), hash_including(:gid => 'group_test')) 470 | .and_return exitstatus 471 | 472 | subject 473 | end 474 | end 475 | end 476 | end 477 | end 478 | end 479 | -------------------------------------------------------------------------------- /spec/unit/puppet/type/maven_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | type = Puppet::Type.type(:maven) 4 | 5 | describe type do 6 | subject { type.new({name: name}.merge params)} 7 | let(:params) { { } } 8 | 9 | let(:name) { 'test' } 10 | 11 | context 'given a valid id' do 12 | let(:params) { {id: 'test_id'}.merge extra_params } 13 | let(:extra_params) { { } } 14 | 15 | example do 16 | expect { subject }.to_not raise_error 17 | end 18 | 19 | context 'and an artifactid' do 20 | let(:extra_params) { { artifactid: 'artifactid_test' } } 21 | 22 | example do 23 | expect { subject }.to raise_error Puppet::Error, /Can't define id and other groupid, artifactid, version, packaging, classifier parameters at the same time/ 24 | end 25 | end 26 | 27 | context 'and a groupid' do 28 | let(:extra_params) { { groupid: 'groupid_test' } } 29 | 30 | example do 31 | expect { subject }.to raise_error Puppet::Error, /Can't define id and other groupid, artifactid, version, packaging, classifier parameters at the same time/ 32 | end 33 | end 34 | 35 | context 'and a version' do 36 | let(:extra_params) { { version: 'version_test' } } 37 | 38 | example do 39 | expect { subject }.to raise_error Puppet::Error, /Can't define id and other groupid, artifactid, version, packaging, classifier parameters at the same time/ 40 | end 41 | end 42 | 43 | context 'and a packaging' do 44 | let(:extra_params) { { packaging: 'packaging_test' } } 45 | 46 | example do 47 | expect { subject }.to raise_error Puppet::Error, /Can't define id and other groupid, artifactid, version, packaging, classifier parameters at the same time/ 48 | end 49 | end 50 | 51 | context 'and a packaging' do 52 | let(:extra_params) { { classifier: 'classifier_test' } } 53 | 54 | example do 55 | expect { subject }.to raise_error Puppet::Error, /Can't define id and other groupid, artifactid, version, packaging, classifier parameters at the same time/ 56 | end 57 | end 58 | end 59 | 60 | context 'given only an artifactid' do 61 | let(:params) { { artifactid: 'artifactid_test' } } 62 | example do 63 | expect { subject }.to raise_error Puppet::Error, /Missing required groupid, artifactid or version parameters/ 64 | end 65 | end 66 | 67 | context 'given only a groupid' do 68 | let(:params) { { groupid: 'groupid_test' } } 69 | example do 70 | expect { subject }.to raise_error Puppet::Error, /Missing required groupid, artifactid or version parameters/ 71 | end 72 | end 73 | 74 | context 'given only a version' do 75 | let(:params) { { version: 'version_test' } } 76 | example do 77 | expect { subject }.to raise_error Puppet::Error, /Missing required groupid, artifactid or version parameters/ 78 | end 79 | end 80 | 81 | context 'given an artifactid, groupid, and version' do 82 | let(:params) do 83 | { 84 | artifactid: 'artifactid_test', 85 | groupid: 'groupid_test', 86 | version: 'version_test', 87 | } 88 | end 89 | 90 | example do 91 | expect { subject }.to_not raise_error 92 | end 93 | 94 | end 95 | end 96 | 97 | 98 | -------------------------------------------------------------------------------- /templates/mavenrc.erb: -------------------------------------------------------------------------------- 1 | <% if has_variable?("maven_opts") and @maven_opts != "" -%> 2 | export MAVEN_OPTS="<%= @maven_opts %> $MAVEN_OPTS" 3 | <% end -%> 4 | <% if has_variable?("maven_path_additions") && @maven_path_additions != "" -%> 5 | export PATH="<%= @maven_path_additions %>:$PATH" 6 | <% end -%> 7 | <% if has_variable?("mavenrc_additions") && @mavenrc_additions != "" -%> 8 | <%= @mavenrc_additions %> 9 | <% end -%> 10 | -------------------------------------------------------------------------------- /templates/settings-security.xml.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= @master_password %> 3 | -------------------------------------------------------------------------------- /templates/settings.xml.erb: -------------------------------------------------------------------------------- 1 | 3 | 4 | <%- unless @local_repo.empty? -%> 5 | <%= @local_repo %> 6 | 7 | <%- end -%> 8 | <% unless @mirrors.empty? -%> 9 | 10 | <% @mirrors.each do |mirror| -%> 11 | 12 | <%= mirror['id'] %> 13 | <%= mirror['url'] %> 14 | <%= mirror['mirrorof'] %> 15 | 16 | <% end -%> 17 | 18 | 19 | <% end -%> 20 | <% unless @servers.empty? -%> 21 | 22 | <% @servers.each do |server| -%> 23 | 24 | <%= server['id'] %> 25 | <% ['username', 'password','privateKey' ] -%> 26 | <%= server['username'] %> 27 | <% unless server['password'].nil? -%> 28 | <%= server['password'] %> 29 | <% end -%> 30 | <% unless server['privateKey'].nil? -%> 31 | <%= server['privateKey'] %> 32 | <% end -%> 33 | 34 | <% end -%> 35 | 36 | 37 | <% end -%> 38 | <% unless @proxies.empty? -%> 39 | 40 | <% @proxies.each do |proxy| -%> 41 | 42 | <% if(proxy['active'].nil?) -%> 43 | true 44 | <% else -%> 45 | <%= proxy['active'] %> 46 | <% end -%> 47 | <% if(proxy['protocol'].nil?) -%> 48 | http 49 | <% else -%> 50 | <%= proxy['protocol'] %> 51 | <% end -%> 52 | <%= proxy['host'] %> 53 | <% unless(proxy['port'].nil?) -%> 54 | <%= proxy['port'] %> 55 | <% end -%> 56 | <% unless(proxy['username'].nil?) -%> 57 | <%= proxy['username'] %> 58 | <% end -%> 59 | <% unless(proxy['password'].nil?) -%> 60 | <%= proxy['password'] %> 61 | <% end -%> 62 | <% unless(proxy['nonProxyHosts'].nil?) -%> 63 | <%= proxy['nonProxyHosts'] %> 64 | <% end -%> 65 | 66 | <% end -%> 67 | 68 | 69 | <% end -%> 70 | <% 71 | unless @default_repo_config.nil? or @default_repo_config.empty? 72 | @default_repo_config['id'] = 'central' 73 | @repos << @default_repo_config 74 | end 75 | -%> 76 | <% unless @repos.empty? and @properties.empty? and @profiles.empty? -%> 77 | 78 | <%- unless @repos.empty? -%> 79 | 80 | default-repo 81 | 82 | true 83 | 84 | 85 | <% @repos.each do |repo| -%> 86 | 87 | <%= repo['id'] %> 88 | <% unless repo['name'].nil? -%> 89 | <%= repo['name'] %> 90 | <% end -%> 91 | <%= repo['url'] %> 92 | <%- unless repo['snapshots'].nil? or repo['snapshots'].empty? -%> 93 | 94 | <%- repo['snapshots'].sort.each { |key,value| -%> 95 | <%= "<#{key}>#{value}" %> 96 | <%- } -%> 97 | 98 | <%- end -%> 99 | <%- unless repo['releases'].nil? or repo['releases'].empty? -%> 100 | 101 | <%- repo['releases'].sort.each { |key,value| -%> 102 | <%= "<#{key}>#{value}" %> 103 | <%- } -%> 104 | 105 | <%- end -%> 106 | 107 | <% end -%> 108 | 109 | 110 | <% @repos.each do |repo| -%> 111 | 112 | <%= repo['id'] %> 113 | <% unless repo['name'].nil? -%> 114 | <%= repo['name'] %> 115 | <% end -%> 116 | <%= repo['url'] %> 117 | <%- unless repo['snapshots'].nil? or repo['snapshots'].empty? -%> 118 | 119 | <%- repo['snapshots'].sort.each { |key,value| -%> 120 | <%= "<#{key}>#{value}" %> 121 | <%- } -%> 122 | 123 | <%- end -%> 124 | <%- unless repo['releases'].nil? or repo['releases'].empty? -%> 125 | 126 | <%- repo['releases'].sort.each { |key,value| -%> 127 | <%= "<#{key}>#{value}" %> 128 | <%- } -%> 129 | 130 | <%- end -%> 131 | 132 | <% end -%> 133 | 134 | 135 | <%- end -%> 136 | <%- unless @properties.empty? -%> 137 | 138 | properties 139 | 140 | true 141 | 142 | 143 | <%- @properties.sort.each { |key, value| -%> 144 | <%= "<#{key}>#{value}" %> 145 | <%- } -%> 146 | 147 | 148 | <%- end -%> 149 | <%- unless @profiles.empty? -%> 150 | <%- @profiles.each do |profile_id, profile| -%> 151 | 152 | <%= profile_id %> 153 | <%- unless (profile['activation']||[]).empty?; activation = profile['activation'] -%> 154 | 155 | <%- if activation.key?('activeByDefault') -%> 156 | <%= activation['activeByDefault'] %> 157 | <%- end -%> 158 | <%- if activation.key?('jdk') -%> 159 | <%= activation['jdk'] %> 160 | <%- end -%> 161 | <%- unless (activation['os']||[]).empty?; os = activation['os'] -%> 162 | 163 | <%- if os.key?('name') -%> 164 | <%= os['name'] %> 165 | <%- end -%> 166 | <%- if os.key?('family') -%> 167 | <%= os['family'] %> 168 | <%- end -%> 169 | <%- if os.key?('arch') -%> 170 | <%= os['arch'] %> 171 | <%- end -%> 172 | <%- if os.key?('version') -%> 173 | <%= os['version'] %> 174 | <%- end -%> 175 | 176 | <%- end -%> 177 | <%- unless (activation['property']||[]).empty?; property = activation['property'] -%> 178 | 179 | <%= property['name'] %> 180 | <%= property['value'] %> 181 | 182 | <%- end -%> 183 | <%- unless (activation['file']||[]).empty?; file = activation['file'] -%> 184 | 185 | <%- if file.key?('exists') -%> 186 | <%= file['exists'] %> 187 | <%- end -%> 188 | <%- if file.key?('missing') -%> 189 | <%= file['missing'] %> 190 | <%- end -%> 191 | 192 | <%- end -%> 193 | 194 | <%- end -%> 195 | <%- unless (profile['repositories']||[]).empty?; repositories = profile['repositories'] -%> 196 | 197 | <%- repositories.each do |repo_id, repo| -%> 198 | 199 | <%= repo_id %> 200 | <%- if repo['name'] -%> 201 | <%= repo['name'] %> 202 | <%- end -%> 203 | <%- unless (repo['releases']||[]).empty? -%> 204 | 205 | <%- repo['releases'].sort.each { |key,value| -%> 206 | <%= "<#{key}>#{value}" %> 207 | <%- } -%> 208 | 209 | <%- end -%> 210 | <%- unless (repo['snapshots']||[]).empty? -%> 211 | 212 | <%- repo['snapshots'].sort.each { |key,value| -%> 213 | <%= "<#{key}>#{value}" %> 214 | <%- } -%> 215 | 216 | <%- end -%> 217 | <%- if repo['url'] -%> 218 | <%= repo['url'] %> 219 | <%- end -%> 220 | <%- if repo['layout'] -%> 221 | <%= repo['layout'] %> 222 | <%- end -%> 223 | 224 | <%- end -%> 225 | 226 | <%- end -%> 227 | <%- unless (profile['pluginRepositories']||[]).empty?; repositories = profile['pluginRepositories'] -%> 228 | 229 | <%- repositories.each do |repo_id, repo| -%> 230 | 231 | <%= repo_id %> 232 | <%- if repo['name'] -%> 233 | <%= repo['name'] %> 234 | <%- end -%> 235 | <%- unless (repo['releases']||[]).empty? -%> 236 | 237 | <%- repo['releases'].sort.each { |key,value| -%> 238 | <%= "<#{key}>#{value}" %> 239 | <%- } -%> 240 | 241 | <%- end -%> 242 | <%- unless (repo['snapshots']||[]).empty? -%> 243 | 244 | <%- repo['snapshots'].sort.each { |key,value| -%> 245 | <%= "<#{key}>#{value}" %> 246 | <%- } -%> 247 | 248 | <%- end -%> 249 | <%- if repo['url'] -%> 250 | <%= repo['url'] %> 251 | <%- end -%> 252 | <%- if repo['layout'] -%> 253 | <%= repo['layout'] %> 254 | <%- end -%> 255 | 256 | <%- end -%> 257 | 258 | <%- end -%> 259 | <%- unless (profile['properties']||[]).empty? -%> 260 | 261 | <%- profile['properties'].sort.each { |key, value| -%> 262 | <%= "<#{key}>#{value}" %> 263 | <%- } -%> 264 | 265 | <%- end -%> 266 | 267 | <%- end -%> 268 | <%- end -%> 269 | 270 | 271 | <% end -%> 272 | <%- unless (@active_profiles||[]).empty? -%> 273 | 274 | <%- @active_profiles.sort.each { |profile| -%> 275 | <%= profile %> 276 | <%- } -%> 277 | 278 | <%- end -%> 279 | 280 | -------------------------------------------------------------------------------- /tests/init.pp: -------------------------------------------------------------------------------- 1 | class { 'java': } 2 | 3 | $repo1 = { 4 | id => 'myrepo', 5 | username => 'myuser', 6 | password => 'mypassword', 7 | url => 'http://repo.acme.com', 8 | } 9 | 10 | class { 'maven::maven': } -> 11 | 12 | #maven::settings { 'root' : 13 | # servers => [$repo1], 14 | #} 15 | 16 | maven { '/tmp/maven-core-3.0.5.jar': 17 | id => 'org.apache.maven:maven-core:3.0.5:jar', 18 | repos => ['central::default::http://repo1.maven.apache.org/maven2','http://mirrors.ibiblio.org/pub/mirrors/maven2'], 19 | } -> 20 | maven { '/tmp/maven-core-3.0.5-sources.jar': 21 | groupid => 'org.apache.maven', 22 | artifactid => 'maven-core', 23 | version => '3.0.5', 24 | classifier => 'sources', 25 | } 26 | --------------------------------------------------------------------------------