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.
Files changed (60) hide show
  1. data/.gitignore +4 -0
  2. data/.rubocop.yml +7 -0
  3. data/.rubocop_todo.yml +241 -0
  4. data/SPECIAL_CASES.md +2 -5
  5. data/integration-tests/commons.sh +2 -0
  6. data/lib/gjp.rb +22 -1
  7. data/lib/gjp/ant_runner.rb +1 -1
  8. data/lib/gjp/archiver.rb +11 -11
  9. data/lib/gjp/commands/ant.rb +21 -0
  10. data/lib/gjp/commands/base.rb +94 -0
  11. data/lib/gjp/commands/download-maven-source-jars.rb +28 -0
  12. data/lib/gjp/commands/dry-run.rb +16 -0
  13. data/lib/gjp/commands/finish.rb +22 -0
  14. data/lib/gjp/commands/generate-all.rb +38 -0
  15. data/lib/gjp/commands/generate-kit-archive.rb +18 -0
  16. data/lib/gjp/commands/generate-kit-spec.rb +16 -0
  17. data/lib/gjp/commands/generate-package-archive.rb +19 -0
  18. data/lib/gjp/commands/generate-package-script.rb +21 -0
  19. data/lib/gjp/commands/generate-package-spec.rb +22 -0
  20. data/lib/gjp/commands/get-pom.rb +31 -0
  21. data/lib/gjp/commands/get-source.rb +35 -0
  22. data/lib/gjp/commands/init.rb +15 -0
  23. data/lib/gjp/commands/list-kit-missing-sources.rb +21 -0
  24. data/lib/gjp/commands/move-jars-to-kit.rb +18 -0
  25. data/lib/gjp/commands/mvn.rb +22 -0
  26. data/lib/gjp/git.rb +18 -8
  27. data/lib/gjp/kit_checker.rb +6 -6
  28. data/lib/gjp/kit_runner.rb +2 -2
  29. data/lib/gjp/kit_spec_adapter.rb +1 -1
  30. data/lib/gjp/main.rb +103 -0
  31. data/lib/gjp/maven_runner.rb +1 -1
  32. data/lib/gjp/maven_website.rb +8 -6
  33. data/lib/gjp/package_spec_adapter.rb +1 -1
  34. data/lib/gjp/pom.rb +3 -1
  35. data/lib/gjp/pom_getter.rb +12 -4
  36. data/lib/gjp/project.rb +4 -2
  37. data/lib/gjp/script_generator.rb +2 -1
  38. data/lib/gjp/spec_generator.rb +2 -2
  39. data/lib/gjp/version.rb +1 -1
  40. data/lib/gjp/version_matcher.rb +3 -3
  41. data/lib/template/kit.spec +1 -0
  42. data/lib/template/package.spec +1 -0
  43. data/spec/lib/ant_runner_spec.rb +3 -3
  44. data/spec/lib/archiver_spec.rb +1 -1
  45. data/spec/lib/git_spec.rb +25 -3
  46. data/spec/lib/kit_checker_spec.rb +6 -6
  47. data/spec/lib/kit_runner_spec.rb +1 -1
  48. data/spec/lib/maven_runner_spec.rb +6 -5
  49. data/spec/lib/maven_website_spec.rb +2 -2
  50. data/spec/lib/pom_getter_spec.rb +1 -1
  51. data/spec/lib/pom_spec.rb +5 -3
  52. data/spec/lib/project_spec.rb +15 -14
  53. data/spec/lib/script_generator_spec.rb +4 -2
  54. data/spec/lib/source_getter_spec.rb +1 -1
  55. data/spec/lib/spec_generator_spec.rb +2 -2
  56. data/spec/lib/template_manager_spec.rb +6 -6
  57. data/spec/lib/version_matcher_spec.rb +1 -1
  58. data/spec/spec_helper.rb +25 -23
  59. metadata +22 -3
  60. data/lib/gjp/cli.rb +0 -384
data/.gitignore CHANGED
@@ -21,3 +21,7 @@ spec/data/test-project
21
21
  .yardoc
22
22
  _yardoc
23
23
  doc/
