-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava_pack.rb
More file actions
57 lines (44 loc) · 1.22 KB
/
java_pack.rb
File metadata and controls
57 lines (44 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#! /usr/bin/ruby
# coding: utf-8
# author: Ulric Qin
# mail: [email protected]
require 'fetcher'
require 'fileutils'
class JavaPack
attr_reader :global
def initialize(global)
@global = global
end
def compile
Fetcher.install_jdk(global)
setup_profiled
end
def setup_profiled
FileUtils.mkdir_p "#{global.build_path}/.profile.d"
File.open("#{global.build_path}/.profile.d/jdk.sh", 'a') { |file| file.puts(bash_script) }
end
private
def java_opts
{
'-Xmx' => '$MEMORY_LIMIT',
'-Xms' => '$MEMORY_LIMIT',
'-Djava.io.tmpdir=' => '\"$TMPDIR\"'
}
end
def bash_script
<<-BASH
#!/usr/bin/env bash
export JAVA_HOME="$HOME/.jdk"
export PATH="$HOME/.jdk/bin:$PATH"
export JAVA_OPTS=${JAVA_OPTS:-"#{java_opts.map{ |k, v| "#{k}#{v}" }.join(' ')}"}
export LANG="${LANG:-en_US.UTF-8}"
if [ -n "$VCAP_DEBUG_MODE" ]; then
if [ "$VCAP_DEBUG_MODE" = "run" ]; then
export JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=$VCAP_DEBUG_PORT,server=y,suspend=n"
elif [ "$VCAP_DEBUG_MODE" = "suspend" ]; then
export JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=$VCAP_DEBUG_PORT,server=y,suspend=y"
fi
fi
BASH
end
end