gjp 0.37.0 → 0.38.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/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +0 -130
- data/Rakefile +2 -2
- data/gjp.gemspec +2 -2
- data/integration-tests/commons.sh +1 -1
- data/lib/gjp.rb +12 -12
- data/lib/gjp/ant_runner.rb +2 -2
- data/lib/gjp/archiver.rb +13 -11
- data/lib/gjp/commands/ant.rb +1 -1
- data/lib/gjp/commands/base.rb +25 -26
- data/lib/gjp/commands/{download-maven-source-jars.rb → download_maven_source_jars.rb} +0 -0
- data/lib/gjp/commands/{dry-run.rb → dry_run.rb} +0 -0
- data/lib/gjp/commands/finish.rb +0 -1
- data/lib/gjp/commands/{generate-all.rb → generate_all.rb} +3 -4
- data/lib/gjp/commands/{generate-kit-archive.rb → generate_kit_archive.rb} +0 -1
- data/lib/gjp/commands/{generate-kit-spec.rb → generate_kit_spec.rb} +0 -1
- data/lib/gjp/commands/{generate-package-archive.rb → generate_package_archive.rb} +1 -2
- data/lib/gjp/commands/{generate-package-script.rb → generate_package_script.rb} +1 -2
- data/lib/gjp/commands/{generate-package-spec.rb → generate_package_spec.rb} +3 -4
- data/lib/gjp/commands/{get-pom.rb → get_pom.rb} +10 -9
- data/lib/gjp/commands/{get-source.rb → get_source.rb} +4 -5
- data/lib/gjp/commands/init.rb +0 -1
- data/lib/gjp/commands/{list-kit-missing-sources.rb → list_kit_missing_sources.rb} +1 -2
- data/lib/gjp/commands/{move-jars-to-kit.rb → move_jars_to_kit.rb} +0 -1
- data/lib/gjp/commands/mvn.rb +1 -2
- data/lib/gjp/git.rb +16 -14
- data/lib/gjp/kit_checker.rb +6 -6
- data/lib/gjp/kit_runner.rb +2 -2
- data/lib/gjp/kit_spec_adapter.rb +1 -2
- data/lib/gjp/logger.rb +16 -13
- data/lib/gjp/main.rb +0 -1
- data/lib/gjp/maven_runner.rb +2 -2
- data/lib/gjp/maven_website.rb +14 -14
- data/lib/gjp/package_spec_adapter.rb +9 -8
- data/lib/gjp/pom.rb +13 -14
- data/lib/gjp/pom_getter.rb +18 -16
- data/lib/gjp/project.rb +21 -22
- data/lib/gjp/script_generator.rb +8 -8
- data/lib/gjp/source_getter.rb +3 -3
- data/lib/gjp/spec_generator.rb +3 -3
- data/lib/gjp/template_manager.rb +2 -2
- data/lib/gjp/version.rb +1 -1
- data/lib/gjp/version_matcher.rb +32 -35
- data/spec/lib/archiver_spec.rb +3 -3
- data/spec/lib/git_spec.rb +1 -1
- data/spec/lib/kit_checker_spec.rb +10 -10
- data/spec/lib/pom_getter_spec.rb +2 -3
- data/spec/lib/pom_spec.rb +2 -3
- data/spec/lib/project_spec.rb +10 -10
- data/spec/lib/script_generator_spec.rb +1 -2
- data/spec/lib/source_getter_spec.rb +0 -1
- data/spec/lib/spec_generator_spec.rb +0 -1
- data/spec/lib/template_manager_spec.rb +1 -1
- data/spec/lib/version_matcher_spec.rb +8 -9
- data/spec/spec_helper.rb +0 -3
- metadata +13 -13
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
module Gjp
|
4
4
|
class GeneratePackageArchiveCommand < Gjp::BaseCommand
|
5
|
-
|
6
|
-
parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", :default => "."
|
5
|
+
parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", default: "."
|
7
6
|
|
8
7
|
def execute
|
9
8
|
checking_exceptions do
|
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
module Gjp
|
4
4
|
class GeneratePackageScriptCommand < Gjp::BaseCommand
|
5
|
-
|
6
|
-
parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", :default => "."
|
5
|
+
parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", default: "."
|
7
6
|
|
8
7
|
def execute
|
9
8
|
checking_exceptions do
|
@@ -2,10 +2,9 @@
|
|
2
2
|
|
3
3
|
module Gjp
|
4
4
|
class GeneratePackageSpecCommand < Gjp::BaseCommand
|
5
|
-
|
6
|
-
|
7
|
-
parameter "[
|
8
|
-
parameter "[POM]", "a pom file path", :default => "pom.xml"
|
5
|
+
option ["-f", "--filter"], "FILTER", "filter files to be installed by this spec", default: "*.jar"
|
6
|
+
parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", default: "."
|
7
|
+
parameter "[POM]", "a pom file path", default: "pom.xml"
|
9
8
|
|
10
9
|
def execute
|
11
10
|
checking_exceptions do
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Gjp
|
4
4
|
class GetPomCommand < Gjp::BaseCommand
|
5
|
-
|
6
5
|
parameter "NAME", "a jar file name or a `name-version` string (heuristic)"
|
7
6
|
|
8
7
|
def execute
|
@@ -12,18 +11,20 @@ module Gjp
|
|
12
11
|
|
13
12
|
path, status = pom_getter.get_pom(name)
|
14
13
|
if path
|
15
|
-
text_status =
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
text_status = (
|
15
|
+
if status == :found_in_jar
|
16
|
+
"was inside the jar"
|
17
|
+
elsif status == :found_via_sha1
|
18
|
+
"found by sha1 search from search.maven.org"
|
19
|
+
elsif status == :found_via_heuristic
|
20
|
+
"found by heuristic search from search.maven.org"
|
21
|
+
end
|
22
|
+
)
|
22
23
|
|
23
24
|
puts "#{format_path(path, project)} written, #{text_status}"
|
24
25
|
else
|
25
26
|
puts "#{name}'s pom not found. Try:"
|
26
|
-
puts "http://google.com/#q=#{URI
|
27
|
+
puts "http://google.com/#q=#{URI.encode(pom_getter.cleanup_name(name) + " pom")}"
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Gjp
|
4
4
|
class GetSourceCommand < Gjp::BaseCommand
|
5
|
-
|
6
5
|
parameter "POM", "a pom file path or URI"
|
7
6
|
|
8
7
|
def execute
|
@@ -17,17 +16,17 @@ module Gjp
|
|
17
16
|
effective_pom_path = Gjp::MavenRunner.new(project).get_effective_pom(pom)
|
18
17
|
puts "Source jar not found in Maven. Try looking here:"
|
19
18
|
pom = Gjp::Pom.new(effective_pom_path)
|
20
|
-
|
19
|
+
unless pom.url.empty?
|
21
20
|
puts "Website: #{pom.url}"
|
22
21
|
end
|
23
|
-
|
22
|
+
unless pom.scm_connection.empty?
|
24
23
|
puts "SCM connection: #{pom.scm_connection}"
|
25
24
|
end
|
26
|
-
|
25
|
+
unless pom.scm_url.empty?
|
27
26
|
puts "SCM connection: #{pom.scm_url}"
|
28
27
|
end
|
29
28
|
puts "The effective POM: #{effective_pom_path}"
|
30
|
-
puts "Google: http://google.com/#q=#{URI
|
29
|
+
puts "Google: http://google.com/#q=#{URI.encode(pom.name + " sources")}"
|
31
30
|
end
|
32
31
|
end
|
33
32
|
end
|
data/lib/gjp/commands/init.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Gjp
|
4
4
|
class ListKitMissingSourcesCommand < Gjp::BaseCommand
|
5
|
-
|
6
5
|
def execute
|
7
6
|
checking_exceptions do
|
8
7
|
project = Gjp::Project.new(".")
|
@@ -11,7 +10,7 @@ module Gjp
|
|
11
10
|
ensure_dry_running(false, project) do
|
12
11
|
puts "Some source files were not found in these archives:"
|
13
12
|
kit_checker.unsourced_archives.each do |archive|
|
14
|
-
percentage = "%.2f" % (100.0 * archive[:unsourced_class_names].length
|
13
|
+
percentage = "%.2f" % (100.0 * archive[:unsourced_class_names].length / archive[:class_names].length)
|
15
14
|
puts "#{format_path(archive[:archive], project)} (~#{percentage}% missing)"
|
16
15
|
end
|
17
16
|
end
|
data/lib/gjp/commands/mvn.rb
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
module Gjp
|
4
4
|
class MavenCommand < Gjp::BaseCommand
|
5
|
-
|
6
|
-
parameter "[MAVEN OPTIONS] ...", "mvn options", :attribute_name => "dummy"
|
5
|
+
parameter "[MAVEN OPTIONS] ...", "mvn options", attribute_name: "dummy"
|
7
6
|
|
8
7
|
# override parsing in order to pipe everything to mvn
|
9
8
|
def parse(args)
|
data/lib/gjp/git.rb
CHANGED
@@ -4,7 +4,7 @@ module Gjp
|
|
4
4
|
# facade to git, currently implemented with calls to the git command
|
5
5
|
# prefixes all tags with "gjp_"
|
6
6
|
class Git
|
7
|
-
include
|
7
|
+
include Logging
|
8
8
|
|
9
9
|
# inits a new git manager object pointing to the specified
|
10
10
|
# directory
|
@@ -15,7 +15,7 @@ module Gjp
|
|
15
15
|
# inits a repo
|
16
16
|
def init
|
17
17
|
Dir.chdir(@directory) do
|
18
|
-
if Dir.
|
18
|
+
if Dir.exist?(".git") == false
|
19
19
|
`git init`
|
20
20
|
else
|
21
21
|
raise GitAlreadyInitedError
|
@@ -34,11 +34,13 @@ module Gjp
|
|
34
34
|
def changed_files_between(start_tag, end_tag, directory)
|
35
35
|
Dir.chdir(@directory) do
|
36
36
|
prefixed_start_tag = "gjp_#{start_tag}"
|
37
|
-
prefixed_end_tag =
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
prefixed_end_tag = (
|
38
|
+
if end_tag
|
39
|
+
"gjp_#{end_tag}"
|
40
|
+
else
|
41
|
+
"HEAD"
|
42
|
+
end
|
43
|
+
)
|
42
44
|
`git diff-tree --no-commit-id --name-only -r #{prefixed_start_tag} #{prefixed_end_tag} -- #{directory}`
|
43
45
|
.split("\n")
|
44
46
|
end
|
@@ -63,8 +65,8 @@ module Gjp
|
|
63
65
|
`git add .`
|
64
66
|
`git commit -m "#{message}"`
|
65
67
|
|
66
|
-
|
67
|
-
if tag_message
|
68
|
+
unless tag.nil?
|
69
|
+
if !tag_message.nil?
|
68
70
|
`git tag gjp_#{tag} -m "#{tag_message}"`
|
69
71
|
else
|
70
72
|
`git tag gjp_#{tag}`
|
@@ -77,11 +79,11 @@ module Gjp
|
|
77
79
|
def get_tag_maximum_suffix(prefix)
|
78
80
|
Dir.chdir(@directory) do
|
79
81
|
`git tag`.split.map do |tag|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
82
|
+
if tag =~ /^gjp_#{prefix}_([0-9]+)$/
|
83
|
+
Regexp.last_match[1].to_i
|
84
|
+
else
|
85
|
+
0
|
86
|
+
end
|
85
87
|
end.max || 0
|
86
88
|
end
|
87
89
|
end
|
data/lib/gjp/kit_checker.rb
CHANGED
@@ -6,9 +6,9 @@ require "zip"
|
|
6
6
|
module Gjp
|
7
7
|
# checks kits for errors
|
8
8
|
class KitChecker
|
9
|
-
include
|
9
|
+
include Logging
|
10
10
|
|
11
|
-
def initialize(project)
|
11
|
+
def initialize(project)
|
12
12
|
@project = project
|
13
13
|
end
|
14
14
|
|
@@ -45,14 +45,14 @@ module Gjp
|
|
45
45
|
path =~ /\.java$/
|
46
46
|
end
|
47
47
|
|
48
|
-
# heuristically add all possible package names, walking
|
48
|
+
# heuristically add all possible package names, walking
|
49
49
|
# back the directory tree all the way back to root.
|
50
50
|
# This could add non-existent names, but allows not looking
|
51
51
|
# in the file at all
|
52
52
|
class_names = source_paths.map do |path, archive|
|
53
53
|
class_name = path_to_class(path)
|
54
54
|
parts = class_name.split(".")
|
55
|
-
last_index = parts.length
|
55
|
+
last_index = parts.length - 1
|
56
56
|
(0..last_index).map do |i|
|
57
57
|
parts[i..last_index].join(".")
|
58
58
|
end
|
@@ -69,7 +69,7 @@ module Gjp
|
|
69
69
|
path =~ /\.class$/
|
70
70
|
end.each do |path, archive|
|
71
71
|
class_name = path_to_class(path)
|
72
|
-
if result[archive]
|
72
|
+
if result[archive].nil?
|
73
73
|
result[archive] = [class_name]
|
74
74
|
else
|
75
75
|
result[archive] << class_name
|
@@ -90,7 +90,7 @@ module Gjp
|
|
90
90
|
unsourced_class_names = class_names.select do |class_name|
|
91
91
|
source_class_names.include?(class_name) == false
|
92
92
|
end
|
93
|
-
{:
|
93
|
+
{ archive: archive, class_names: class_names, unsourced_class_names: unsourced_class_names }
|
94
94
|
end.select do |archive|
|
95
95
|
archive[:unsourced_class_names].any?
|
96
96
|
end
|
data/lib/gjp/kit_runner.rb
CHANGED
data/lib/gjp/kit_spec_adapter.rb
CHANGED
data/lib/gjp/logger.rb
CHANGED
@@ -1,27 +1,30 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
require "singleton"
|
4
|
+
require "forwardable"
|
3
5
|
require "logger"
|
4
6
|
|
5
7
|
module Gjp
|
6
|
-
|
7
|
-
|
8
|
+
class Logger
|
9
|
+
include Singleton
|
10
|
+
extend Forwardable
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
12
|
+
def_delegators :@logger, :debug, :info, :warn, :error, :fatal, :level=
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@logger = ::Logger.new(STDERR)
|
16
|
+
@logger.datetime_format = "%Y-%m-%d %H:%M "
|
17
|
+
@logger.level = ::Logger::ERROR
|
18
|
+
@logger.formatter = proc do |severity, datetime, progname, msg|
|
19
|
+
"#{severity.chars.first}: #{msg}\n"
|
18
20
|
end
|
19
|
-
@@logger
|
20
21
|
end
|
22
|
+
end
|
21
23
|
|
24
|
+
module Logging
|
22
25
|
# convenience instance method
|
23
26
|
def log
|
24
|
-
Gjp::Logger.
|
27
|
+
Gjp::Logger.instance
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
data/lib/gjp/main.rb
CHANGED
data/lib/gjp/maven_runner.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Gjp
|
4
4
|
# runs Maven with gjp-specific options
|
5
5
|
class MavenRunner < KitRunner
|
6
|
-
include
|
6
|
+
include Logging
|
7
7
|
|
8
8
|
# runs Maven in a subprocess
|
9
9
|
def mvn(options)
|
@@ -33,7 +33,7 @@ module Gjp
|
|
33
33
|
def get_maven_commandline(prefix, options)
|
34
34
|
executable = find_executable("mvn")
|
35
35
|
|
36
|
-
if executable
|
36
|
+
if !executable.nil?
|
37
37
|
mvn_path = File.join(prefix, executable)
|
38
38
|
repo_path = File.join(prefix, "kit", "m2")
|
39
39
|
config_path = File.join(prefix, "kit", "m2", "settings.xml")
|
data/lib/gjp/maven_website.rb
CHANGED
@@ -4,58 +4,58 @@ require "text"
|
|
4
4
|
|
5
5
|
module Gjp
|
6
6
|
# Facade to search.maven.org
|
7
|
-
class MavenWebsite
|
8
|
-
include
|
7
|
+
class MavenWebsite
|
8
|
+
include Logging
|
9
9
|
|
10
10
|
# returns a search result object from search.maven.com
|
11
11
|
# searching by a jar sha1 hash
|
12
12
|
# see output format at http://search.maven.org/#api
|
13
13
|
def search_by_sha1(sha1)
|
14
|
-
|
14
|
+
search(q: "1:\"#{sha1}\"")
|
15
15
|
end
|
16
16
|
|
17
17
|
# returns a search result object from search.maven.com
|
18
18
|
# searching by keyword (name)
|
19
19
|
# see output format at http://search.maven.org/#api
|
20
20
|
def search_by_name(name)
|
21
|
-
|
21
|
+
search(q: name)
|
22
22
|
end
|
23
23
|
|
24
24
|
# returns a search result object from search.maven.com
|
25
25
|
# searching by Maven's group id and artifact id
|
26
26
|
# see output format at http://search.maven.org/#api
|
27
27
|
def search_by_group_id_and_artifact_id(group_id, artifact_id)
|
28
|
-
|
28
|
+
search(q: "g:\"#{group_id}\" AND a:\"#{artifact_id}\"", core: "gav")
|
29
29
|
end
|
30
30
|
|
31
31
|
# returns a search result object from search.maven.com
|
32
32
|
# searching by Maven's id (group id, artifact id and version)
|
33
33
|
# see output format at http://search.maven.org/#api
|
34
34
|
def search_by_maven_id(group_id, artifact_id, version)
|
35
|
-
|
35
|
+
search(q: "g:\"#{group_id}\" AND a:\"#{artifact_id}\" AND v:\"#{version}\"")
|
36
36
|
end
|
37
37
|
|
38
38
|
# returns a search result object from search.maven.com
|
39
39
|
# see input and output format at http://search.maven.org/#api
|
40
40
|
def search(params)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
response = RestClient.get("http://search.maven.org/solrsearch/select",
|
42
|
+
params: params.merge("rows" => "100", "wt" => "json")
|
43
|
+
)
|
44
|
+
json = JSON.parse(response.to_s)
|
45
|
+
json["response"]["docs"]
|
46
46
|
end
|
47
47
|
|
48
48
|
# returns a Maven's triple (artifactId, groupId, version)
|
49
49
|
# from a result object
|
50
50
|
def get_maven_id_from(result)
|
51
|
-
|
51
|
+
[result["g"], result["a"], result["v"]]
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
# downloads a POM from a search.maven.com search result
|
55
55
|
def download_pom(group_id, artifact_id, version)
|
56
56
|
path = "#{group_id.gsub(".", "/")}/#{artifact_id}/#{version}/#{artifact_id}-#{version}.pom"
|
57
57
|
log.debug("downloading #{path}...")
|
58
|
-
|
58
|
+
(RestClient.get "http://search.maven.org/remotecontent", params: { filepath: path }).to_s
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|