maven-helper-script 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +4 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +31 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +56 -0
- data/Rakefile +35 -0
- data/VERSION +1 -0
- data/bin/m +5 -0
- data/lib/argument_parser.rb +57 -0
- data/lib/configuration_checker.rb +62 -0
- data/lib/project_home_finder.rb +37 -0
- data/lib/script_runner.rb +51 -0
- data/maven-helper-script.gemspec +69 -0
- data/sample-mvn-project/m.yml +17 -0
- data/sample-mvn-project/other/pom.xml +17 -0
- data/sample-mvn-project/parent/pom.xml +12 -0
- data/sample-mvn-project/pom.xml +17 -0
- data/test/argument_parser_spec.rb +52 -0
- data/test/configuration_checker_spec.rb +34 -0
- data/test/m.yml +16 -0
- data/test/project_home_finder_spec.rb +23 -0
- metadata +136 -0
data/.document
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.3)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.8.4)
|
7
|
+
bundler (~> 1.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
rdoc
|
11
|
+
json (1.7.3)
|
12
|
+
rake (0.9.2.2)
|
13
|
+
rdoc (3.12)
|
14
|
+
json (~> 1.4)
|
15
|
+
rspec (2.11.0)
|
16
|
+
rspec-core (~> 2.11.0)
|
17
|
+
rspec-expectations (~> 2.11.0)
|
18
|
+
rspec-mocks (~> 2.11.0)
|
19
|
+
rspec-core (2.11.1)
|
20
|
+
rspec-expectations (2.11.2)
|
21
|
+
diff-lcs (~> 1.1.3)
|
22
|
+
rspec-mocks (2.11.2)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
x86-mingw32
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
bundler (~> 1.2.0)
|
29
|
+
jeweler (~> 1.8.4)
|
30
|
+
rdoc (~> 3.12)
|
31
|
+
rspec (~> 2.11.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 to the original authors
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
= Maven Helper Script
|
2
|
+
|
3
|
+
== What is it?
|
4
|
+
|
5
|
+
A script to simplify how you execute Maven commands. For example, instead of:
|
6
|
+
|
7
|
+
mvn clean install -pl parent && mvn clean install -pl domain
|
8
|
+
|
9
|
+
You can do something like:
|
10
|
+
|
11
|
+
m ci p ci d
|
12
|
+
|
13
|
+
All you need is a YAML file with contents like this:
|
14
|
+
|
15
|
+
modules:
|
16
|
+
p: parent
|
17
|
+
d: domain
|
18
|
+
|
19
|
+
commands:
|
20
|
+
- clean
|
21
|
+
- install
|
22
|
+
- jetty:run
|
23
|
+
|
24
|
+
arguments:
|
25
|
+
- -ff
|
26
|
+
|
27
|
+
== Additional Features
|
28
|
+
|
29
|
+
If you don't want to define a mapping for your module, you can use it's name.
|
30
|
+
|
31
|
+
m ci parent ci d
|
32
|
+
|
33
|
+
You can also create shorthand commands for various plugin phases. For example, executing "jetty:run" on your "web module could be:
|
34
|
+
|
35
|
+
m jr web
|
36
|
+
|
37
|
+
All parameters passed into the helper script are applied to every execution. So you only need to flag a command like offline mode once:
|
38
|
+
|
39
|
+
m ci web ci parent -o
|
40
|
+
|
41
|
+
Including the optional "arguments:" mapping in your m.yml file allows you to apply arguments without typing them in the command line. The example "m.yml above would trigger the "-ff" arg for maven.
|
42
|
+
|
43
|
+
Commands can be executed in any directory of your project, as long as there is an "m.yml" file in your project's top-level directory.
|
44
|
+
|
45
|
+
== How do I use it?
|
46
|
+
- Make sure you have ruby installed and on your path.
|
47
|
+
- Check out the project to a directory on your machine.
|
48
|
+
- From the checkout directory, type "rake install".
|
49
|
+
- Find one of your existing maven projects and put an "m.yml" file like the one above in the top-level directory.
|
50
|
+
- In a command window, "cd" to a directory in your project.
|
51
|
+
- Execute a command.
|
52
|
+
|
53
|
+
If you're having trouble, take a look at the sample-mvn-project located within the project on github.
|
54
|
+
|
55
|
+
== To Do
|
56
|
+
- Support commands in the form of a map, similar to how the modules are defined.
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
|
6
|
+
begin
|
7
|
+
Bundler.setup(:default, :development)
|
8
|
+
rescue Bundler::BundlerError => e
|
9
|
+
$stderr.puts e.message
|
10
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
11
|
+
exit e.status_code
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'rake'
|
15
|
+
require 'jeweler'
|
16
|
+
|
17
|
+
Jeweler::Tasks.new do |gem|
|
18
|
+
gem.name = "maven-helper-script"
|
19
|
+
gem.homepage = "http://github.com/kingOburgers/mvn-helper-script"
|
20
|
+
gem.summary = %Q{Ruby gem to simplify maven command execution}
|
21
|
+
gem.description = %Q{Execute your complex maven commands faster with the shortened helper syntax. See the rdoc for more details and examples.}
|
22
|
+
gem.email = "kieferfam@msn.com"
|
23
|
+
gem.authors = ["kingOburgers"]
|
24
|
+
end
|
25
|
+
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core/rake_task'
|
29
|
+
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = 'test/**/*_spec.rb'
|
32
|
+
end
|
33
|
+
|
34
|
+
task :default => :spec
|
35
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/m
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative 'configuration_checker'
|
2
|
+
|
3
|
+
module MavenHelperScript
|
4
|
+
|
5
|
+
class ArgumentParser
|
6
|
+
def initialize(file)
|
7
|
+
@projectPom = File.join(file, "pom.xml")
|
8
|
+
@configChecker = MavenHelperScript::ConfigurationChecker.new(file)
|
9
|
+
end
|
10
|
+
|
11
|
+
public
|
12
|
+
def parse(args)
|
13
|
+
resultingCommands = Array[]
|
14
|
+
specialtyCommands = @configChecker.checkForArguments()
|
15
|
+
result = ""
|
16
|
+
processingCommand = true
|
17
|
+
|
18
|
+
args.each do |arg|
|
19
|
+
if isSpecialtyCommand arg
|
20
|
+
specialtyCommands << arg
|
21
|
+
else
|
22
|
+
if processingCommand
|
23
|
+
result << "mvn " << @configChecker.checkForCommand(arg)
|
24
|
+
processingCommand = false
|
25
|
+
else
|
26
|
+
foundModule = @configChecker.checkForModule(arg)
|
27
|
+
result << " -pl " << foundModule << " -f " << @projectPom
|
28
|
+
resultingCommands << result
|
29
|
+
result = ""
|
30
|
+
processingCommand = true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
applySpecialtyCommandsTo(specialtyCommands, resultingCommands)
|
36
|
+
|
37
|
+
resultingCommands
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def applySpecialtyCommandsTo(specialtyCommands, resultingCommands)
|
42
|
+
specialtyCommands.each do |command|
|
43
|
+
resultingCommands.each do |it|
|
44
|
+
it = it << " " << command
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def isSpecialtyCommand(command)
|
50
|
+
if command.start_with?('-')
|
51
|
+
return true
|
52
|
+
end
|
53
|
+
false
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module MavenHelperScript
|
4
|
+
|
5
|
+
class ConfigurationChecker
|
6
|
+
def initialize(file)
|
7
|
+
@yml = YAML::load_file(File.join(file, 'm.yml'))
|
8
|
+
@commands = buildCommandKeys()
|
9
|
+
end
|
10
|
+
|
11
|
+
public
|
12
|
+
def checkForArguments()
|
13
|
+
@yml['arguments'] || Array[]
|
14
|
+
end
|
15
|
+
|
16
|
+
def checkForModule(mapping)
|
17
|
+
@yml['modules'][mapping] || mapping
|
18
|
+
end
|
19
|
+
|
20
|
+
def checkForCommand(mapping)
|
21
|
+
result = @commands[mapping]
|
22
|
+
|
23
|
+
if !result
|
24
|
+
result = ""
|
25
|
+
mapping.each_char do |character|
|
26
|
+
result << findCommandFor(character) << " "
|
27
|
+
end
|
28
|
+
result.strip!
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
if !result || result.empty?
|
33
|
+
raise "Unable to locate command for: " << mapping
|
34
|
+
end
|
35
|
+
|
36
|
+
result
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def buildCommandKeys()
|
41
|
+
commandKeys = Hash.new()
|
42
|
+
@yml['commands'].each do |phase|
|
43
|
+
if phase.include? ':'
|
44
|
+
key = ""
|
45
|
+
phase.split(':').each do |part|
|
46
|
+
key << part[0]
|
47
|
+
end
|
48
|
+
commandKeys[key] = phase
|
49
|
+
else
|
50
|
+
commandKeys[phase[0]] = phase
|
51
|
+
end
|
52
|
+
end
|
53
|
+
commandKeys
|
54
|
+
end
|
55
|
+
|
56
|
+
def findCommandFor(mapping)
|
57
|
+
@commands[mapping] || ""
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
module MavenHelperScript
|
4
|
+
|
5
|
+
class ProjectHomeFinder
|
6
|
+
public
|
7
|
+
def findProjectDirectory(file)
|
8
|
+
@originalPath = Pathname.new(File.expand_path(file))
|
9
|
+
@path = @originalPath
|
10
|
+
found = false
|
11
|
+
|
12
|
+
while !found
|
13
|
+
found = foundProjectArtifacts(File.join(@path))
|
14
|
+
if !found
|
15
|
+
if !outOfDirectoriesToCheck @path
|
16
|
+
@path = @path.parent
|
17
|
+
else
|
18
|
+
raise "Unable to locate configuration and project information for: " << @originalPath.to_s
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
File.join(@path)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def outOfDirectoriesToCheck(currentPath)
|
28
|
+
currentPath == currentPath.parent
|
29
|
+
end
|
30
|
+
|
31
|
+
def foundProjectArtifacts(file)
|
32
|
+
FileTest.exist?(File.join(file, 'm.yml')) && FileTest.exist?(File.join(file, 'pom.xml'))
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'argument_parser'
|
2
|
+
require 'project_home_finder'
|
3
|
+
|
4
|
+
module MavenHelperScript
|
5
|
+
|
6
|
+
class ScriptRunner
|
7
|
+
LINE = "\n-------------------------------------------------------------------------------\n\n"
|
8
|
+
|
9
|
+
def initialize()
|
10
|
+
finder = MavenHelperScript::ProjectHomeFinder.new
|
11
|
+
@projectFolder = finder.findProjectDirectory(File.expand_path("."))
|
12
|
+
@parser = MavenHelperScript::ArgumentParser.new(@projectFolder)
|
13
|
+
end
|
14
|
+
|
15
|
+
def run(args)
|
16
|
+
commands = @parser.parse(args)
|
17
|
+
|
18
|
+
successful = true
|
19
|
+
i = 0
|
20
|
+
|
21
|
+
while successful && i < commands.length
|
22
|
+
command = commands[i]
|
23
|
+
puts LINE
|
24
|
+
puts "#{command}"
|
25
|
+
puts LINE
|
26
|
+
|
27
|
+
successful = system command
|
28
|
+
i += 1
|
29
|
+
end
|
30
|
+
|
31
|
+
if successful
|
32
|
+
puts LINE
|
33
|
+
puts "Successfully executed the following commands: "
|
34
|
+
commands.each do |command|
|
35
|
+
puts " - " << command
|
36
|
+
end
|
37
|
+
puts LINE
|
38
|
+
else
|
39
|
+
puts LINE
|
40
|
+
puts "Failed executing command: " << command
|
41
|
+
puts LINE
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "maven-helper-script"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["kingOburgers"]
|
12
|
+
s.date = "2012-09-09"
|
13
|
+
s.description = "Execute your complex maven commands faster with the shortened helper syntax. See the rdoc for more details and examples."
|
14
|
+
s.email = "kieferfam@msn.com"
|
15
|
+
s.executables = ["m"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/m",
|
29
|
+
"lib/argument_parser.rb",
|
30
|
+
"lib/configuration_checker.rb",
|
31
|
+
"lib/project_home_finder.rb",
|
32
|
+
"lib/script_runner.rb",
|
33
|
+
"maven-helper-script.gemspec",
|
34
|
+
"sample-mvn-project/m.yml",
|
35
|
+
"sample-mvn-project/other/pom.xml",
|
36
|
+
"sample-mvn-project/parent/pom.xml",
|
37
|
+
"sample-mvn-project/pom.xml",
|
38
|
+
"test/argument_parser_spec.rb",
|
39
|
+
"test/configuration_checker_spec.rb",
|
40
|
+
"test/m.yml",
|
41
|
+
"test/project_home_finder_spec.rb"
|
42
|
+
]
|
43
|
+
s.homepage = "http://github.com/kingOburgers/mvn-helper-script"
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
s.rubygems_version = "1.8.24"
|
46
|
+
s.summary = "Ruby gem to simplify maven command execution"
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
s.specification_version = 3
|
50
|
+
|
51
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
53
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.2.0"])
|
54
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
55
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.11.0"])
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
58
|
+
s.add_dependency(%q<bundler>, ["~> 1.2.0"])
|
59
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
60
|
+
s.add_dependency(%q<rspec>, ["~> 2.11.0"])
|
61
|
+
end
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
64
|
+
s.add_dependency(%q<bundler>, ["~> 1.2.0"])
|
65
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
66
|
+
s.add_dependency(%q<rspec>, ["~> 2.11.0"])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
5
|
+
|
6
|
+
<parent>
|
7
|
+
<artifactId>sample-maven-project-parent</artifactId>
|
8
|
+
<groupId>org.burgers</groupId>
|
9
|
+
<version>1.0-SNAPSHOT</version>
|
10
|
+
<relativePath>../parent/pom.xml</relativePath>
|
11
|
+
</parent>
|
12
|
+
<modelVersion>4.0.0</modelVersion>
|
13
|
+
|
14
|
+
<artifactId>sample-maven-project-other</artifactId>
|
15
|
+
<packaging>pom</packaging>
|
16
|
+
|
17
|
+
</project>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
5
|
+
<modelVersion>4.0.0</modelVersion>
|
6
|
+
|
7
|
+
<groupId>org.burgers</groupId>
|
8
|
+
<artifactId>sample-maven-project-parent</artifactId>
|
9
|
+
<packaging>pom</packaging>
|
10
|
+
<version>1.0-SNAPSHOT</version>
|
11
|
+
|
12
|
+
</project>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
5
|
+
<modelVersion>4.0.0</modelVersion>
|
6
|
+
|
7
|
+
<groupId>org.burgers</groupId>
|
8
|
+
<artifactId>sample-maven-project</artifactId>
|
9
|
+
<packaging>pom</packaging>
|
10
|
+
<version>1.0-SNAPSHOT</version>
|
11
|
+
|
12
|
+
<modules>
|
13
|
+
<module>parent</module>
|
14
|
+
<module>other </module>
|
15
|
+
</modules>
|
16
|
+
|
17
|
+
</project>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
+
require "argument_parser"
|
3
|
+
|
4
|
+
describe MavenHelperScript::ArgumentParser do
|
5
|
+
before(:each) do
|
6
|
+
file = File.join(File.dirname(__FILE__))
|
7
|
+
@expectedPom = File.join(file, "pom.xml")
|
8
|
+
@parser = MavenHelperScript::ArgumentParser.new(file)
|
9
|
+
@expectedArgs = ' -ff -DskipTests'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should convert command and module then append parent pom" do
|
13
|
+
args = Array['ci', 'p']
|
14
|
+
result = @parser.parse(args)
|
15
|
+
result.length.should == 1
|
16
|
+
result[0].should == 'mvn clean install -pl parent -f ' << @expectedPom << @expectedArgs
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
it "should convert command, use given module, then append parent pom" do
|
21
|
+
args = Array['ci', 'parent']
|
22
|
+
result = @parser.parse(args)
|
23
|
+
result.length.should == 1
|
24
|
+
result[0].should == 'mvn clean install -pl parent -f ' << @expectedPom << @expectedArgs
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should convert command, module, append parent pom, and apply specialty arguments" do
|
28
|
+
args = Array['ci', 'p', '-o']
|
29
|
+
result = @parser.parse(args)
|
30
|
+
result.length.should == 1
|
31
|
+
result[0].should == 'mvn clean install -pl parent -f ' << @expectedPom << @expectedArgs << " -o"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should convert multiple arguments" do
|
35
|
+
args = Array['ci', 'p', 'ci', 'p']
|
36
|
+
result = @parser.parse(args)
|
37
|
+
result.length.should == 2
|
38
|
+
result[0].should == 'mvn clean install -pl parent -f ' << @expectedPom << @expectedArgs
|
39
|
+
result[1].should == 'mvn clean install -pl parent -f ' << @expectedPom << @expectedArgs
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should convert multiple arguments and append special commands" do
|
43
|
+
args = Array['ci', 'p', 'ci', 'p', '-o', '-blah']
|
44
|
+
result = @parser.parse(args)
|
45
|
+
result.length.should == 2
|
46
|
+
expected = 'mvn clean install -pl parent -f ' << @expectedPom << @expectedArgs << " -o" << " -blah"
|
47
|
+
result[0].should == expected
|
48
|
+
result[1].should == expected
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
+
require "configuration_checker"
|
3
|
+
|
4
|
+
describe MavenHelperScript::ConfigurationChecker do
|
5
|
+
before(:each) do
|
6
|
+
@checker = MavenHelperScript::ConfigurationChecker.new(File.join(File.dirname(__FILE__)))
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should find module by mapping" do
|
10
|
+
@checker.checkForModule("p").should == "parent"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should send back mapping name when no module found, assume that is the correct module name" do
|
14
|
+
@checker.checkForModule("boo").should == "boo"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should find command using first characters when not a plugin execution" do
|
18
|
+
@checker.checkForCommand("ci").should == "clean install"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should find plugin execution" do
|
22
|
+
@checker.checkForCommand("jr").should == "jetty:run"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should blow up when can't find command" do
|
26
|
+
expect {@checker.checkForCommand("j") }.to raise_error(RuntimeError, "Unable to locate command for: j")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return all command arguments" do
|
30
|
+
args = Array['-ff', '-DskipTests']
|
31
|
+
expect @checker.checkForArguments().should == args
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/test/m.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
+
require "project_home_finder"
|
3
|
+
|
4
|
+
describe MavenHelperScript::ProjectHomeFinder do
|
5
|
+
before(:each) do
|
6
|
+
@mvnProjectFolder = File.expand_path(File.join(File.dirname(__FILE__), "..", "sample-mvn-project"))
|
7
|
+
@finder = MavenHelperScript::ProjectHomeFinder.new()
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should find project folder from sub folder" do
|
11
|
+
@finder.findProjectDirectory(File.join(@mvnProjectFolder, "other")).should == @mvnProjectFolder
|
12
|
+
@finder.findProjectDirectory(File.join(@mvnProjectFolder, "parent")).should == @mvnProjectFolder
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should find project folder from project folder" do
|
16
|
+
@finder.findProjectDirectory(File.join(@mvnProjectFolder)).should == @mvnProjectFolder
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should blow up when can't find project folder" do
|
20
|
+
expect { @finder.findProjectDirectory(File.join(@mvnProjectFolder, "..")) }.to raise_error(RuntimeError)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: maven-helper-script
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- kingOburgers
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rdoc
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.12'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.12'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.2.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.2.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: jeweler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.8.4
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.4
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.11.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.11.0
|
78
|
+
description: Execute your complex maven commands faster with the shortened helper
|
79
|
+
syntax. See the rdoc for more details and examples.
|
80
|
+
email: kieferfam@msn.com
|
81
|
+
executables:
|
82
|
+
- m
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files:
|
85
|
+
- LICENSE.txt
|
86
|
+
- README.rdoc
|
87
|
+
files:
|
88
|
+
- .document
|
89
|
+
- Gemfile
|
90
|
+
- Gemfile.lock
|
91
|
+
- LICENSE.txt
|
92
|
+
- README.rdoc
|
93
|
+
- Rakefile
|
94
|
+
- VERSION
|
95
|
+
- bin/m
|
96
|
+
- lib/argument_parser.rb
|
97
|
+
- lib/configuration_checker.rb
|
98
|
+
- lib/project_home_finder.rb
|
99
|
+
- lib/script_runner.rb
|
100
|
+
- maven-helper-script.gemspec
|
101
|
+
- sample-mvn-project/m.yml
|
102
|
+
- sample-mvn-project/other/pom.xml
|
103
|
+
- sample-mvn-project/parent/pom.xml
|
104
|
+
- sample-mvn-project/pom.xml
|
105
|
+
- test/argument_parser_spec.rb
|
106
|
+
- test/configuration_checker_spec.rb
|
107
|
+
- test/m.yml
|
108
|
+
- test/project_home_finder_spec.rb
|
109
|
+
homepage: http://github.com/kingOburgers/mvn-helper-script
|
110
|
+
licenses: []
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
segments:
|
122
|
+
- 0
|
123
|
+
hash: -897089923
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ! '>='
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 1.8.24
|
133
|
+
signing_key:
|
134
|
+
specification_version: 3
|
135
|
+
summary: Ruby gem to simplify maven command execution
|
136
|
+
test_files: []
|