# # Copyright (C) 2009 Red Hat, Inc. # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. The # ASF licenses this file to you 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. # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require 'rake' require 'rake/testtask' require 'rake/gempackagetask' begin require 'ci/reporter/rake/test_unit' rescue LoadError end desc "Run basic unit tests" Rake::TestTask.new("test") { |t| t.test_files = FileList[ 'tests/api_test.rb', 'tests/hardware_profiles_test.rb', 'tests/realms_test.rb', 'tests/images_test.rb', 'tests/instances_test.rb', 'tests/instance_states_test.rb', 'tests/url_for_test.rb' ] t.verbose = true t.warning = false } begin require 'yard' YARD::Rake::YardocTask.new do |t| t.files = ['lib/**/*.rb', '*.rb'] # optional end rescue LoadError end @specs = ['ruby', 'java'].inject({}) do |hash, spec_platform| $platform = spec_platform hash.update(spec_platform => Gem::Specification.load('deltacloud-core.gemspec')) end @specs.values.each do |spec| Rake::GemPackageTask.new(spec) do |pkg| pkg.need_tar = true end end desc "Install API" task :install, [:install_dir, :bin_dir] do |t, args| require 'fileutils' require 'pp' files = FileList[ Dir["config/**/**"], Dir["features/**/**"], Dir["lib/**/**"], Dir["public/**/**"], Dir["views/**/**"], "config.ru", "COPYING", "README", "*.rb" ] INSTALL_DIR=args.install_dir || "/usr/local/share/deltacloud-core" BIN_DIR=args.bin_dir || "/usr/local/bin" exit(1) unless FileUtils.mkdir_p(INSTALL_DIR) exit(1) unless FileUtils.mkdir_p(BIN_DIR) files.each do |f| install_path = "#{INSTALL_DIR}/#{File.dirname(f)}" unless File.directory?(install_path) FileUtils.mkdir_p(install_path, :mode => 0755, :verbose => true) end next if File.directory?(f) FileUtils.install(f, "#{INSTALL_DIR}/#{File.dirname(f)}", :verbose => true) end FileUtils.install('bin/deltacloudd', BIN_DIR, :verbose => true, :mode => 0755) end desc "Uninstall API" task :uninstall do require 'fileutils' INSTALL_DIR="/usr/share/deltacloud-core" FileUtils.rm_rf(INSTALL_DIR) end