Skip to content
This repository has been archived by the owner on Nov 24, 2020. It is now read-only.

Commit

Permalink
Simple examples work
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed Apr 21, 2012
1 parent 61b66db commit ad971c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 71 deletions.
76 changes: 7 additions & 69 deletions lib/buildrizpack/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class IzPackTask < Buildr::ArchiveTask
attr_accessor :compression
# defaults to 9. The compression level of the installation (defaults to -1 for no compression). Valid values are -1 to 9.
attr_accessor :compressionLevel
# defaults to package(:jar). The jars for the main pack
attr_accessor :jars

# The ArchiveTask class delegates this method
# so we can create the archive.
Expand All @@ -62,33 +60,8 @@ def create_from(file_map)
@inheritAll ||= 'true'
@compression ||= 'deflate'
@compressionLevel ||= '9'
p 5
raise "You must include at least one file to create an izPack installer" if file_map.size == 0
p @jars
p file_map
@jars ||= [ package(:jar).to_s ]
izPackArtifact = Buildr.artifact( "org.codehaus.izpack:izpack-standalone-compiler:jar:#{@izpackVersion}")
p "create from #{file_map.inspect} using #{izPackArtifact.to_s}"
p "create with jars #{@jars.inspect}"
file_map.each do |path, content|
p 4
p path
p content
p root
_path = File.join(root, path)
if content.respond_to?(:call)
raise "Not implemented"
#content.call path
elsif content.nil?
mkdir_p _path
elsif File.directory?(content.to_s)
p 8888
else
mkdir_p File.dirname(_path) if !File.exists?(File.dirname(_path))
cp content.to_s, _path
end
end
p "68: #{@input} #{File.exists?(@input)}"
doc = nil
if !File.exists?(@input)
# Then we generate a default, very basic installer
Expand All @@ -102,42 +75,23 @@ def create_from(file_map)
doc.elements['installation'].add_element('packs').add_element('pack').attributes['name'] = 'main'
doc.elements['installation/packs/pack'].add_element('description').text = "A dummy description for #{@appName}"
doc.elements['installation/packs/pack'].attributes['required'] = 'yes'
@jars.each{
|aJar|
doc.elements['installation'].add_element('guiprefs').attributes['width'] = '700'
doc.elements['installation/guiprefs'].attributes['height'] = '520'
doc.elements['installation/guiprefs'].attributes['resizable'] = 'yes'
file_map.each{
|src, aJar|
doc.elements['installation/packs/pack'].add_element('file').attributes['targetdir']="$SYSTEM_user_home/#{@appName}"
doc.elements['installation/packs/pack/file'].attributes['src']=aJar
}
doc.write(File.open(@input, 'w+'), 2)
# doc.write($stdout, 2)
# doc.write($stdout, 2)
else
p 71
doc = Document.new File.new(@input)
end
shouldBe = %(
<installation version="1.0">
<info>
<appname>demo app</appname>
<appversion>7.6.5</appversion>
</info>
<locale>
<langpack iso3="eng" />
</locale>
<panels>
<panel classname="InstallPanel" />
</panels>
<packs>
<pack name="Demo-App" required="yes">
<description>Our demo app.</description>
<file src="withXml-1.0.0.001.jar" targetdir="$SYSTEM_user_home/demo" />
</pack>
</packs>
</installation>)
p @izpackBaseDir
p @output
Buildr.ant('izpack-ant') do |x|
izPackArtifact.invoke
msg = "Generating izpack aus #{File.expand_path(@input)} #{File.exists?(File.expand_path(@input))}"
p msg
trace msg
if properties
properties.each{ |name, value|
puts "Need added property #{name} with value #{value}"
Expand All @@ -160,29 +114,13 @@ def create_from(file_map)
end

end
was= %(
module ActAsDebPackager
include Extension

def package_as_deb(file_name)
deb = DebTask.define_task(file_name)
deb.enhance do |task|
task.enhance do
package ||= project.id
version ||= project.version
end
end
return deb
end
end
)
module ActAsIzPackPackager
include Extension

def package_as_izpack(file_name)
izpack = IzPackTask.define_task(file_name)
izpack.enhance do |task|
task.jars ||= [ package(:jar).to_s ]
task.enhance do
package ||= project.id
version ||= project.version
Expand Down
9 changes: 7 additions & 2 deletions spec/buildrizpack/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def writeSimpleInstaller(filename)
<appname>demo app</appname>
<appversion>7.6.5</appversion>
</info>
<guiprefs width="700" height="520" resizable="yes" />
<locale>
<langpack iso3="eng" />
</locale>
Expand All @@ -62,13 +63,13 @@ def writeSimpleInstaller(filename)
@path = @project.package(:jar).to_s
File.exists?(@path).should be_true
@path.to_s.should include(".jar")
FileUtils.cp(@path, "/home/niklaus/tmp.jar", :verbose => true)
Zip::ZipFile.open(@path) do |zip|
zip.find_entry("Main.class").should_not be_nil
zip.find_entry("META-INF/MANIFEST.MF").should_not be_nil
end
File.exists?(@path).should be_true
@instPath = File.join(@project.path_to(:target, :main), "#{@project.id}-#{@project.id}.installer.jar")
@instPath = File.join(@project.path_to(:target, :main), "#{@project.name}-#{@project.version}.izpack.jar")
File.exists?(@instPath).should be_true
end

it "should use the provided install.xml" do
Expand All @@ -79,6 +80,10 @@ def writeSimpleInstaller(filename)
@project.package(:jar).invoke
@project.package(:izpack).invoke
@instPath = File.join(@project.path_to(:target, :main), "#{@project.name}-#{@project.version}.izpack.jar")
p Dir.glob(@project.path_to(:target,'**/*.jar'))
p @project.path_to(:target)
p @instPath
FileUtils.cp(@instPath, "/home/niklaus/tmp.jar", :verbose => true)
File.exists?(@instPath).should be_true
end

Expand Down

0 comments on commit ad971c0

Please sign in to comment.