gjp 0.26.0 → 0.27.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/README.md CHANGED
@@ -113,7 +113,7 @@ The following command will generate the kit archive in `output/galaxy-kit/`:
113
113
 
114
114
  gjp generate-kit-archive
115
115
 
116
- Note that, in later runs, you can also use the `--incremental` option to create an additional "diff" tar.xz file instead of rebuilding it from scratch.
116
+ Note that, in later runs, only an additional "diff" tar.xz file will be created to ease uploads. You can use the `--full` option to regenerate a single complete archive.
117
117
 
118
118
  The following command will generate the kit spec:
119
119
 
@@ -40,7 +40,7 @@ cd commons-fileupload-1.3-src/
40
40
  gjp mvn package -DskipTests
41
41
  gjp finish
42
42
 
43
- gjp generate-kit-archive -i
43
+ gjp generate-kit-archive
44
44
  gjp generate-kit-spec
45
45
  gjp generate-package-script
46
46
  gjp generate-package-archive
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(incremental)
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
16
  destination_file_prefix = "#{@project.name}-kit"
@@ -18,12 +18,12 @@ module Gjp
18
18
 
19
19
  @project.take_snapshot "Kit archival started"
20
20
 
21
- destination_file = if incremental
22
- log.debug "doing incremental archive"
23
- archive_incremental("kit", destination_dir, destination_file_prefix, destination_file_suffix, :archive_kit)
24
- else
21
+ destination_file = if full
25
22
  remove_stale_incremental(destination_dir, destination_file_prefix, destination_file_suffix)
26
23
  archive_single("kit", File.join(destination_dir, destination_file_prefix + destination_file_suffix))
24
+ else
25
+ log.debug "doing incremental archive"
26
+ archive_incremental("kit", destination_dir, destination_file_prefix, destination_file_suffix, :archive_kit)
27
27
  end
28
28
 
29
29
  @project.take_snapshot "Kit archive generated", :archive_kit
data/lib/gjp/cli.rb CHANGED
@@ -71,7 +71,9 @@ module Gjp
71
71
  def execute
72
72
  checking_exceptions do
73
73
  project = Gjp::Project.new(".")
74
- Gjp::KitRunner.new(project).mvn(@options)
74
+ ensure_dry_running(true, project) do
75
+ Gjp::KitRunner.new(project).mvn(@options)
76
+ end
75
77
  end
76
78
  end
77
79
  end
@@ -87,7 +89,9 @@ module Gjp
87
89
  def execute
88
90
  checking_exceptions do
89
91
  project = Gjp::Project.new(".")
90
- Gjp::KitRunner.new(project).ant(@options)
92
+ ensure_dry_running(true, project) do
93
+ Gjp::KitRunner.new(project).ant(@options)
94
+ end
91
95
  end
92
96
  end
93
97
  end
@@ -109,23 +113,27 @@ module Gjp
109
113
  end
110
114
  end
111
115
 
112
- subcommand "generate-kit-spec", "Create or refresh a spec file for the kit" do
116
+ subcommand "generate-kit-archive", "Create or refresh the kit tarball" do
117
+ option ["-f", "--full"], :flag, "create a full archive (not incremental)"
113
118
  def execute
114
119
  checking_exceptions do
115
120
  project = Gjp::Project.new(".")
116
- result_path, conflict_count = Gjp::SpecGenerator.new(project).generate_kit_spec
117
- print_generation_result(project, result_path, conflict_count)
121
+ ensure_dry_running(false, project) do
122
+ result_path = Gjp::Archiver.new(project).archive_kit(full?)
123
+ print_generation_result(project, result_path)
124
+ end
118
125
  end
119
126
  end
120
127
  end
121
128
 
122
- subcommand "generate-kit-archive", "Create or refresh the kit tarball" do
123
- option ["-i", "--incremental"], :flag, "create an archive with only the difference from the previous one"
129
+ subcommand "generate-kit-spec", "Create or refresh a spec file for the kit" do
124
130
  def execute
125
131
  checking_exceptions do
126
132
  project = Gjp::Project.new(".")
127
- result_path = Gjp::Archiver.new(project).archive_kit(incremental?)
128
- print_generation_result(project, result_path)
133
+ ensure_dry_running(false, project) do
134
+ result_path, conflict_count = Gjp::SpecGenerator.new(project).generate_kit_spec
135
+ print_generation_result(project, result_path, conflict_count)
136
+ end
129
137
  end
130
138
  end
131
139
  end
@@ -135,73 +143,85 @@ module Gjp
135
143
  def execute
136
144
  checking_exceptions do
137
145
  project = Gjp::Project.new(".")
138
- package_name = project.get_package_name(directory)
139
- history_file = File.join(Dir.home, ".bash_history")
140
- result_path, conflict_count = Gjp::ScriptGenerator.new(project, history_file).generate_build_script(package_name)
141
- print_generation_result(project, result_path, conflict_count)
146
+ ensure_dry_running(false, project) do
147
+ package_name = project.get_package_name(directory)
148
+ history_file = File.join(Dir.home, ".bash_history")
149
+ result_path, conflict_count = Gjp::ScriptGenerator.new(project, history_file).generate_build_script(package_name)
150
+ print_generation_result(project, result_path, conflict_count)
151
+ end
142
152
  end
