def define(definition_name, template_name, options = {})

      # Default is not to overwrite
      options = { 'force' => false }.merge(options)

      env.logger.debug("Forceflag : #{options['force']}")

      git_template = false
      # Check if the template is a git repo
      if template_name.start_with?("git://", "git+ssh://", "git+http://")
        git_template = true
      end

      # Check if template exists
      template = env.templates[template_name]
      if template.nil? and ! git_template
        env.logger.fatal("Template '#{template_name}' does not exist")
        raise Veewee::TemplateError, "Template '#{template_name}' does not exist"
      else
        env.logger.debug("Template '#{template_name}' exists")
      end

      create_definition_dir_if_needed

      # Check if definition does not exist
      definition = env.definitions[definition_name]
      unless definition.nil?
        env.logger.debug("Definition '#{definition_name}' exists")
        if options['force'] == true
          self.undefine(definition_name, options)
        else
          raise Veewee::DefinitionError, "Definition #{definition_name} already exists and no force option was given"
        end
      end

      env.logger.info("Creating definition #{definition_name} in directory '#{env.definition_dir}' ")
      dst_dir = "#{File.join(env.definition_dir, definition_name)}"
      FileUtils.mkdir(dst_dir)
      env.logger.debug("Definition Directory '#{File.join(env.definition_dir, definition_name)}' succesfuly created")

      # Start copying/cloning the directory of the template to the definition directory
      if (git_template)
        begin
          env.logger.info("Starting git clone #{template_name} #{dst_dir}")
          g = Grit::Git.new(dst_dir)
          g.clone({ :timeout => false }, template_name, dst_dir)
        rescue Exception => ex
          err = "git clone #{template_name} #{dst_dir} failed: #{ex}"
          env.logger.fatal(err)
          raise Veewee::DefinitionError, err
        end
      else
        begin
          env.logger.debug("Starting copy '#{template.path}' to '#{dst_dir}'")
          FileUtils.cp_r(template.path + "/.", dst_dir, :preserve => true)
          env.logger.debug("Copy '#{template.path}' to '#{dst_dir}' succesful")
        rescue Exception => ex
          env.logger.fatal("Copy '#{template.path}' to #{dst_dir}' failed: #{ex}")
          raise Veewee::Error, "Copy '#{template.path}' to #{dst_dir}' failed: #{ex}"
        end
      end

      # If the template includes a NOTICE.erb or NOTICE.txt file, display it to the user
      # .erb file takes priority, then .txt
      notice_erb = File.join(dst_dir, 'NOTICE.erb')
      notice_txt = File.join(dst_dir, 'NOTICE.txt')
      if File.exist?(notice_erb)
        template = File.read(notice_erb)
        text = ERB.new(template).result(binding)
      elsif File.exist?(notice_txt)
        text = File.read(notice_txt)
      end

      if text
        env.ui.warn("Template #{template_name} includes this NOTICE text you should first read:\n")
        env.ui.info("#{text}\n")
      end

      definition = env.definitions[definition_name]
      return definition
    end
def define(definition_name, template_name, options = {})

      # Default is not to overwrite
      options = { 'force' => false }.merge(options)

      env.logger.debug("Forceflag : #{options['force']}")

      git_template = false
      # Check if the template is a git repo
      if template_name.start_with?("git://", "git+ssh://", "git+http://")
        git_template = true
      end

      # Check if template exists
      template = env.templates[template_name]
      if template.nil? and ! git_template
        env.logger.fatal("Template '#{template_name}' does not exist")
        raise Veewee::TemplateError, "Template '#{template_name}' does not exist"
      else
        env.logger.debug("Template '#{template_name}' exists")
      end

      create_definition_dir_if_needed

      # Check if definition does not exist
      definition = env.definitions[definition_name]
      unless definition.nil?
        env.logger.debug("Definition '#{definition_name}' exists")
        if options['force'] == true
          self.undefine(definition_name, options)
        else
          raise Veewee::DefinitionError, "Definition #{definition_name} already exists and no force option was given"
        end
      end

      env.logger.info("Creating definition #{definition_name} in directory '#{env.definition_dir}' ")
      dst_dir = "#{File.join(env.definition_dir, definition_name)}"
      FileUtils.mkdir(dst_dir)
      env.logger.debug("Definition Directory '#{File.join(env.definition_dir, definition_name)}' succesfuly created")

      # Start copying/cloning the directory of the template to the definition directory
      if (git_template)
        begin
          env.logger.info("Starting git clone #{template_name} #{dst_dir}")
          g = Grit::Git.new(dst_dir)
          g.clone({ :timeout => false }, template_name, dst_dir)
        rescue Exception => ex
          err = "git clone #{template_name} #{dst_dir} failed: #{ex}"
          env.logger.fatal(err)
          raise Veewee::DefinitionError, err
        end
      else
        begin
          env.logger.debug("Starting copy '#{template.path}' to '#{dst_dir}'")
          FileUtils.cp_r(template.path + "/.", dst_dir, :preserve => true)
          env.logger.debug("Copy '#{template.path}' to '#{dst_dir}' succesful")
        rescue Exception => ex
          env.logger.fatal("Copy '#{template.path}' to #{dst_dir}' failed: #{ex}")
          raise Veewee::Error, "Copy '#{template.path}' to #{dst_dir}' failed: #{ex}"
        end
      end

      # If the template includes a NOTICE.erb or NOTICE.txt file, display it to the user
      # .erb file takes priority, then .txt
      notice_erb = File.join(dst_dir, 'NOTICE.erb')
      notice_txt = File.join(dst_dir, 'NOTICE.txt')
      if File.exist?(notice_erb)
        template = File.read(notice_erb)
        text = ERB.new(template).result(binding)
      elsif File.exist?(notice_txt)
        text = File.read(notice_txt)
      end

      if text
        env.ui.warn("Template #{template_name} includes this NOTICE text you should first read:\n")
        env.ui.info("#{text}\n")
      end

      definition = env.definitions[definition_name]
      return definition
    end
This function 'defines'/'clones'/'instantiates a template:
 It copies from a template dir with template_name
           to a new definition dir with definition_name

 Options are : :force => true to overwrite an existing definition

 Returns definition object