Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #229 from gildegoma/maven-3.1.0

Install Maven 3.1.0
  • Loading branch information...
commit 6179e7e6547b8e9e4cf20e914cf3d1ac7bf150d6 2 parents 0462f13 + fabb5c2
@michaelklishin michaelklishin authored
Showing with 845 additions and 208 deletions.
  1. +60 −0 ci_environment/maven/CHANGELOG.md
  2. +29 −0 ci_environment/maven/CONTRIBUTING
  3. +201 −0 ci_environment/maven/LICENSE
  4. +117 −0 ci_environment/maven/README.md
  5. +25 −0 ci_environment/maven/TESTING.md
  6. +36 −0 ci_environment/maven/attributes/default.rb
  7. +54 −0 ci_environment/maven/files/default/tests/minitest/test_test.rb
  8. +36 −0 ci_environment/maven/metadata.json
  9. +16 −0 ci_environment/maven/metadata.rb
  10. +87 −0 ci_environment/maven/providers/default.rb
  11. +39 −0 ci_environment/maven/recipes/default.rb
  12. +82 −0 ci_environment/maven/recipes/test.rb
  13. +43 −0 ci_environment/maven/resources/default.rb
  14. +3 −0  ci_environment/maven/templates/default/mavenrc.erb
  15. +0 −3  ci_environment/maven3/attributes/default.rb
  16. +0 −8 ci_environment/maven3/metadata.rb
  17. +0 −56 ci_environment/maven3/recipes/default.rb
  18. +0 −27 ci_environment/maven3/recipes/package.rb
  19. +0 −44 ci_environment/maven3/recipes/ppa.rb
  20. +0 −37 ci_environment/maven3/recipes/tarball.rb
  21. +0 −32 ci_environment/maven3/templates/ubuntu-11.04/install_maven3.sh.erb
  22. 0  ...3/files/default/settings.xml → travis_build_environment/files/default/ci_user/maven_user_settings.xml}
  23. +0 −1  ci_environment/travis_build_environment/files/default/ci_user/travis_environment.sh
  24. +17 −0 ci_environment/travis_build_environment/recipes/ci_user.rb