24
+
25
+ # integration test files
26
+ integration-tests/galaxy
27
+
@@ -0,0 +1,7 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ LineLength:
4
+ Max: 120
5
+
6
+ StringLiterals:
7
+ EnforcedStyle: double_quotes
@@ -0,0 +1,241 @@
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: 2
9
+ ClassVars:
10
+ Enabled: false
11
+
12
+ # Offense count: 2
13
+ # Cop supports --auto-correct.
14
+ ColonMethodCall:
15
+ Enabled: false
16
+
17
+ # Offense count: 6
18
+ # Cop supports --auto-correct.
19
+ CommentIndentation:
20
+ Enabled: false
21
+
22
+ # Offense count: 1
23
+ CyclomaticComplexity:
24
+ Max: 8
25
+
26
+ # Offense count: 6
27
+ # Cop supports --auto-correct.
28
+ DeprecatedClassMethods:
29
+ Enabled: false
30
+
31
+ # Offense count: 8
32
+ Documentation:
33
+ Enabled: false
34
+
35
+ # Offense count: 1
36
+ DoubleNegation:
37
+ Enabled: false
38
+
39
+ # Offense count: 1
40
+ # Cop supports --auto-correct.
41
+ EmptyLines:
42
+ Enabled: false
43
+
44
+ # Offense count: 1
45
+ EmptyLinesAroundAccessModifier:
46
+ Enabled: false
47
+
48
+ # Offense count: 1
49
+ # Cop supports --auto-correct.
50
+ EmptyLinesAroundBody:
51
+ Enabled: false
52
+
53
+ # Offense count: 2
54
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
55
+ Encoding:
56
+ Enabled: false
57
+
58
+ # Offense count: 9
59
+ # Configuration parameters: AlignWith, SupportedStyles.
60
+ EndAlignment:
61
+ Enabled: false
62
+
63
+ # Offense count: 2
64
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
65
+ FormatString:
66
+ Enabled: false
67
+
68
+ # Offense count: 4
69
+ # Configuration parameters: MinBodyLength.
70
+ GuardClause:
71
+ Enabled: false
72
+
73
+ # Offense count: 27
74
+ # Cop supports --auto-correct.
75
+ # Configuration parameters: SupportedStyles.
76
+ HashSyntax:
77
+ EnforcedStyle: hash_rockets
78
+
79
+ # Offense count: 7
80
+ # Configuration parameters: MaxLineLength.
81
+ IfUnlessModifier:
82
+ Enabled: false
83
+
84
+ # Offense count: 3
85
+ # Cop supports --auto-correct.
86
+ IndentationConsistency:
87
+ Enabled: false
88
+
89
+ # Offense count: 15
90
+ # Cop supports --auto-correct.
91
+ IndentationWidth:
92
+ Enabled: false
93
+
94
+ # Offense count: 3
95
+ # Cop supports --auto-correct.
96
+ LineEndConcatenation:
97
+ Enabled: false
98
+
99
+ # Offense count: 4
100
+ # Cop supports --auto-correct.
101
+ MethodCallParentheses:
102
+ Enabled: false
103
+
104
+ # Offense count: 28
105
+ # Configuration parameters: CountComments.
106
+ MethodLength:
107
+ Max: 34
108
+
109
+ # Offense count: 6
110
+ MultilineBlockChain:
111
+ Enabled: false
112
+
113
+ # Offense count: 3
114
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
115
+ Next:
116
+ Enabled: false
117
+
118
+ # Offense count: 8
119
+ # Cop supports --auto-correct.
120
+ NilComparison:
121
+ Enabled: false
122
+
123
+ # Offense count: 12
124
+ # Cop supports --auto-correct.
125
+ # Configuration parameters: IncludeSemanticChanges.
126
+ NonNilCheck:
127
+ Enabled: false
128
+
129
+ # Offense count: 1
130
+ # Cop supports --auto-correct.
131
+ PerlBackrefs:
132
+ Enabled: false
133
+
134
+ # Offense count: 3
135
+ # Configuration parameters: NamePrefixBlacklist.
136
+ PredicateName:
137
+ Enabled: false
138
+
139
+ # Offense count: 4
140
+ # Configuration parameters: SupportedStyles.
141
+ RaiseArgs:
142
+ EnforcedStyle: compact
143
+
144
+ # Offense count: 2
145
+ # Cop supports --auto-correct.
146
+ RedundantBegin:
147
+ Enabled: false
148
+
149
+ # Offense count: 8
150
+ # Cop supports --auto-correct.
151
+ # Configuration parameters: AllowMultipleReturnValues.
152
+ RedundantReturn:
153
+ Enabled: false
154
+
155
+ # Offense count: 1
156
+ # Configuration parameters: MaxSlashes.
157
+ RegexpLiteral:
158
+ Enabled: false
159
+
160
+ # Offense count: 1
161
+ ShadowingOuterLocalVariable:
162
+ Enabled: false
163
+
164
+ # Offense count: 5
165
+ # Cop supports --auto-correct.
166
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
167
+ SignalException:
168
+ Enabled: false
169
+
170
+ # Offense count: 11
171
+ # Cop supports --auto-correct.
172
+ SpaceAfterComma:
173
+ Enabled: false
174
+
175
+ # Offense count: 8
176
+ # Cop supports --auto-correct.
177
+ SpaceAroundOperators:
178
+ Enabled: false
179
+
180
+ # Offense count: 2
181
+ # Cop supports --auto-correct.
182
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
183
+ SpaceBeforeBlockBraces:
184
+ Enabled: false
185
+
186
+ # Offense count: 13
187
+ # Cop supports --auto-correct.
188
+ # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
189
+ SpaceInsideBlockBraces:
190
+ Enabled: false
191
+
192
+ # Offense count: 22
193
+ # Cop supports --auto-correct.
194
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
195
+ SpaceInsideHashLiteralBraces:
196
+ Enabled: false
197
+
198
+ # Offense count: 4
199
+ # Cop supports --auto-correct.
200
+ SpecialGlobalVars:
201
+ Enabled: false
202
+
203
+ # Offense count: 7
204
+ Tab:
205
+ Enabled: false
206
+
207
+ # Offense count: 8
208
+ # Cop supports --auto-correct.
209
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
210
+ TrailingBlankLines:
211
+ Enabled: false
212
+
213
+ # Offense count: 2
214
+ # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
215
+ TrailingComma:
216
+ Enabled: false
217
+
218
+ # Offense count: 45
219
+ # Cop supports --auto-correct.
220
+ TrailingWhitespace:
221
+ Enabled: false
222
+
223
+ # Offense count: 2
224
+ # Cop supports --auto-correct.
225
+ # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist.
226
+ TrivialAccessors:
227
+ Enabled: false
228
+
229
+ # Offense count: 8
230
+ # Cop supports --auto-correct.
231
+ UnusedBlockArgument:
232
+ Enabled: false
233
+
234
+ # Offense count: 6
235
+ UselessAssignment:
236
+ Enabled: false
237
+
238
+ # Offense count: 6
239
+ # Cop supports --auto-correct.
240
+ WordArray:
241
+ MinSize: 2
@@ -68,11 +68,6 @@ Note that the kit package is needed at build time only by OBS, no end user shoul
68
68
  ## Gotchas
