mvnizer 0.0.2 → 0.0.3
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/Gemfile +3 -0
- data/Gemfile.lock +28 -1
- data/README.md +20 -3
- data/TODO.md +16 -9
- data/bin/mvnizer +10 -0
- data/features/new_project.feature +37 -0
- data/features/search_artefact.feature +14 -0
- data/features/step_definitions/pom_steps.rb +18 -0
- data/features/support/env.rb +24 -0
- data/lib/mvnizer/commands/new_project.rb +7 -35
- data/lib/mvnizer/commands/new_war_project.rb +6 -4
- data/lib/mvnizer/commands/search_artefact.rb +41 -0
- data/lib/mvnizer/commands.rb +1 -0
- data/lib/mvnizer/mvnize.rb +41 -15
- data/lib/mvnizer/task_helper.rb +32 -0
- data/lib/mvnizer/version.rb +1 -1
- data/lib/mvnizer.rb +1 -3
- data/mvnizer.gemspec +17 -7
- data/spec/commands/new_project_spec.rb +7 -52
- data/spec/commands/new_war_project_spec.rb +11 -24
- data/spec/commands/search_artefact_spec.rb +98 -0
- data/spec/mvnize_spec.rb +51 -11
- data/spec/task_helper_spec.rb +53 -0
- metadata +42 -6
- data/lib/mvnizer/dir_creator.rb +0 -10
- data/lib/mvnizer/pom_generator.rb +0 -10
- data/spec/dir_creator_spec.rb +0 -17
- data/spec/generator_spec.rb +0 -46
data/Gemfile
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
|
+
gem 'httparty', '~> 0.9.0'
|
4
|
+
|
3
5
|
group :development do
|
4
6
|
gem 'rspec', '~> 2.11.0'
|
5
7
|
gem 'rspec-mocks', '~> 2.11.2'
|
6
8
|
gem 'fakefs', '~> 0.4.0'
|
7
9
|
gem 'nokogiri', '~> 1.5.5'
|
8
10
|
gem 'jeweler', '~> 1.8.4'
|
11
|
+
gem 'aruba', '~> 0.4.11'
|
9
12
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,40 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
aruba (0.4.11)
|
5
|
+
childprocess (>= 0.2.3)
|
6
|
+
cucumber (>= 1.1.1)
|
7
|
+
ffi (>= 1.0.11)
|
8
|
+
rspec (>= 2.7.0)
|
9
|
+
builder (3.1.3)
|
10
|
+
childprocess (0.3.5)
|
11
|
+
ffi (~> 1.0, >= 1.0.6)
|
12
|
+
cucumber (1.2.1)
|
13
|
+
builder (>= 2.1.2)
|
14
|
+
diff-lcs (>= 1.1.3)
|
15
|
+
gherkin (~> 2.11.0)
|
16
|
+
json (>= 1.4.6)
|
4
17
|
diff-lcs (1.1.3)
|
5
18
|
fakefs (0.4.0)
|
19
|
+
ffi (1.1.5)
|
20
|
+
ffi (1.1.5-java)
|
21
|
+
gherkin (2.11.2)
|
22
|
+
json (>= 1.4.6)
|
23
|
+
gherkin (2.11.2-java)
|
24
|
+
json (>= 1.4.6)
|
6
25
|
git (1.2.5)
|
26
|
+
httparty (0.9.0)
|
27
|
+
multi_json (~> 1.0)
|
28
|
+
multi_xml
|
7
29
|
jeweler (1.8.4)
|
8
30
|
bundler (~> 1.0)
|
9
31
|
git (>= 1.2.5)
|
10
32
|
rake
|
11
33
|
rdoc
|
12
34
|
json (1.7.5)
|
35
|
+
json (1.7.5-java)
|
36
|
+
multi_json (1.3.6)
|
37
|
+
multi_xml (0.5.1)
|
13
38
|
nokogiri (1.5.5)
|
14
39
|
nokogiri (1.5.5-java)
|
15
40
|
rake (0.9.2.2)
|
@@ -22,14 +47,16 @@ GEM
|
|
22
47
|
rspec-core (2.11.1)
|
23
48
|
rspec-expectations (2.11.3)
|
24
49
|
diff-lcs (~> 1.1.3)
|
25
|
-
rspec-mocks (2.11.
|
50
|
+
rspec-mocks (2.11.3)
|
26
51
|
|
27
52
|
PLATFORMS
|
28
53
|
java
|
29
54
|
ruby
|
30
55
|
|
31
56
|
DEPENDENCIES
|
57
|
+
aruba (~> 0.4.11)
|
32
58
|
fakefs (~> 0.4.0)
|
59
|
+
httparty (~> 0.9.0)
|
33
60
|
jeweler (~> 1.8.4)
|
34
61
|
nokogiri (~> 1.5.5)
|
35
62
|
rspec (~> 2.11.0)
|
data/README.md
CHANGED
@@ -4,7 +4,9 @@ Bootstraps a Maven project. Because archetypes shouldn't be so complicated.
|
|
4
4
|
|
5
5
|
Mvnizer is ideal to create a throw-away Maven project that adds junit as a dependency and sets up the Maven project structure.
|
6
6
|
|
7
|
-
#
|
7
|
+
# Commands
|
8
|
+
|
9
|
+
## Project Creation
|
8
10
|
|
9
11
|
Mvnizer is used as follows:
|
10
12
|
|
@@ -14,9 +16,24 @@ The coordinates can have the following format:
|
|
14
16
|
|
15
17
|
<group:>artifact<:version><:type>
|
16
18
|
|
17
|
-
with the values between angled brackets optional. `type` can only have one of the following three values: `jar` (default), `war` or `pom`.
|
19
|
+
with the values between angled brackets optional. `type` can only have one of the following three values: `jar` (default), `war` or `pom`. This command creates a project in the `artifact` folder, populating the proper values in the pom file.
|
20
|
+
|
21
|
+
Here are some examples of valid commands:
|
22
|
+
|
23
|
+
mvnizer new foo
|
24
|
+
mvnizer new foo:war
|
25
|
+
mvnizer new foo:1.0:war
|
26
|
+
mvnizer new com.example:foo
|
27
|
+
mvnizer new com.example:foo:war
|
28
|
+
mvnizer new com.example:foo:1.0:war
|
29
|
+
|
30
|
+
## Dependency Search
|
31
|
+
|
32
|
+
You can search for dependencies in the Maven central repository with the command:
|
33
|
+
|
34
|
+
$ mvnizer search <text>
|
35
|
+
|
18
36
|
|
19
|
-
This command creates a project in the `artifact` folder, populating the proper values in the pom file.
|
20
37
|
|
21
38
|
# License
|
22
39
|
|
data/TODO.md
CHANGED
@@ -1,14 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
blah
|
4
|
-
blah:1.0.0-SNAPSHOT
|
5
|
-
blah:war
|
6
|
-
com.weblogism:blah
|
7
|
-
com.weblogism:blah:1.0.0-SNAPSHOT
|
8
|
-
com.weblogism:blah:war
|
1
|
+
# New Project
|
2
|
+
|
9
3
|
- Depending on type of artifact (jar, war, etc.), generate appropriate pom and structure.
|
4
|
+
- Add specific options to add classic dependencies / plugins:
|
5
|
+
|
6
|
+
mvnizer new foo --slf4j
|
7
|
+
mvnizer new foo --shade # adds the maven-shade-plugin, and possibly a Main class.
|
10
8
|
- Provide way to add dependency to pom given coordinates, e.g.:
|
11
9
|
|
12
10
|
mvnizer add org.junit:junit:4.10
|
11
|
+
|
12
|
+
# Search
|
13
|
+
|
13
14
|
- Provide dependency search facility.
|
14
|
-
|
15
|
+
|
16
|
+
mvnizer search junit
|
17
|
+
|
18
|
+
|
19
|
+
# Options
|
20
|
+
|
21
|
+
- Support external config file (e.g. ~/.mvnizerrc) to override current defaults.
|
data/bin/mvnizer
CHANGED
@@ -9,6 +9,16 @@ help = <<HELP
|
|
9
9
|
Mvnizer bootstraps a Maven project without the pain of archetypes.
|
10
10
|
|
11
11
|
mvnizer new <project_name>
|
12
|
+
Creates a new project. Example of valid project names:
|
13
|
+
mvnizer new foo
|
14
|
+
mvnizer new foo:war
|
15
|
+
mvnizer new foo:1.0:war
|
16
|
+
mvnizer new com.example:foo
|
17
|
+
mvnizer new com.example:foo:war
|
18
|
+
mvnizer new com.example:foo:1.0:war
|
19
|
+
|
20
|
+
mvnizer search <text>
|
21
|
+
Searches for artefacts in the Maven central repository.
|
12
22
|
HELP
|
13
23
|
|
14
24
|
options = {}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Feature: Create a new Maven project
|
2
|
+
|
3
|
+
In order to rapidly run a project
|
4
|
+
As a user of Mvnizer
|
5
|
+
I want to quickly create Maven projects
|
6
|
+
|
7
|
+
Scenario: create a jar project
|
8
|
+
Given a directory named "foo"
|
9
|
+
When I run `mvnizer new com.weblogism:foonbar`
|
10
|
+
Then the output should contain "success"
|
11
|
+
And a file named "foonbar/pom.xml" should exist
|
12
|
+
And "/project/groupId" in the xml file "foonbar/pom.xml" should be "com.weblogism"
|
13
|
+
And "/project/artifactId" in the xml file "foonbar/pom.xml" should be "foonbar"
|
14
|
+
And "/project/name" in the xml file "foonbar/pom.xml" should be "foonbar"
|
15
|
+
And "/project/version" in the xml file "foonbar/pom.xml" should be "0.0.1-SNAPSHOT"
|
16
|
+
And "/project/packaging" should not be in the xml file "foonbar/pom.xml"
|
17
|
+
And a file named "foonbar/src/main/webapp/WEB-INF/web.xml" should not exist
|
18
|
+
|
19
|
+
Scenario: create a war project
|
20
|
+
Given a directory named "foo"
|
21
|
+
When I run `mvnizer new com.weblogism:foonbar:war`
|
22
|
+
Then the output should contain "success"
|
23
|
+
And a file named "foonbar/pom.xml" should exist
|
24
|
+
And "/project/groupId" in the xml file "foonbar/pom.xml" should be "com.weblogism"
|
25
|
+
And "/project/artifactId" in the xml file "foonbar/pom.xml" should be "foonbar"
|
26
|
+
And "/project/name" in the xml file "foonbar/pom.xml" should be "foonbar"
|
27
|
+
And "/project/version" in the xml file "foonbar/pom.xml" should be "0.0.1-SNAPSHOT"
|
28
|
+
And "/project/packaging" in the xml file "foonbar/pom.xml" should be "war"
|
29
|
+
And a file named "foonbar/src/main/webapp/WEB-INF/web.xml" should exist
|
30
|
+
|
31
|
+
Scenario: add the dependencies
|
32
|
+
Given a directory named "foo"
|
33
|
+
When I run `mvnizer new com.weblogism:foonbar`
|
34
|
+
Then "/project/dependencies/dependency/groupId" in the xml file "foonbar/pom.xml" should be "junit"
|
35
|
+
And "/project/dependencies/dependency/artifactId" in the xml file "foonbar/pom.xml" should be "junit"
|
36
|
+
And "/project/dependencies/dependency/version" in the xml file "foonbar/pom.xml" should be "4.10"
|
37
|
+
And "/project/dependencies/dependency/scope" in the xml file "foonbar/pom.xml" should be "test"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: Search for a Maven artefact
|
2
|
+
|
3
|
+
In order to easily find dependencies
|
4
|
+
As a user of Mvnizer
|
5
|
+
I want to search the Maven central repositories through the command line
|
6
|
+
|
7
|
+
Scenario: search for log4j
|
8
|
+
When I run `mvnizer search log4j`
|
9
|
+
Then the output should contain "log4j:log4j:"
|
10
|
+
And the output should contain "ant:ant-apache-log4j"
|
11
|
+
|
12
|
+
Scenario: message when no result
|
13
|
+
When I run `mvnizer search ffffl`
|
14
|
+
Then the output should contain "No result found"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
Then /^"([^"]+)" should not be in the xml file "([^"]+)"$/ do |xpath,path|
|
4
|
+
in_current_dir do
|
5
|
+
doc = Nokogiri::XML(File.open(path))
|
6
|
+
doc.remove_namespaces!
|
7
|
+
doc.xpath(xpath).first.should be_nil
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
Then /^"([^"]+)" in the xml file "([^"]+)" should be "([^"]+)"$/ do |xpath,path,value|
|
13
|
+
in_current_dir do
|
14
|
+
doc = Nokogiri::XML(File.open(path))
|
15
|
+
doc.remove_namespaces!
|
16
|
+
doc.xpath(xpath).first.text().should == value
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
root_dir = File.join(File.dirname(__FILE__), '..', '..')
|
5
|
+
bin_dir = File.expand_path(File.join(root_dir, 'bin'))
|
6
|
+
# FIXME: This actually doesn't work:
|
7
|
+
# aruba doesn't find the mvnizer script unless it is added to the PATH
|
8
|
+
# outside ruby.
|
9
|
+
ENV['PATH'] = "#{bin_dir}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
10
|
+
|
11
|
+
|
12
|
+
Before do
|
13
|
+
@aruba_timeout_seconds = 30
|
14
|
+
end
|
15
|
+
|
16
|
+
# Aruba.configure do |config|
|
17
|
+
# config.before_cmd do |cmd|
|
18
|
+
# puts "About to run '#{cmd}' with path = #{ENV["PATH"]}"
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
|
22
|
+
After do
|
23
|
+
FileUtils.rm_rf("#{root_dir}/tmp")
|
24
|
+
end
|
@@ -2,48 +2,20 @@ module Mvnizer
|
|
2
2
|
module Command
|
3
3
|
class NewProject
|
4
4
|
include Mvnizer::Configuration
|
5
|
-
|
6
|
-
def initialize(generator = Mvnizer::PomGenerator.new,
|
7
|
-
dir_creator = Mvnizer::DirCreator.new,
|
8
|
-
coordinate_parser = Mvnizer::CoordinateParser.new)
|
9
|
-
@generator = generator
|
10
|
-
@dir_creator = dir_creator
|
11
|
-
@coordinate_parser = coordinate_parser
|
12
|
-
end
|
5
|
+
include Mvnizer::TaskHelper
|
13
6
|
|
14
7
|
# Creates the Maven project structure, and creates the pom file
|
15
8
|
# from the options
|
16
|
-
def run(
|
17
|
-
@project = define_project(options)
|
9
|
+
def run(project)
|
18
10
|
|
19
|
-
|
20
|
-
|
11
|
+
create_dir("#{project.artifact_id}/src/main/java",
|
12
|
+
"#{project.artifact_id}/src/test/java")
|
21
13
|
|
22
|
-
File.
|
23
|
-
|
24
|
-
|
14
|
+
generate_file(File.join(TEMPLATE_DIR, "pom.xml.erb"),
|
15
|
+
"#{project.artifact_id}/pom.xml",
|
16
|
+
project)
|
25
17
|
end
|
26
18
|
|
27
|
-
private
|
28
|
-
# Creates an instance of +Project+ class populated with the coordinates
|
29
|
-
# set with the user’s definition, or default values if not set.
|
30
|
-
def define_project(options)
|
31
|
-
coordinates = options[:name]
|
32
|
-
options = conf(options)
|
33
|
-
|
34
|
-
project = @coordinate_parser.parse(coordinates)
|
35
|
-
return_project = Project.new(project.group_id || options[:group_id],
|
36
|
-
project.artifact_id,
|
37
|
-
project.version || options[:version],
|
38
|
-
project.type || options[:type])
|
39
|
-
|
40
|
-
dependencies = options[:dependencies]
|
41
|
-
dependencies.each do |d|
|
42
|
-
return_project.add_dependency(@coordinate_parser.parse_scoped_coordinates(d))
|
43
|
-
end if dependencies
|
44
|
-
|
45
|
-
return_project
|
46
|
-
end
|
47
19
|
end
|
48
20
|
end
|
49
21
|
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
module Mvnizer
|
2
2
|
module Command
|
3
3
|
class NewWarProject < NewProject
|
4
|
-
def run(
|
4
|
+
def run(project)
|
5
5
|
super
|
6
6
|
|
7
|
-
|
7
|
+
create_dir("#{project.artifact_id}/src/main/webapp/WEB-INF")
|
8
8
|
|
9
9
|
# web.xml is optional in Servlet 3.0
|
10
10
|
# Do we keep its generation here?
|
11
|
-
|
12
|
-
|
11
|
+
generate_file(File.join(TEMPLATE_DIR, "web.xml.erb"),
|
12
|
+
"#{project.artifact_id}/src/main/webapp/WEB-INF/web.xml",
|
13
|
+
project)
|
14
|
+
|
13
15
|
|
14
16
|
# TODO:
|
15
17
|
# Create sample @WebServlet?
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Mvnizer
|
4
|
+
module Command
|
5
|
+
class SearchArtefact
|
6
|
+
include HTTParty
|
7
|
+
MAVEN_REPO_SEARCH_URL = "http://search.maven.org/solrsearch/select?q=:q&rows=:limit&wt=json"
|
8
|
+
|
9
|
+
attr_writer :out
|
10
|
+
def out
|
11
|
+
@out ||= STDOUT
|
12
|
+
end
|
13
|
+
|
14
|
+
def run(options)
|
15
|
+
url = MAVEN_REPO_SEARCH_URL.dup
|
16
|
+
url[":q"] = options[:name]
|
17
|
+
url[":limit"] = "5"
|
18
|
+
|
19
|
+
response = self.class.get(url)
|
20
|
+
if response
|
21
|
+
if response.code != 200
|
22
|
+
out.puts "Error during search: #{response.code}"
|
23
|
+
exit(1)
|
24
|
+
end
|
25
|
+
|
26
|
+
if response["response"]["numFound"].to_i > 0
|
27
|
+
hits = response["response"]["docs"].each do |a|
|
28
|
+
out.puts " #{a['g']}:#{a['a']}:#{a['latestVersion']}:#{a['p']}"
|
29
|
+
end
|
30
|
+
else
|
31
|
+
out.puts " No result found."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# TODO:
|
36
|
+
# Error handling,
|
37
|
+
# Do something for "bundle" packaging (e.g. for log4j)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/mvnizer/commands.rb
CHANGED
data/lib/mvnizer/mvnize.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
module Mvnizer
|
2
2
|
# Mvnize is the main entry point into Mvnizer.
|
3
3
|
class Mvnize
|
4
|
+
include Configuration
|
4
5
|
attr_writer :out
|
5
6
|
|
6
|
-
def
|
7
|
-
@
|
7
|
+
def initialize(coordinate_parser = Mvnizer::CoordinateParser.new)
|
8
|
+
@coordinate_parser = coordinate_parser
|
8
9
|
end
|
9
10
|
|
10
|
-
def
|
11
|
-
@
|
11
|
+
def out
|
12
|
+
@out ||= $stdout
|
12
13
|
end
|
13
14
|
|
14
15
|
# Execute the right command depending on the :command parameter
|
@@ -16,21 +17,46 @@ module Mvnizer
|
|
16
17
|
# If the command does not exit, throw an error.
|
17
18
|
def run(options)
|
18
19
|
raise ArgumentError, "Please give a name to the project." unless options[:name]
|
19
|
-
if options[:command] == "new"
|
20
|
-
# FIXME: coordinates should be parsed here to check type.
|
21
|
-
# and pass to the factory, rather than doing this if,
|
22
|
-
# and parse coordinates later down in NewProject.
|
23
|
-
if options[:name] =~ /:war$/
|
24
|
-
project = Mvnizer::Command::ProjectFactory.create("war")
|
25
|
-
else
|
26
|
-
project = Mvnizer::Command::ProjectFactory.create("jar")
|
27
|
-
end
|
28
20
|
|
29
|
-
|
30
|
-
|
21
|
+
case options[:command]
|
22
|
+
when "new"
|
23
|
+
project_details = define_project(options)
|
24
|
+
project_command = Mvnizer::Command::ProjectFactory.create(project_details.type)
|
25
|
+
|
26
|
+
project_command.run(project_details)
|
27
|
+
out.puts("Project #{project_details.artifact_id} created successfully.")
|
28
|
+
when "search"
|
29
|
+
search_command = Command::SearchArtefact.new
|
30
|
+
search_command.run(options)
|
31
31
|
else
|
32
32
|
raise ArgumentError, "#{options[:command]} is not a valid command."
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
private
|
37
|
+
# Creates an instance of +Project+ class populated with the coordinates
|
38
|
+
# set with the user’s definition, or default values if not set.
|
39
|
+
def define_project(options)
|
40
|
+
# Get coordinates provided by the user on the CLI.
|
41
|
+
coordinates = options[:name]
|
42
|
+
# Retrieve default options
|
43
|
+
options = conf(options)
|
44
|
+
|
45
|
+
# Parse user coordinates, and found values override options
|
46
|
+
project = @coordinate_parser.parse(coordinates)
|
47
|
+
return_project = Project.new(project.group_id || options[:group_id],
|
48
|
+
project.artifact_id,
|
49
|
+
project.version || options[:version],
|
50
|
+
project.type || options[:type])
|
51
|
+
|
52
|
+
|
53
|
+
# Get default dependencies, and add them after having parsed their coords.
|
54
|
+
dependencies = options[:dependencies]
|
55
|
+
dependencies.each do |d|
|
56
|
+
return_project.add_dependency(@coordinate_parser.parse_scoped_coordinates(d))
|
57
|
+
end if dependencies
|
58
|
+
|
59
|
+
return_project
|
60
|
+
end
|
35
61
|
end
|
36
62
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Mvnizer
|
4
|
+
# The +TaskHelper+ provides different functions that can be used in tasks,
|
5
|
+
# such as function to create directories, generate files from templates, etc.
|
6
|
+
module TaskHelper
|
7
|
+
# path to the template location.
|
8
|
+
TEMPLATE_DIR = File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
9
|
+
|
10
|
+
# creates recursively all directories passed as a param.
|
11
|
+
def create_dir(*dir)
|
12
|
+
dir.each { |d| FileUtils.mkdir_p d }
|
13
|
+
end
|
14
|
+
|
15
|
+
# generates the file +destination_file+ from template +template+
|
16
|
+
# and object +binding+. +binding+ must be an ERB binding.
|
17
|
+
# +destination_file+ must be the aboslute location to the generated
|
18
|
+
# file.
|
19
|
+
# If the output folder in which the file gets generated does not exist,
|
20
|
+
# it automatically gets created.
|
21
|
+
def generate_file(template, destination_file, binding)
|
22
|
+
dir = File.dirname(destination_file)
|
23
|
+
create_dir(dir) unless File.exists?(dir)
|
24
|
+
|
25
|
+
template = File.open(template, 'r').read
|
26
|
+
|
27
|
+
File.open(destination_file, "w") do |f|
|
28
|
+
f.write(ERB.new(template).result(binding.get_binding))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/mvnizer/version.rb
CHANGED
data/lib/mvnizer.rb
CHANGED
@@ -4,12 +4,10 @@ require 'erb'
|
|
4
4
|
|
5
5
|
require 'mvnizer/version'
|
6
6
|
require 'mvnizer/erb_helper'
|
7
|
+
require 'mvnizer/task_helper'
|
7
8
|
require 'mvnizer/project'
|
8
9
|
require 'mvnizer/configuration'
|
9
10
|
require 'mvnizer/commands'
|
10
11
|
require 'mvnizer/coordinate_parser'
|
11
|
-
require 'mvnizer/pom_generator'
|
12
|
-
require 'mvnizer/dir_creator'
|
13
12
|
require 'mvnizer/mvnize'
|
14
13
|
|
15
|
-
|
data/mvnizer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "mvnizer"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["S\u{e9}bastien Le Callonnec"]
|
12
|
-
s.date = "2012-09-
|
12
|
+
s.date = "2012-09-25"
|
13
13
|
s.description = "Bootstrap a Maven project without the pain of archetypes."
|
14
14
|
s.email = "sebastien@weblogism.com"
|
15
15
|
s.executables = ["mvnizer"]
|
@@ -27,18 +27,22 @@ Gem::Specification.new do |s|
|
|
27
27
|
"TODO.md",
|
28
28
|
"bin/mvnizer",
|
29
29
|
"conf/default.yml",
|
30
|
+
"features/new_project.feature",
|
31
|
+
"features/search_artefact.feature",
|
32
|
+
"features/step_definitions/pom_steps.rb",
|
33
|
+
"features/support/env.rb",
|
30
34
|
"lib/mvnizer.rb",
|
31
35
|
"lib/mvnizer/commands.rb",
|
32
36
|
"lib/mvnizer/commands/new_project.rb",
|
33
37
|
"lib/mvnizer/commands/new_war_project.rb",
|
34
38
|
"lib/mvnizer/commands/project_factory.rb",
|
39
|
+
"lib/mvnizer/commands/search_artefact.rb",
|
35
40
|
"lib/mvnizer/configuration.rb",
|
36
41
|
"lib/mvnizer/coordinate_parser.rb",
|
37
|
-
"lib/mvnizer/dir_creator.rb",
|
38
42
|
"lib/mvnizer/erb_helper.rb",
|
39
43
|
"lib/mvnizer/mvnize.rb",
|
40
|
-
"lib/mvnizer/pom_generator.rb",
|
41
44
|
"lib/mvnizer/project.rb",
|
45
|
+
"lib/mvnizer/task_helper.rb",
|
42
46
|
"lib/mvnizer/templates/_dependency.xml.erb",
|
43
47
|
"lib/mvnizer/templates/pom.xml.erb",
|
44
48
|
"lib/mvnizer/templates/web.xml.erb",
|
@@ -50,12 +54,12 @@ Gem::Specification.new do |s|
|
|
50
54
|
"spec/commands/new_project_spec.rb",
|
51
55
|
"spec/commands/new_war_project_spec.rb",
|
52
56
|
"spec/commands/project_factory_spec.rb",
|
57
|
+
"spec/commands/search_artefact_spec.rb",
|
53
58
|
"spec/configuration_spec.rb",
|
54
59
|
"spec/coordinate_parser_spec.rb",
|
55
|
-
"spec/dir_creator_spec.rb",
|
56
|
-
"spec/generator_spec.rb",
|
57
60
|
"spec/mvnize_spec.rb",
|
58
|
-
"spec/spec_helper.rb"
|
61
|
+
"spec/spec_helper.rb",
|
62
|
+
"spec/task_helper_spec.rb"
|
59
63
|
]
|
60
64
|
s.homepage = "http://github.com/tychobrailleur/mvnizer"
|
61
65
|
s.licenses = ["MIT"]
|
@@ -67,24 +71,30 @@ Gem::Specification.new do |s|
|
|
67
71
|
s.specification_version = 3
|
68
72
|
|
69
73
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
74
|
+
s.add_runtime_dependency(%q<httparty>, ["~> 0.9.0"])
|
70
75
|
s.add_development_dependency(%q<rspec>, ["~> 2.11.0"])
|
71
76
|
s.add_development_dependency(%q<rspec-mocks>, ["~> 2.11.2"])
|
72
77
|
s.add_development_dependency(%q<fakefs>, ["~> 0.4.0"])
|
73
78
|
s.add_development_dependency(%q<nokogiri>, ["~> 1.5.5"])
|
74
79
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
80
|
+
s.add_development_dependency(%q<aruba>, ["~> 0.4.11"])
|
75
81
|
else
|
82
|
+
s.add_dependency(%q<httparty>, ["~> 0.9.0"])
|
76
83
|
s.add_dependency(%q<rspec>, ["~> 2.11.0"])
|
77
84
|
s.add_dependency(%q<rspec-mocks>, ["~> 2.11.2"])
|
78
85
|
s.add_dependency(%q<fakefs>, ["~> 0.4.0"])
|
79
86
|
s.add_dependency(%q<nokogiri>, ["~> 1.5.5"])
|
80
87
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
88
|
+
s.add_dependency(%q<aruba>, ["~> 0.4.11"])
|
81
89
|
end
|
82
90
|
else
|
91
|
+
s.add_dependency(%q<httparty>, ["~> 0.9.0"])
|
83
92
|
s.add_dependency(%q<rspec>, ["~> 2.11.0"])
|
84
93
|
s.add_dependency(%q<rspec-mocks>, ["~> 2.11.2"])
|
85
94
|
s.add_dependency(%q<fakefs>, ["~> 0.4.0"])
|
86
95
|
s.add_dependency(%q<nokogiri>, ["~> 1.5.5"])
|
87
96
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
97
|
+
s.add_dependency(%q<aruba>, ["~> 0.4.11"])
|
88
98
|
end
|
89
99
|
end
|
90
100
|
|
@@ -4,65 +4,20 @@ require 'spec_helper'
|
|
4
4
|
module Mvnizer
|
5
5
|
module Command
|
6
6
|
describe NewProject do
|
7
|
-
let(:
|
8
|
-
|
7
|
+
let(:project) { Mvnizer::Project.new("com.example", "foobar", "1.0.0-SNAPSHOT", "war") }
|
8
|
+
subject { Mvnizer::Command::NewProject.new }
|
9
9
|
|
10
|
-
let(:generator) { double("generator") }
|
11
|
-
let(:coordinate_parser) { double("coordinate_parser") }
|
12
|
-
let(:dir_creator) { double("dir_creator") }
|
13
|
-
subject { Mvnizer::Command::NewProject.new(generator, dir_creator, coordinate_parser) }
|
14
|
-
|
15
|
-
before do
|
16
|
-
FakeFS.activate!
|
17
|
-
FileUtils.mkdir_p("foobar")
|
18
|
-
end
|
19
|
-
|
20
|
-
it "reads the configuration" do
|
21
|
-
generator.should_receive(:generate)
|
22
|
-
coordinate_parser.should_receive(:parse).and_return(project)
|
23
|
-
dir_creator.should_receive(:create)
|
24
|
-
subject.should_receive(:conf).with(options).and_return(options)
|
25
|
-
|
26
|
-
subject.run(options)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "creates a project from the provided coordinates" do
|
30
|
-
o = { name: "foobar"}
|
31
|
-
|
32
|
-
subject.should_receive(:conf).with(o).and_return(options)
|
33
|
-
generator.should_receive(:generate)
|
34
|
-
dir_creator.should_receive(:create)
|
35
|
-
|
36
|
-
p = Mvnizer::Project.new("group", "foobar", "version", "type")
|
37
|
-
coordinate_parser.should_receive(:parse).with("foobar").and_return(p)
|
38
|
-
|
39
|
-
subject.run(o)
|
40
|
-
end
|
41
10
|
|
42
11
|
it "creates the project directory" do
|
43
|
-
subject.should_receive(:
|
44
|
-
|
45
|
-
generator.should_receive(:generate)
|
46
|
-
dir_creator.should_receive(:create).with("foobar/src/main/java", "foobar/src/test/java")
|
12
|
+
subject.should_receive(:generate_file)
|
13
|
+
subject.should_receive(:create_dir).with("foobar/src/main/java", "foobar/src/test/java")
|
47
14
|
|
48
|
-
subject.run(
|
15
|
+
subject.run(project)
|
49
16
|
end
|
50
17
|
|
51
18
|
it "generates the pom file" do
|
52
|
-
|
53
|
-
|
54
|
-
subject.should_receive(:conf).with(options).and_return(options)
|
55
|
-
coordinate_parser.should_receive(:parse).and_return(p)
|
56
|
-
generator.should_receive(:generate).with(p)
|
57
|
-
dir_creator.should_receive(:create)
|
58
|
-
subject.run(options)
|
59
|
-
|
60
|
-
File.exists?("foobar/pom.xml").should be_true
|
61
|
-
end
|
62
|
-
|
63
|
-
after do
|
64
|
-
FileUtils.rm_rf("foobar")
|
65
|
-
FakeFS.deactivate!
|
19
|
+
subject.should_receive(:generate_file).with(File.join(TaskHelper::TEMPLATE_DIR, "pom.xml.erb"), "foobar/pom.xml", project)
|
20
|
+
subject.run(project)
|
66
21
|
end
|
67
22
|
end
|
68
23
|
end
|
@@ -6,54 +6,41 @@ module Mvnizer
|
|
6
6
|
describe NewWarProject do
|
7
7
|
|
8
8
|
let(:project) { Mvnizer::Project.new(nil, "foobar", nil, nil) }
|
9
|
-
|
10
|
-
let(:coordinate_parser) { double("coordinate_parser") }
|
11
|
-
let(:dir_creator) { double("dir_creator") }
|
12
|
-
|
13
|
-
subject { Mvnizer::Command::NewWarProject.new(generator, dir_creator, coordinate_parser) }
|
9
|
+
subject { Mvnizer::Command::NewWarProject.new }
|
14
10
|
|
15
11
|
before do
|
16
12
|
$run = false
|
17
13
|
class NewProject
|
18
14
|
alias old_run run
|
19
|
-
def run(
|
15
|
+
def run(project)
|
20
16
|
$run = true
|
21
17
|
end
|
22
18
|
end
|
23
19
|
|
24
20
|
subject.instance_variable_set(:@project, project)
|
25
|
-
FakeFS.activate!
|
26
|
-
FileUtils.mkdir_p("foobar")
|
27
|
-
|
28
|
-
templates_dir = File.join(File.dirname(__FILE__), '..', '..', 'lib', 'mvnizer', 'templates')
|
29
|
-
FileUtils.mkdir_p(templates_dir)
|
30
|
-
FileUtils.touch(File.join(templates_dir, "web.xml.erb"))
|
31
21
|
end
|
32
22
|
|
33
23
|
it "creates a basic project" do
|
34
|
-
|
35
|
-
|
36
|
-
subject.run(
|
24
|
+
subject.should_receive(:create_dir)
|
25
|
+
subject.should_receive(:generate_file)
|
26
|
+
subject.run(project)
|
37
27
|
$run.should be_true
|
38
28
|
end
|
39
29
|
|
40
30
|
it "creates the webapp directory" do
|
41
|
-
|
42
|
-
|
43
|
-
subject.run(
|
31
|
+
subject.should_receive(:create_dir).with("foobar/src/main/webapp/WEB-INF")
|
32
|
+
subject.should_receive(:generate_file)
|
33
|
+
subject.run(project)
|
44
34
|
end
|
45
35
|
|
46
36
|
it "generates the web.xml file" do
|
47
|
-
|
48
|
-
|
37
|
+
subject.should_receive(:create_dir)
|
38
|
+
subject.should_receive(:generate_file).with(File.join(TaskHelper::TEMPLATE_DIR, "web.xml.erb"), "foobar/src/main/webapp/WEB-INF/web.xml", project)
|
49
39
|
|
50
|
-
subject.run(
|
51
|
-
File.exists?("foobar/src/main/webapp/WEB-INF/web.xml").should be_true
|
40
|
+
subject.run(project)
|
52
41
|
end
|
53
42
|
|
54
43
|
after do
|
55
|
-
FileUtils.rm_rf("foobar")
|
56
|
-
FakeFS.deactivate!
|
57
44
|
class NewProject
|
58
45
|
alias run old_run
|
59
46
|
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
module Mvnizer
|
5
|
+
module Command
|
6
|
+
describe SearchArtefact do
|
7
|
+
|
8
|
+
subject { SearchArtefact.new }
|
9
|
+
before do
|
10
|
+
subject.out = StringIO.new
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def httparty_response_mock(mock_response_content)
|
16
|
+
request_object = HTTParty::Request.new Net::HTTP::Get, '/'
|
17
|
+
response_object = Net::HTTPOK.new('1.1', 200, 'OK')
|
18
|
+
response_object.stub(:body => mock_response_content)
|
19
|
+
mock_response = HTTParty::Response.new(request_object, response_object, -> { mock_response_content })
|
20
|
+
end
|
21
|
+
|
22
|
+
def response_mock(klass)
|
23
|
+
response = klass.new('', '', '')
|
24
|
+
response.stub(:body)
|
25
|
+
response
|
26
|
+
end
|
27
|
+
|
28
|
+
it "performs a search in the Maven repository" do
|
29
|
+
options = { command:"search", name: "junit" }
|
30
|
+
SearchArtefact.should_receive(:get).with("http://search.maven.org/solrsearch/select?q=junit&rows=5&wt=json")
|
31
|
+
|
32
|
+
subject.run(options)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "displays the coordinates of the found artefacts" do
|
36
|
+
require 'json'
|
37
|
+
|
38
|
+
mock_response_content = JSON.parse(<<JSON)
|
39
|
+
{
|
40
|
+
"response": {
|
41
|
+
"numFound": "1",
|
42
|
+
"docs": [
|
43
|
+
{
|
44
|
+
"g": "blah",
|
45
|
+
"a": "blah",
|
46
|
+
"latestVersion": "1.0",
|
47
|
+
"p": "jar"
|
48
|
+
}
|
49
|
+
]
|
50
|
+
}
|
51
|
+
}
|
52
|
+
JSON
|
53
|
+
|
54
|
+
mock_response = httparty_response_mock(mock_response_content)
|
55
|
+
options = { command:"search", name: "junit" }
|
56
|
+
SearchArtefact.should_receive(:get).and_return(mock_response)
|
57
|
+
|
58
|
+
io = StringIO.new
|
59
|
+
subject.out = io
|
60
|
+
|
61
|
+
subject.run(options)
|
62
|
+
|
63
|
+
io.string.should =~ Regexp.new("blah:blah:1.0:jar")
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
it "displays an informative message when no result is found" do
|
68
|
+
mock_response_content = '{ "response": { "numFound": "0"} }'
|
69
|
+
mock_response = httparty_response_mock(mock_response_content)
|
70
|
+
|
71
|
+
options = { command:"search", name: "junit" }
|
72
|
+
SearchArtefact.should_receive(:get).and_return(mock_response)
|
73
|
+
|
74
|
+
io = StringIO.new
|
75
|
+
subject.out = io
|
76
|
+
|
77
|
+
subject.run(options)
|
78
|
+
|
79
|
+
io.string.should match("No result found.")
|
80
|
+
end
|
81
|
+
|
82
|
+
it "displays an error message when something went wrong" do
|
83
|
+
net_response = response_mock(Net::HTTPServerError)
|
84
|
+
SearchArtefact.should_receive(:get).and_return(net_response)
|
85
|
+
|
86
|
+
options = { command:"search", name: "junit" }
|
87
|
+
io = StringIO.new
|
88
|
+
subject.out = io
|
89
|
+
|
90
|
+
lambda { subject.run(options) }.should raise_error(SystemExit)
|
91
|
+
|
92
|
+
io.string.should match("Error during search: ")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
data/spec/mvnize_spec.rb
CHANGED
@@ -3,13 +3,50 @@ require 'spec_helper'
|
|
3
3
|
module Mvnizer
|
4
4
|
describe Mvnize do
|
5
5
|
|
6
|
+
let (:project) { Project.new(nil, "quxbaz", nil, nil) }
|
6
7
|
let (:new_project) { double("new_project") }
|
7
|
-
|
8
|
+
let (:search) { double("search") }
|
9
|
+
|
10
|
+
let(:coordinate_parser) { double("coordinate_parser") }
|
11
|
+
subject { Mvnizer::Mvnize.new(coordinate_parser) }
|
12
|
+
|
13
|
+
before { subject.out = StringIO.new }
|
14
|
+
|
15
|
+
it "reads the configuration" do
|
16
|
+
options = {name: "foobar", command: "new"}
|
17
|
+
subject.should_receive(:conf).with(options).and_return(options)
|
18
|
+
|
19
|
+
p = Mvnizer::Project.new("group", "foobar", "version", "jar")
|
20
|
+
coordinate_parser.should_receive(:parse).and_return(project)
|
21
|
+
Command::ProjectFactory.should_receive(:create).and_return(new_project)
|
22
|
+
new_project.should_receive(:run)
|
23
|
+
|
24
|
+
subject.run(options)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "creates a project from the provided coordinates" do
|
28
|
+
options = {name: "foobar", command: "new"}
|
29
|
+
|
30
|
+
subject.should_receive(:conf).with(options).and_return(options)
|
31
|
+
|
32
|
+
p = Mvnizer::Project.new("group", "foobar", "version", "jar")
|
33
|
+
coordinate_parser.should_receive(:parse).with("foobar").and_return(p)
|
34
|
+
Command::ProjectFactory.should_receive(:create).and_return(new_project)
|
35
|
+
new_project.should_receive(:run)
|
36
|
+
|
37
|
+
subject.run(options)
|
38
|
+
end
|
8
39
|
|
9
40
|
it "chooses what command to run depending on the options" do
|
10
41
|
options = {name: "quxbaz", command: "new"}
|
11
|
-
|
12
|
-
|
42
|
+
|
43
|
+
subject.should_receive(:conf).and_return(Hash.new)
|
44
|
+
|
45
|
+
p = Mvnizer::Project.new("group", "foobar", "version", "pom")
|
46
|
+
coordinate_parser.should_receive(:parse).and_return(p)
|
47
|
+
Command::ProjectFactory.should_receive(:create).with("pom").and_return(new_project)
|
48
|
+
new_project.should_receive(:run)
|
49
|
+
|
13
50
|
subject.run(options)
|
14
51
|
end
|
15
52
|
|
@@ -18,6 +55,7 @@ module Mvnizer
|
|
18
55
|
end
|
19
56
|
|
20
57
|
it "displays a success message when done" do
|
58
|
+
subject.should_receive(:define_project).and_return(project)
|
21
59
|
Command::ProjectFactory.should_receive(:create).and_return(new_project)
|
22
60
|
new_project.should_receive(:run)
|
23
61
|
# For some obscure reason, this does not work:
|
@@ -35,17 +73,19 @@ module Mvnizer
|
|
35
73
|
subject.run(name: "quxbaz", command: "new")
|
36
74
|
string_io.string.should match(/success/i)
|
37
75
|
end
|
38
|
-
|
39
|
-
it "performs war tasks if name ends with :war" do
|
40
|
-
options = {name: "quxbaz:war", command: "new"}
|
41
|
-
Command::ProjectFactory.should_receive(:create).with("war").and_return(new_project)
|
42
|
-
new_project.should_receive(:run).with(options)
|
43
|
-
subject.run(options)
|
44
|
-
end
|
45
|
-
|
76
|
+
|
46
77
|
it "throws an error if the command to run is not valid" do
|
47
78
|
lambda { subject.run(name: "quxbaz", command: "foobar") }.should raise_error(ArgumentError, "foobar is not a valid command.")
|
48
79
|
end
|
49
80
|
|
81
|
+
it "calls the search command when doing a search" do
|
82
|
+
options = { command:"search", name: "junit" }
|
83
|
+
|
84
|
+
Command::SearchArtefact.should_receive(:new).and_return(search)
|
85
|
+
search.should_receive(:run).with(options)
|
86
|
+
|
87
|
+
subject.run(options)
|
88
|
+
end
|
89
|
+
|
50
90
|
end
|
51
91
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
module Mvnizer
|
5
|
+
class Dummy
|
6
|
+
include TaskHelper
|
7
|
+
end
|
8
|
+
|
9
|
+
describe TaskHelper do
|
10
|
+
let (:binding) { double("binding") }
|
11
|
+
let (:erb) { double("erb") }
|
12
|
+
let (:file) { double("file") }
|
13
|
+
subject { Dummy.new }
|
14
|
+
|
15
|
+
# Make use of fakefs explicit by using activate! / deactivate!
|
16
|
+
before do
|
17
|
+
FakeFS.activate!
|
18
|
+
FileUtils.mkdir("foobar")
|
19
|
+
FileUtils.touch("dummy.txt.erb")
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#create_dir" do
|
23
|
+
it "creates a list of directories" do
|
24
|
+
subject.create_dir("/tmp/blah/blah", "/tmp/foo/bar")
|
25
|
+
Dir.exists?("/tmp/blah/blah").should be_true
|
26
|
+
Dir.exists?("/tmp/foo/bar").should be_true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#generate_file" do
|
31
|
+
it "generates a file from a template into a given directory" do
|
32
|
+
ERB.should_receive(:new).and_return(erb)
|
33
|
+
binding.should_receive(:get_binding)
|
34
|
+
erb.should_receive(:result).and_return("")
|
35
|
+
subject.generate_file("dummy.txt.erb", "foobar/dummy.txt", binding)
|
36
|
+
|
37
|
+
File.exists?("foobar/dummy.txt").should be_true
|
38
|
+
end
|
39
|
+
|
40
|
+
it "creates the output directory if it does not exist" do
|
41
|
+
subject.should_receive(:create_dir).with("foo")
|
42
|
+
File.should_receive(:open).any_number_of_times.and_return(file)
|
43
|
+
file.should_receive(:read)
|
44
|
+
subject.generate_file("dummy.txt.erb", "foo/dummy.txt", binding)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
after do
|
49
|
+
FileUtils.rm_rf("foobar")
|
50
|
+
FakeFS.deactivate!
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
CHANGED
@@ -2,15 +2,31 @@
|
|
2
2
|
name: mvnizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sébastien Le Callonnec
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.9.0
|
21
|
+
none: false
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.0
|
27
|
+
none: false
|
28
|
+
prerelease: false
|
29
|
+
type: :runtime
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: rspec
|
16
32
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -91,6 +107,22 @@ dependencies:
|
|
91
107
|
none: false
|
92
108
|
prerelease: false
|
93
109
|
type: :development
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: aruba
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ~>
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 0.4.11
|
117
|
+
none: false
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ~>
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 0.4.11
|
123
|
+
none: false
|
124
|
+
prerelease: false
|
125
|
+
type: :development
|
94
126
|
description: Bootstrap a Maven project without the pain of archetypes.
|
95
127
|
email: sebastien@weblogism.com
|
96
128
|
executables:
|
@@ -109,18 +141,22 @@ files:
|
|
109
141
|
- TODO.md
|
110
142
|
- bin/mvnizer
|
111
143
|
- conf/default.yml
|
144
|
+
- features/new_project.feature
|
145
|
+
- features/search_artefact.feature
|
146
|
+
- features/step_definitions/pom_steps.rb
|
147
|
+
- features/support/env.rb
|
112
148
|
- lib/mvnizer.rb
|
113
149
|
- lib/mvnizer/commands.rb
|
114
150
|
- lib/mvnizer/commands/new_project.rb
|
115
151
|
- lib/mvnizer/commands/new_war_project.rb
|
116
152
|
- lib/mvnizer/commands/project_factory.rb
|
153
|
+
- lib/mvnizer/commands/search_artefact.rb
|
117
154
|
- lib/mvnizer/configuration.rb
|
118
155
|
- lib/mvnizer/coordinate_parser.rb
|
119
|
-
- lib/mvnizer/dir_creator.rb
|
120
156
|
- lib/mvnizer/erb_helper.rb
|
121
157
|
- lib/mvnizer/mvnize.rb
|
122
|
-
- lib/mvnizer/pom_generator.rb
|
123
158
|
- lib/mvnizer/project.rb
|
159
|
+
- lib/mvnizer/task_helper.rb
|
124
160
|
- lib/mvnizer/templates/_dependency.xml.erb
|
125
161
|
- lib/mvnizer/templates/pom.xml.erb
|
126
162
|
- lib/mvnizer/templates/web.xml.erb
|
@@ -132,12 +168,12 @@ files:
|
|
132
168
|
- spec/commands/new_project_spec.rb
|
133
169
|
- spec/commands/new_war_project_spec.rb
|
134
170
|
- spec/commands/project_factory_spec.rb
|
171
|
+
- spec/commands/search_artefact_spec.rb
|
135
172
|
- spec/configuration_spec.rb
|
136
173
|
- spec/coordinate_parser_spec.rb
|
137
|
-
- spec/dir_creator_spec.rb
|
138
|
-
- spec/generator_spec.rb
|
139
174
|
- spec/mvnize_spec.rb
|
140
175
|
- spec/spec_helper.rb
|
176
|
+
- spec/task_helper_spec.rb
|
141
177
|
homepage: http://github.com/tychobrailleur/mvnizer
|
142
178
|
licenses:
|
143
179
|
- MIT
|
data/lib/mvnizer/dir_creator.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
module Mvnizer
|
2
|
-
# This class handles the generation of the content of the pom file.
|
3
|
-
class PomGenerator
|
4
|
-
# Creates the pom content by reading the erb template.
|
5
|
-
def generate(project)
|
6
|
-
template = File.open(File.join(File.dirname(__FILE__), 'templates', 'pom.xml.erb'), 'r').read
|
7
|
-
ERB.new(template).result(project.get_binding)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
data/spec/dir_creator_spec.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
describe Mvnizer::DirCreator do
|
5
|
-
subject { Mvnizer::DirCreator.new }
|
6
|
-
# Make use of fakefs explicit by using activate! / deactivate!
|
7
|
-
before { FakeFS.activate! }
|
8
|
-
|
9
|
-
it "creates a list of directories" do
|
10
|
-
subject.create("/tmp/blah/blah", "/tmp/foo/bar")
|
11
|
-
Dir.exists?("/tmp/blah/blah").should == true
|
12
|
-
Dir.exists?("/tmp/foo/bar").should == true
|
13
|
-
end
|
14
|
-
|
15
|
-
after { FakeFS.deactivate! }
|
16
|
-
# after { ["/tmp/blah", "/tmp/foo"].each { |d| FileUtils.rm_rf(d) } }
|
17
|
-
end
|
data/spec/generator_spec.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'nokogiri'
|
3
|
-
|
4
|
-
# TODO Refactor when dealing with packaging-specific tasks.
|
5
|
-
module Mvnizer
|
6
|
-
describe PomGenerator do
|
7
|
-
|
8
|
-
let (:project) { Mvnizer::Project.new("test", "mvnizer", "1.0.0-SNAPSHOT", "jar")}
|
9
|
-
subject { Mvnizer::PomGenerator.new }
|
10
|
-
|
11
|
-
it "generates a pom" do
|
12
|
-
output = subject.generate(project)
|
13
|
-
|
14
|
-
# TODO: Ain't that a bit overkill for test?
|
15
|
-
doc = Nokogiri::XML(output)
|
16
|
-
doc.remove_namespaces!
|
17
|
-
doc.xpath("/project/groupId").first.text().should == "test"
|
18
|
-
doc.xpath("/project/artifactId").first.text().should == "mvnizer"
|
19
|
-
doc.xpath("/project/version").first.text().should == "1.0.0-SNAPSHOT"
|
20
|
-
doc.xpath("/project/name").first.text().should == "mvnizer"
|
21
|
-
doc.xpath("/project/packaging").first.should be_nil
|
22
|
-
end
|
23
|
-
|
24
|
-
it "adds the packaging when the type is not jar" do
|
25
|
-
project = Mvnizer::Project.new("test", "mvnizer", "1.0.0", "war")
|
26
|
-
output = subject.generate(project)
|
27
|
-
|
28
|
-
doc = Nokogiri::XML(output)
|
29
|
-
doc.remove_namespaces!
|
30
|
-
doc.xpath("/project/packaging").first.text().should == "war"
|
31
|
-
end
|
32
|
-
|
33
|
-
it "adds the dependencies" do
|
34
|
-
dependency = Mvnizer::Project.new("junit", "junit", "4.8.2", "jar", [], "test")
|
35
|
-
project.add_dependency(dependency)
|
36
|
-
output = subject.generate(project)
|
37
|
-
|
38
|
-
doc = Nokogiri::XML(output)
|
39
|
-
doc.remove_namespaces!
|
40
|
-
doc.xpath("/project/dependencies/dependency/groupId").first.text().should == "junit"
|
41
|
-
doc.xpath("/project/dependencies/dependency/artifactId").first.text().should == "junit"
|
42
|
-
doc.xpath("/project/dependencies/dependency/version").first.text().should == "4.8.2"
|
43
|
-
doc.xpath("/project/dependencies/dependency/scope").first.text().should == "test"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|