gjp 0.36.0 → 0.37.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/.gitignore +4 -0
- data/.rubocop.yml +7 -0
- data/.rubocop_todo.yml +241 -0
- data/SPECIAL_CASES.md +2 -5
- data/integration-tests/commons.sh +2 -0
- data/lib/gjp.rb +22 -1
- data/lib/gjp/ant_runner.rb +1 -1
- data/lib/gjp/archiver.rb +11 -11
- data/lib/gjp/commands/ant.rb +21 -0
- data/lib/gjp/commands/base.rb +94 -0
- data/lib/gjp/commands/download-maven-source-jars.rb +28 -0
- data/lib/gjp/commands/dry-run.rb +16 -0
- data/lib/gjp/commands/finish.rb +22 -0
- data/lib/gjp/commands/generate-all.rb +38 -0
- data/lib/gjp/commands/generate-kit-archive.rb +18 -0
- data/lib/gjp/commands/generate-kit-spec.rb +16 -0
- data/lib/gjp/commands/generate-package-archive.rb +19 -0
- data/lib/gjp/commands/generate-package-script.rb +21 -0
- data/lib/gjp/commands/generate-package-spec.rb +22 -0
- data/lib/gjp/commands/get-pom.rb +31 -0
- data/lib/gjp/commands/get-source.rb +35 -0
- data/lib/gjp/commands/init.rb +15 -0
- data/lib/gjp/commands/list-kit-missing-sources.rb +21 -0
- data/lib/gjp/commands/move-jars-to-kit.rb +18 -0
- data/lib/gjp/commands/mvn.rb +22 -0
- data/lib/gjp/git.rb +18 -8
- data/lib/gjp/kit_checker.rb +6 -6
- data/lib/gjp/kit_runner.rb +2 -2
- data/lib/gjp/kit_spec_adapter.rb +1 -1
- data/lib/gjp/main.rb +103 -0
- data/lib/gjp/maven_runner.rb +1 -1
- data/lib/gjp/maven_website.rb +8 -6
- data/lib/gjp/package_spec_adapter.rb +1 -1
- data/lib/gjp/pom.rb +3 -1
- data/lib/gjp/pom_getter.rb +12 -4
- data/lib/gjp/project.rb +4 -2
- data/lib/gjp/script_generator.rb +2 -1
- data/lib/gjp/spec_generator.rb +2 -2
- data/lib/gjp/version.rb +1 -1
- data/lib/gjp/version_matcher.rb +3 -3
- data/lib/template/kit.spec +1 -0
- data/lib/template/package.spec +1 -0
- data/spec/lib/ant_runner_spec.rb +3 -3
- data/spec/lib/archiver_spec.rb +1 -1
- data/spec/lib/git_spec.rb +25 -3
- data/spec/lib/kit_checker_spec.rb +6 -6
- data/spec/lib/kit_runner_spec.rb +1 -1
- data/spec/lib/maven_runner_spec.rb +6 -5
- data/spec/lib/maven_website_spec.rb +2 -2
- data/spec/lib/pom_getter_spec.rb +1 -1
- data/spec/lib/pom_spec.rb +5 -3
- data/spec/lib/project_spec.rb +15 -14
- data/spec/lib/script_generator_spec.rb +4 -2
- data/spec/lib/source_getter_spec.rb +1 -1
- data/spec/lib/spec_generator_spec.rb +2 -2
- data/spec/lib/template_manager_spec.rb +6 -6
- data/spec/lib/version_matcher_spec.rb +1 -1
- data/spec/spec_helper.rb +25 -23
- metadata +22 -3
- data/lib/gjp/cli.rb +0 -384
data/lib/gjp/kit_runner.rb
CHANGED
data/lib/gjp/kit_spec_adapter.rb
CHANGED
data/lib/gjp/main.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require "clamp"
|
3
|
+
|
4
|
+
module Gjp
|
5
|
+
class MainCommand < Clamp::Command
|
6
|
+
|
7
|
+
subcommand(
|
8
|
+
"init",
|
9
|
+
"Inits a gjp project in the current directory",
|
10
|
+
Gjp::InitCommand
|
11
|
+
)
|
12
|
+
|
13
|
+
subcommand(
|
14
|
+
"dry-run",
|
15
|
+
"Starts a dry-run build",
|
16
|
+
Gjp::DryRunCommand
|
17
|
+
)
|
18
|
+
|
19
|
+
subcommand(
|
20
|
+
"mvn",
|
21
|
+
"Locates and runs Maven from any directory in kit/",
|
22
|
+
Gjp::MavenCommand
|
23
|
+
)
|
24
|
+
|
25
|
+
subcommand(
|
26
|
+
"ant",
|
27
|
+
"Locates and runs Ant from any directory in kit/",
|
28
|
+
Gjp::AntCommand
|
29
|
+
)
|
30
|
+
|
31
|
+
subcommand(
|
32
|
+
"finish",
|
33
|
+
"Ends the current dry-run",
|
34
|
+
Gjp::FinishCommand
|
35
|
+
)
|
36
|
+
|
37
|
+
subcommand(
|
38
|
+
"generate-kit-archive",
|
39
|
+
"Create or refresh the kit tarball",
|
40
|
+
Gjp::GenerateKitArchiveCommand
|
41
|
+
)
|
42
|
+
|
43
|
+
subcommand(
|
44
|
+
"generate-kit-spec",
|
45
|
+
"Create or refresh a spec file for the kit",
|
46
|
+
Gjp::GenerateKitSpecCommand
|
47
|
+
)
|
48
|
+
|
49
|
+
subcommand(
|
50
|
+
"generate-package-script",
|
51
|
+
"Create or refresh a build.sh file for a package",
|
52
|
+
Gjp::GeneratePackageScriptCommand
|
53
|
+
)
|
54
|
+
|
55
|
+
subcommand(
|
56
|
+
"generate-package-archive",
|
57
|
+
"Create or refresh a package tarball",
|
58
|
+
Gjp::GeneratePackageArchiveCommand
|
59
|
+
)
|
60
|
+
|
61
|
+
subcommand(
|
62
|
+
"generate-package-spec",
|
63
|
+
"Create or refresh a spec file for a package",
|
64
|
+
Gjp::GeneratePackageSpecCommand
|
65
|
+
)
|
66
|
+
|
67
|
+
subcommand(
|
68
|
+
"generate-all",
|
69
|
+
"Create or refresh specs, archives, scripts for a package and the kit",
|
70
|
+
Gjp::GenerateAllCommand
|
71
|
+
)
|
72
|
+
|
73
|
+
subcommand(
|
74
|
+
"move-jars-to-kit",
|
75
|
+
"Locates jars in src/ and moves them to kit/",
|
76
|
+
Gjp::MoveJarsToKitCommand
|
77
|
+
)
|
78
|
+
|
79
|
+
subcommand(
|
80
|
+
"download-maven-source-jars",
|
81
|
+
"Attempts to download Maven kit/ sources",
|
82
|
+
Gjp::DownloadMavenSourceJarsCommand
|
83
|
+
)
|
84
|
+
|
85
|
+
subcommand(
|
86
|
+
"get-pom",
|
87
|
+
"Retrieves a pom file",
|
88
|
+
Gjp::GetPomCommand
|
89
|
+
)
|
90
|
+
|
91
|
+
subcommand(
|
92
|
+
"get-source",
|
93
|
+
"Attempts to retrieve a project's sources",
|
94
|
+
Gjp::GetSourceCommand
|
95
|
+
)
|
96
|
+
|
97
|
+
subcommand(
|
98
|
+
"list-kit-missing-sources",
|
99
|
+
"Locates jars in kit/ that have no source files",
|
100
|
+
Gjp::ListKitMissingSourcesCommand
|
101
|
+
)
|
102
|
+
end
|
103
|
+
end
|
data/lib/gjp/maven_runner.rb
CHANGED
@@ -38,7 +38,7 @@ module Gjp
|
|
38
38
|
repo_path = File.join(prefix, "kit", "m2")
|
39
39
|
config_path = File.join(prefix, "kit", "m2", "settings.xml")
|
40
40
|
|
41
|
-
"#{mvn_path} -Dmaven.repo.local=#{repo_path} -s#{config_path} #{options.join(
|
41
|
+
"#{mvn_path} -Dmaven.repo.local=#{repo_path} -s#{config_path} #{options.join(" ")}"
|
42
42
|
else
|
43
43
|
raise ExecutableNotFoundError.new("mvn")
|
44
44
|
end
|
data/lib/gjp/maven_website.rb
CHANGED
@@ -11,34 +11,36 @@ module Gjp
|
|
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
|
-
return search(
|
14
|
+
return 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
|
-
return search(
|
21
|
+
return 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
|
-
return search(
|
28
|
+
return 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
|
-
return search(
|
35
|
+
return 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
|
-
response = RestClient.get
|
41
|
+
response = RestClient.get("http://search.maven.org/solrsearch/select",
|
42
|
+
:params => params.merge("rows" => "100", "wt" => "json")
|
43
|
+
)
|
42
44
|
json = JSON.parse(response.to_s)
|
43
45
|
return json["response"]["docs"]
|
44
46
|
end
|
@@ -53,7 +55,7 @@ module Gjp
|
|
53
55
|
def download_pom(group_id, artifact_id, version)
|
54
56
|
path = "#{group_id.gsub(".", "/")}/#{artifact_id}/#{version}/#{artifact_id}-#{version}.pom"
|
55
57
|
log.debug("downloading #{path}...")
|
56
|
-
return (RestClient.get "http://search.maven.org/remotecontent",
|
58
|
+
return (RestClient.get "http://search.maven.org/remotecontent", :params => {:filepath => path}).to_s
|
57
59
|
end
|
58
60
|
end
|
59
61
|
end
|
data/lib/gjp/pom.rb
CHANGED
@@ -40,7 +40,9 @@ module Gjp
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def runtime_dependency_ids
|
43
|
-
result = @doc.xpath("project/dependencies/dependency[
|
43
|
+
result = @doc.xpath("project/dependencies/dependency[\
|
44
|
+
not(optional='true') and not(scope='provided') and not(scope='test') and not(scope='system')\
|
45
|
+
]").map do |element|
|
44
46
|
[element.xpath("groupId").text, element.xpath("artifactId").text, element.xpath("version").text]
|
45
47
|
end
|
46
48
|
end
|
data/lib/gjp/pom_getter.rb
CHANGED
@@ -16,7 +16,7 @@ module Gjp
|
|
16
16
|
# saves a jar poms in <jar_filename>.pom
|
17
17
|
# returns filename and status if found, else nil
|
18
18
|
def get_pom(filename)
|
19
|
-
content, status = (get_pom_from_jar(filename)
|
19
|
+
content, status = (get_pom_from_jar(filename) || get_pom_from_sha1(filename) || get_pom_from_heuristic(filename))
|
20
20
|
if content
|
21
21
|
pom_filename = filename.sub(/(\.jar)?$/, ".pom")
|
22
22
|
File.open(pom_filename, "w") { |io| io.write(content) }
|
@@ -52,7 +52,9 @@ module Gjp
|
|
52
52
|
results = site.search_by_sha1(sha1).select {|result| result["ec"].include?(".pom")}
|
53
53
|
result = results.first
|
54
54
|
if result != nil
|
55
|
-
log.info("pom.xml for #{file} found on search.maven.org for sha1 #{sha1}
|
55
|
+
log.info("pom.xml for #{file} found on search.maven.org for sha1 #{sha1}\
|
56
|
+
(#{result["g"]}:#{result["a"]}:#{result["v"]})"
|
57
|
+
)
|
56
58
|
group_id, artifact_id, version = site.get_maven_id_from result
|
57
59
|
return site.download_pom(group_id, artifact_id, version), :found_via_sha1
|
58
60
|
end
|
@@ -80,11 +82,17 @@ module Gjp
|
|
80
82
|
results = site.search_by_group_id_and_artifact_id(group_id, artifact_id)
|
81
83
|
log.debug("All versions: #{results}")
|
82
84
|
their_versions = results.map {|doc| doc["v"]}
|
83
|
-
best_matched_version = if my_version != nil
|
85
|
+
best_matched_version = if my_version != nil
|
86
|
+
version_matcher.best_match(my_version, their_versions)
|
87
|
+
else
|
88
|
+
their_versions.max
|
89
|
+
end
|
84
90
|
best_matched_result = (results.select{|result| result["v"] == best_matched_version}).first
|
85
91
|
|
86
92
|
group_id, artifact_id, version = site.get_maven_id_from(best_matched_result)
|
87
|
-
log.warn("pom.xml for #{filename} found on search.maven.org with heuristic search
|
93
|
+
log.warn("pom.xml for #{filename} found on search.maven.org with heuristic search\
|
94
|
+
(#{group_id}:#{artifact_id}:#{version})"
|
95
|
+
)
|
88
96
|
|
89
97
|
return site.download_pom(group_id, artifact_id, version), :found_via_heuristic
|
90
98
|
end
|
data/lib/gjp/project.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require "find"
|
4
4
|
|
5
5
|
module Gjp
|
6
6
|
# encapsulates a Gjp project directory
|
@@ -49,7 +49,9 @@ module Gjp
|
|
49
49
|
dir_path = Pathname.new(File.expand_path(dir)).relative_path_from(Pathname.new(@full_path))
|
50
50
|
components = dir_path.to_s.split(File::SEPARATOR)
|
51
51
|
|
52
|
-
if components.count >= 2 &&
|
52
|
+
if components.count >= 2 &&
|
53
|
+
components.first == "src" &&
|
54
|
+
Dir.exist?(File.join(@full_path, components[0], components[1]))
|
53
55
|
components[1]
|
54
56
|
else
|
55
57
|
raise NoPackageDirectoryError
|
data/lib/gjp/script_generator.rb
CHANGED
@@ -42,7 +42,8 @@ module Gjp
|
|
42
42
|
|
43
43
|
script_name = "build.sh"
|
44
44
|
result_path = File.join("src", name, script_name)
|
45
|
-
conflict_count = @project.merge_new_content(new_content, result_path, "Build script generated",
|
45
|
+
conflict_count = @project.merge_new_content(new_content, result_path, "Build script generated",
|
46
|
+
"generate_#{name}_build_script")
|
46
47
|
|
47
48
|
destination_dir = File.join("output", name)
|
48
49
|
FileUtils.mkdir_p(destination_dir)
|
data/lib/gjp/spec_generator.rb
CHANGED
@@ -17,7 +17,7 @@ module Gjp
|
|
17
17
|
FileUtils.mkdir_p(output_dir)
|
18
18
|
|
19
19
|
adapter = Gjp::KitSpecAdapter.new(@project)
|
20
|
-
conflict_count = generate_merging("kit.spec", adapter.
|
20
|
+
conflict_count = generate_merging("kit.spec", adapter.public_binding, spec_path, :generate_kit_spec)
|
21
21
|
|
22
22
|
symlink_to_output(spec_path, output_dir)
|
23
23
|
|
@@ -34,7 +34,7 @@ module Gjp
|
|
34
34
|
FileUtils.mkdir_p(output_dir)
|
35
35
|
|
36
36
|
adapter = Gjp::PackageSpecAdapter.new(@project, name, pom, filter)
|
37
|
-
conflict_count = generate_merging("package.spec", adapter.
|
37
|
+
conflict_count = generate_merging("package.spec", adapter.public_binding, spec_path, "generate_#{name}_spec")
|
38
38
|
|
39
39
|
symlink_to_output(spec_path, output_dir)
|
40
40
|
|
data/lib/gjp/version.rb
CHANGED
data/lib/gjp/version_matcher.rb
CHANGED
@@ -28,13 +28,13 @@ module Gjp
|
|
28
28
|
# - score weighs differently on chunk index (first chunks are most important)
|
29
29
|
# - lowest score wins
|
30
30
|
def best_match(my_version, their_versions)
|
31
|
-
log.debug("version comparison: #{my_version} vs #{their_versions.join(
|
31
|
+
log.debug("version comparison: #{my_version} vs #{their_versions.join(", ")}")
|
32
32
|
|
33
|
-
my_chunks = my_version.split
|
33
|
+
my_chunks = my_version.split(/[\.\-\_ ~,]/)
|
34
34
|
their_chunks_hash = Hash[
|
35
35
|
their_versions.map do |their_version|
|
36
36
|
their_chunks_for_version = if their_version != nil
|
37
|
-
their_version.split
|
37
|
+
their_version.split(/[\.\-\_ ~,]/)
|
38
38
|
else
|
39
39
|
[]
|
40
40
|
end
|
data/lib/template/kit.spec
CHANGED
@@ -52,6 +52,7 @@ be installed on end users' systems.
|
|
52
52
|
# nothing to do, gjp kits are precompiled by design
|
53
53
|
|
54
54
|
%install
|
55
|
+
export NO_BRP_CHECK_BYTECODE_VERSION=true
|
55
56
|
install -d -m 0755 %{buildroot}%{_datadir}/gjp/%{name}/
|
56
57
|
cp -a * %{buildroot}%{_datadir}/gjp/%{name}/
|
57
58
|
%fdupes -s %{buildroot}%{_datadir}/gjp/%{name}/
|
data/lib/template/package.spec
CHANGED
data/spec/lib/ant_runner_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "spec_helper"
|
4
|
+
require "lib/kit_runner_spec"
|
5
5
|
|
6
6
|
describe Gjp::AntRunner do
|
7
7
|
it_behaves_like Gjp::KitRunner
|
@@ -34,7 +34,7 @@ describe Gjp::AntRunner do
|
|
34
34
|
executable_path = create_mock_executable("ant")
|
35
35
|
@project.from_directory do
|
36
36
|
@kit_runner.ant(["extra-option"])
|
37
|
-
File.read("test_out").strip.should match
|
37
|
+
File.read("test_out").strip.should match(/extra-option$/)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
it "doesn't run Ant if it is not available" do
|
data/spec/lib/archiver_spec.rb
CHANGED
data/spec/lib/git_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe Gjp::Git do
|
6
6
|
before(:each) do
|
@@ -17,9 +17,31 @@ describe Gjp::Git do
|
|
17
17
|
|
18
18
|
describe "#init" do
|
19
19
|
it "complains if a double initialization is attempted" do
|
20
|
-
expect
|
20
|
+
expect do
|
21
21
|
@git.init
|
22
|
-
|
22
|
+
end.to raise_error(Gjp::GitAlreadyInitedError)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#commit_whole_directory" do
|
27
|
+
it "commits all contents of a directory to git for later use" do
|
28
|
+
Dir.chdir(@git_path) do
|
29
|
+
File.open("file1", "w") do |file|
|
30
|
+
file.write "test"
|
31
|
+
end
|
32
|
+
|
33
|
+
# check that gitignore files are moved correctly
|
34
|
+
File.open(".gitignore", "w") do |file|
|
35
|
+
file.write "file1o"
|
36
|
+
end
|
37
|
+
|
38
|
+
@git.commit_whole_directory("test", "test")
|
39
|
+
|
40
|
+
files = `git ls-tree --name-only -r HEAD`.split("\n")
|
41
|
+
|
42
|
+
files.should include("file1")
|
43
|
+
files.should include(".gitignore_disabled_by_gjp")
|
44
|
+
end
|
23
45
|
end
|
24
46
|
end
|
25
47
|
|
@@ -39,7 +39,7 @@ describe Gjp::KitChecker do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
describe "#
|
42
|
+
describe "#source_class_names" do
|
43
43
|
it "distills source class names in kit" do
|
44
44
|
all_files = [
|
45
45
|
["path/to/ClassOne.java", nil],
|
@@ -48,7 +48,7 @@ describe Gjp::KitChecker do
|
|
48
48
|
["path/to/CompiledClass.class", "yet_another.jar"],
|
49
49
|
]
|
50
50
|
|
51
|
-
class_names = @kit_checker.
|
51
|
+
class_names = @kit_checker.source_class_names(all_files)
|
52
52
|
|
53
53
|
class_names.should include "path.to.ClassOne"
|
54
54
|
class_names.should include "path.to.ClassTwo"
|
@@ -57,7 +57,7 @@ describe Gjp::KitChecker do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
describe "#
|
60
|
+
describe "#compiled_classes" do
|
61
61
|
it "distills source class names in kit" do
|
62
62
|
all_files = [
|
63
63
|
["path/to/ClassOne.class", nil],
|
@@ -66,7 +66,7 @@ describe Gjp::KitChecker do
|
|
66
66
|
["path/to/SourceClass.java", "yet_another.jar"],
|
67
67
|
]
|
68
68
|
|
69
|
-
classes = @kit_checker.
|
69
|
+
classes = @kit_checker.compiled_classes(all_files)
|
70
70
|
|
71
71
|
classes[nil].should include "path.to.ClassOne"
|
72
72
|
classes["path/to/archive.jar"].should include "path.to.ClassTwo"
|
@@ -75,7 +75,7 @@ describe Gjp::KitChecker do
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
describe "#
|
78
|
+
describe "#unsourced_archives" do
|
79
79
|
it "returns a list of jars wich source files are missing" do
|
80
80
|
@project.from_directory("kit") do
|
81
81
|
FileUtils.mkdir_p("package1")
|
@@ -106,7 +106,7 @@ describe Gjp::KitChecker do
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
unsourced = @kit_checker.
|
109
|
+
unsourced = @kit_checker.unsourced_archives
|
110
110
|
unsourced.length().should eq 1
|
111
111
|
|
112
112
|
unsourced.first[:archive].should be_nil
|