gjp 0.29.0 → 0.30.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/README.md +86 -111
- data/lib/gjp.rb +2 -2
- data/lib/gjp/ant_runner.rb +27 -0
- data/lib/gjp/cli.rb +27 -26
- data/lib/gjp/kit_runner.rb +2 -42
- data/lib/gjp/limited_network_user.rb +1 -1
- data/lib/gjp/maven_runner.rb +47 -0
- data/lib/gjp/pom.rb +10 -17
- data/lib/gjp/pom_getter.rb +10 -3
- data/lib/gjp/project.rb +5 -5
- data/lib/gjp/script_generator.rb +4 -3
- data/lib/gjp/source_getter.rb +12 -81
- data/lib/gjp/version.rb +1 -1
- data/lib/gjp/version_matcher.rb +2 -2
- data/spec/lib/ant_runner_spec.rb +46 -0
- data/spec/lib/kit_runner_spec.rb +5 -76
- data/spec/lib/maven_runner_spec.rb +67 -0
- data/spec/lib/pom_getter_spec.rb +6 -0
- data/spec/lib/pom_spec.rb +12 -22
- data/spec/lib/source_getter_spec.rb +9 -42
- data/spec/spec_helper.rb +28 -11
- metadata +8 -8
- data/lib/gjp/parent_pom_getter.rb +0 -22
- data/lib/gjp/source_address_getter.rb +0 -51
- data/spec/lib/parent_pom_getter_spec.rb +0 -16
- data/spec/lib/source_address_getter_spec.rb +0 -20
@@ -0,0 +1,67 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'lib/kit_runner_spec'
|
5
|
+
|
6
|
+
describe Gjp::MavenRunner do
|
7
|
+
it_behaves_like Gjp::KitRunner
|
8
|
+
include Gjp::Mockers
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
create_mock_project
|
12
|
+
@kit_runner = Gjp::MavenRunner.new(@project)
|
13
|
+
end
|
14
|
+
|
15
|
+
after(:each) do
|
16
|
+
delete_mock_project
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#get_maven_commandline" do
|
20
|
+
it "returns commandline options for running maven" do
|
21
|
+
executable_path = create_mock_executable("mvn")
|
22
|
+
|
23
|
+
@project.from_directory do
|
24
|
+
commandline = @kit_runner.get_maven_commandline(".")
|
25
|
+
commandline.should eq "./#{executable_path} -Dmaven.repo.local=./kit/m2 -s./kit/m2/settings.xml"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
it "doesn't return commandline options if Maven is not available" do
|
29
|
+
expect { @kit_runner.get_maven_commandline(".") }.to raise_error(Gjp::ExecutableNotFoundError)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#mvn" do
|
34
|
+
it "runs maven" do
|
35
|
+
create_mock_executable("mvn")
|
36
|
+
@project.from_directory do
|
37
|
+
@kit_runner.mvn(["extra-option"])
|
38
|
+
File.read("test_out").strip.should match /extra-option$/
|
39
|
+
end
|
40
|
+
end
|
41
|
+
it "doesn't run Maven if it is not available" do
|
42
|
+
@project.from_directory do
|
43
|
+
expect { @kit_runner.mvn([]) }.to raise_error(Gjp::ExecutableNotFoundError)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#get_source_jar" do
|
49
|
+
it "runs maven to get a source jar" do
|
50
|
+
create_mock_executable("mvn")
|
51
|
+
@project.from_directory do
|
52
|
+
@kit_runner.get_source_jar("test_group", "test_artifact_id", "test_version")
|
53
|
+
File.read("test_out").strip.should match /dependency:get -Dartifact=test_group:test_artifact_id:test_version:jar:sources -Dtransitive=false$/
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#get_effective_pom" do
|
59
|
+
it "runs maven to get an effective pom" do
|
60
|
+
create_mock_executable("mvn")
|
61
|
+
@project.from_directory do
|
62
|
+
@kit_runner.get_effective_pom("test.pom").should eq "test.pom.effective"
|
63
|
+
File.read("test_out").strip.should match /help:effective-pom -ftest.pom -Doutput=test.pom.effective$/
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/spec/lib/pom_getter_spec.rb
CHANGED
@@ -11,6 +11,8 @@ describe Gjp::PomGetter do
|
|
11
11
|
jar_path = File.join(dir_path, "commons-logging-1.1.1.jar")
|
12
12
|
path, status = pom_getter.get_pom(jar_path)
|
13
13
|
status.should eq :found_in_jar
|
14
|
+
File.exist?(path).should be_true
|
15
|
+
FileUtils.rm(path)
|
14
16
|
end
|
15
17
|
|
16
18
|
it "gets the pom from sha1" do
|
@@ -18,6 +20,8 @@ describe Gjp::PomGetter do
|
|
18
20
|
jar_path = File.join(dir_path, "antlr-2.7.2.jar")
|
19
21
|
path, status = pom_getter.get_pom(jar_path)
|
20
22
|
status.should eq :found_via_sha1
|
23
|
+
File.exist?(path).should be_true
|
24
|
+
FileUtils.rm(path)
|
21
25
|
end
|
22
26
|
|
23
27
|
it "gets the pom from a heuristic" do
|
@@ -25,6 +29,8 @@ describe Gjp::PomGetter do
|
|
25
29
|
jar_path = File.join(dir_path, "nailgun-0.7.1.jar")
|
26
30
|
path, status = pom_getter.get_pom(jar_path)
|
27
31
|
status.should eq :found_via_heuristic
|
32
|
+
File.exist?(path).should be_true
|
33
|
+
FileUtils.rm(path)
|
28
34
|
end
|
29
35
|
end
|
30
36
|
end
|
data/spec/lib/pom_spec.rb
CHANGED
@@ -5,16 +5,6 @@ require 'spec_helper'
|
|
5
5
|
describe Gjp::Pom do
|
6
6
|
let(:pom) { Gjp::Pom.new(File.join("spec", "data", "commons-logging", "pom.xml")) }
|
7
7
|
|
8
|
-
describe "#connection_address" do
|
9
|
-
it "reads the SCM connection address" do
|
10
|
-
pom.connection_address.should eq "svn:http://svn.apache.org/repos/asf/commons/proper/logging/tags/commons-logging-1.1.1"
|
11
|
-
end
|
12
|
-
|
13
|
-
it "reads the SCM connection address from a remote repository" do
|
14
|
-
pom.connection_address.should eq "svn:http://svn.apache.org/repos/asf/commons/proper/logging/tags/commons-logging-1.1.1"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
8
|
describe "#group_id" do
|
19
9
|
it "reads the group id" do
|
20
10
|
pom.group_id.should eq "commons-logging"
|
@@ -27,6 +17,12 @@ describe Gjp::Pom do
|
|
27
17
|
end
|
28
18
|
end
|
29
19
|
|
20
|
+
describe "#name" do
|
21
|
+
it "reads artifact name" do
|
22
|
+
pom.name.should eq "Commons Logging"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
30
26
|
describe "#version" do
|
31
27
|
it "reads the version" do
|
32
28
|
pom.version.should eq "1.1.1"
|
@@ -57,21 +53,15 @@ describe Gjp::Pom do
|
|
57
53
|
end
|
58
54
|
end
|
59
55
|
|
60
|
-
describe "#
|
61
|
-
it "reads the
|
62
|
-
pom.
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "#parent_artifact_id" do
|
67
|
-
it "reads the parent's artifact id" do
|
68
|
-
pom.parent_artifact_id.should eq "commons-parent"
|
56
|
+
describe "#scm_connection" do
|
57
|
+
it "reads the SCM connection address" do
|
58
|
+
pom.scm_connection.should eq "scm:svn:http://svn.apache.org/repos/asf/commons/proper/logging/tags/commons-logging-1.1.1"
|
69
59
|
end
|
70
60
|
end
|
71
61
|
|
72
|
-
describe "#
|
73
|
-
it "reads the
|
74
|
-
pom.
|
62
|
+
describe "#scm_url" do
|
63
|
+
it "reads the SCM connection url" do
|
64
|
+
pom.scm_url.should eq "http://svn.apache.org/repos/asf/commons/proper/logging/tags/commons-logging-1.1.1"
|
75
65
|
end
|
76
66
|
end
|
77
67
|
end
|
@@ -4,19 +4,20 @@ require "spec_helper"
|
|
4
4
|
require "fileutils"
|
5
5
|
|
6
6
|
describe Gjp::SourceGetter do
|
7
|
+
include Gjp::Mockers
|
7
8
|
let(:source_getter) { Gjp::SourceGetter.new }
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
Dir.mkdir(@project_path)
|
10
|
+
before(:each) do
|
11
|
+
create_mock_project
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
after(:each) do
|
15
|
+
delete_mock_project
|
16
|
+
end
|
17
17
|
|
18
|
+
describe "#get_maven_source_jars" do
|
18
19
|
it "gets sources for jars in the Maven repo through Maven itself" do
|
19
|
-
|
20
|
+
create_mock_executable("mvn")
|
20
21
|
|
21
22
|
@project.from_directory(File.join("kit", "m2")) do
|
22
23
|
jar_dir_path = File.join("net", "test", "artifact", "1.0")
|
@@ -31,40 +32,6 @@ describe Gjp::SourceGetter do
|
|
31
32
|
failures.should eq []
|
32
33
|
end
|
33
34
|
end
|
34
|
-
|
35
|
-
after(:each) do
|
36
|
-
FileUtils.rm_rf(@project_path)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "#get_source_from_git" do
|
41
|
-
it "gets the sources from a git repo" do
|
42
|
-
dir_path = File.join("spec", "data", "nailgun")
|
43
|
-
pom_path = File.join(dir_path, "pom.xml")
|
44
|
-
repo_path = File.join(dir_path, "com.martiansoftware:nailgun-all:0.9.1")
|
45
|
-
file_path = File.join(repo_path, "README.md")
|
46
|
-
|
47
|
-
FileUtils.rm_rf(repo_path)
|
48
|
-
|
49
|
-
source_getter.get_source("git:git@github.com:martylamb/nailgun.git", pom_path, dir_path)
|
50
|
-
|
51
|
-
File.open(file_path).readline.should eq "nailgun\n"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "#get_source_from_svn" do
|
56
|
-
it "gets the sources from an svn repo" do
|
57
|
-
dir_path = File.join("spec", "data", "struts-apps")
|
58
|
-
pom_path = File.join(dir_path, "pom.xml")
|
59
|
-
repo_path = File.join(dir_path, "org.apache.struts:struts2-apps:")
|
60
|
-
file_path = File.join(repo_path, "showcase", "README.txt")
|
61
|
-
|
62
|
-
FileUtils.rm_rf(repo_path)
|
63
|
-
|
64
|
-
source_getter.get_source("svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_14/apps", pom_path, dir_path)
|
65
|
-
|
66
|
-
File.open(file_path).readline.should eq "README.txt - showcase\n"
|
67
|
-
end
|
68
35
|
end
|
69
36
|
end
|
70
37
|
|
data/spec/spec_helper.rb
CHANGED
@@ -5,16 +5,33 @@ require "gjp/logger"
|
|
5
5
|
|
6
6
|
Gjp::Logger.log.level = ::Logger::DEBUG
|
7
7
|
|
8
|
-
#
|
9
|
-
|
10
|
-
#
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
# custom mock methods
|
9
|
+
module Gjp::Mockers
|
10
|
+
# creates a minimal gjp project
|
11
|
+
def create_mock_project
|
12
|
+
@project_path = File.join("spec", "data", "test-project")
|
13
|
+
Dir.mkdir(@project_path)
|
14
|
+
|
15
|
+
Gjp::Project.init(@project_path)
|
16
|
+
@project = Gjp::Project.new(@project_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
# deletes the mock project and all contents
|
20
|
+
def delete_mock_project
|
21
|
+
FileUtils.rm_rf(@project_path)
|
22
|
+
end
|
23
|
+
|
24
|
+
# creates an executable in kit that will print its parameters
|
25
|
+
# in a test_out file for checking. Returns mocked executable
|
26
|
+
# full path
|
27
|
+
def create_mock_executable(executable_name)
|
28
|
+
Dir.chdir(@project_path) do
|
29
|
+
bin_dir = File.join("kit", executable_name, "bin")
|
30
|
+
FileUtils.mkdir_p(bin_dir)
|
31
|
+
executable_path = File.join(bin_dir, executable_name)
|
32
|
+
File.open(executable_path, "w") { |io| io.puts "echo $0 $*>test_out" }
|
33
|
+
File.chmod(0777, executable_path)
|
34
|
+
executable_path
|
35
|
+
end
|
19
36
|
end
|
20
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gjp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.30.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- gjp.gemspec
|
158
158
|
- integration-tests/commons.sh
|
159
159
|
- lib/gjp.rb
|
160
|
+
- lib/gjp/ant_runner.rb
|
160
161
|
- lib/gjp/archiver.rb
|
161
162
|
- lib/gjp/cli.rb
|
162
163
|
- lib/gjp/git.rb
|
@@ -164,14 +165,13 @@ files:
|
|
164
165
|
- lib/gjp/kit_spec_adapter.rb
|
165
166
|
- lib/gjp/limited_network_user.rb
|
166
167
|
- lib/gjp/logger.rb
|
168
|
+
- lib/gjp/maven_runner.rb
|
167
169
|
- lib/gjp/maven_website.rb
|
168
170
|
- lib/gjp/package_spec_adapter.rb
|
169
|
-
- lib/gjp/parent_pom_getter.rb
|
170
171
|
- lib/gjp/pom.rb
|
171
172
|
- lib/gjp/pom_getter.rb
|
172
173
|
- lib/gjp/project.rb
|
173
174
|
- lib/gjp/script_generator.rb
|
174
|
-
- lib/gjp/source_address_getter.rb
|
175
175
|
- lib/gjp/source_getter.rb
|
176
176
|
- lib/gjp/spec_generator.rb
|
177
177
|
- lib/gjp/template_manager.rb
|
@@ -201,17 +201,17 @@ files:
|
|
201
201
|
- spec/data/nailgun/pom.xml
|
202
202
|
- spec/data/struts-apps/pom.xml
|
203
203
|
- spec/data/tomcat/pom.xml
|
204
|
+
- spec/lib/ant_runner_spec.rb
|
204
205
|
- spec/lib/archiver_spec.rb
|
205
206
|
- spec/lib/git_spec.rb
|
206
207
|
- spec/lib/kit_runner_spec.rb
|
207
208
|
- spec/lib/limited_network_user_spec_interactive.rb
|
209
|
+
- spec/lib/maven_runner_spec.rb
|
208
210
|
- spec/lib/maven_website_spec.rb
|
209
|
-
- spec/lib/parent_pom_getter_spec.rb
|
210
211
|
- spec/lib/pom_getter_spec.rb
|
211
212
|
- spec/lib/pom_spec.rb
|
212
213
|
- spec/lib/project_spec.rb
|
213
214
|
- spec/lib/script_generator_spec.rb
|
214
|
-
- spec/lib/source_address_getter_spec.rb
|
215
215
|
- spec/lib/source_getter_spec.rb
|
216
216
|
- spec/lib/spec_generator_spec.rb
|
217
217
|
- spec/lib/template_manager_spec.rb
|
@@ -259,17 +259,17 @@ test_files:
|
|
259
259
|
- spec/data/nailgun/pom.xml
|
260
260
|
- spec/data/struts-apps/pom.xml
|
261
261
|
- spec/data/tomcat/pom.xml
|
262
|
+
- spec/lib/ant_runner_spec.rb
|
262
263
|
- spec/lib/archiver_spec.rb
|
263
264
|
- spec/lib/git_spec.rb
|
264
265
|
- spec/lib/kit_runner_spec.rb
|
265
266
|
- spec/lib/limited_network_user_spec_interactive.rb
|
267
|
+
- spec/lib/maven_runner_spec.rb
|
266
268
|
- spec/lib/maven_website_spec.rb
|
267
|
-
- spec/lib/parent_pom_getter_spec.rb
|
268
269
|
- spec/lib/pom_getter_spec.rb
|
269
270
|
- spec/lib/pom_spec.rb
|
270
271
|
- spec/lib/project_spec.rb
|
271
272
|
- spec/lib/script_generator_spec.rb
|
272
|
-
- spec/lib/source_address_getter_spec.rb
|
273
273
|
- spec/lib/source_getter_spec.rb
|
274
274
|
- spec/lib/spec_generator_spec.rb
|
275
275
|
- spec/lib/template_manager_spec.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require "pathname"
|
4
|
-
|
5
|
-
module Gjp
|
6
|
-
# attempts to get a pom's parent pom
|
7
|
-
class ParentPomGetter
|
8
|
-
include Logger
|
9
|
-
|
10
|
-
# returns the pom's parent, if any
|
11
|
-
def get_parent_pom(filename)
|
12
|
-
begin
|
13
|
-
pom = Pom.new(filename)
|
14
|
-
site = MavenWebsite.new
|
15
|
-
|
16
|
-
site.download_pom(pom.parent_group_id, pom.parent_artifact_id, pom.parent_version)
|
17
|
-
rescue RestClient::ResourceNotFound
|
18
|
-
$stderr.puts "Could not find a parent for this pom!"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require "rest_client"
|
4
|
-
require "json"
|
5
|
-
require "open-uri"
|
6
|
-
|
7
|
-
module Gjp
|
8
|
-
# attempts to get java projects' scm addresses
|
9
|
-
class SourceAddressGetter
|
10
|
-
include Logger
|
11
|
-
|
12
|
-
# returns the pom corresponding to a file or directory, if it can be found
|
13
|
-
def get_source_address(file)
|
14
|
-
log.info("looking for source address for: #{file}")
|
15
|
-
(get_source_address_from_pom(file) or get_source_address_from_github(file))
|
16
|
-
end
|
17
|
-
|
18
|
-
# returns an scm address in a pom file
|
19
|
-
def get_source_address_from_pom(file)
|
20
|
-
pom = Pom.new(file)
|
21
|
-
result = pom.connection_address
|
22
|
-
|
23
|
-
if result != nil
|
24
|
-
log.info("address found in pom")
|
25
|
-
result
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# returns an scm address looking for it on github
|
30
|
-
def get_source_address_from_github(file)
|
31
|
-
pom = Pom.new(file)
|
32
|
-
|
33
|
-
result = (github_search(pom.artifact_id) or github_search(pom.artifact_id.split("-").first) or github_search(pom.group_id))
|
34
|
-
|
35
|
-
if result != nil
|
36
|
-
log.info("address found on Github: #{result}")
|
37
|
-
result
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# returns a Giuthub repo address based on the keyword
|
42
|
-
def github_search(keyword)
|
43
|
-
if keyword != "" and keyword != nil
|
44
|
-
response = RestClient.get "https://api.github.com/legacy/repos/search/" + CGI::escape(keyword), :user_agent => "gjp/" + Gjp::VERSION, :language => "java", :sort => "forks"
|
45
|
-
json = JSON.parse(response.to_s)
|
46
|
-
|
47
|
-
(json["repositories"].map {|repository| "git:" + repository["url"]}).first
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Gjp::ParentPomGetter do
|
6
|
-
let(:parent_pom_getter) { Gjp::ParentPomGetter.new }
|
7
|
-
|
8
|
-
describe "#get_parent_pom" do
|
9
|
-
it "gets the the parent of a pom" do
|
10
|
-
dir_path = File.join("spec", "data", "commons-logging")
|
11
|
-
pom_path = File.join(dir_path, "pom.xml")
|
12
|
-
parent_pom_path = File.join(dir_path, "parent_pom.xml")
|
13
|
-
parent_pom_getter.get_parent_pom(pom_path).should eq(File.read(parent_pom_path))
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Gjp::SourceAddressGetter do
|
6
|
-
let(:source_address_getter) { Gjp::SourceAddressGetter.new }
|
7
|
-
|
8
|
-
describe "#get_source_address" do
|
9
|
-
it "gets the source address from a pom file" do
|
10
|
-
pom_path = File.join("spec", "data", "commons-logging", "pom.xml")
|
11
|
-
source_address_getter.get_source_address(pom_path).should eq "svn:http://svn.apache.org/repos/asf/commons/proper/logging/tags/commons-logging-1.1.1"
|
12
|
-
end
|
13
|
-
|
14
|
-
it "gets the source address from Github" do
|
15
|
-
pom_path = File.join("spec", "data", "antlr", "pom.xml")
|
16
|
-
source_address_getter.get_source_address(pom_path).should eq "git:https://github.com/antlr/antlr4"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|