Class: Doubleshot::CLI::Commands::Gem

Inherits:
Doubleshot::CLI show all
Defined in:
lib/doubleshot/commands/gem.rb

Constant Summary

Constants inherited from Doubleshot::CLI

USAGE

Class Method Summary collapse

Methods inherited from Doubleshot::CLI

commands, detect, inherited, task_name, usage

Class Method Details

.optionsObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/doubleshot/commands/gem.rb', line 10

def self.options
  Options.new do |options|
    options.banner = "Usage: doubleshot gem"
    options.separator ""
    options.separator "Options"

    options.test = true
    options.on "--no-test", "Disable testing as a packaging prerequisite." do
      options.test = false
    end

    options.separator ""
    options.separator "Summary: #{summary}"
  end
end

.start(args) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/doubleshot/commands/gem.rb', line 26

def self.start(args)
  options = self.options.parse!(args)
  doubleshot = Doubleshot::current

  if options.test
    puts "Executing tests..."
    if Doubleshot::CLI::Commands::Test.start([ "--ci" ]) != 0
      STDERR.puts "Test failed, aborting Gem creation."
      return 1
    end
  else
    doubleshot.setup!
    doubleshot.build! false
  end

  target = doubleshot.config.target
  jarfile = target + "#{doubleshot.config.project}.jar"
  jarfile.delete if jarfile.exist?
  
  begin
    unless Pathname::glob(doubleshot.config.source.java + "**/*.java").empty?
      ant.jar jarfile: jarfile, basedir: target do
        doubleshot.lockfile.jars.each do |jar|
          zipfileset src: jar.path.expand_path, excludes: "META-INF/*.SF"
        end
      end
    end

    # WARN: This is version specific since in HEAD they've changed this to Gem::Package::build.
    ::Gem::Builder.new(doubleshot.config.gemspec).build
  ensure
    jarfile.delete if jarfile.exist?
  end

  puts("  Size: %.2fM" % (Pathname(doubleshot.config.gemspec.file_name).size.to_f / 1024 / 1024))

  return 0
end

.summaryObject



3
4
5
6
7
8
# File 'lib/doubleshot/commands/gem.rb', line 3

def self.summary
  <<-EOS.margin
    Package your project as a Rubygem, bundling any
    JAR dependencies and Java classes in with the distribution.
  EOS
end