diff --git a/attributes/default.rb b/attributes/default.rb new file mode 100644 index 0000000..1c9238b --- /dev/null +++ b/attributes/default.rb @@ -0,0 +1,21 @@ +# +# Cookbook Name:: chef-sudo +# Attribute File:: default +# +# Copyright 2013 Matt Farmer +# +# 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['sbt']['version'] = '0.12.4' +default['sbt']['java_options'] = '-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512M' diff --git a/metadata.rb b/metadata.rb new file mode 100644 index 0000000..8aca983 --- /dev/null +++ b/metadata.rb @@ -0,0 +1,29 @@ +name 'sbt' +maintainer 'Matt Farmer' +maintainer_email 'matt@frmr.me' +license 'Apache 2.0' +description 'Installs the sbt version you request from manual download.' +version '0.0.1' + +recipe 'sbt', 'Downloads and installs sbt in your path.' + +%w{ubuntu debian}.each do |os| + supports os +end + +attribute 'sbt', + :display_name => 'SBT', + :description => 'Hash of SBT attributes', + :type => 'hash' + +attribute 'sbt/version', + :display_name => 'SBT Version', + :description => 'The version of SBT to install', + :type => 'string', + :default => '0.12.4' + +attribute 'sbt/java_options', + :display_name => 'SBT Java Options', + :description => 'Java options passed to the JVM running SBT.', + :type => 'string', + :default => '-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512M' diff --git a/recipes/default.rb b/recipes/default.rb new file mode 100644 index 0000000..1f96f4a --- /dev/null +++ b/recipes/default.rb @@ -0,0 +1,41 @@ +# +# Cookbook Name:: chef-sbt +# Recipe:: default +# +# Copyright 2013 Matt Farmer +# +# 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. +# + +remote_file "/usr/local/bin/sbt-launch.jar" do + source "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/#{node[:sbt][:version]}/sbt-launch.jar" + action :create + + not_if "java -jar /usr/local/bin/sbt-launch.jar \"sbt-version\" | tail -1 | awk '{print $2}' | grep '#{node[:sbt][:version]}'" +end + +execute "sudo chown root:root /usr/local/bin/sbt-launch.jar" +execute "sudo chmod 0755 /usr/local/bin/sbt-launch.jar" + +template "/usr/local/bin/sbt" do + source "sbt.erb" + variables({ + :java_options => node[:sbt][:java_options] + }) + + action :create + + owner "root" + group "root" + mode 0755 +end diff --git a/templates/default/sbt.erb b/templates/default/sbt.erb new file mode 100644 index 0000000..7a9cf67 --- /dev/null +++ b/templates/default/sbt.erb @@ -0,0 +1 @@ +java <%= @java_options %> -jar `dirname $0`/sbt-launch.jar "$@"