143
153
  end
144
154
  end
145
155
 
146
- subcommand "generate-package-spec", "Create or refresh a spec file for a package" do
147
- option ["-f", "--filter"], "FILTER", "filter files to be installed by this spec", :default => "*.jar"
156
+ subcommand "generate-package-archive", "Create or refresh a package tarball" do
148
157
  parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", :default => "."
149
- parameter "[POM]", "a pom file path", :default => "pom.xml"
150
158
  def execute
151
159
  checking_exceptions do
152
160
  project = Gjp::Project.new(".")
153
- package_name = project.get_package_name(directory)
154
- result_path, conflict_count = Gjp::SpecGenerator.new(project).generate_package_spec package_name, pom, filter
155
- print_generation_result(project, result_path, conflict_count)
161
+ ensure_dry_running(false, project) do
162
+ package_name = project.get_package_name(directory)
163
+ result_path = Gjp::Archiver.new(project).archive_package package_name
164
+ print_generation_result(project, result_path)
165
+ end
156
166
  end
157
167
  end
158
168
  end
159
169
 
160
- subcommand "generate-package-archive", "Create or refresh a package tarball" do
170
+ subcommand "generate-package-spec", "Create or refresh a spec file for a package" do
171
+ option ["-f", "--filter"], "FILTER", "filter files to be installed by this spec", :default => "*.jar"
161
172
  parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", :default => "."
173
+ parameter "[POM]", "a pom file path", :default => "pom.xml"
162
174
  def execute
163
175
  checking_exceptions do
164
176
  project = Gjp::Project.new(".")
165
- package_name = project.get_package_name(directory)
166
- result_path = Gjp::Archiver.new(project).archive_package package_name
167
- print_generation_result(project, result_path)
177
+ ensure_dry_running(false, project) do
178
+ package_name = project.get_package_name(directory)
179
+ result_path, conflict_count = Gjp::SpecGenerator.new(project).generate_package_spec package_name, pom, filter
180
+ print_generation_result(project, result_path, conflict_count)
181
+ end
168
182
  end
169
183
  end
170
184
  end
171
185
 
172
186
  subcommand "generate-all", "Create or refresh specs, archives, scripts for a package and the kit" do
173
187
  option ["-f", "--filter"], "FILTER", "filter files to be installed by this package spec", :default => "*.jar"
174
- option ["-i", "--incremental"], :flag, "create a kit archive with only the difference from the previous one", :default => true
188
+ option ["-f", "--full"], :flag, "create a full archive (not incremental)"
175
189
  parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", :default => "."
176
190
  parameter "[POM]", "a package pom file path", :default => "pom.xml"
177
191
  def execute
178
192
  checking_exceptions do
179
193
  project = Gjp::Project.new(".")
180
- package_name = project.get_package_name(directory)
194
+ ensure_dry_running(false, project) do
195
+ package_name = project.get_package_name(directory)
181
196
 
182
- result_path = Gjp::Archiver.new(project).archive_kit(incremental?)
183
- print_generation_result(project, result_path)
197
+ result_path = Gjp::Archiver.new(project).archive_kit(full?)
198
+ print_generation_result(project, result_path)
184
199
 
185
- result_path, conflict_count = Gjp::SpecGenerator.new(project).generate_kit_spec
186
- print_generation_result(project, result_path, conflict_count)
200
+ result_path, conflict_count = Gjp::SpecGenerator.new(project).generate_kit_spec
201
+ print_generation_result(project, result_path, conflict_count)
187
202
 
188
- history_file = File.join(Dir.home, ".bash_history")
189
- result_path, conflict_count = Gjp::ScriptGenerator.new(project, history_file).generate_build_script(package_name)
190
- print_generation_result(project, result_path, conflict_count)
203
+ history_file = File.join(Dir.home, ".bash_history")
204
+ result_path, conflict_count = Gjp::ScriptGenerator.new(project, history_file).generate_build_script(package_name)
205
+ print_generation_result(project, result_path, conflict_count)
191
206
 
192
- result_path = Gjp::Archiver.new(project).archive_package package_name
193
- print_generation_result(project, result_path)
207
+ result_path = Gjp::Archiver.new(project).archive_package package_name
208
+ print_generation_result(project, result_path)
194
209
 
195
- result_path, conflict_count = Gjp::SpecGenerator.new(project).generate_package_spec package_name, pom, filter
196
- print_generation_result(project, result_path, conflict_count)
210
+ result_path, conflict_count = Gjp::SpecGenerator.new(project).generate_package_spec package_name, pom, filter
211
+ print_generation_result(project, result_path, conflict_count)
212
+ end
197
213
  end
198
214
  end
199
215
  end
200
216
 
201
217
  subcommand "purge-jars", "Locates jars in src/ and moves them to kit/" do
202
218
  def execute
