lib/puck/jar.rb
# Create a new instance with the specified configuration.
#
# Puck tries to use sane defaults like assuming that the application name
# is the same as the name of the directory containing the "lib" directory.
#
# @param [Hash] configuration
# @option configuration [String] :extra_files a list of files to include in
#   the Jar. The paths must be below the `:app_dir`.
# @option configuration [String] :gem_groups ([:default]) a list of gem
#   groups to include in the Jar. Remember to include the default group if
#   you override this option.
# @option configuration [String] :jruby_complete a path to the
#   `jruby-complete.jar` that you want to use. If you don't specify this
#   option you need to have `jruby-jars` in your `Gemfile` (it contains
#   the equivalent of `jruby-complete.jar`. This option is mostly useful
#   when you have a customized JRuby runtime that you want to use.
# @option configuration [String] :app_dir (Dir.pwd)
#   the application's base directory (i.e. the directory that contains the
#   "lib" directory)
# @option configuration [String] :app_name (File.basename(configuration[:app_dir]))
#   the name of the application, primarily used to name the Jar
# @option configuration [String] :build_dir ("build") the directory where
#   the Jar file will be created
#
Create a new instance with the specified configuration.
Puck tries to use sane defaults like assuming that the application name
is the same as the name of the directory containing the "lib" directory.
Create a new instance with the specified configuration . Puck tries to use sane defaults like assuming that the application name is the same as the name of the directory containing the " lib " directory .
def resolve_gem_dependencies
      gem_specs = Bundler::LockfileParser.new(File.read('Gemfile.lock')).specs.group_by(&:name)
      definition = Bundler::Definition.build('Gemfile', 'Gemfile.lock', false)
      dependencies = definition.dependencies.select { |d| (d.groups & @configuration[:gem_groups]).any? }.map(&:name)
      specs = resolve_gem_specs(gem_specs, dependencies)
      specs = specs.map do |bundler_spec|
        case bundler_spec.source
        when Bundler::Source::Git
          revision = bundler_spec.source.options['revision']
          gemspec_path = File.join(ENV['GEM_HOME'], 'bundler', 'gems', "#{bundler_spec.name}-#{revision[0, 12]}", "#{bundler_spec.name}.gemspec")
          base_path = File.dirname(gemspec_path)
        else
          gemspec_path = File.join(ENV['GEM_HOME'], 'specifications', "#{bundler_spec.full_name}.gemspec")
          base_path = File.join(ENV['GEM_HOME'], 'gems', bundler_spec.full_name)
        end
        if File.exists?(gemspec_path)
          gem_spec = Gem::Specification.load(gemspec_path)
          load_paths = gem_spec.load_paths.map do |load_path|
            index = load_path.index(gem_spec.full_name)
            File.join(JAR_GEM_HOME, load_path[index, load_path.length - index])
          end
          bin_path = File.join(JAR_GEM_HOME, gem_spec.full_name, gem_spec.bindir)
          {
            :name => gem_spec.name,
            :versioned_name => gem_spec.full_name,
            :base_path => base_path,
            :jar_path => File.join(JAR_GEM_HOME, gem_spec.full_name),
            :load_paths => load_paths,
            :bin_path => bin_path,
          }
        else
          nil
        end
      end
      specs.compact.uniq { |s| s[:versioned_name] }
    end
def resolve_gem_dependencies gem_specs = Bundler :: LockfileParser . new ( File . read ( 'Gemfile.lock' ) ) . specs . group_by ( & :name ) definition = Bundler :: Definition . build ( 'Gemfile' , 'Gemfile.lock' , false ) dependencies = definition . dependencies . select { | d | ( d . groups & @configuration [ :gem_groups ] ) . any? } . map ( & :name ) specs = resolve_gem_specs ( gem_specs , dependencies ) specs = specs . map do | bundler_spec | case bundler_spec . source when Bundler :: Source :: Git revision = bundler_spec . source . options [ 'revision' ] gemspec_path = File . join ( ENV [ 'GEM_HOME' ] , 'bundler' , 'gems' , "#{bundler_spec.name}-#{revision[0, 12]}" , "#{bundler_spec.name}.gemspec" ) base_path = File . dirname ( gemspec_path ) else gemspec_path = File . join ( ENV [ 'GEM_HOME' ] , 'specifications' , "#{bundler_spec.full_name}.gemspec" ) base_path = File . join ( ENV [ 'GEM_HOME' ] , 'gems' , bundler_spec . full_name ) end if File . exists? ( gemspec_path ) gem_spec = Gem :: Specification . load ( gemspec_path ) load_paths = gem_spec . load_paths . map do | load_path | index = load_path . index ( gem_spec . full_name ) File . join ( JAR_GEM_HOME , load_path [ index , load_path . length - index ] ) end bin_path = File . join ( JAR_GEM_HOME , gem_spec . full_name , gem_spec . bindir ) { :name => gem_spec . name , :versioned_name => gem_spec . full_name , :base_path => base_path , :jar_path => File . join ( JAR_GEM_HOME , gem_spec . full_name ) , :load_paths => load_paths , :bin_path => bin_path , } else nil end end specs . compact . uniq { | s | s [ :versioned_name ] } end
Create a new instance with the specified configuration.
Create a new instance with the specified configuration .
<not_specific>
None
configuration
<not_specific>
:build_dir ("build") the directory where the Jar file will be created
: build_dir ( " build " ) the directory where the Jar file will be created