Class: PluginGenerator

Inherits:
VraptorScaffold::Base show all
Defined in:
lib/vraptor-scaffold/generators/plugin/plugin_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, opts = []) ⇒ PluginGenerator



15
16
17
18
19
# File 'lib/vraptor-scaffold/generators/plugin/plugin_generator.rb', line 15

def initialize(args, opts=[])
  super([args], opts)
  @version = options[:version]
  @group = options[:group]
end

Class Method Details



11
12
13
# File 'lib/vraptor-scaffold/generators/plugin/plugin_generator.rb', line 11

def self.banner
  "vraptor plugin #{self.arguments.map(&:usage).join(' ')} [options]"
end

Instance Method Details

#buildObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/vraptor-scaffold/generators/plugin/plugin_generator.rb', line 21

def build
  if is_ivy?
    plugin = "\n\t\t<dependency org=\"#{@group}\" name=\"#{name}\" rev=\"#{@version}\" conf=\"default\" />"
    inject_into_file("ivy.xml", plugin, :after => "<dependencies>")
  elsif is_maven?
    plugin = "\n\t\t<dependency>\n\t\t\t<groupId>#{@group}</groupId>\n\t\t\t<artifactId>#{name}</artifactId>\n\t\t\t<version>#{@version}</version>\n\t\t</dependency>"
    inject_into_file("pom.xml", plugin, :after => "<dependencies>")
  else
    plugin = "\n    compile group: '#{@group}', name: '#{name}', version: '#{@version}'\n"
    inject_into_file("build.gradle", plugin, :after => "dependencies {")
  end
end

#is_ivy?Boolean



34
35
36
# File 'lib/vraptor-scaffold/generators/plugin/plugin_generator.rb', line 34

def is_ivy?
  File.exist?("ivy.xml")
end

#is_maven?Boolean



38
39
40
# File 'lib/vraptor-scaffold/generators/plugin/plugin_generator.rb', line 38

def is_maven?
  File.exist?("pom.xml")
end