Skip to content

Commit

Permalink
Implement sbt recipe.
Browse files Browse the repository at this point in the history
  • Loading branch information
farmdawgnation committed Jul 25, 2013
1 parent 448b5ef commit 5367ddd
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
21 changes: 21 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -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'
29 changes: 29 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -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'
41 changes: 41 additions & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions templates/default/sbt.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java <%= @java_options %> -jar `dirname $0`/sbt-launch.jar "$@"

0 comments on commit 5367ddd

Please sign in to comment.