69
69
 
70
70
  * `gjp` internally uses `git` to keep track of files, any gjp project is actually also a `git` repo. Feel free to navigate it, you can commit, push and pull as long as the `gjp` tags are preserved. You can also delete commits and tags, effectively rewinding gjp history (just make sure to delete all tags pointing to a certain commit when you discard it);
71
- * if your sources come from a Git repo, be sure to remove any `.git`/`.gitignore` files, otherwise `gjp` might get confused;
72
- * if OBS complains that jars in your kit or package are compiled for a JDK version higher than 1.5, add the following line after `%install` to squelch the error:
73
-
74
- export NO_BRP_CHECK_BYTECODE_VERSION=true
75
-
76
71
  * some Maven plugins like the Eclipse Project ones ([Tycho](https://www.eclipse.org/tycho/)) will save data in `/tmp` downloaded from the Internet and will produce errors if this data is not there during offline builds. One way to work around that is to force Java to use a kit subdirectory as `/tmp`. Add the following option to `gjp mvn` during your build:
77
72
 
78
73
  -DskipTests=true -Djava.io.tmpdir=<full path to project>/kit/tmp
@@ -81,6 +76,8 @@ Use the following option in `mvn` in your build.sh file to make it reproducible:
81
76
 
82
77
  -DskipTests=true -Djava.io.tmpdir=$PROJECT_PREFIX/kit/tmp
83
78
 
79
+ * Tycho builds may also require NSS, so if you get NSS errors be sure to add `mozilla-nss` or an equivalent package in a BuildRequires: line;
80
+
84
81
  * if you want to be 100% sure your package builds without network access, you can use scripts in the `utils/` folder to create a special `nonet` user that cannot use the Internet and retry the build from that user.
85
82
 
86
83
  ## Frequently used sources
@@ -2,6 +2,8 @@
2
2
 
3
3
  # A crude integration test that builds commons-collections
4
4
 
5
+ set -e
6
+
5
7
  rm -Rf galaxy
6
8
  mkdir galaxy
7
9
  cd galaxy
data/lib/gjp.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # backend
1
2
  require "gjp/version"
2
3
  require "gjp/logger"
3
4
  require "gjp/template_manager"
@@ -18,4 +19,24 @@ require "gjp/spec_generator"
18
19
  require "gjp/archiver"
19
20
  require "gjp/kit_checker"
20
21
 
21
- require "gjp/cli"
22
+ # UI
23
+ require "gjp/commands/base"
24
+
25
+ require "gjp/commands/ant"
26
+ require "gjp/commands/download-maven-source-jars"
27
+ require "gjp/commands/dry-run"
28
+ require "gjp/commands/finish"
29
+ require "gjp/commands/generate-all"
30
+ require "gjp/commands/generate-kit-archive"
31
+ require "gjp/commands/generate-kit-spec"
32
+ require "gjp/commands/generate-package-archive"
33
+ require "gjp/commands/generate-package-script"
34
+ require "gjp/commands/generate-package-spec"
35
+ require "gjp/commands/get-pom"
36
+ require "gjp/commands/get-source"
37
+ require "gjp/commands/init"
38
+ require "gjp/commands/list-kit-missing-sources"
39
+ require "gjp/commands/move-jars-to-kit"
40
+ require "gjp/commands/mvn"
41
+
42
+ require "gjp/main"
@@ -7,7 +7,7 @@ module Gjp
7
7
 
8
8
  # runs ant in a subprocess
9
9
  def ant(options)
10
- run_executable("#{get_ant_commandline(@project.full_path)} #{options.join(' ')}")
10
+ run_executable("#{get_ant_commandline(@project.full_path)} #{options.join(" ")}")
11
11
  end
12
12
 
13
13
  # returns a command line for running Ant from the specified
@@ -13,17 +13,17 @@ module Gjp
13
13
  def archive_kit(full)
14
14
  destination_dir = File.join(@project.full_path, "output", "#{@project.name}-kit")
15
15
  FileUtils.mkdir_p(destination_dir)
16
- destination_file_prefix = "#{@project.name}-kit"
17
- destination_file_suffix = ".tar.xz"
16
+ file_prefix = "#{@project.name}-kit"
17
+ file_suffix = ".tar.xz"
18
18
 
19
19
  @project.take_snapshot "Kit archival started"
20
20
 
21
21
  destination_file = if full
22
- remove_stale_incremental(destination_dir, destination_file_prefix, destination_file_suffix)
23
- archive_single("kit", File.join(destination_dir, destination_file_prefix + destination_file_suffix))
22
+ remove_stale_incremental(destination_dir, file_prefix, file_suffix)
23
+ archive_single("kit", File.join(destination_dir, file_prefix + file_suffix))
24
24
  else
25
25
  log.debug "doing incremental archive"
26
- archive_incremental("kit", destination_dir, destination_file_prefix, destination_file_suffix, :archive_kit)
26
+ archive_incremental("kit", destination_dir, file_prefix, file_suffix, :archive_kit)
27
27
  end
28
28
 
29
29
  @project.take_snapshot "Kit archive generated", :archive_kit
@@ -52,15 +52,15 @@ module Gjp
52
52
 
53
53
  # archives a directory's changed contents since last time archive_incremental was called
54
54
  # uses snapshots with tag_prefix to keep track of calls to this method
55
- # destination files will be destination_file_prefix_NNNN_destination_file_suffix
56
- def archive_incremental(source_directory, destination_dir, destination_file_prefix, destination_file_suffix, tag_prefix)
55
+ # destination files will be file_prefix_NNNN_file_suffix
56
+ def archive_incremental(source_directory, destination_dir, file_prefix, file_suffix, tag_prefix)
57
57
  @project.from_directory do
58
58
  latest_tag_count = @project.latest_tag_count(tag_prefix)
59
59
 
60
60
  if latest_tag_count == 0
61
- archive_single(source_directory, File.join(destination_dir, destination_file_prefix + destination_file_suffix))
61
+ archive_single(source_directory, File.join(destination_dir, file_prefix + file_suffix))
62
62
  else
63
- destination_file = File.join(destination_dir, "#{destination_file_prefix}_#{"%04d" % (latest_tag_count)}#{destination_file_suffix}")
63
+ destination_file = File.join(destination_dir, "#{file_prefix}_#{"%04d" % (latest_tag_count)}#{file_suffix}")
64
64
  tag = @project.latest_tag(tag_prefix)
65
65
  log.debug "creating #{destination_file} with files newer than #{tag}"
66
66
 
@@ -80,9 +80,9 @@ module Gjp
80
80
  end
81
81
 
82
82
  # removes any stale incremental files
83
- def remove_stale_incremental(destination_dir, destination_file_prefix, destination_file_suffix)
83
+ def remove_stale_incremental(destination_dir, file_prefix, file_suffix)
84
84
  Dir.entries(destination_dir)
85
- .select { |f| f =~ /^#{destination_file_prefix}_([0-9]+)#{destination_file_suffix}$/}
85
+ .select { |f| f =~ /^#{file_prefix}_([0-9]+)#{file_suffix}$/}
86
86
  .each do |f|
87
87
  log.debug "removing stale incremental archive #{f}"
88
88
  File.delete(File.join(destination_dir, f))
@@ -0,0 +1,21 @@
1
+ # encoding: UTF-8
2
+
3
+ module Gjp
4
+ class AntCommand < Gjp::BaseCommand
5
+ parameter "[ANT OPTIONS] ...", "ant options", :attribute_name => "dummy"
6
+
7
+ # override parsing in order to pipe everything to mvn
8
+ def parse(args)
9
+ @options = args
10
+ end
11
+
12
+ def execute
13
+ checking_exceptions do
14
+ project = Gjp::Project.new(".")
15
+ ensure_dry_running(true, project) do
16
+ Gjp::AntRunner.new(project).ant(@options)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,94 @@
1
+ # encoding: UTF-8
2
+ require "clamp"
3
+ require "gjp/logger"
4
+
5
+ module Gjp
6
+
7
+ # implements common options and utility methods
8
+ class BaseCommand < Clamp::Command
9
+ include Logger
10
+
11
+ # Options available to all gjp commands
12
+ option ["-v", "--verbose"], :flag, "verbose output"
13
+ option ["--very-verbose"], :flag, "very verbose output"
14
+ option ["--very-very-verbose"], :flag, "very very verbose output"
15
+
16
+ # verbosity handlers
17
+ def very_very_verbose=(flag)
18
+ configure_log_level(verbose?, very_verbose?, flag)
19
+ end
20
+
21
+ def very_verbose=(flag)
22
+ configure_log_level(verbose?, flag, very_very_verbose?)
23
+ end
24
+
25
+ def verbose=(flag)
26
+ configure_log_level(flag, very_verbose?, very_very_verbose?)
27
+ end
28
+
29
+ # maps verbosity options to log level
30
+ def configure_log_level(v, vv, vvv)
31
+ if vvv
32
+ log.level = ::Logger::DEBUG
33
+ elsif vv
34
+ log.level = ::Logger::INFO
35
+ elsif v
36
+ log.level = ::Logger::WARN
37
+ else
38
+ log.level = ::Logger::ERROR
39
+ end
40
+ end
41
+
42
+ # prints an error message and exits unless there is a dry-run in progress
43
+ def ensure_dry_running(state, project)
44
+ if project.is_dry_running == state
45
+ yield
46
+ else
47
+ if state == true
48
+ puts "Please start a dry-run first, use \"gjp dry-run\""
49
+ else
50
+ puts "Please finish or abort this dry-run first, use \"gjp finish\" or \"gjp finish --abort\""
51
+ end
52
+ end
53
+ end
54
+
55
+ # outputs output of a file generation
56
+ def print_generation_result(project, result_path, conflict_count = 0)
57
+ puts "#{format_path(result_path, project)} generated"
58
+ if conflict_count > 0
59
+ puts "Warning: #{conflict_count} unresolved conflicts"
60
+ end
61
+ end
62
+
63
+ # generates a version of path relative to the current directory
64
+ def format_path(path, project)
65
+ full_path = if Pathname.new(path).relative?
66
+ File.join(project.full_path, path)
67
+ else
68
+ path
69
+ end
70
+ Pathname.new(full_path).relative_path_from(Pathname.new(Dir.pwd))
71
+ end
72
+
73
+ # handles most fatal exceptions
74
+ def checking_exceptions
75
+ begin
76
+ yield
77
+ rescue Errno::EACCES => e
78
+ $stderr.puts e
79
+ rescue Errno::ENOENT => e
80
+ $stderr.puts e
81
+ rescue Errno::EEXIST => e
82
+ $stderr.puts e
83
+ rescue NoProjectDirectoryError => e
84
+ $stderr.puts "#{e.directory} is not a gjp project directory, see gjp init"
85
+ rescue NoPackageDirectoryError => e
86
+ $stderr.puts "#{e.directory} is not a gjp package directory, see README"
87
+ rescue GitAlreadyInitedError => e
88
+ $stderr.puts "This directory is already a gjp project"
89
+ rescue ExecutableNotFoundError => e
90
+ $stderr.puts "Executable #{e.executable} not found in kit/ or any of its subdirectories"
91
+ end
92
+ end
93
+ end
94
+ end