gjp 0.38.0 → 0.39.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rubocop.yml +6 -2
- data/Rakefile +2 -0
- data/SPECIAL_CASES.md +1 -1
- data/bin/gjp +1 -1
- data/gjp.gemspec +1 -1
- data/lib/gjp.rb +23 -2
- data/lib/gjp/ant_runner.rb +1 -1
- data/lib/gjp/archiver.rb +4 -3
- data/lib/gjp/commands/ant.rb +2 -0
- data/lib/gjp/commands/base.rb +4 -8
- data/lib/gjp/commands/download_maven_source_jars.rb +1 -0
- data/lib/gjp/commands/dry_run.rb +1 -0
- data/lib/gjp/commands/finish.rb +2 -1
- data/lib/gjp/commands/generate_all.rb +4 -3
- data/lib/gjp/commands/generate_kit_archive.rb +3 -2
- data/lib/gjp/commands/generate_kit_spec.rb +1 -0
- data/lib/gjp/commands/generate_package_archive.rb +1 -0
- data/lib/gjp/commands/generate_package_script.rb +1 -0
- data/lib/gjp/commands/generate_package_spec.rb +2 -1
- data/lib/gjp/commands/get_pom.rb +1 -0
- data/lib/gjp/commands/get_source.rb +6 -10
- data/lib/gjp/commands/init.rb +1 -0
- data/lib/gjp/commands/list_kit_missing_sources.rb +3 -2
- data/lib/gjp/commands/move_jars_to_kit.rb +1 -0
- data/lib/gjp/commands/mvn.rb +2 -0
- data/lib/gjp/git.rb +5 -5
- data/lib/gjp/kit_checker.rb +8 -12
- data/lib/gjp/kit_runner.rb +6 -8
- data/lib/gjp/logger.rb +3 -5
- data/lib/gjp/main.rb +1 -1
- data/lib/gjp/maven_runner.rb +1 -1
- data/lib/gjp/maven_website.rb +0 -2
- data/lib/gjp/pom.rb +1 -4
- data/lib/gjp/pom_getter.rb +7 -15
- data/lib/gjp/project.rb +24 -25
- data/lib/gjp/source_getter.rb +3 -7
- data/lib/gjp/template_manager.rb +0 -2
- data/lib/gjp/version.rb +2 -1
- data/lib/gjp/version_matcher.rb +8 -14
- data/spec/lib/ant_runner_spec.rb +1 -2
- data/spec/lib/maven_runner_spec.rb +0 -1
- data/spec/lib/project_spec.rb +10 -10
- data/spec/lib/script_generator_spec.rb +1 -0
- data/spec/lib/template_manager_spec.rb +1 -0
- data/spec/spec_helper.rb +2 -1
- data/spec/{lib/kit_runner_spec.rb → support/kit_runner_examples.rb} +0 -2
- metadata +4 -5
- data/.rubocop_todo.yml +0 -111
data/.rubocop.yml
CHANGED
data/Rakefile
CHANGED
data/SPECIAL_CASES.md
CHANGED
@@ -14,7 +14,7 @@ You can do any manual changes to spec and build.sh files and regenerate them lat
|
|
14
14
|
* `gjp generate-package-archive`: (re)generates a package tarball;
|
15
15
|
* `gjp generate-package-spec`: (re)generates a package spec;
|
16
16
|
|
17
|
-
Note that, by default, `generate-kit-archive` will generate additional "diff" tar.xz files instead of rewriting the whole archive - this will result in faster uploads if you use OBS (see below). You can use the `--
|
17
|
+
Note that, by default, `generate-kit-archive` will generate additional "diff" tar.xz files instead of rewriting the whole archive - this will result in faster uploads if you use OBS (see below). You can use the `--whole` option to regenerate a single complete archive.
|
18
18
|
|
19
19
|
## Kit sources
|
20
20
|
|
data/bin/gjp
CHANGED
data/gjp.gemspec
CHANGED
data/lib/gjp.rb
CHANGED
@@ -1,4 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# ruby standard library
|
4
|
+
require "digest/sha1"
|
5
|
+
require "English"
|
6
|
+
require "erb"
|
7
|
+
require "find"
|
8
|
+
require "forwardable"
|
9
|
+
require "logger"
|
10
|
+
require "open-uri"
|
11
|
+
require "pathname"
|
12
|
+
require "singleton"
|
13
|
+
require "text"
|
14
|
+
|
15
|
+
# third party libraries
|
16
|
+
require "clamp"
|
17
|
+
require "json"
|
18
|
+
require "nokogiri"
|
19
|
+
require "rest_client"
|
20
|
+
require "zip"
|
21
|
+
|
22
|
+
# internal, backend
|
2
23
|
require "gjp/version"
|
3
24
|
require "gjp/logger"
|
4
25
|
require "gjp/template_manager"
|
@@ -19,7 +40,7 @@ require "gjp/spec_generator"
|
|
19
40
|
require "gjp/archiver"
|
20
41
|
require "gjp/kit_checker"
|
21
42
|
|
22
|
-
# UI
|
43
|
+
# internal, UI
|
23
44
|
require "gjp/commands/base"
|
24
45
|
|
25
46
|
require "gjp/commands/ant"
|
data/lib/gjp/ant_runner.rb
CHANGED
data/lib/gjp/archiver.rb
CHANGED
@@ -10,7 +10,7 @@ module Gjp
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# generates an archive for the kit package
|
13
|
-
def archive_kit(
|
13
|
+
def archive_kit(whole)
|
14
14
|
destination_dir = File.join(@project.full_path, "output", "#{@project.name}-kit")
|
15
15
|
FileUtils.mkdir_p(destination_dir)
|
16
16
|
file_prefix = "#{@project.name}-kit"
|
@@ -19,7 +19,7 @@ module Gjp
|
|
19
19
|
@project.take_snapshot "Kit archival started"
|
20
20
|
|
21
21
|
destination_file = (
|
22
|
-
if
|
22
|
+
if whole
|
23
23
|
remove_stale_incremental(destination_dir, file_prefix, file_suffix)
|
24
24
|
archive_single("kit", File.join(destination_dir, file_prefix + file_suffix))
|
25
25
|
else
|
@@ -62,7 +62,8 @@ module Gjp
|
|
62
62
|
if latest_tag_count == 0
|
63
63
|
archive_single(source_directory, File.join(destination_dir, file_prefix + file_suffix))
|
64
64
|
else
|
65
|
-
destination_file = File.join(destination_dir,
|
65
|
+
destination_file = File.join(destination_dir,
|
66
|
+
"#{file_prefix}_#{format("%04d", latest_tag_count)}#{file_suffix}")
|
66
67
|
tag = @project.latest_tag(tag_prefix)
|
67
68
|
log.debug "creating #{destination_file} with files newer than #{tag}"
|
68
69
|
|
data/lib/gjp/commands/ant.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Gjp
|
4
|
+
# gjp ant
|
4
5
|
class AntCommand < Gjp::BaseCommand
|
5
6
|
parameter "[ANT OPTIONS] ...", "ant options", attribute_name: "dummy"
|
6
7
|
|
7
8
|
# override parsing in order to pipe everything to mvn
|
9
|
+
# rubocop:disable TrivialAccessors
|
8
10
|
def parse(args)
|
9
11
|
@options = args
|
10
12
|
end
|
data/lib/gjp/commands/base.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require "clamp"
|
3
|
-
require "gjp/logger"
|
4
2
|
|
5
3
|
module Gjp
|
6
4
|
# implements common options and utility methods
|
@@ -8,7 +6,7 @@ module Gjp
|
|
8
6
|
include Logging
|
9
7
|
|
10
8
|
# Options available to all gjp commands
|
11
|
-
option
|
9
|
+
option %w(-v --verbose), :flag, "verbose output"
|
12
10
|
option ["--very-verbose"], :flag, "very verbose output"
|
13
11
|
option ["--very-very-verbose"], :flag, "very very verbose output"
|
14
12
|
|
@@ -40,7 +38,7 @@ module Gjp
|
|
40
38
|
|
41
39
|
# prints an error message and exits unless there is a dry-run in progress
|
42
40
|
def ensure_dry_running(state, project)
|
43
|
-
if project.
|
41
|
+
if project.dry_running? == state
|
44
42
|
yield
|
45
43
|
else
|
46
44
|
if state == true
|
@@ -54,9 +52,7 @@ module Gjp
|
|
54
52
|
# outputs output of a file generation
|
55
53
|
def print_generation_result(project, result_path, conflict_count = 0)
|
56
54
|
puts "#{format_path(result_path, project)} generated"
|
57
|
-
if conflict_count > 0
|
58
|
-
puts "Warning: #{conflict_count} unresolved conflicts"
|
59
|
-
end
|
55
|
+
puts "Warning: #{conflict_count} unresolved conflicts" if conflict_count > 0
|
60
56
|
end
|
61
57
|
|
62
58
|
# generates a version of path relative to the current directory
|
@@ -84,7 +80,7 @@ module Gjp
|
|
84
80
|
$stderr.puts "#{e.directory} is not a gjp project directory, see gjp init"
|
85
81
|
rescue NoPackageDirectoryError => e
|
86
82
|
$stderr.puts "#{e.directory} is not a gjp package directory, see README"
|
87
|
-
rescue GitAlreadyInitedError
|
83
|
+
rescue GitAlreadyInitedError
|
88
84
|
$stderr.puts "This directory is already a gjp project"
|
89
85
|
rescue ExecutableNotFoundError => e
|
90
86
|
$stderr.puts "Executable #{e.executable} not found in kit/ or any of its subdirectories"
|
data/lib/gjp/commands/dry_run.rb
CHANGED
data/lib/gjp/commands/finish.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Gjp
|
4
|
+
# gjp finish
|
4
5
|
class FinishCommand < Gjp::BaseCommand
|
5
|
-
option
|
6
|
+
option %w(-a --abort), :flag, "build abort, restore files as before dry-run"
|
6
7
|
|
7
8
|
def execute
|
8
9
|
checking_exceptions do
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Gjp
|
4
|
+
# gjp generate-all
|
4
5
|
class GenerateAllCommand < Gjp::BaseCommand
|
5
|
-
option
|
6
|
-
option
|
6
|
+
option %w(-f --filter), "FILTER", "filter files to be installed by this package spec", default: "*.jar"
|
7
|
+
option %w(-w --whole), :flag, "recreate the whole archive (not incremental)"
|
7
8
|
parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", default: "."
|
8
9
|
parameter "[POM]", "a package pom file path", default: "pom.xml"
|
9
10
|
|
@@ -13,7 +14,7 @@ module Gjp
|
|
13
14
|
ensure_dry_running(false, project) do
|
14
15
|
package_name = project.get_package_name(directory)
|
15
16
|
|
16
|
-
result_path = Gjp::Archiver.new(project).archive_kit(
|
17
|
+
result_path = Gjp::Archiver.new(project).archive_kit(whole?)
|
17
18
|
print_generation_result(project, result_path)
|
18
19
|
|
19
20
|
result_path, conflict_count = Gjp::SpecGenerator.new(project).generate_kit_spec
|
@@ -1,14 +1,15 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Gjp
|
4
|
+
# gjp generate-kit-archive
|
4
5
|
class GenerateKitArchiveCommand < Gjp::BaseCommand
|
5
|
-
option
|
6
|
+
option %w(-w --whole), :flag, "recreate the whole archive (not incremental)"
|
6
7
|
|
7
8
|
def execute
|
8
9
|
checking_exceptions do
|
9
10
|
project = Gjp::Project.new(".")
|
10
11
|
ensure_dry_running(false, project) do
|
11
|
-
result_path = Gjp::Archiver.new(project).archive_kit(
|
12
|
+
result_path = Gjp::Archiver.new(project).archive_kit(whole?)
|
12
13
|
print_generation_result(project, result_path)
|
13
14
|
end
|
14
15
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Gjp
|
4
|
+
# gjp generate-package-spec
|
4
5
|
class GeneratePackageSpecCommand < Gjp::BaseCommand
|
5
|
-
option
|
6
|
+
option %w(-f --filter), "FILTER", "filter files to be installed by this spec", default: "*.jar"
|
6
7
|
parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", default: "."
|
7
8
|
parameter "[POM]", "a pom file path", default: "pom.xml"
|
8
9
|
|
data/lib/gjp/commands/get_pom.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Gjp
|
4
|
+
# gjp get-source
|
4
5
|
class GetSourceCommand < Gjp::BaseCommand
|
5
6
|
parameter "POM", "a pom file path or URI"
|
6
7
|
|
@@ -16,17 +17,12 @@ module Gjp
|
|
16
17
|
effective_pom_path = Gjp::MavenRunner.new(project).get_effective_pom(pom)
|
17
18
|
puts "Source jar not found in Maven. Try looking here:"
|
18
19
|
pom = Gjp::Pom.new(effective_pom_path)
|
19
|
-
unless pom.url.empty?
|
20
|
-
|
21
|
-
|
22
|
-
unless pom.scm_connection.empty?
|
23
|
-
puts "SCM connection: #{pom.scm_connection}"
|
24
|
-
end
|
25
|
-
unless pom.scm_url.empty?
|
26
|
-
puts "SCM connection: #{pom.scm_url}"
|
27
|
-
end
|
20
|
+
puts "Website: #{pom.url}" unless pom.url.empty?
|
21
|
+
puts "SCM connection: #{pom.scm_connection}" unless pom.scm_connection.empty?
|
22
|
+
puts "SCM connection: #{pom.scm_url}" unless pom.scm_url.empty?
|
28
23
|
puts "The effective POM: #{effective_pom_path}"
|
29
|
-
|
24
|
+
name = !pom.name.empty? ? pom.name : pom.artifact_id
|
25
|
+
puts "Google: http://google.com/#q=#{URI.encode("#{name} sources")}"
|
30
26
|
end
|
31
27
|
end
|
32
28
|
end
|
data/lib/gjp/commands/init.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Gjp
|
4
|
+
# gjp list-kit-missing-sources
|
4
5
|
class ListKitMissingSourcesCommand < Gjp::BaseCommand
|
5
6
|
def execute
|
6
7
|
checking_exceptions do
|
@@ -10,8 +11,8 @@ module Gjp
|
|
10
11
|
ensure_dry_running(false, project) do
|
11
12
|
puts "Some source files were not found in these archives:"
|
12
13
|
kit_checker.unsourced_archives.each do |archive|
|
13
|
-
percentage =
|
14
|
-
puts "#{format_path(archive[:archive], project)} (~#{percentage}% missing)"
|
14
|
+
percentage = 100.0 * archive[:unsourced_class_names].length / archive[:class_names].length
|
15
|
+
puts "#{format_path(archive[:archive], project)} (~#{format("%.2f", percentage)}% missing)"
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
data/lib/gjp/commands/mvn.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Gjp
|
4
|
+
# gjp mvn
|
4
5
|
class MavenCommand < Gjp::BaseCommand
|
5
6
|
parameter "[MAVEN OPTIONS] ...", "mvn options", attribute_name: "dummy"
|
6
7
|
|
7
8
|
# override parsing in order to pipe everything to mvn
|
9
|
+
# rubocop:disable TrivialAccessors
|
8
10
|
def parse(args)
|
9
11
|
@options = args
|
10
12
|
end
|
data/lib/gjp/git.rb
CHANGED
@@ -18,7 +18,7 @@ module Gjp
|
|
18
18
|
if Dir.exist?(".git") == false
|
19
19
|
`git init`
|
20
20
|
else
|
21
|
-
|
21
|
+
fail GitAlreadyInitedError
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -56,9 +56,9 @@ module Gjp
|
|
56
56
|
# rename all .gitignore files by default as
|
57
57
|
# they prevent snapshotting
|
58
58
|
Find.find(".") do |file|
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
next unless file =~ /\.gitignore$/
|
60
|
+
|
61
|
+
FileUtils.mv(file, "#{file}_disabled_by_gjp")
|
62
62
|
end
|
63
63
|
|
64
64
|
`git rm -r --cached --ignore-unmatch .`
|
@@ -116,7 +116,7 @@ module Gjp
|
|
116
116
|
log.debug "calling git merge-file #{path} #{path}.old_version #{new_path}, output follows"
|
117
117
|
`git merge-file #{path} #{path}.old_version #{new_path} \
|
118
118
|
-L "newly generated" -L "previously generated" -L "user edited"`
|
119
|
-
conflict_count =
|
119
|
+
conflict_count = $CHILD_STATUS.exitstatus
|
120
120
|
File.delete "#{path}.old_version"
|
121
121
|
return conflict_count
|
122
122
|
end
|
data/lib/gjp/kit_checker.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require "find"
|
4
|
-
require "zip"
|
5
|
-
|
6
3
|
module Gjp
|
7
4
|
# checks kits for errors
|
8
5
|
class KitChecker
|
@@ -22,14 +19,12 @@ module Gjp
|
|
22
19
|
[path, nil]
|
23
20
|
end
|
24
21
|
|
25
|
-
archived_file_paths = plain_file_paths.select do |path,
|
22
|
+
archived_file_paths = plain_file_paths.select do |path, _archive|
|
26
23
|
path. =~ (/\.(zip)|([jwe]ar)$/)
|
27
|
-
end.map do |path,
|
24
|
+
end.map do |path, _archive|
|
28
25
|
result = []
|
29
26
|
Zip::File.foreach(path) do |entry|
|
30
|
-
if entry.file?
|
31
|
-
result << [entry.to_s, path]
|
32
|
-
end
|
27
|
+
result << [entry.to_s, path] if entry.file?
|
33
28
|
end
|
34
29
|
result
|
35
30
|
end.flatten(1)
|
@@ -41,7 +36,7 @@ module Gjp
|
|
41
36
|
# returns a list of class names for which
|
42
37
|
# we have source files in kit/
|
43
38
|
def source_class_names(paths)
|
44
|
-
source_paths = paths.select do |path,
|
39
|
+
source_paths = paths.select do |path, _archive|
|
45
40
|
path =~ /\.java$/
|
46
41
|
end
|
47
42
|
|
@@ -49,7 +44,7 @@ module Gjp
|
|
49
44
|
# back the directory tree all the way back to root.
|
50
45
|
# This could add non-existent names, but allows not looking
|
51
46
|
# in the file at all
|
52
|
-
class_names = source_paths.map do |path,
|
47
|
+
class_names = source_paths.map do |path, _archive|
|
53
48
|
class_name = path_to_class(path)
|
54
49
|
parts = class_name.split(".")
|
55
50
|
last_index = parts.length - 1
|
@@ -65,7 +60,7 @@ module Gjp
|
|
65
60
|
# we have binary files in kit/
|
66
61
|
def compiled_classes(paths)
|
67
62
|
result = {}
|
68
|
-
|
63
|
+
paths.select do |path, _archive|
|
69
64
|
path =~ /\.class$/
|
70
65
|
end.each do |path, archive|
|
71
66
|
class_name = path_to_class(path)
|
@@ -86,7 +81,7 @@ module Gjp
|
|
86
81
|
source_class_names = source_class_names(paths)
|
87
82
|
archive_paths_to_class_names = compiled_classes(paths)
|
88
83
|
|
89
|
-
|
84
|
+
archive_paths_to_class_names.map do |archive, class_names|
|
90
85
|
unsourced_class_names = class_names.select do |class_name|
|
91
86
|
source_class_names.include?(class_name) == false
|
92
87
|
end
|
@@ -97,6 +92,7 @@ module Gjp
|
|
97
92
|
end
|
98
93
|
|
99
94
|
private
|
95
|
+
|
100
96
|
# attempts to turn a .java/.class file name into a class name
|
101
97
|
def path_to_class(path)
|
102
98
|
path
|
data/lib/gjp/kit_runner.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require "find"
|
4
|
-
require "pathname"
|
5
|
-
|
6
3
|
module Gjp
|
7
4
|
# runs programs from a gjp kit with gjp-specific options
|
8
5
|
class KitRunner
|
@@ -16,10 +13,10 @@ module Gjp
|
|
16
13
|
def find_executable(name)
|
17
14
|
@project.from_directory do
|
18
15
|
Find.find("kit") do |path|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
next unless path =~ /bin\/#{name}$/
|
17
|
+
|
18
|
+
log.debug("found #{name} executable: #{path}")
|
19
|
+
return path
|
23
20
|
end
|
24
21
|
end
|
25
22
|
|
@@ -31,10 +28,11 @@ module Gjp
|
|
31
28
|
def run_executable(full_commandline)
|
32
29
|
log.debug "running #{full_commandline}"
|
33
30
|
Process.wait(Process.spawn(full_commandline))
|
34
|
-
|
31
|
+
$CHILD_STATUS.exitstatus == 0
|
35
32
|
end
|
36
33
|
end
|
37
34
|
|
35
|
+
# an executable from the kit was not found
|
38
36
|
class ExecutableNotFoundError < Exception
|
39
37
|
attr_reader :executable
|
40
38
|
|
data/lib/gjp/logger.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require "singleton"
|
4
|
-
require "forwardable"
|
5
|
-
require "logger"
|
6
|
-
|
7
3
|
module Gjp
|
4
|
+
# configures logging for this application
|
8
5
|
class Logger
|
9
6
|
include Singleton
|
10
7
|
extend Forwardable
|
@@ -15,12 +12,13 @@ module Gjp
|
|
15
12
|
@logger = ::Logger.new(STDERR)
|
16
13
|
@logger.datetime_format = "%Y-%m-%d %H:%M "
|
17
14
|
@logger.level = ::Logger::ERROR
|
18
|
-
@logger.formatter = proc do |severity,
|
15
|
+
@logger.formatter = proc do |severity, _datetime, _progname, msg|
|
19
16
|
"#{severity.chars.first}: #{msg}\n"
|
20
17
|
end
|
21
18
|
end
|
22
19
|
end
|
23
20
|
|
21
|
+
# convenience methods
|
24
22
|
module Logging
|
25
23
|
# convenience instance method
|
26
24
|
def log
|
data/lib/gjp/main.rb
CHANGED
data/lib/gjp/maven_runner.rb
CHANGED
data/lib/gjp/maven_website.rb
CHANGED
data/lib/gjp/pom.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require "nokogiri"
|
4
|
-
require "open-uri"
|
5
|
-
|
6
3
|
module Gjp
|
7
4
|
# encapsulates a pom.xml file
|
8
5
|
class Pom
|
@@ -40,7 +37,7 @@ module Gjp
|
|
40
37
|
end
|
41
38
|
|
42
39
|
def runtime_dependency_ids
|
43
|
-
|
40
|
+
@doc.xpath("project/dependencies/dependency[\
|
44
41
|
not(optional='true') and not(scope='provided') and not(scope='test') and not(scope='system')\
|
45
42
|
]").map do |element|
|
46
43
|
[element.xpath("groupId").text, element.xpath("artifactId").text, element.xpath("version").text]
|
data/lib/gjp/pom_getter.rb
CHANGED
@@ -1,13 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require "digest/sha1"
|
4
|
-
require "zip"
|
5
|
-
require "rest_client"
|
6
|
-
require "json"
|
7
|
-
require "pathname"
|
8
|
-
|
9
|
-
require "gjp/version_matcher"
|
10
|
-
|
11
3
|
module Gjp
|
12
4
|
# attempts to get java projects' pom file
|
13
5
|
class PomGetter
|
@@ -17,11 +9,11 @@ module Gjp
|
|
17
9
|
# returns filename and status if found, else nil
|
18
10
|
def get_pom(filename)
|
19
11
|
content, status = (get_pom_from_jar(filename) || get_pom_from_sha1(filename) || get_pom_from_heuristic(filename))
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
12
|
+
return unless content
|
13
|
+
|
14
|
+
pom_filename = filename.sub(/(\.jar)?$/, ".pom")
|
15
|
+
File.open(pom_filename, "w") { |io| io.write(content) }
|
16
|
+
[pom_filename, status]
|
25
17
|
end
|
26
18
|
|
27
19
|
# returns a pom embedded in a jar file
|
@@ -78,7 +70,7 @@ module Gjp
|
|
78
70
|
result = site.search_by_name(my_artifact_id).first
|
79
71
|
log.debug("Artifact id search result: #{result}")
|
80
72
|
unless result.nil?
|
81
|
-
group_id, artifact_id,
|
73
|
+
group_id, artifact_id, _ = site.get_maven_id_from result
|
82
74
|
results = site.search_by_group_id_and_artifact_id(group_id, artifact_id)
|
83
75
|
log.debug("All versions: #{results}")
|
84
76
|
their_versions = results.map { |doc| doc["v"] }
|
@@ -89,7 +81,7 @@ module Gjp
|
|
89
81
|
their_versions.max
|
90
82
|
end
|
91
83
|
)
|
92
|
-
best_matched_result = (results.select { |
|
84
|
+
best_matched_result = (results.select { |r| r["v"] == best_matched_version }).first
|
93
85
|
|
94
86
|
group_id, artifact_id, version = site.get_maven_id_from(best_matched_result)
|
95
87
|
log.warn("pom.xml for #{filename} found on search.maven.org with heuristic search\
|
data/lib/gjp/project.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require "find"
|
4
|
-
|
5
3
|
module Gjp
|
6
4
|
# encapsulates a Gjp project directory
|
7
5
|
class Project
|
@@ -26,17 +24,17 @@ module Gjp
|
|
26
24
|
# finds the project directory up in the tree, like git does
|
27
25
|
def self.find_project_dir(starting_dir)
|
28
26
|
result = starting_dir
|
29
|
-
while
|
27
|
+
while project?(result) == false && result != "/"
|
30
28
|
result = File.expand_path("..", result)
|
31
29
|
end
|
32
30
|
|
33
|
-
|
31
|
+
fail NoProjectDirectoryError, starting_dir if result == "/"
|
34
32
|
|
35
33
|
result
|
36
34
|
end
|
37
35
|
|
38
36
|
# returns true if the specified directory is a valid gjp project
|
39
|
-
def self.
|
37
|
+
def self.project?(dir)
|
40
38
|
File.directory?(File.join(dir, "src")) &&
|
41
39
|
File.directory?(File.join(dir, "kit")) &&
|
42
40
|
File.directory?(File.join(dir, ".git"))
|
@@ -48,14 +46,14 @@ module Gjp
|
|
48
46
|
dir_path = Pathname.new(File.expand_path(dir)).relative_path_from(Pathname.new(@full_path))
|
49
47
|
components = dir_path.to_s.split(File::SEPARATOR)
|
50
48
|
if components.count >= 2 &&
|
51
|
-
|
52
|
-
|
49
|
+
components.first == "src" &&
|
50
|
+
Dir.exist?(File.join(@full_path, components[0], components[1]))
|
53
51
|
components[1]
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
else
|
53
|
+
fail NoPackageDirectoryError
|
54
|
+
end
|
57
55
|
rescue ArgumentError, NoProjectDirectoryError
|
58
|
-
raise NoPackageDirectoryError
|
56
|
+
raise NoPackageDirectoryError, dir
|
59
57
|
end
|
60
58
|
|
61
59
|
# inits a new project directory structure
|
@@ -83,9 +81,7 @@ module Gjp
|
|
83
81
|
# to the kit package, src/ will be reset at the current state
|
84
82
|
# when finished
|
85
83
|
def dry_run
|
86
|
-
if
|
87
|
-
return false
|
88
|
-
end
|
84
|
+
return false if dry_running?
|
89
85
|
|
90
86
|
current_directory = Pathname.new(Dir.pwd).relative_path_from Pathname.new(@full_path)
|
91
87
|
|
@@ -94,7 +90,7 @@ module Gjp
|
|
94
90
|
end
|
95
91
|
|
96
92
|
# returns true iff we are currently dry-running
|
97
|
-
def
|
93
|
+
def dry_running?
|
98
94
|
latest_tag_count(:dry_run_started) > latest_tag_count(:dry_run_finished)
|
99
95
|
end
|
100
96
|
|
@@ -102,7 +98,7 @@ module Gjp
|
|
102
98
|
# if abort is true, reverts the whole directory
|
103
99
|
# if abort is false, reverts sources and updates output file lists
|
104
100
|
def finish(abort)
|
105
|
-
if
|
101
|
+
if dry_running?
|
106
102
|
if abort
|
107
103
|
@git.revert_whole_directory(".", latest_tag(:dry_run_started))
|
108
104
|
@git.delete_tag(latest_tag(:dry_run_started))
|
@@ -211,17 +207,17 @@ module Gjp
|
|
211
207
|
from_directory do
|
212
208
|
result = []
|
213
209
|
Find.find("src") do |file|
|
214
|
-
|
215
|
-
new_location = File.join("kit", "jars", Pathname.new(file).split[1])
|
216
|
-
FileUtils.mv(file, new_location)
|
210
|
+
next unless file =~ /.jar$/ && !File.symlink?(file)
|
217
211
|
|
218
|
-
|
219
|
-
|
220
|
-
.to_s
|
212
|
+
new_location = File.join("kit", "jars", Pathname.new(file).split[1])
|
213
|
+
FileUtils.mv(file, new_location)
|
221
214
|
|
222
|
-
|
223
|
-
|
224
|
-
|
215
|
+
link_target = Pathname.new(new_location)
|
216
|
+
.relative_path_from(Pathname.new(file).split.first)
|
217
|
+
.to_s
|
218
|
+
|
219
|
+
File.symlink(link_target, file)
|
220
|
+
result << [file, new_location]
|
225
221
|
end
|
226
222
|
|
227
223
|
result
|
@@ -229,6 +225,7 @@ module Gjp
|
|
229
225
|
end
|
230
226
|
end
|
231
227
|
|
228
|
+
# current directory is not a gjp project
|
232
229
|
class NoProjectDirectoryError < StandardError
|
233
230
|
attr_reader :directory
|
234
231
|
|
@@ -236,6 +233,8 @@ module Gjp
|
|
236
233
|
@directory = directory
|
237
234
|
end
|
238
235
|
end
|
236
|
+
|
237
|
+
# current directory is not a gjp package directory
|
239
238
|
class NoPackageDirectoryError < StandardError
|
240
239
|
attr_reader :directory
|
241
240
|
|
data/lib/gjp/source_getter.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require "rest_client"
|
4
|
-
|
5
3
|
module Gjp
|
6
4
|
# attempts to get java projects' sources
|
7
5
|
class SourceGetter
|
@@ -22,7 +20,7 @@ module Gjp
|
|
22
20
|
project.from_directory do
|
23
21
|
paths = Find.find(".").reject { |path| artifact_from_path(path).nil? }.sort
|
24
22
|
|
25
|
-
succeded_paths = paths.
|
23
|
+
succeded_paths = paths.each do |path|
|
26
24
|
group_id, artifact_id, version = artifact_from_path(path)
|
27
25
|
log.info("attempting source download for #{path} (#{group_id}:#{artifact_id}:#{version})")
|
28
26
|
maven_runner.get_source_jar(group_id, artifact_id, version)
|
@@ -36,10 +34,8 @@ module Gjp
|
|
36
34
|
|
37
35
|
# if possible, turn path into a Maven artifact name, otherwise return nil
|
38
36
|
def artifact_from_path(path)
|
39
|
-
match = path.match(
|
40
|
-
unless match.nil?
|
41
|
-
[match[1].gsub("/", "."), match[2], match[3]]
|
42
|
-
end
|
37
|
+
match = path.match(%r{\./kit/m2/(.+)/(.+)/(.+)/\2-\3.*\.jar$})
|
38
|
+
[match[1].gsub("/", "."), match[2], match[3]] unless match.nil?
|
43
39
|
end
|
44
40
|
end
|
45
41
|
end
|
data/lib/gjp/template_manager.rb
CHANGED
data/lib/gjp/version.rb
CHANGED
data/lib/gjp/version_matcher.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require "text"
|
4
|
-
|
5
3
|
module Gjp
|
6
4
|
# heuristically matches version strings
|
7
5
|
class VersionMatcher
|
@@ -74,23 +72,19 @@ module Gjp
|
|
74
72
|
# for strings, the score is the Levenshtein distance
|
75
73
|
# in any case score is normalized between 0 (identical) and 99 (very different/uncomparable)
|
76
74
|
def chunk_distance(my_chunk, their_chunk)
|
77
|
-
if my_chunk.nil?
|
78
|
-
|
79
|
-
|
80
|
-
if their_chunk
|
81
|
-
their_chunk = "0"
|
82
|
-
end
|
83
|
-
if my_chunk.is_i? && their_chunk.is_i?
|
75
|
+
my_chunk = "0" if my_chunk.nil?
|
76
|
+
their_chunk = "0" if their_chunk.nil?
|
77
|
+
|
78
|
+
if i?(my_chunk) && i?(their_chunk)
|
84
79
|
return [(my_chunk.to_i - their_chunk.to_i).abs, 99].min
|
85
80
|
else
|
86
81
|
return [Text::Levenshtein.distance(my_chunk.upcase, their_chunk.upcase), 99].min
|
87
82
|
end
|
88
83
|
end
|
89
|
-
end
|
90
|
-
end
|
91
84
|
|
92
|
-
|
93
|
-
|
94
|
-
|
85
|
+
# true for integer strings
|
86
|
+
def i?(string)
|
87
|
+
string =~ /^[0-9]+$/
|
88
|
+
end
|
95
89
|
end
|
96
90
|
end
|
data/spec/lib/ant_runner_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
|
-
require "lib/kit_runner_spec"
|
5
4
|
|
6
5
|
describe Gjp::AntRunner do
|
7
6
|
it_behaves_like Gjp::KitRunner
|
@@ -31,7 +30,7 @@ describe Gjp::AntRunner do
|
|
31
30
|
|
32
31
|
describe "#ant" do
|
33
32
|
it "runs Ant" do
|
34
|
-
|
33
|
+
create_mock_executable("ant")
|
35
34
|
@project.from_directory do
|
36
35
|
@kit_runner.ant(["extra-option"])
|
37
36
|
File.read("test_out").strip.should match(/extra-option$/)
|
data/spec/lib/project_spec.rb
CHANGED
@@ -15,10 +15,10 @@ describe Gjp::Project do
|
|
15
15
|
FileUtils.rm_rf(@project_path)
|
16
16
|
end
|
17
17
|
|
18
|
-
describe "#
|
18
|
+
describe "#project?" do
|
19
19
|
it "checks if a directory is a gjp project or not" do
|
20
|
-
Gjp::Project.
|
21
|
-
Gjp::Project.
|
20
|
+
Gjp::Project.project?(@project_path).should be_true
|
21
|
+
Gjp::Project.project?(File.join(@project_path, "..")).should be_false
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -99,14 +99,14 @@ describe Gjp::Project do
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
describe "#
|
102
|
+
describe "#dry_running?" do
|
103
103
|
it "checks if a project is dry running" do
|
104
104
|
@project.from_directory do
|
105
|
-
@project.
|
105
|
+
@project.dry_running?.should be_false
|
106
106
|
@project.dry_run
|
107
|
-
@project.
|
107
|
+
@project.dry_running?.should be_true
|
108
108
|
@project.finish(false)
|
109
|
-
@project.
|
109
|
+
@project.dry_running?.should be_false
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
@@ -142,7 +142,7 @@ describe Gjp::Project do
|
|
142
142
|
end
|
143
143
|
|
144
144
|
@project.finish(false).should be_true
|
145
|
-
@project.
|
145
|
+
@project.dry_running?.should be_false
|
146
146
|
|
147
147
|
@project.from_directory do
|
148
148
|
`git rev-list --all`.split("\n").length.should eq 4
|
@@ -172,7 +172,7 @@ describe Gjp::Project do
|
|
172
172
|
end
|
173
173
|
|
174
174
|
@project.finish(true).should be_true
|
175
|
-
@project.
|
175
|
+
@project.dry_running?.should be_false
|
176
176
|
|
177
177
|
@project.from_directory do
|
178
178
|
`git rev-list --all`.split("\n").length.should eq 2
|
@@ -198,7 +198,7 @@ describe Gjp::Project do
|
|
198
198
|
end
|
199
199
|
|
200
200
|
@project.from_directory do
|
201
|
-
@project.
|
201
|
+
@project.dry_running?.should be_true
|
202
202
|
`git rev-list --all`.split("\n").length.should eq 2
|
203
203
|
`git diff-tree --no-commit-id --name-only -r HEAD`.split("\n").should include("src/test")
|
204
204
|
`git cat-file tag gjp_dry_run_started_1 | tail -1`.should include("src")
|
data/spec/spec_helper.rb
CHANGED
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.39.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: 2014-05-
|
12
|
+
date: 2014-05-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -149,7 +149,6 @@ extra_rdoc_files: []
|
|
149
149
|
files:
|
150
150
|
- .gitignore
|
151
151
|
- .rubocop.yml
|
152
|
-
- .rubocop_todo.yml
|
153
152
|
- Gemfile
|
154
153
|
- LICENSE
|
155
154
|
- MOTIVATION.md
|
@@ -225,7 +224,6 @@ files:
|
|
225
224
|
- spec/lib/archiver_spec.rb
|
226
225
|
- spec/lib/git_spec.rb
|
227
226
|
- spec/lib/kit_checker_spec.rb
|
228
|
-
- spec/lib/kit_runner_spec.rb
|
229
227
|
- spec/lib/maven_runner_spec.rb
|
230
228
|
- spec/lib/maven_website_spec.rb
|
231
229
|
- spec/lib/pom_getter_spec.rb
|
@@ -237,6 +235,7 @@ files:
|
|
237
235
|
- spec/lib/template_manager_spec.rb
|
238
236
|
- spec/lib/version_matcher_spec.rb
|
239
237
|
- spec/spec_helper.rb
|
238
|
+
- spec/support/kit_runner_examples.rb
|
240
239
|
- utils/delete_nonet_user.sh
|
241
240
|
- utils/setup_nonet_user.sh
|
242
241
|
homepage: https://github.com/SilvioMoioli/gjp
|
@@ -285,7 +284,6 @@ test_files:
|
|
285
284
|
- spec/lib/archiver_spec.rb
|
286
285
|
- spec/lib/git_spec.rb
|
287
286
|
- spec/lib/kit_checker_spec.rb
|
288
|
-
- spec/lib/kit_runner_spec.rb
|
289
287
|
- spec/lib/maven_runner_spec.rb
|
290
288
|
- spec/lib/maven_website_spec.rb
|
291
289
|
- spec/lib/pom_getter_spec.rb
|
@@ -297,3 +295,4 @@ test_files:
|
|
297
295
|
- spec/lib/template_manager_spec.rb
|
298
296
|
- spec/lib/version_matcher_spec.rb
|
299
297
|
- spec/spec_helper.rb
|
298
|
+
- spec/support/kit_runner_examples.rb
|
data/.rubocop_todo.yml
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
-
# on 2014-05-23 15:40:35 +0200 using RuboCop version 0.22.0.
|
3
|
-
# The point is for the user to remove these configuration records
|
4
|
-
# one by one as the offenses are removed from the code base.
|
5
|
-
# Note that changes in the inspected code, or installation of new
|
6
|
-
# versions of RuboCop, may require this file to be generated again.
|
7
|
-
|
8
|
-
# Offense count: 8
|
9
|
-
Documentation:
|
10
|
-
Enabled: false
|
11
|
-
|
12
|
-
# Offense count: 1
|
13
|
-
DoubleNegation:
|
14
|
-
Enabled: false
|
15
|
-
|
16
|
-
# Offense count: 1
|
17
|
-
EmptyLinesAroundAccessModifier:
|
18
|
-
Enabled: false
|
19
|
-
|
20
|
-
# Offense count: 2
|
21
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
22
|
-
Encoding:
|
23
|
-
Enabled: false
|
24
|
-
|
25
|
-
# Offense count: 9
|
26
|
-
# Configuration parameters: AlignWith, SupportedStyles.
|
27
|
-
EndAlignment:
|
28
|
-
Enabled: false
|
29
|
-
|
30
|
-
# Offense count: 2
|
31
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
32
|
-
FormatString:
|
33
|
-
Enabled: false
|
34
|
-
|
35
|
-
# Offense count: 4
|
36
|
-
# Configuration parameters: MinBodyLength.
|
37
|
-
GuardClause:
|
38
|
-
Enabled: false
|
39
|
-
|
40
|
-
# Offense count: 7
|
41
|
-
# Configuration parameters: MaxLineLength.
|
42
|
-
IfUnlessModifier:
|
43
|
-
Enabled: false
|
44
|
-
|
45
|
-
# Offense count: 28
|
46
|
-
# Configuration parameters: CountComments.
|
47
|
-
MethodLength:
|
48
|
-
Max: 34
|
49
|
-
|
50
|
-
# Offense count: 6
|
51
|
-
MultilineBlockChain:
|
52
|
-
Enabled: false
|
53
|
-
|
54
|
-
# Offense count: 3
|
55
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
56
|
-
Next:
|
57
|
-
Enabled: false
|
58
|
-
|
59
|
-
# Offense count: 3
|
60
|
-
# Configuration parameters: NamePrefixBlacklist.
|
61
|
-
PredicateName:
|
62
|
-
Enabled: false
|
63
|
-
|
64
|
-
# Offense count: 4
|
65
|
-
# Configuration parameters: SupportedStyles.
|
66
|
-
RaiseArgs:
|
67
|
-
EnforcedStyle: compact
|
68
|
-
|
69
|
-
# Offense count: 1
|
70
|
-
# Configuration parameters: MaxSlashes.
|
71
|
-
RegexpLiteral:
|
72
|
-
Enabled: false
|
73
|
-
|
74
|
-
# Offense count: 1
|
75
|
-
ShadowingOuterLocalVariable:
|
76
|
-
Enabled: false
|
77
|
-
|
78
|
-
# Offense count: 5
|
79
|
-
# Cop supports --auto-correct.
|
80
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
81
|
-
SignalException:
|
82
|
-
Enabled: false
|
83
|
-
|
84
|
-
# Offense count: 4
|
85
|
-
# Cop supports --auto-correct.
|
86
|
-
SpecialGlobalVars:
|
87
|
-
Enabled: false
|
88
|
-
|
89
|
-
# Offense count: 7
|
90
|
-
Tab:
|
91
|
-
Enabled: false
|
92
|
-
|
93
|
-
# Offense count: 2
|
94
|
-
# Cop supports --auto-correct.
|
95
|
-
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist.
|
96
|
-
TrivialAccessors:
|
97
|
-
Enabled: false
|
98
|
-
|
99
|
-
# Offense count: 8
|
100
|
-
# Cop supports --auto-correct.
|
101
|
-
UnusedBlockArgument:
|
102
|
-
Enabled: false
|
103
|
-
|
104
|
-
# Offense count: 6
|
105
|
-
UselessAssignment:
|
106
|
-
Enabled: false
|
107
|
-
|
108
|
-
# Offense count: 6
|
109
|
-
# Cop supports --auto-correct.
|
110
|
-
WordArray:
|
111
|
-
MinSize: 2
|