Sha256: 0ad5ffe178a56faa99d17d41b8a69e83ba400635885d61e8292c96f2a12c97b0

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

class PluginGenerator < VraptorScaffold::Base

  argument :name

  class_option :group, :default => "br.com.caelum.vraptor", :aliases => "-g",
               :desc => "Plugin group"

  class_option :version, :aliases => "-v",
               :desc => "Plugin version"

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

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

  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

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

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

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vraptor-scaffold-1.3.0 lib/vraptor-scaffold/generators/plugin/plugin_generator.rb
vraptor-scaffold-1.3.0.rc lib/vraptor-scaffold/generators/plugin/plugin_generator.rb
vraptor-scaffold-1.2.3 lib/vraptor-scaffold/generators/plugin/plugin_generator.rb
vraptor-scaffold-1.2.1 lib/vraptor-scaffold/generators/plugin/plugin_generator.rb
vraptor-scaffold-1.2.0 lib/vraptor-scaffold/generators/plugin/plugin_generator.rb