View
60 ci_environment/maven/CHANGELOG.md
@@ -0,0 +1,60 @@
+maven Cookbook CHANGELOG
+========================
+This file is used to list changes made in each version of the maven cookbook.
+
+
+v1.0.0
+------
+### Improvement
+- **[COOK-3470](https://tickets.opscode.com/browse/COOK-3470)** - Improve `/etc/mavenrc` template
+- **[COOK-3459](https://tickets.opscode.com/browse/COOK-3459)** - Install Maven 3.1.0 by default
+
+v0.16.4
+-------
+### Improvement
+- **[COOK-3352](https://tickets.opscode.com/browse/COOK-3352)** - Improve `repository_root` attribute customization
+
+### Bug
+- **[COOK-2799](https://tickets.opscode.com/browse/COOK-2799)** - Fix idempotency in LWRP
+
+v0.16.2
+-------
+The following changes were originally released as 0.16.0, but the README incorrectly referred to the maven# recipes, which are now removed.
+
+### Task
+- [COOK-1874]: refactor maven default recipe to use version attributes
+
+### Bug
+- [COOK-2770]: maven cookbook broken for maven3 now that maven 3.0.5 has been released
+
+v0.15.0
+-------
+- [COOK-1336] - Make Transitive Flag Configurable
+
+v0.14.0
+-------
+- [COOK-2191] - maven3 recipe's "version" doesn't match the attributes
+- [COOK-2208] - Add 'classifier' attribute to maven cookbook
+
+v0.13.0
+-------
+- [COOK-2116] - maven should be available on the path
+
+v0.12.0
+-------
+- [COOK-1860] - refactor maven provider to use resources and `shell_out`
+
+v0.11.0
+-------
+- [COOK-1337] - add put action to maven lwrp to control name of the downloaded file
+- [COOK-1657] - fix download urls
+
+v0.3.0
+------
+- [COOK-1145] - maven lwrp to download artifacts
+- [COOK-1196] - convert lwrp attributes to snake_case
+- [COOK-1423] - check version attribute in default recipe
+
+v0.2.0
+------
+- [COOK-813] - installs maven2 and maven3 using the binaries from maven.apache.org
View
29 ci_environment/maven/CONTRIBUTING
@@ -0,0 +1,29 @@
+If you would like to contribute, please open a ticket in JIRA:
+
+* http://tickets.opscode.com
+
+Create the ticket in the COOK project and use the cookbook name as the
+component.
+
+For all code contributions, we ask that contributors sign a
+contributor license agreement (CLA). Instructions may be found here:
+
+* http://wiki.opscode.com/display/chef/How+to+Contribute
+
+When contributing changes to individual cookbooks, please do not
+modify the version number in the metadata.rb. Also please do not
+update the CHANGELOG.md for a new version. Not all changes to a
+cookbook may be merged and released in the same versions. Opscode will
+handle the version updates during the release process. You are welcome
+to correct typos or otherwise make updates to documentation in the
+README.
+
+If a contribution adds new platforms or platform versions, indicate
+such in the body of the commit message(s), and update the relevant
+COOK ticket. When writing commit messages, it is helpful for others if
+you indicate the COOK ticket. For example:
+
+ git commit -m '[COOK-1041] Updated pool resource to correctly delete.'
+
+In the ticket itself, it is also helpful if you include log output of
+a successful Chef run, but this is not absolutely required.
View
201 ci_environment/maven/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
View
117 ci_environment/maven/README.md
@@ -0,0 +1,117 @@
+maven Cookbook
+==============
+Install and configure maven2 and maven3 from the binaries provided by the maven project.
+
+Provides the `maven` LWRP for pulling a maven artifact from a mave repository and placing it in an arbitrary location.
+
+
+Requirements
+------------
+### Platforms
+- Debian
+- Ubuntu
+- CentOS
+- Red Hat
+- Fedora
+
+The following Opscode cookbooks are dependencies:
+- java - this cookbook not only depends on the java virtual machine but it also depends on the java_ark LWRP present in the java cookbooks
+- ark - used to unpack the maven tarball
+
+
+Attributes
+----------
+* `node['maven']['version']` - defaults to 3, specifies the major version of maven to install.
+* `node['maven']['m2_home']` - defaults to '/usr/local/maven/'
+* `node['maven']['2']['url']` - the download url for maven2
+* `node['maven']['2']['checksum']` - the checksum, which you will have to recalculate if you change the download url using shasum -a 256 <file>
+* `node['maven']['3']['url']` - download url for maven3
+* `node['maven']['3']['checksum']` - the checksum, which you will have to recalculate if you change the download url using shasum -a 256 <file>
+* `node['maven']['repositories']` - an array of maven repositories to use; must be specified as an array. Used in the maven LWRP.
+* `node['maven']['setup_bin']` - Whether or not to put mvn on your system path, defaults to false
+* `node['maven']['mavenrc']['opts']` - Value of `MAVEN_OPTS` environment variable exported via `/etc/mavenrc` template, defaults to `-Dmaven.repo.local=$HOME/.m2/repository -Xmx384m -XX:MaxPermSize=192m`
+
+
+Recipes
+-------
+### default
+Includes the java recipe, and then installs maven according to the version specified by the `node['maven']['version']` attribute.
+
+### test
+**For testing only**. From the development repository, use test-kitchen to test that the LWRP is operating with this recipe. Also contains example usage of the LWRP.
+
+
+Usage
+-----
+Simply include the recipe where you want Apache Maven installed.
+
+The maven lwrp has two actions, `:install` and `:put`. They are essentially the same accept that the install action will name the the downloaded file `artifact_id-version.packaging`. For example, the mysql jar would be named mysql-5.1.19.jar.
+
+Use the put action when you want to explicitly control the name of the downloaded file. This is useful when you download an artifact and then want to have Chef resources act on files within that the artifact. The put action will creat a file named `name.packaging` where name corresponds to the name attribute.
+
+
+Providers/Resources
+-------------------
+### maven
+- `artifact_id` - if this is not specified, the resource's name is used
+- `group_id` - group_id for the artifact
+- `version` - version of the artifact
+- `dest` - the destination folder for the jar and its dependencies
+- `packaging` - defaults to 'jar'
+- `classifier` - distinguishes artifacts that were built from the same POM but differ in context
+- `repositories` - array of maven repositories to use, defaults to ["http://repo1.maven.apache.org/maven2"]
+- `owner` - the owner of the resulting file, default is root
+- `mode` - integer value for file permissions, default is 0644
+- `transitive` - whether to resolve dependencies transitively, defaults to false. Please note: Event true will only place one artifact in dest. All others are downloaded to the local repository.
+
+#### Examples
+
+```ruby
+maven 'mysql-connector-java' do
+ group_id 'mysql'
+ version '5.1.19'
+ dest '/usr/local/tomcat/lib/'
+end
+# The artifact will be downloaded to /usr/local/tomcat/lib/mysql-connector-java-5.1.19.jar
+
+maven 'solr' do
+ group_id 'org.apache.solr'
+ version '3.6.1'
+ packaging 'war'
+ dest '/usr/local/tomcat/webapps/'
+ action :put
+end
+# The artifact will be downloaded to /usr/local/tomcat/webapps/solr.war
+
+maven 'custom-application' do
+ group_id 'com.company.name'
+ version '2.0.0'
+ dest '/usr/local/tomcat/lib'
+ classifier 'client'
+ action :put
+end
+# The artifact will be downloaded to /usr/local/tomcat/lib/custom-application-2.0.0-client.jar
+```
+
+
+License & Authors
+-----------------
+- Author:: Seth Chisamore (<schisamo@opscode.com>)
+- Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
+- Author:: Leif Madsen (<lmadsen@thinkingphones.com>)
+
+```text
+Copyright 2010-2013, Opscode, Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+```
View
25 ci_environment/maven/TESTING.md
@@ -0,0 +1,25 @@
+This cookbook includes support for running tests via Test Kitchen (1.0). This has some requirements.
+
+1. You must be using the Git repository, rather than the downloaded cookbook from the Chef Community Site.
+2. You must have Vagrant 1.1 installed.
+3. You must have a "sane" Ruby 1.9.3 environment.
+
+Once the above requirements are met, install the additional requirements:
+
+Install the berkshelf plugin for vagrant, and berkshelf to your local Ruby environment.
+
+ vagrant plugin install vagrant-berkshelf
+ gem install berkshelf
+
+Install Test Kitchen 1.0 (unreleased yet, use the alpha / prerelease version).
+
+ gem install test-kitchen --pre
+
+Install the Vagrant driver for Test Kitchen.
+
+ gem install kitchen-vagrant
+
+Once the above are installed, you should be able to run Test Kitchen:
+
+ kitchen list
+ kitchen test
View
36 ci_environment/maven/attributes/default.rb
@@ -0,0 +1,36 @@
+#
+# Cookbook Name:: maven
+# Attributes:: default
+#
+# Author:: Seth Chisamore (<schisamo@opscode.com>)
+# Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
+#
+# Copyright:: Copyright (c) 2010-2013, Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+default['maven']['version'] = 3
+default['maven']['m2_home'] = '/usr/local/maven'
+default['maven']['mavenrc']['opts'] = '-Dmaven.repo.local=$HOME/.m2/repository -Xmx512m -XX:MaxPermSize=192m'
+default['maven']['2']['version'] = '2.2.1'
+default['maven']['2']['url'] = "http://apache.mirrors.tds.net/maven/maven-2/#{node['maven']['2']['version']}/binaries/apache-maven-#{node['maven']['2']['version']}-bin.tar.gz"
+default['maven']['2']['checksum'] = 'b9a36559486a862abfc7fb2064fd1429f20333caae95ac51215d06d72c02d376'
+default['maven']['2']['plugin_version'] = '2.4'
+default['maven']['3']['version'] = '3.1.0'
+default['maven']['3']['url'] = "http://apache.mirrors.tds.net/maven/maven-3/#{node['maven']['3']['version']}/binaries/apache-maven-#{node['maven']['3']['version']}-bin.tar.gz"
+default['maven']['3']['checksum'] = '59088c62c14b996d597bbd55e720866b0e13e36daed8a46a81c01058ee74bd54'
+default['maven']['3']['plugin_version'] = '2.4'
+default['maven']['repositories'] = ['http://repo1.maven.apache.org/maven2']
+default['maven']['setup_bin'] = false
View
54 ci_environment/maven/files/default/tests/minitest/test_test.rb
@@ -0,0 +1,54 @@
+class TestMaven < MiniTest::Chef::TestCase
+
+ def path
+ "/usr/local/foobar/lib/"
+ end
+
+ def test_mysql_jar_unpacked
+ assert File.exists? "#{path}/mysql-connector-java-5.1.19.jar"
+ end
+
+ def test_mysql_jar_perms
+ file_mode = File.stat("#{path}/mysql-connector-java-5.1.19.jar").mode
+ octal_mode = sprintf("%o", file_mode)[-4..-1]
+ assert octal_mode == "0755"
+ end
+
+ def test_mysql_jar_owner
+ require 'etc'
+ assert File.stat("#{path}/mysql-connector-java-5.1.19.jar").uid == Etc.getpwnam("foobarbaz").uid
+ assert File.stat("#{path}/mysql-connector-java-5.1.19.jar").gid == Etc.getpwnam("foobarbaz").gid
+ end
+
+ def test_javax_persistence_from_alt_repo
+ assert File.exists? "#{path}/javax.persistence-2.0.0.jar"
+ end
+
+ def test_with_multiple_repos
+ assert File.exists? "#{path}/postgresql-9.0-801.jdbc4.jar"
+ end
+
+ def test_alt_packaging
+ assert File.exists? "#{path}/mm-mysql-2.0.13.pom"
+ end
+
+ def test_CamelCaseAliases
+ assert File.exists? "#{path}/mm-mysql-2.0.13.pom"
+ end
+
+ def test_PutAction
+ assert File.exists? "#{path}/solr-foo.war"
+ end
+
+ def test_mavenrc
+ assert File.exists? "/etc/mavenrc"
+ end
+
+ def test_notifies
+ assert File.exists? "/usr/local/notifyOne"
+ end
+
+ def test_is_idempotent
+ assert !(File.exists? "/usr/local/notifyTwo")
+ end
+end
View
36 ci_environment/maven/metadata.json
@@ -0,0 +1,36 @@
+{
+ "name": "maven",
+ "version": "1.0.0",
+ "description": "Installs maven 2 or 3 and includes a maven resource.",
+ "long_description": "maven Cookbook\n==============\nInstall and configure maven2 and maven3 from the binaries provided by the maven project.\n\nProvides the `maven` LWRP for pulling a maven artifact from a mave repository and placing it in an arbitrary location.\n\n\nRequirements\n------------\n### Platforms\n- Debian\n- Ubuntu\n- CentOS\n- Red Hat\n- Fedora\n\nThe following Opscode cookbooks are dependencies:\n- java - this cookbook not only depends on the java virtual machine but it also depends on the java_ark LWRP present in the java cookbooks\n- ark - used to unpack the maven tarball\n\n\nAttributes\n----------\n* `node['maven']['version']` - defaults to 3, specifies the major version of maven to install.\n* `node['maven']['m2_home']` - defaults to '/usr/local/maven/'\n* `node['maven']['2']['url']` - the download url for maven2\n* `node['maven']['2']['checksum']` - the checksum, which you will have to recalculate if you change the download url using shasum -a 256 <file>\n* `node['maven']['3']['url']` - download url for maven3\n* `node['maven']['3']['checksum']` - the checksum, which you will have to recalculate if you change the download url using shasum -a 256 <file>\n* `node['maven']['repositories']` - an array of maven repositories to use; must be specified as an array. Used in the maven LWRP.\n* `node['maven']['setup_bin']` - Whether or not to put mvn on your system path, defaults to false\n* `node['maven']['mavenrc']['opts']` - Value of `MAVEN_OPTS` environment variable exported via `/etc/mavenrc` template, defaults to `-Dmaven.repo.local=$HOME/.m2/repository -Xmx384m -XX:MaxPermSize=192m`\n\n\nRecipes\n-------\n### default\nIncludes the java recipe, and then installs maven according to the version specified by the `node['maven']['version']` attribute.\n\n### test\n**For testing only**. From the development repository, use test-kitchen to test that the LWRP is operating with this recipe. Also contains example usage of the LWRP.\n\n\nUsage\n-----\nSimply include the recipe where you want Apache Maven installed.\n\nThe maven lwrp has two actions, `:install` and `:put`. They are essentially the same accept that the install action will name the the downloaded file `artifact_id-version.packaging`. For example, the mysql jar would be named mysql-5.1.19.jar.\n\nUse the put action when you want to explicitly control the name of the downloaded file. This is useful when you download an artifact and then want to have Chef resources act on files within that the artifact. The put action will creat a file named `name.packaging` where name corresponds to the name attribute.\n\n\nProviders/Resources\n-------------------\n### maven\n- `artifact_id` - if this is not specified, the resource's name is used\n- `group_id` - group_id for the artifact\n- `version` - version of the artifact\n- `dest` - the destination folder for the jar and its dependencies\n- `packaging` - defaults to 'jar'\n- `classifier` - distinguishes artifacts that were built from the same POM but differ in context\n- `repositories` - array of maven repositories to use, defaults to [\"http://repo1.maven.apache.org/maven2\"]\n- `owner` - the owner of the resulting file, default is root\n- `mode` - integer value for file permissions, default is 0644\n- `transitive` - whether to resolve dependencies transitively, defaults to false. Please note: Event true will only place one artifact in dest. All others are downloaded to the local repository.\n\n#### Examples\n\n```ruby\nmaven 'mysql-connector-java' do\n group_id 'mysql'\n version '5.1.19'\n dest '/usr/local/tomcat/lib/'\nend\n# The artifact will be downloaded to /usr/local/tomcat/lib/mysql-connector-java-5.1.19.jar\n\nmaven 'solr' do\n group_id 'org.apache.solr'\n version '3.6.1'\n packaging 'war'\n dest '/usr/local/tomcat/webapps/'\n action :put\nend\n# The artifact will be downloaded to /usr/local/tomcat/webapps/solr.war\n\nmaven 'custom-application' do\n group_id 'com.company.name'\n version '2.0.0'\n dest '/usr/local/tomcat/lib'\n classifier 'client'\n action :put\nend\n# The artifact will be downloaded to /usr/local/tomcat/lib/custom-application-2.0.0-client.jar\n```\n\n\nLicense & Authors\n-----------------\n- Author:: Seth Chisamore (<schisamo@opscode.com>)\n- Author:: Bryan W. Berry (<bryan.berry@gmail.com>)\n- Author:: Leif Madsen (<lmadsen@thinkingphones.com>)\n\n```text\nCopyright 2010-2013, Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n",
+ "maintainer": "Opscode, Inc.",
+ "maintainer_email": "cookbooks@opscode.com",
+ "license": "Apache 2.0",
+ "platforms": {
+ "centos": ">= 0.0.0",
+ "debian": ">= 0.0.0",
+ "fedora": ">= 0.0.0",
+ "redhat": ">= 0.0.0",
+ "ubuntu": ">= 0.0.0"
+ },
+ "dependencies": {
+ "ark": "~> 0.4",
+ "java": "~> 1.13"
+ },
+ "recommendations": {
+ },
+ "suggestions": {
+ },
+ "conflicting": {
+ },
+ "providing": {
+ },
+ "replacing": {
+ },
+ "attributes": {
+ },
+ "groupings": {
+ },
+ "recipes": {
+ }
+}
View
16 ci_environment/maven/metadata.rb
@@ -0,0 +1,16 @@
+name 'maven'
+maintainer 'Opscode, Inc.'
+maintainer_email 'cookbooks@opscode.com'
+license 'Apache 2.0'
+description 'Installs maven 2 or 3 and includes a maven resource.'
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version '1.0.0'
+
+depends 'ark', '~> 0.4'
+depends 'java', '~> 1.13'
+
+supports 'centos'
+supports 'debian'
+supports 'fedora'
+supports 'redhat'
+supports 'ubuntu'
View
87 ci_environment/maven/providers/default.rb
@@ -0,0 +1,87 @@
+#
+# Cookbook Name:: maven
+# Provider:: default
+#
+# Author:: Bryan W. Berry <bryan.berry@gmail.com>
+# Copyright 2011-2013, Opscode Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/mixin/shell_out'
+require 'chef/mixin/checksum'
+require 'fileutils'
+
+include Chef::Mixin::ShellOut
+include Chef::Mixin::Checksum
+
+def create_command_string(artifact_file, new_resource)
+ group_id = '-DgroupId=' + new_resource.group_id
+ artifact_id = '-DartifactId=' + new_resource.artifact_id
+ version = '-Dversion=' + new_resource.version
+ dest = '-Ddest=' + artifact_file
+ repos = '-DremoteRepositories=' + new_resource.repositories.join(',')
+ packaging = '-Dpackaging=' + new_resource.packaging
+ classifier = '-Dclassifier=' + new_resource.classifier if new_resource.classifier
+ plugin_version = '2.4'
+ plugin = "org.apache.maven.plugins:maven-dependency-plugin:#{plugin_version}:get"
+ transitive = '-Dtransitive=' + new_resource.transitive.to_s
+ %Q{mvn #{plugin} #{group_id} #{artifact_id} #{version} #{packaging} #{classifier} #{dest} #{repos} #{transitive}}
+end
+
+def get_mvn_artifact(action, new_resource)
+ if action == 'put'
+ artifact_file_name = "#{new_resource.name}.#{new_resource.packaging}"
+ else
+ artifact_file_name = if new_resource.classifier.nil?
+ "#{new_resource.artifact_id}-#{new_resource.version}.#{new_resource.packaging}"
+ else
+ "#{new_resource.artifact_id}-#{new_resource.version}-#{new_resource.classifier}.#{new_resource.packaging}"
+ end
+ end
+
+ Dir.mktmpdir('chef_maven_lwrp') do |tmp_dir|
+ tmp_file = ::File.join(tmp_dir, artifact_file_name)
+ shell_out!(create_command_string(tmp_file, new_resource))
+ dest_file = ::File.join(new_resource.dest, artifact_file_name)
+
+ unless ::File.exists?(dest_file) && checksum(tmp_file) == checksum(dest_file)
+ directory new_resource.dest do
+ recursive true
+ mode '0755'
+ end.run_action(:create)
+
+ FileUtils.cp(tmp_file, dest_file, :preserve => true)
+
+ file dest_file do
+ owner new_resource.owner
+ group new_resource.owner
+ mode new_resource.mode
+ end.run_action(:create)
+
+ new_resource.updated_by_last_action(true)
+ end
+ end
+end
+
+action :install do
+ converge_by("Install #{new_resource}") do
+ get_mvn_artifact('install', new_resource)
+ end
+end
+
+action :put do
+ converge_by("Put #{new_resource}") do
+ get_mvn_artifact('put', new_resource)
+ end
+end
View
39 ci_environment/maven/recipes/default.rb
@@ -0,0 +1,39 @@
+#
+# Cookbook Name:: maven
+# Recipe:: default
+#
+# Author:: Seth Chisamore (<schisamo@opscode.com>)
+# Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
+#
+# Copyright:: 2010-2012, Opscode, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+include_recipe 'java::default'
+include_recipe 'ark::default'
+
+mvn_version = node['maven']['version'].to_s
+
+ark 'maven' do
+ url node['maven'][mvn_version]['url']
+ checksum node['maven'][mvn_version]['checksum']
+ home_dir node['maven']['m2_home']
+ version node['maven'][mvn_version]['version']
+ append_env_path true
+end
+
+template '/etc/mavenrc' do
+ source 'mavenrc.erb'
+ mode '0755'
+end
View
82 ci_environment/maven/recipes/test.rb
@@ -0,0 +1,82 @@
+include_recipe "maven"
+
+user "foobarbaz"
+
+%w(/usr/local/notifyOne /usr/local/notifyTwo /usr/local/foobar/lib/mysql-connector-java-5.1.19.jar).each do |fname|
+ file fname do
+ action :delete
+ ignore_failure true
+ end
+end
+
+
+file "/usr/local/notifyOne" do
+ content "I was notified"
+ action :nothing
+end
+
+file "/usr/local/notifyTwo" do
+ content "I was notified"
+ action :nothing
+end
+
+
+# basic test
+maven "mysql-connector-java" do
+ group_id "mysql"
+ version "5.1.19"
+ mode 0755
+ owner "foobarbaz"
+ dest "/usr/local/foobar/lib/"
+ notifies :create, "file[/usr/local/notifyOne]"
+end
+
+maven "otherNameThanBefore" do
+ artifact_id "mysql-connector-java"
+ group_id "mysql"
+ version "5.1.19"
+ mode 0755
+ owner "foobarbaz"
+ dest "/usr/local/foobar/lib/"
+ notifies :create, "file[/usr/local/notifyTwo]"
+end
+
+
+# test from alternate repo
+maven "java persistence library" do
+ artifact_id "javax.persistence"
+ group_id "org.eclipse.persistence"
+ version "2.0.0"
+ repositories [ "http://mirrors.ibiblio.org/pub/mirrors/maven2/" ]
+ dest "/usr/local/foobar/lib"
+end
+
+# test from multiple repositories
+maven "postgresql" do
+ group_id "postgresql"
+ version "9.0-801.jdbc4"
+ repositories [
+ "http://mirrors.ibiblio.org/pub/mirrors/maven2/",
+ "http://repo1.maven.apache.org/maven2"
+ ]
+ dest "/usr/local/foobar/lib"
+end
+
+
+# test downloading hudson plugin and use old alias
+maven "mm-mysql" do
+ groupId "mm-mysql"
+ version "2.0.13"
+ packaging "pom"
+ dest "/usr/local/foobar/lib"
+end
+
+maven "solr-foo" do
+ artifact_id "solr"
+ groupId "org.apache.solr"
+ version "3.6.1"
+ packaging "war"
+ dest "/usr/local/foobar/lib"
+ action :put
+ transitive true
+end
View
43 ci_environment/maven/resources/default.rb
@@ -0,0 +1,43 @@
+#
+# Cookbook Name:: maven
+# Resource:: default
+#
+# Author:: Bryan W. Berry <bryan.berry@gmail.com>
+# Copyright 2012, Opscode Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+actions :install, :put
+
+attribute :artifact_id, :kind_of => String
+attribute :group_id, :kind_of => String, :required => true
+attribute :dest, :kind_of => String
+attribute :version, :kind_of => String, :required => true
+attribute :packaging, :kind_of => String, :default => 'jar'
+attribute :classifier, :kind_of => String
+attribute :owner, :kind_of => String, :default => 'root'
+attribute :mode, :kind_of => [Integer, String], :default => '0644'
+attribute :repositories, :kind_of => Array
+attribute :transitive, :kind_of => [TrueClass, FalseClass], :default => false
+
+alias_method :artifactId, :artifact_id # rubocop:disable SymbolName
+alias_method :groupId, :group_id # rubocop:disable SymbolName
+
+def initialize(*args)
+ super
+ # we can't use the node properties when initially specifying the resource
+ @artifact_id ||= @name
+ @repositories ||= node['maven']['repositories']
+ @action = :install
+end
View
3  ci_environment/maven/templates/default/mavenrc.erb
@@ -0,0 +1,3 @@
+export M2_HOME=<%= node['maven']['m2_home'] %>
+
+export MAVEN_OPTS="<%= node['maven']['mavenrc']['opts'] %>"
View
3  ci_environment/maven3/attributes/default.rb
@@ -1,3 +0,0 @@
-default[:maven] = {
- :version => "3.0.4"
-}
View
8 ci_environment/maven3/metadata.rb
@@ -1,8 +0,0 @@
-name "maven3"
-maintainer "Travis CI Development Team"
-license "Apache v2.0"
-description "Installs/Configures maven3"
-
-%w{ java jpackage }.each do |cb|
- depends cb
-end
View
56 ci_environment/maven3/recipes/default.rb
@@ -1,56 +0,0 @@
-#
-# Cookbook Name:: maven3
-# Recipe:: default
-#
-# Copyright 2011-2013, Travis CI Development Team <contact@travis-ci.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-
-
-include_recipe "java"
-
-case node.platform
-when "redhat", "centos", "fedora" then
- include_recipe "jpackage"
- include_recipe "maven3::tarball"
-when "ubuntu", "debian" then
- case node.platform_version
- when "11.04" then
- include_recipe "maven3::tarball"
- when "11.10" then
- include_recipe "maven3::ppa"
- else
- include_recipe "maven3::package"
- end
-end
-
-per_user_settings = File.join(node.travis_build_environment.home, ".m2", "settings.xml")
-cookbook_file(per_user_settings) do
- owner node.travis_build_environment.user
- group node.travis_build_environment.group
-
- mode 0644
-
- action :nothing
-end
-
-
-directory(File.join(node.travis_build_environment.home, ".m2")) do
- owner node.travis_build_environment.user
- group node.travis_build_environment.group
-
- action :create
- notifies :create, resources(:cookbook_file => per_user_settings)
-end
View
27 ci_environment/maven3/recipes/package.rb
@@ -1,27 +0,0 @@
-#
-# Cookbook Name:: maven3
-# Recipe:: package
-#
-# Copyright 2011-2013, Travis CI Development Team <contact@travis-ci.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# This recipe relies on a PPA package and is Ubuntu/Debian specific. Please
-# keep this in mind.
-
-include_recipe "java"
-
-package "maven" do
- action :install
-end
View
44 ci_environment/maven3/recipes/ppa.rb
@@ -1,44 +0,0 @@
-#
-# Cookbook Name:: maven3
-# Recipe:: ppa
-#
-# Copyright 2011-2013, Travis CI Development Team <contact@travis-ci.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# This recipe relies on a PPA package and is Ubuntu/Debian specific. Please
-# keep this in mind.
-
-include_recipe "java"
-
-apt_repository "maven3-ppa" do
- uri "http://ppa.launchpad.net/natecarlson/maven3/ubuntu"
- distribution node['lsb']['codename']
- components ["main"]
- key "b70731143dd9f856"
- keyserver "keyserver.ubuntu.com"
-
- action :add
-end
-
-package "maven3" do
- action :install
-end
-
-link "/usr/bin/mvn" do
- owner "root"
- group "root"
-
- to "/usr/bin/mvn3"
-end
View
37 ci_environment/maven3/recipes/tarball.rb
@@ -1,37 +0,0 @@
-#
-# Cookbook Name:: maven3
-# Recipe:: tarball
-#
-# Copyright 2011-2013, Travis CI Development Team <contact@travis-ci.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-include_recipe "java"
-
-package "wget" do
- action :install
-end
-
-template "/tmp/install_maven3.sh" do
- source "install_maven3.sh.erb"
- mode 0755
- backup false
-end
-
-execute "/tmp/install_maven3.sh" do
- command "/bin/sh /tmp/install_maven3.sh"
- action :run
-
- not_if "which mvn && mvn --version | grep 'Apache Maven 3'"
-end
View
32 ci_environment/maven3/templates/ubuntu-11.04/install_maven3.sh.erb
@@ -1,32 +0,0 @@
-# @author Yucca Nel
-# @author Michael S. Klishin
-
-#!/bin/bash
-
-set -e
-
-# a workaround for Ubuntu 11.04-specific installation annoyances. MK.
-sudo apt-get install maven2
-sudo mkdir -p /usr/lib/mvn
-
-sudo rm -rf /tmp/*.tar.gz
-cd /tmp
-
-# some Apache mirrors occasionally provide broken packages (tar fails to uncompress them). MK.
-{
- wget ftp://mirror.netcologne.de/apache.org/maven/binaries/apache-maven-<%= node.maven.version %>-bin.tar.gz && tar -xvf ./*gz
-} || {
- echo "Falling back to the main Apache mirror..."
- wget http://www.apache.org/dist//maven/binaries/apache-maven-<%= node.maven.version %>-bin.tar.gz && tar -xvf ./*gz
-} || {
- echo "Falling back to files.travis-ci.org..."
- wget http://files.travis-ci.org/packages/tar/maven3/apache-maven-<%= node.maven.version %>-bin.tar.gz && tar -xvf ./*gz
-}
-
-sudo apt-get remove maven2
-sudo rm -f /usr/bin/mvn
-sudo mkdir -p /usr/lib/mvn
-sudo mv /tmp/apache-maven-3.* /usr/lib/mvn/
-sudo ln -s /usr/lib/mvn/apache-maven-<%= node.maven.version %>/bin/mvn /usr/bin/mvn
-
-mvn -version
View
0  ci_environment/maven3/files/default/settings.xml → ...ent/files/default/ci_user/maven_user_settings.xml
File renamed without changes
View
1  ci_environment/travis_build_environment/files/default/ci_user/travis_environment.sh
@@ -27,4 +27,3 @@ export COMPOSER_NO_INTERACTION=1
# to improve startup time, especially on JDK 7+)
# -Xcompile.invokedynamic=false disables invokedynamic which seemingly causes 32 bit OpenJDKs (6 and 7) to segfault
export JRUBY_OPTS="--server -Xcext.enabled=false -Xcompile.invokedynamic=false -J-Xss2m -J-Xmx256m -J-XX:+TieredCompilation"
-export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=192m"
View
17 ci_environment/travis_build_environment/recipes/ci_user.rb
@@ -101,6 +101,23 @@
only_if { node.travis_build_environment[:use_tmpfs_for_builds] }
end
+
+directory(File.join(node.travis_build_environment.home, ".m2")) do
+ owner node.travis_build_environment.user
+ group node.travis_build_environment.group
+ mode 0755
+end
+
+maven_user_settings = File.join(node.travis_build_environment.home, ".m2", "settings.xml")
+cookbook_file(maven_user_settings) do
+ owner node.travis_build_environment.user
+ group node.travis_build_environment.group
+ mode 0644
+
+ source "ci_user/maven_user_settings.xml"
+end
+
+
# link /home/vagrant for those poor projects that absolutely depend on that legacy
# home directory to be present. MK.
if node.travis_build_environment.user != "vagrant"
Please sign in to comment.
Something went wrong with that request. Please try again.