Permalink
Browse files

Add support for PhantomJS

  • Loading branch information...
rgiard committed Aug 8, 2014
1 parent 717d8bf commit 39d4b1db3935cd3519344f7baebf1cac1bb8bbab
Showing with 69 additions and 0 deletions.
  1. +1 −0 config/components.yml
  2. +19 −0 config/phantom_js.yml
  3. +49 −0 lib/java_buildpack/framework/phantom_js.rb
View
@@ -41,3 +41,4 @@ frameworks:
- "JavaBuildpack::Framework::PostgresqlJDBC"
- "JavaBuildpack::Framework::SpringAutoReconfiguration"
- "JavaBuildpack::Framework::SpringInsight"
- "JavaBuildpack::Framework::PhantomJs"
View
@@ -0,0 +1,19 @@
# Cloud Foundry Java Buildpack
# Copyright (c) 2013 the original author or authors.
#
# 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.
# Configuration for the PhantomJS framework
---
version: 1.9.7
repository_root: https://bitbucket.org/ariya/phantomjs/downloads
@@ -0,0 +1,49 @@
require 'java_buildpack/component/base_component'
require 'java_buildpack/framework'
require 'java_buildpack/util/dash_case'
require 'shellwords'
module JavaBuildpack
module Framework
# Encapsulates the functionality for contributing custom Java options to an application.
class PhantomJs < JavaBuildpack::Component::BaseComponent
def detect
'PhantomJs'
end
def compile
archive_name = "phantomjs-#{version}-linux-x86_64.tar.bz2"
package_uri = "#{repository_root}/#{archive_name}"
download(version, package_uri) do |file|
with_timing "Expanding PhantomJs to #{@droplet.sandbox.relative_path_from(@droplet.root)}" do
FileUtils.mkdir_p @droplet.sandbox
shell "tar xfvj #{file.path} -C #{@droplet.sandbox} --strip 1 2>&1"
end
end
@droplet.copy_resources
@droplet.java_opts.add_system_property('phantomjs.binary.path', phantom_path)
end
def release
@droplet.java_opts.add_system_property('phantomjs.binary.path', phantom_path)
end
private
def phantom_path
"$PWD/#{(@droplet.sandbox + 'bin/phantomjs').relative_path_from(@droplet.root)}"
end
def version
@configuration['version']
end
def repository_root
@configuration['repository_root']
end
end
end
end

0 comments on commit 39d4b1d

Please sign in to comment.