Class: CommandPlugin
- Inherits:
-
Object
- Object
- CommandPlugin
- Extended by:
- Plugin, PluginType
- Defined in:
- lib/mvn2/plugin/command.plugin.rb
Class Method Summary collapse
Class Method Details
.def_actions ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/mvn2/plugin/command.plugin.rb', line 49 def self.def_actions register(:before_start, order: 10) { || run_cmd([:run_before]) } register(:after_end, order: 10) { |, result| run_cmd([:run_after]) result ? run_cmd([:run_success]) : run_cmd([:run_failure]) } end |
.def_options ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/mvn2/plugin/command.plugin.rb', line 7 def self. register :option_with_param, sym: :command_override, names: ['--command-override'], desc: 'override the maven command (disables average tracking options and skip test option)' register :option, sym: :package, names: %w(-p --package), desc: 'run "mvn clean package" (with optional "-D skipTests")' register :option_with_param, sym: :run_before, names: ['--run-before'], desc: 'run a command before calling the maven build' register :option_with_param, sym: :run_after, names: ['--run-after'], desc: 'run a command after finishing the maven build' register :option_with_param, sym: :run_success, names: ['--run-success'], desc: 'run a command after finishing a successful maven build' register :option_with_param, sym: :run_failure, names: ['--run-failure'], desc: 'run a command after finishing an unsuccessful maven build' register :option_with_param, sym: :run_test, names: ['--run-test'], desc: 'run a specific test class or method(s) (support dependent on maven surefire plugin version)' register :option_with_param, sym: :maven_option, names: ['--maven-option'], desc: 'specify a maven option (leave off the -D)', append: true register :option_with_param, sym: :maven_profile, names: ['--maven-profile'], desc: 'specify a maven profile' register :option, sym: :test_only, names: %w(-o --test-only), desc: 'instead of cleaning and rebuilding before running tests, only run test-compile before running tests' end |
.def_others ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/mvn2/plugin/command.plugin.rb', line 22 def self.def_others # register :goal_override, order: 10, option: :package, goal: 'package' register(:goal_override, order: 10) { || ([:run_test].nil? && ![:test_only] && [:package]) ? 'package' : nil } register(:goal_override, order: 20) { || ([:run_test].nil? && ![:test_only]) ? nil : 'test' } register :clean_block, option: :test_only register :goal_override, order: 10, option: :test_only, goal: 'test-compile' register(:command_flag) { |, flags| flags << ' -Dtest=' << [:run_test] << ' -DfailIfNoTests=false' unless [:run_test].nil? } register(:command_flag) { |, flags| [:maven_option].each { |opt| flags << " -D#{opt}" } unless [:maven_option].nil? || [:maven_option].empty? } register(:command_flag) { |, flags| flags << ' -P ' << [:maven_profile] unless [:maven_profile].nil? } register :goal_override, override_all: true, priority: 100, option: :command_override register(:full_avg_name, order: 20) { || [:package] ? '-package' : '' } register(:operation_name, priority: 100) { || [:command_override].nil? ? nil : 'Operation' } register(:block_average) { || ![:command_override].nil? || ![:run_test].nil? || [:test_only] } end |
.run_cmd(cmd) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/mvn2/plugin/command.plugin.rb', line 60 def self.run_cmd(cmd) unless cmd.nil? puts "$ #{cmd}" system(cmd) print "\n" end end |