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
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Gjp
|
4
|
+
class DownloadMavenSourceJarsCommand < Gjp::BaseCommand
|
5
|
+
def execute
|
6
|
+
checking_exceptions do
|
7
|
+
project = Gjp::Project.new(".")
|
8
|
+
source_getter = Gjp::SourceGetter.new
|
9
|
+
|
10
|
+
ensure_dry_running(false, project) do
|
11
|
+
puts "Getting sources from Maven..."
|
12
|
+
succeeded, failed = source_getter.get_maven_source_jars(project)
|
13
|
+
|
14
|
+
puts "\n**SUMMARY**\n"
|
15
|
+
puts "Sources found for:"
|
16
|
+
succeeded.each do |path|
|
17
|
+
puts " #{format_path(path, project)}"
|
18
|
+
end
|
19
|
+
|
20
|
+
puts "\nSources not found for:"
|
21
|
+
failed.each do |path|
|
22
|
+
puts " #{format_path(path, project)}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Gjp
|
4
|
+
class DryRunCommand < Gjp::BaseCommand
|
5
|
+
def execute
|
6
|
+
checking_exceptions do
|
7
|
+
if Gjp::Project.new(".").dry_run
|
8
|
+
puts "Now dry-running, please start your build."
|
9
|
+
puts "To run a Maven installation from the kit, use \"gjp mvn\"."
|
10
|
+
puts "If the build succeedes end this dry run with \"gjp finish\"."
|
11
|
+
puts "If the build does not succeed use \"gjp finish --abort\" to restore files."
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Gjp
|
4
|
+
class FinishCommand < Gjp::BaseCommand
|
5
|
+
|
6
|
+
option ["-a", "--abort"], :flag, "build abort, restore files as before dry-run"
|
7
|
+
|
8
|
+
def execute
|
9
|
+
checking_exceptions do
|
10
|
+
if Gjp::Project.new(".").finish(abort?)
|
11
|
+
if abort?
|
12
|
+
puts "Project reverted as before dry-run."
|
13
|
+
else
|
14
|
+
puts "Dry-run finished."
|
15
|
+
end
|
16
|
+
else
|
17
|
+
puts "No dry-run is in progress."
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Gjp
|
4
|
+
class GenerateAllCommand < Gjp::BaseCommand
|
5
|
+
|
6
|
+
option ["-f", "--filter"], "FILTER", "filter files to be installed by this package spec", :default => "*.jar"
|
7
|
+
option ["-f", "--full"], :flag, "create a full archive (not incremental)"
|
8
|
+
parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", :default => "."
|
9
|
+
parameter "[POM]", "a package pom file path", :default => "pom.xml"
|
10
|
+
|
11
|
+
def execute
|
12
|
+
checking_exceptions do
|
13
|
+
project = Gjp::Project.new(".")
|
14
|
+
ensure_dry_running(false, project) do
|
15
|
+
package_name = project.get_package_name(directory)
|
16
|
+
|
17
|
+
result_path = Gjp::Archiver.new(project).archive_kit(full?)
|
18
|
+
print_generation_result(project, result_path)
|
19
|
+
|
20
|
+
result_path, conflict_count = Gjp::SpecGenerator.new(project).generate_kit_spec
|
21
|
+
print_generation_result(project, result_path, conflict_count)
|
22
|
+
|
23
|
+
history_file = File.join(Dir.home, ".bash_history")
|
24
|
+
result_path, conflict_count = Gjp::ScriptGenerator.new(project, history_file)
|
25
|
+
.generate_build_script(package_name)
|
26
|
+
print_generation_result(project, result_path, conflict_count)
|
27
|
+
|
28
|
+
result_path = Gjp::Archiver.new(project).archive_package package_name
|
29
|
+
print_generation_result(project, result_path)
|
30
|
+
|
31
|
+
result_path, conflict_count = Gjp::SpecGenerator.new(project)
|
32
|
+
.generate_package_spec package_name, pom, filter
|
33
|
+
print_generation_result(project, result_path, conflict_count)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Gjp
|
4
|
+
class GenerateKitArchiveCommand < Gjp::BaseCommand
|
5
|
+
|
6
|
+
option ["-f", "--full"], :flag, "create a full archive (not incremental)"
|
7
|
+
|
8
|
+
def execute
|
9
|
+
checking_exceptions do
|
10
|
+
project = Gjp::Project.new(".")
|
11
|
+
ensure_dry_running(false, project) do
|
12
|
+
result_path = Gjp::Archiver.new(project).archive_kit(full?)
|
13
|
+
print_generation_result(project, result_path)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Gjp
|
4
|
+
class GenerateKitSpecCommand < Gjp::BaseCommand
|
5
|
+
|
6
|
+
def execute
|
7
|
+
checking_exceptions do
|
8
|
+
project = Gjp::Project.new(".")
|
9
|
+
ensure_dry_running(false, project) do
|
10
|
+
result_path, conflict_count = Gjp::SpecGenerator.new(project).generate_kit_spec
|
11
|
+
print_generation_result(project, result_path, conflict_count)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Gjp
|
4
|
+
class GeneratePackageArchiveCommand < Gjp::BaseCommand
|
5
|
+
|
6
|
+
parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", :default => "."
|
7
|
+
|
8
|
+
def execute
|
9
|
+
checking_exceptions do
|
10
|
+
project = Gjp::Project.new(".")
|
11
|
+
ensure_dry_running(false, project) do
|
12
|
+
package_name = project.get_package_name(directory)
|
13
|
+
result_path = Gjp::Archiver.new(project).archive_package package_name
|
14
|
+
print_generation_result(project, result_path)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Gjp
|
4
|
+
class GeneratePackageScriptCommand < Gjp::BaseCommand
|
5
|
+
|
6
|
+
parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", :default => "."
|
7
|
+
|
8
|
+
def execute
|
9
|
+
checking_exceptions do
|
10
|
+
project = Gjp::Project.new(".")
|
11
|
+
ensure_dry_running(false, project) do
|
12
|
+
package_name = project.get_package_name(directory)
|
13
|
+
history_file = File.join(Dir.home, ".bash_history")
|
14
|
+
result_path, conflict_count = Gjp::ScriptGenerator.new(project, history_file)
|
15
|
+
.generate_build_script(package_name)
|
16
|
+
print_generation_result(project, result_path, conflict_count)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Gjp
|
4
|
+
class GeneratePackageSpecCommand < Gjp::BaseCommand
|
5
|
+
|
6
|
+
option ["-f", "--filter"], "FILTER", "filter files to be installed by this spec", :default => "*.jar"
|
7
|
+
parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", :default => "."
|
8
|
+
parameter "[POM]", "a pom file path", :default => "pom.xml"
|
9
|
+
|
10
|
+
def execute
|
11
|
+
checking_exceptions do
|
12
|
+
project = Gjp::Project.new(".")
|
13
|
+
ensure_dry_running(false, project) do
|
14
|
+
package_name = project.get_package_name(directory)
|
15
|
+
result_path, conflict_count = Gjp::SpecGenerator.new(project)
|
16
|
+
.generate_package_spec(package_name, pom, filter)
|
17
|
+
print_generation_result(project, result_path, conflict_count)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Gjp
|
4
|
+
class GetPomCommand < Gjp::BaseCommand
|
5
|
+
|
6
|
+
parameter "NAME", "a jar file name or a `name-version` string (heuristic)"
|
7
|
+
|
8
|
+
def execute
|
9
|
+
checking_exceptions do
|
10
|
+
project = Gjp::Project.new(".")
|
11
|
+
pom_getter = Gjp::PomGetter.new
|
12
|
+
|
13
|
+
path, status = pom_getter.get_pom(name)
|
14
|
+
if path
|
15
|
+
text_status = 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
|
+
|
23
|
+
puts "#{format_path(path, project)} written, #{text_status}"
|
24
|
+
else
|
25
|
+
puts "#{name}'s pom not found. Try:"
|
26
|
+
puts "http://google.com/#q=#{URI::encode(pom_getter.cleanup_name(name) + " pom")}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Gjp
|
4
|
+
class GetSourceCommand < Gjp::BaseCommand
|
5
|
+
|
6
|
+
parameter "POM", "a pom file path or URI"
|
7
|
+
|
8
|
+
def execute
|
9
|
+
checking_exceptions do
|
10
|
+
project = Gjp::Project.new(".")
|
11
|
+
source_getter = Gjp::SourceGetter.new
|
12
|
+
|
13
|
+
puts "Attempting to find source through Maven..."
|
14
|
+
if source_getter.get_maven_source_jar(project, pom)
|
15
|
+
puts "Source jar found and added to Maven repository."
|
16
|
+
else
|
17
|
+
effective_pom_path = Gjp::MavenRunner.new(project).get_effective_pom(pom)
|
18
|
+
puts "Source jar not found in Maven. Try looking here:"
|
19
|
+
pom = Gjp::Pom.new(effective_pom_path)
|
20
|
+
if pom.url && !pom.url.empty?
|
21
|
+
puts "Website: #{pom.url}"
|
22
|
+
end
|
23
|
+
if pom.scm_connection && !pom.scm_connection.empty?
|
24
|
+
puts "SCM connection: #{pom.scm_connection}"
|
25
|
+
end
|
26
|
+
if pom.scm_url && !pom.scm_url.empty?
|
27
|
+
puts "SCM connection: #{pom.scm_url}"
|
28
|
+
end
|
29
|
+
puts "The effective POM: #{effective_pom_path}"
|
30
|
+
puts "Google: http://google.com/#q=#{URI::encode(pom.name + " sources")}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Gjp
|
4
|
+
class InitCommand < Gjp::BaseCommand
|
5
|
+
|
6
|
+
def execute
|
7
|
+
checking_exceptions do
|
8
|
+
Gjp::Project.init(".")
|
9
|
+
puts "Project inited."
|
10
|
+
puts "Add sources to src/<package name>, binary dependencies to kit/."
|
11
|
+
puts "When you are ready to test a build, use \"gjp dry-run\"."
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Gjp
|
4
|
+
class ListKitMissingSourcesCommand < Gjp::BaseCommand
|
5
|
+
|
6
|
+
def execute
|
7
|
+
checking_exceptions do
|
8
|
+
project = Gjp::Project.new(".")
|
9
|
+
kit_checker = Gjp::KitChecker.new(project)
|
10
|
+
|
11
|
+
ensure_dry_running(false, project) do
|
12
|
+
puts "Some source files were not found in these archives:"
|
13
|
+
kit_checker.unsourced_archives.each do |archive|
|
14
|
+
percentage = "%.2f" % (100.0 * archive[:unsourced_class_names].length()/archive[:class_names].length())
|
15
|
+
puts "#{format_path(archive[:archive], project)} (~#{percentage}% missing)"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Gjp
|
4
|
+
class MoveJarsToKitCommand < Gjp::BaseCommand
|
5
|
+
|
6
|
+
def execute
|
7
|
+
checking_exceptions do
|
8
|
+
project = Gjp::Project.new(".")
|
9
|
+
|
10
|
+
ensure_dry_running(false, project) do
|
11
|
+
project.purge_jars.each do |original, final|
|
12
|
+
puts "Replaced #{original} with symlink pointing to to #{final}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Gjp
|
4
|
+
class MavenCommand < Gjp::BaseCommand
|
5
|
+
|
6
|
+
parameter "[MAVEN OPTIONS] ...", "mvn options", :attribute_name => "dummy"
|
7
|
+
|
8
|
+
# override parsing in order to pipe everything to mvn
|
9
|
+
def parse(args)
|
10
|
+
@options = args
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute
|
14
|
+
checking_exceptions do
|
15
|
+
project = Gjp::Project.new(".")
|
16
|
+
ensure_dry_running(true, project) do
|
17
|
+
Gjp::MavenRunner.new(project).mvn(@options)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/gjp/git.rb
CHANGED
@@ -39,7 +39,8 @@ module Gjp
|
|
39
39
|
else
|
40
40
|
"HEAD"
|
41
41
|
end
|
42
|
-
`git diff-tree --no-commit-id --name-only -r #{prefixed_start_tag} #{prefixed_end_tag} -- #{directory}
|
42
|
+
`git diff-tree --no-commit-id --name-only -r #{prefixed_start_tag} #{prefixed_end_tag} -- #{directory}`
|
43
|
+
.split("\n")
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
@@ -50,6 +51,14 @@ module Gjp
|
|
50
51
|
Dir.chdir(@directory) do
|
51
52
|
log.debug "committing with message: #{message}"
|
52
53
|
|
54
|
+
# rename all .gitignore files by default as
|
55
|
+
# they prevent snapshotting
|
56
|
+
Find.find(".") do |file|
|
57
|
+
if file =~ /\.gitignore$/
|
58
|
+
FileUtils.mv(file, "#{file}_disabled_by_gjp")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
53
62
|
`git rm -r --cached --ignore-unmatch .`
|
54
63
|
`git add .`
|
55
64
|
`git commit -m "#{message}"`
|
@@ -68,12 +77,12 @@ module Gjp
|
|
68
77
|
def get_tag_maximum_suffix(prefix)
|
69
78
|
Dir.chdir(@directory) do
|
70
79
|
`git tag`.split.map do |tag|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
80
|
+
if tag =~ /^gjp_#{prefix}_([0-9]+)$/
|
81
|
+
$1.to_i
|
82
|
+
else
|
83
|
+
0
|
84
|
+
end
|
85
|
+
end.max || 0
|
77
86
|
end
|
78
87
|
end
|
79
88
|
|
@@ -103,7 +112,8 @@ module Gjp
|
|
103
112
|
log.debug "calling git show gjp_#{tag}:#{path} > #{path}.old_version, output follows"
|
104
113
|
`git show gjp_#{tag}:#{path} > #{path}.old_version`
|
105
114
|
log.debug "calling git merge-file #{path} #{path}.old_version #{new_path}, output follows"
|
106
|
-
`git merge-file #{path} #{path}.old_version #{new_path}
|
115
|
+
`git merge-file #{path} #{path}.old_version #{new_path} \
|
116
|
+
-L "newly generated" -L "previously generated" -L "user edited"`
|
107
117
|
conflict_count = $?.exitstatus
|
108
118
|
File.delete "#{path}.old_version"
|
109
119
|
return conflict_count
|
data/lib/gjp/kit_checker.rb
CHANGED
@@ -23,7 +23,7 @@ module Gjp
|
|
23
23
|
end
|
24
24
|
|
25
25
|
archived_file_paths = plain_file_paths.select do |path, archive|
|
26
|
-
path. =~ /\.(zip)|([jwe]ar)$/
|
26
|
+
path. =~ (/\.(zip)|([jwe]ar)$/)
|
27
27
|
end.map do |path, archive|
|
28
28
|
result = []
|
29
29
|
Zip::File.foreach(path) do |entry|
|
@@ -40,7 +40,7 @@ module Gjp
|
|
40
40
|
|
41
41
|
# returns a list of class names for which
|
42
42
|
# we have source files in kit/
|
43
|
-
def
|
43
|
+
def source_class_names(paths)
|
44
44
|
source_paths = paths.select do |path, archive|
|
45
45
|
path =~ /\.java$/
|
46
46
|
end
|
@@ -63,7 +63,7 @@ module Gjp
|
|
63
63
|
|
64
64
|
# returns a list of class names for which
|
65
65
|
# we have binary files in kit/
|
66
|
-
def
|
66
|
+
def compiled_classes(paths)
|
67
67
|
result = {}
|
68
68
|
compiled_paths = paths.select do |path, archive|
|
69
69
|
path =~ /\.class$/
|
@@ -81,10 +81,10 @@ module Gjp
|
|
81
81
|
|
82
82
|
# returns a hash that associates archive names and
|
83
83
|
# the unsourced classes within them
|
84
|
-
def
|
84
|
+
def unsourced_archives
|
85
85
|
paths = kit_file_paths
|
86
|
-
source_class_names =
|
87
|
-
archive_paths_to_class_names =
|
86
|
+
source_class_names = source_class_names(paths)
|
87
|
+
archive_paths_to_class_names = compiled_classes(paths)
|
88
88
|
|
89
89
|
result = archive_paths_to_class_names.map do |archive, class_names|
|
90
90
|
unsourced_class_names = class_names.select do |class_name|
|