lib/airake/tasks/air.rake in airake-0.3.2 vs lib/airake/tasks/air.rake in airake-0.4.0

- old
+ new

@@ -1,31 +1,39 @@ namespace :air do desc "Compile" task :compile => :clean do begin - project = Airake::Project.new_from_rake(ENV) + project = Airake::Project.new fcsh = PatternPark::FCSH.new_from_rake(ENV) fcsh.execute([ project.base_dir, project.amxmlc.compile ]) rescue PatternPark::FCSHConnectError => e puts "Cannot connect to FCSHD (start by running: rake fcsh:start); Continuing compilation..." Airake::Runner.run(project.amxmlc, :compile) end end desc "Test" - task :test => :clean do - ENV["DEBUG"] = "true" unless ENV.has_key?("DEBUG") - test_project = Airake::Project.new_from_rake(ENV, :test) + task :test do + ENV["AIRAKE_ENV"] = "test" + Rake::Task["air:clean"].invoke + + test_project = Airake::Project.new Airake::Runner.run(test_project.amxmlc, :compile) Airake::Runner.run(test_project.adl, :launch) end desc "Generate certificate" task :certificate do + pfx_file = ENV["CERTIFICATE"] + unless pfx_file + project = Airake::Project.new + pfx_file = project.certificate + end + if pfx_file.blank? || pfx_file == "path/to/certificate.pfx" print "Certificate file (to create; e.g. cert.pfx): " pfx_file = STDIN.gets.chomp! end @@ -37,11 +45,11 @@ end puts "Will generate a certificate file at: #{pfx_file}" - project = Airake::Project.new_from_rake(ENV) + project = Airake::Project.new optionals = {} print "Specify common name (e.g. SelfSign, ADigitalID) [SelfSign]: " cn = STDIN.gets.chomp! cn = "SelfSign" if cn.blank? @@ -68,13 +76,18 @@ # Check certificate configuration for package task task :check_certificate do pfx_file = ENV["CERTIFICATE"] + unless pfx_file + project = Airake::Project.new + pfx_file = project.certificate + end + if pfx_file.blank? || pfx_file == "path/to/certificate.pfx" raise <<-EOS - No certificate path found (or not set). Please specify ENV[\"CERTIFICATE\"] = \"path/to/certificate.pfx\" in Rakefile. + No certificate path found (or not set). Please specify ENV[\"CERTIFICATE\"] = \"path/to/certificate.pfx\" in Rakefile. Or certificate: path/to/cert.pfx in airake.yml. If you don't have a certificate run rake air:certificate to generate one. EOS end raise "Certificate does not exist yet. Run rake air:certificate to generate one at #{pfx_file}" unless File.exist?(pfx_file) @@ -83,11 +96,11 @@ desc "Package" task :package => [ :check_certificate, :compile, :package_only ] do; end desc "Package only" task :package_only do - project = Airake::Project.new_from_rake(ENV) + project = Airake::Project.new Airake::Runner.run(project.adt, :package) end task :set_debug do ENV["DEBUG"] = "true" unless ENV.has_key?("DEBUG") @@ -96,11 +109,11 @@ desc "Launch ADL" task :adl => [ :set_debug, :compile, :adl_only ] do; end desc "Launch ADL only" task :adl_only do - project = Airake::Project.new_from_rake(ENV) + project = Airake::Project.new Airake::Runner.run(project.adl, :launch) end desc "Compile component" task :acompc do @@ -138,24 +151,16 @@ Airake::Runner.run(Airake::Commands::Acompc.new(:source_path => source_path, :include_packages => packages.split(" "), :output_path => output_path), :compile) end desc "Docs" task :docs do - project = Airake::Project.new_from_rake(ENV) + project = Airake::Project.new Airake::Runner.run(project.asdoc, :generate) end desc "Clean" task :clean do - project = Airake::Project.new_from_rake(ENV) - paths = project.to_clean - - # Test - test_project = Airake::Project.new_from_rake(ENV, :test) - paths += project.to_clean - - paths.each do |path| - FileUtils.rm(path, :verbose => true) if File.exist?(path) - end + project = Airake::Project.new + project.clean end end \ No newline at end of file