# File lib/buildr/java/packaging.rb, line 414
        def add(*args)
          options = Hash === args.last ? args.pop.clone : {}
          args.flatten!
          args.map! do |pkg|
            case pkg
            when Project
              pkg.packages.select { |pp| JarTask === pp && SUPPORTED_TYPES.include?(pp.type) }
            when Rake::FileTask
              pkg # add the explicitly provided file
            when Hash
              Buildr.artifact(pkg)
            when String
              begin
                Buildr.artifact(pkg)
              rescue # not an artifact spec, it must me a filename
                file(pkg)
              end
            else
              raise "Invalid EAR component #{pkg.class}: #{pkg}"
            end
          end
          args.flatten!
          args.compact!
          if args.empty?
            raise ":type must not be specified for type=>component argument style" if options.key?(:type)
            raise ":as must not be specified for type=>component argument style" if options.key?(:as)
            comps = {}
            options.delete_if { |k, v| comps[k] = v if SUPPORTED_TYPES.include?(k) }
            raise "You must specify at least one valid component to add" if comps.empty?
            comps.each { |k, v| add(v, {:as => k}.merge(options)) }
          else
            args.each do |artifact|
              type = options[:as] || options[:type]
              unless type
                type = artifact.respond_to?(:type) ? artifact.type : artifact.to_s.pathmap('%x').to_sym
                type = :lib if type == :jar
              end
              raise "Unknown EAR component type: #{type}. Perhaps you may explicity tell what component type to use." unless
                SUPPORTED_TYPES.include?(type)
              component = options.merge(:artifact => artifact, :type => type,
                :id=>artifact.respond_to?(:to_spec) ? artifact.id : artifact.to_s.pathmap('%n'),
                :path=>options[:path] || dirs[type].to_s)
              component[:clone] = component_clone(component) unless :lib == type
              # update_classpath(component) unless :lib == type || Artifact === artifact
              @components << component
            end
          end
          self
        end