203
- Gjp::Project.new(".").purge_jars.each do |original, final|
204
- puts "Replaced #{original} with symlink pointing to to #{final}"
219
+ project = Gjp::Project.new(".")
220
+
221
+ ensure_dry_running(false, project) do
222
+ project.purge_jars.each do |original, final|
223
+ puts "Replaced #{original} with symlink pointing to to #{final}"
224
+ end
205
225
  end
206
226
  end
207
227
  end
@@ -276,6 +296,18 @@ module Gjp
276
296
 
277
297
  private
278
298
 
299
+ def ensure_dry_running(state, project)
300
+ if project.is_dry_running == state
301
+ yield
302
+ else
303
+ if state == true
304
+ puts "Please start a dry-run first, use \"gjp dry-run\""
305
+ else
306
+ puts "Please finish or abort this dry-run first, use \"gjp finish\" or \"gjp finish --abort\""
307
+ end
308
+ end
309
+ end
310
+
279
311
  # outputs output of a file generation
280
312
  def print_generation_result(project, result_path, conflict_count = 0)
281
313
  puts "#{format_path(result_path, project)} generated"
@@ -306,7 +338,7 @@ module Gjp
306
338
  $stderr.puts e
307
339
  rescue NoProjectDirectoryError => e
308
340
  $stderr.puts "#{e.directory} not a gjp project directory, see gjp init"
309
- rescue NoPackageDirectoryException => e
341
+ rescue NoPackageDirectoryError => e
310
342
  $stderr.puts "#{e.directory} is not a gjp package directory, see README"
311
343
  rescue GitAlreadyInitedError => e
312
344
  $stderr.puts "This directory is already a gjp project"
@@ -30,6 +30,8 @@ module Gjp
30
30
  relevant_lines.map do |line|
31
31
  if line =~ /gjp +mvn/
32
32
  line.gsub(/gjp +mvn/, "#{@kit_runner.get_maven_commandline("$PROJECT_PREFIX")}")
33
+ elsif line =~ /gjp +ant/
34
+ line.gsub(/gjp +ant/, "#{@kit_runner.get_ant_commandline("$PROJECT_PREFIX")}")
33
35
  else
34
36
  line
35
37
  end
@@ -37,8 +39,15 @@ module Gjp
37
39
 
38
40
  new_content = script_lines.join("\n") + "\n"
39
41
 
40
- result_path = File.join("src", name, "build.sh")
42
+ script_name = "build.sh"
43
+ result_path = File.join("src", name, script_name)
41
44
  conflict_count = @project.merge_new_content(new_content, result_path, "Build script generated", "generate_#{name}_build_script")
45
+
46
+ destination_dir = File.join("output", name)
47
+ FileUtils.mkdir_p(destination_dir)
48
+ destination_script_path = File.join(destination_dir, script_name)
49
+ FileUtils.symlink(File.expand_path(result_path), destination_script_path, :force => true)
50
+
42
51
  [result_path, conflict_count]
43
52
  end
44
53
  end
data/lib/gjp/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Gjp
4
- VERSION = "0.26.0"
4
+ VERSION = "0.27.0"
5
5
  end
@@ -23,6 +23,7 @@ Summary: <%= summary %>
23
23
  Url: <%= url %>
24
24
  Group: Development/Libraries/Java
25
25
  Source0: %{name}.tar.xz
26
+ Source1: build.sh
26
27
  BuildRoot: %{_tmppath}/%{name}-%{version}-build
27
28
  BuildRequires: xz
28
29
  BuildRequires: java-devel
@@ -41,6 +42,7 @@ Requires: mvn(<%= dependency_id[0] %>:<%= dependency_id[1] %>) <% if depen
41
42
 
42
43
  %prep
43
44
  %setup -q -c -n src/<%= name %>
45
+ cp -f %{SOURCE1} .
44
46
  ln -sf %{_datadir}/gjp/<%= project_name %>-kit ../../kit
45
47
 
46
48
  %build
@@ -60,7 +60,7 @@ describe Gjp::Archiver do
60
60
  end
61
61
  @project.finish(false)
62
62
 
63
- archiver.archive_kit(false)
63
+ archiver.archive_kit(true)
64
64
  @project.from_directory do
65
65
  `tar -Jtf output/test-project-kit/test-project-kit.tar.xz`.split.should include("kit_test")
66
66
  end
@@ -71,7 +71,7 @@ describe Gjp::Archiver do
71
71
  end
72
72
  @project.finish(false)
73
73
 
74
- archiver.archive_kit(true)
74
+ archiver.archive_kit(false)
75
75
  @project.from_directory do
76
76
  `tar -Jtf output/test-project-kit/test-project-kit.tar.xz`.split.should include("kit_test")
77
77
  end
@@ -80,7 +80,7 @@ describe Gjp::Archiver do
80
80
  File.open(File.join("kit","kit_test2"), "w") { |io| io.puts "test content" }
81
81
  end
82
82
 
83
- archiver.archive_kit(true)
83
+ archiver.archive_kit(false)
84
84
  @project.from_directory do
85
85
  files = `tar -Jtf output/test-project-kit/test-project-kit_0001.tar.xz`.split
86
86
  files.should include("kit_test2")
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.26.0
4
+ version: 0.27.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: