buildrizpack 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,195 @@
1
+ # encoding: UTF-8
2
+
3
+ # Licensed to the Apache Software Foundation (ASF) under one or more
4
+ # contributor license agreements. See the NOTICE file distributed with this
5
+ # work for additional information regarding copyright ownership. The ASF
6
+ # licenses this file to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+ # License for the specific language governing permissions and limitations under
16
+ # the License.
17
+
18
+ require "rexml/document"
19
+ include REXML
20
+
21
+ module BuildrIzPack
22
+
23
+ class IzPackTask < Buildr::ArchiveTask
24
+
25
+ # a hash of name => value to be passed when calling the izpack installer
26
+ # See also IzPackTask.html[http://www.jarvana.com/jarvana/view/org/codehaus/izpack/izpack-standalone-compiler/4.0.1/izpack-standalone-compiler-4.0.1-javadoc.jar!/com/izforge/izpack/ant/IzPackTask.html]
27
+ attr_accessor :properties
28
+ # "IzPack"[http://izpack.org/documentation/installation-files.html] to be used as starting point for calling the izpack installer
29
+ # some or all of its content may be overwritten, if you specify other attributes, e.g.
30
+ # if you want to specify one or mor pack bundles with a file list maintained by buildr.
31
+ # If not specified BuildrIzPack will create one at File.join(project.path_to(:target, 'install.xml'))
32
+ attr_accessor :input
33
+ # ther version of the izpack installer to be used. Defaults to 4.3.5
34
+ attr_accessor :izpackVersion
35
+ # Application name used by the IzPack installer. Defaults to the current project
36
+ attr_accessor :appName
37
+ # The installer output directory and filename (defaults to <project>-<version>.izpack)
38
+ attr_accessor :output
39
+ # The base directory of compilation process (defaults project.path_to(:target))
40
+ attr_accessor :basedir
41
+ # The installer type (defaults to standard). You can select between standard and web.
42
+ attr_accessor :installerType
43
+ # It seems that in order to propagate all project properties to the the izpack compiler you need to set the inheritAll attribute to "true".
44
+ # Therefore it defaults to true
45
+ attr_accessor :inheritAll
46
+ # defaults to deflate. You can select between default, deflate and raw.
47
+ attr_accessor :compression
48
+ # defaults to 9. The compression level of the installation (defaults to -1 for no compression). Valid values are -1 to 9.
49
+ attr_accessor :compressionLevel
50
+ # the packs (including attributes, fileset, os-dependencies etc). Must be an array of XmlMarkup object.
51
+ attr_accessor :packs
52
+
53
+ # The supported locale's for the installer. Must be an array of XmlMarkup object. Defaults to ['eng']
54
+ # For details look at IzPacks installation.dtd (Distributed with this gem)
55
+ attr_accessor :locales
56
+ # IzPacks panels's. Must be an array of XmlMarkup object. Defaults to ['TargetPanel', 'InstallPack']
57
+ attr_accessor :panels
58
+ # the supported locale's. Must be an array of XmlMarkup object. Defaults to 680 x 520
59
+ attr_accessor :guiprefs
60
+
61
+ attr_accessor :packaging, :properties, :variables, :dynamicvariables, :conditions, :installerrequirements,:resources,
62
+ :listeners, :jar, :native
63
+ # Adds the filePaths to a given pack.
64
+ #
65
+ # * May be called several times for the same package
66
+ #
67
+ # * +packName+ - the name of the destination pack, if it is a Hash, then it must point to a hash of attributes for the pack
68
+ # * +filePaths+ - May be a single filename or an array of filenames
69
+ # * +description+ - Description of the pack
70
+ # * +destination+ - IzPack will copy the files at installation time to this directory/file.
71
+ #
72
+ def addToPack(packName, filePaths, description=packName, destination='')
73
+ end
74
+ # The ArchiveTask class delegates this method
75
+ # so we can create the archive.
76
+ # the file_map is the result of the computations of the include and exclude filters.
77
+ #
78
+ def create_from(file_map)
79
+ @izpackVersion ||= '4.3.5'
80
+ @appName ||= project.id
81
+ @izpackBaseDir = File.dirname(@output) if !@izpackBaseDir
82
+ @installerType ||= 'standard'
83
+ @inheritAll ||= 'true'
84
+ @compression ||= 'deflate'
85
+ @compressionLevel ||= '9'
86
+ @locales ||= ['eng']
87
+ @panels ||= ['TargetPanel', 'InstallPanel']
88
+ @packs ||=
89
+ raise "You must include at least one file to create an izPack installer" if file_map.size == 0 and !File.exists?(@input)
90
+ izPackArtifact = Buildr.artifact( "org.codehaus.izpack:izpack-standalone-compiler:jar:#{@izpackVersion}")
91
+ doc = nil
92
+ if !File.exists?(@input)
93
+ # genInstaller(Builder::XmlMarkup.new(:target=>$stdout, :indent => 2), file_map)
94
+ genInstaller(Builder::XmlMarkup.new(:target=>File.open(@input, 'w+'), :indent => 2), file_map)
95
+ # genInstaller(Builder::XmlMarkup.new(:target=>File.open('/home/niklaus/tmp2.xml', 'w+'), :indent => 2), file_map)
96
+ end
97
+ Buildr.ant('izpack-ant') do |x|
98
+ izPackArtifact.invoke
99
+ msg = "Generating izpack aus #{File.expand_path(@input)} #{File.size(@input)}"
100
+ trace msg
101
+ if properties
102
+ properties.each{ |name, value|
103
+ puts "Need added property #{name} with value #{value}"
104
+ x.property(:name => name, :value => value)
105
+ }
106
+ end
107
+ x.echo(:message =>msg)
108
+ x.taskdef :name=>'izpack',
109
+ :classname=>'com.izforge.izpack.ant.IzPackTask',
110
+ :classpath=>izPackArtifact.to_s
111
+ x.izpack :input=> @input,
112
+ :output => @output,
113
+ :basedir => @izpackBaseDir,
114
+ :installerType=> @installerType,
115
+ :inheritAll=> @inheritAll,
116
+ :compression => @compression,
117
+ :compressionLevel => @compressionLevel do
118
+ end
119
+ end
120
+ end
121
+
122
+ private
123
+ def genInstaller(xm, file_map)
124
+ xm.instruct!
125
+ xm.installation('version'=>'1.0') {
126
+ xm.tag!('info') { xm.appname(@appName); xm.appversion(@version)}
127
+ if @guiprefs then xm << @guiprefs
128
+ else
129
+ xm.guiprefs('width' => '680', 'height' => '520', 'resizable' => 'yes')
130
+ end
131
+ if @panels.class == String then xm << @panels
132
+ else
133
+ xm.panels {
134
+ @panels.each{ |x| xm.panel('classname' => x) }
135
+ }
136
+ end
137
+ if @panels.class == String then xm << @panels
138
+ else
139
+ xm.locale {
140
+ @locales.each{ |x| xm.langpack('iso3'=>x) }
141
+ }
142
+ end
143
+ if @packs then xm << @packs
144
+ else
145
+ #default definiton of packs
146
+ xm.packs {
147
+ xm.pack('name' => 'main', 'required' => 'yes') {
148
+ xm.description("Main pack of #{@appName}")
149
+ file_map.each{ |src,aJar|
150
+ xm.file('src'=> aJar, 'targetdir' =>'$INSTALL_PATH')
151
+ }
152
+ }
153
+ }
154
+ end
155
+ [@packaging, @properties, @variables, @dynamicvariables, @conditions, @installerrequirements,@resources,@listeners, @jar, @native].each do
156
+ |element|
157
+ xm << element if element
158
+ end
159
+
160
+ }
161
+ # Don't close $stdout
162
+ xm.target!().close if xm.target!.class == File
163
+ end
164
+
165
+ end
166
+
167
+ module ActAsIzPackPackager
168
+ include Extension
169
+
170
+ def package_as_izpack(file_name)
171
+ izpack = IzPackTask.define_task(file_name)
172
+ izpack.enhance do |task|
173
+ task.enhance do
174
+ package ||= project.id
175
+ version ||= project.version
176
+ end
177
+ task.input ||= File.join(project.path_to(:target, 'install.xml'))
178
+ task.appName ||= project.id
179
+ task.output ||= file_name
180
+ task.basedir ||= project.path_to(:target)
181
+ task.installerType ||= 'standard'
182
+ task.inheritAll ||= 'true'
183
+ task.compression ||= 'deflate'
184
+ task.compressionLevel ||= '9'
185
+ end
186
+ return izpack
187
+ end
188
+ end
189
+ end
190
+
191
+ module Buildr
192
+ class Project
193
+ include BuildrIzPack::ActAsIzPackPackager
194
+ end
195
+ end
@@ -0,0 +1,122 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ desc "Create JRuby all-in-one distribution"
17
+ task "all-in-one" => 'all-in-one:all-in-one'
18
+
19
+ namespace :'all-in-one' do
20
+
21
+ version = "1.6.4"
22
+ jruby_distro = "jruby-bin-#{version}.tar.gz"
23
+ url = "http://jruby.org.s3.amazonaws.com/downloads/#{version}/#{jruby_distro}"
24
+ dir = "jruby-#{version}"
25
+
26
+ task "all-in-one" => [:gem,
27
+ # Prepare to run
28
+ :prepare,
29
+ # Download and extract JRuby
30
+ :download_and_extract,
31
+ # Cleanup JRuby distribution
32
+ :clean_dist,
33
+ # Install Buildr gem and dependencies
34
+ :install_dependencies,
35
+ # Add Buildr executables/scripts
36
+ :add_execs,
37
+ # Package distribution
38
+ :package
39
+ ]
40
+
41
+ desc 'Prepare to run'
42
+ task :prepare do
43
+ mkpath '_all-in-one'
44
+ cd '_all-in-one'
45
+ end
46
+
47
+ desc 'Download and extract JRuby'
48
+ task :download_and_extract do
49
+ unless File.exist? jruby_distro
50
+ puts "Downloading JRuby from #{url} ..."
51
+ sh 'wget', url
52
+ puts "[X] Downloaded JRuby"
53
+ end
54
+
55
+ rm_rf dir if File.exist? dir
56
+
57
+ puts "Extracting JRuby to #{dir} ..."
58
+ sh 'tar', 'xzf', jruby_distro
59
+ puts "[X] Extracted JRuby"
60
+ cd dir
61
+ end
62
+
63
+ desc 'Cleanup JRuby distribution'
64
+ task :clean_dist do
65
+ puts 'Cleaning...'
66
+ rm_rf 'docs'
67
+ mkpath 'jruby-docs'
68
+ mv Dir["COPYING*"], 'jruby-docs'
69
+ mv Dir["LICENSE*"], 'jruby-docs'
70
+ mv 'README', 'jruby-docs'
71
+ rm_rf 'lib/ruby/1.9'
72
+ rm_rf 'lib/ruby/gems/1.8/doc'
73
+ rm_rf 'samples'
74
+ rm_rf 'share'
75
+ end
76
+
77
+ desc 'Install Buildr gem and dependencies'
78
+ task :install_dependencies do
79
+ puts "Install rubygems-update"
80
+ sh "bin/jruby -S gem install rubygems-update"
81
+
82
+ puts "Upgrade Rubygems"
83
+ sh "bin/jruby -S gem update --system"
84
+
85
+ puts "Install ffi-ncurses"
86
+ sh "bin/jruby -S gem install ffi-ncurses"
87
+
88
+ puts "Install Buildr gem ..."
89
+ sh "bin/jruby", '-S', 'gem', 'install', FileList['../../pkg/*-java.gem'].first,
90
+ '--no-rdoc', '--no-ri'
91
+ puts "[X] Install Buildr gem"
92
+ end
93
+
94
+ desc 'Add Buildr executables/scripts'
95
+ task :add_execs do
96
+ cp 'bin/jruby.exe', 'bin/_buildr.exe'
97
+ cp Dir["../../all-in-one/*"], 'bin'
98
+ end
99
+
100
+ desc 'Package distribution'
101
+ task :package do
102
+ puts "Zipping distribution ..."
103
+ cd '..'
104
+ new_dir = "#{spec.name}-all-in-one-#{spec.version}"
105
+ mv dir, new_dir
106
+ zip = "#{new_dir}.zip"
107
+ rm zip if File.exist? zip
108
+ sh 'zip', '-q', '-r', zip, new_dir
109
+ puts "[X] Zipped distribution"
110
+
111
+ puts "Tarring distribution ..."
112
+ tar = "#{new_dir}.tar.gz"
113
+ rm tar if File.exist? tar
114
+ sh 'tar', 'czf', tar, new_dir
115
+ puts "[X] Tarred distribution"
116
+
117
+ rm_rf new_dir
118
+ end
119
+
120
+ end
121
+
122
+ task(:clobber) { rm_rf '_all-in-one' }
@@ -0,0 +1,28 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ desc "Check that source files contain the Apache license"
18
+ task :license=>FileList["**/*.{rb,rake,java,gemspec,buildfile}", 'Rakefile'] do |task|
19
+ puts "Checking that files contain the Apache license ... "
20
+ required = task.prerequisites.select { |fn| File.file?(fn) }
21
+ missing = required.reject { |fn|
22
+ comments = File.read(fn).scan(/(\/\*(.*?)\*\/)|^#\s+(.*?)$|^-#\s+(.*?)$|<!--(.*?)-->/m).
23
+ map { |match| match.compact }.flatten.join("\n")
24
+ comments =~ /Licensed to the Apache Software Foundation/ && comments =~ /http:\/\/www.apache.org\/licenses\/LICENSE-2.0/
25
+ }
26
+ fail "#{missing.join(', ')} missing Apache License, please add it before making a release!" unless missing.empty?
27
+ puts "[x] Source files contain the Apache license"
28
+ end
@@ -0,0 +1,123 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ if !RUBY_PLATFORM[/java/]
17
+ gem 'rdoc'
18
+ require 'rdoc/task'
19
+ desc "Creates a symlink to rake's lib directory to support combined rdoc generation"
20
+ file "rake/lib" do
21
+ rake_path = $LOAD_PATH.find { |p| File.exist? File.join(p, "rake.rb") }
22
+ mkdir_p "rake"
23
+ File.symlink(rake_path, "rake/lib")
24
+ end
25
+
26
+ desc "Generate RDoc documentation in rdoc/"
27
+ RDoc::Task.new :rdoc do |rdoc|
28
+ rdoc.rdoc_dir = 'rdoc'
29
+ rdoc.title = spec.name
30
+ rdoc.options = spec.rdoc_options.clone
31
+ rdoc.rdoc_files.include('lib/**/*.rb')
32
+ rdoc.rdoc_files.include spec.extra_rdoc_files
33
+
34
+ # include rake source for better inheritance rdoc
35
+ rdoc.rdoc_files.include('rake/lib/**.rb')
36
+ end
37
+ task :rdoc => ["rake/lib"]
38
+
39
+ begin
40
+ require 'jekylltask'
41
+ module TocFilter
42
+ def toc(input)
43
+ output = "<ol class=\"toc\">"
44
+ input.scan(/<(h2)(?:>|\s+(.*?)>)([^<]*)<\/\1\s*>/mi).each do |entry|
45
+ id = (entry[1][/^id=(['"])(.*)\1$/, 2] rescue nil)
46
+ title = entry[2].gsub(/<(\w*).*?>(.*?)<\/\1\s*>/m, '\2').strip
47
+ if id
48
+ output << %{<li><a href="##{id}">#{title}</a></li>}
49
+ else
50
+ output << %{<li>#{title}</li>}
51
+ end
52
+ end
53
+ output << "</ol>"
54
+ output
55
+ end
56
+ end
57
+ Liquid::Template.register_filter(TocFilter)
58
+
59
+ desc "Generate Buildr documentation in _site/"
60
+ JekyllTask.new :jekyll do |task|
61
+ task.source = 'doc'
62
+ task.target = '_site'
63
+ end
64
+
65
+ rescue LoadError
66
+ puts "Buildr uses the jekyll gem to generate the Web site. You can install it by running bundler"
67
+ end
68
+
69
+ if `pygmentize -V`.empty?
70
+ puts "Buildr uses the Pygments python library. You can install it by running 'sudo easy_install Pygments'"
71
+ end
72
+
73
+ desc "Generate Buildr documentation as buildr.pdf"
74
+ file 'buildr.pdf'=>'_site' do |task|
75
+ pages = File.read('_site/preface.html').scan(/<li><a href=['"]([^'"]+)/).flatten.map { |f| "_site/#{f}" }
76
+ sh 'prince', '--input=html', '--no-network', '--log=prince_errors.log', "--output=#{task.name}", '_site/preface.html', *pages
77
+ end
78
+
79
+ desc "Build a copy of the Web site in the ./_site"
80
+ task :site=>['_site', :rdoc, '_reports/specs.html', '_reports/coverage', 'buildr.pdf'] do
81
+ cp_r 'rdoc', '_site'
82
+ fail 'No RDocs in site directory' unless File.exist?('_site/rdoc/lib/buildr_rb.html')
83
+ cp '_reports/specs.html', '_site'
84
+ cp_r '_reports/coverage', '_site'
85
+ fail 'No coverage report in site directory' unless File.exist?('_site/coverage/index.html')
86
+ cp 'CHANGELOG', '_site'
87
+ open("_site/.htaccess", "w") do |htaccess|
88
+ htaccess << %Q{
89
+ <FilesMatch "CHANGELOG">
90
+ ForceType 'text/plain; charset=UTF-8'
91
+ </FilesMatch>
92
+ }
93
+ end
94
+ cp 'buildr.pdf', '_site'
95
+ fail 'No PDF in site directory' unless File.exist?('_site/buildr.pdf')
96
+ puts 'OK'
97
+ end
98
+
99
+ # Publish prerequisites to Web site.
100
+ task 'publish'=>:site do
101
+ target = "people.apache.org:/www/#{spec.name}.apache.org/"
102
+ puts "Uploading new site to #{target} ..."
103
+ sh 'rsync', '--progress', '--recursive', '--delete', '_site/', target
104
+ sh 'ssh', 'people.apache.org', 'chmod', '-f', '-R', 'g+w', "/www/#{spec.name}.apache.org/*"
105
+ puts "Done"
106
+ end
107
+
108
+ # Update HTML + PDF documentation (but not entire site; no specs, coverage, etc.)
109
+ task 'publish-doc' => ['buildr.pdf', '_site'] do
110
+ cp 'buildr.pdf', '_site'
111
+ target = "people.apache.org:/www/#{spec.name}.apache.org/"
112
+ puts "Uploading new site to #{target} ..."
113
+ sh 'rsync', '--progress', '--recursive', '_site/', target # Note: no --delete
114
+ sh 'ssh', 'people.apache.org', 'chmod', '-f', '-R', 'g+w', "/www/#{spec.name}.apache.org/*"
115
+ puts "Done"
116
+ end
117
+
118
+ task :clobber do
119
+ rm_rf '_site'
120
+ rm_f 'buildr.pdf'
121
+ rm_f 'prince_errors.log'
122
+ end
123
+ end