gjp 0.20.0 → 0.21.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 +5 -6
- data/lib/gjp/archiver.rb +6 -2
- data/lib/gjp/cli.rb +8 -13
- data/lib/gjp/package_spec_adapter.rb +9 -5
- data/lib/gjp/project.rb +22 -15
- data/lib/gjp/spec_generator.rb +6 -7
- data/lib/gjp/version.rb +1 -1
- data/lib/template/{.gitignore → output/.gitignore} +1 -1
- data/lib/template/output/CONTENTS +3 -0
- data/spec/lib/archiver_spec.rb +2 -2
- data/spec/lib/project_spec.rb +2 -2
- data/spec/lib/spec_generator_spec.rb +6 -6
- metadata +3 -5
- data/lib/template/file_lists/CONTENTS +0 -3
- data/lib/template/specs/CONTENTS +0 -3
data/README.md
CHANGED
@@ -50,7 +50,7 @@ Note that:
|
|
50
50
|
* a `gjp` project can be used to build a number of packages that share one binary kit. This can help if the kit becomes big in size;
|
51
51
|
* `gjp` will take advantage of Maven's pom files to generate its specs if they are available. This allows to precompile most spec fields automatically.
|
52
52
|
|
53
|
-
### Sample project (commons-
|
53
|
+
### Sample project (commons-collections)
|
54
54
|
|
55
55
|
#### Initialization and project setup
|
56
56
|
|
@@ -91,7 +91,7 @@ Success! Now we have to tell gjp to return in normal mode:
|
|
91
91
|
|
92
92
|
gjp finish
|
93
93
|
|
94
|
-
At this point `gjp` restored `src/` as it was before the build and listed outputs in `
|
94
|
+
At this point `gjp` restored `src/` as it was before the build and listed outputs in `output/commons-collections/produced_file_list`. It will be used later to compile the `%install` and `%files` sections of the project spec.
|
95
95
|
|
96
96
|
Note that, if the build was unsusccesful, the following command can be used to cancel it and return to pre-dry running state:
|
97
97
|
|
@@ -112,22 +112,21 @@ Of course this script can also be manually modified, and it must be in more diff
|
|
112
112
|
The following command will generate the kit spec:
|
113
113
|
|
114
114
|
gjp generate-kit-spec
|
115
|
-
less
|
115
|
+
less output/galaxy-kit/galaxy-kit.spec
|
116
116
|
|
117
117
|
Nothing fancy here, the spec simply copies `kit/` contents in a special directory to be available for later compilation of packages.
|
118
118
|
You can also edit the spec file manually if you want. When you later regenerate it, `gjp` will automatically try to reconcile changes with a [three-way merge](http://en.wikipedia.org/wiki/Three-way_merge#Three-way_merge).
|
119
119
|
|
120
|
-
You can also generate the corresponding .tar.xz file with:
|
120
|
+
You can also generate the corresponding .tar.xz file in `output/galaxy-kit/` with:
|
121
121
|
|
122
122
|
gjp generate-kit-archive
|
123
123
|
|
124
|
-
The contents of this file were tracked by `gjp` during gathering and dry-run phases, and are listed in `file_lists/kit`. You can also edit it if you want.
|
125
124
|
|
126
125
|
You can then generate the project spec and archive files provided you have a pom file (more formats will be supported in future). In this case:
|
127
126
|
|
128
127
|
gjp generate-package-spec commons-collections src/commons-collections/commons-collections-3.2.1-src/pom.xml
|
129
128
|
gjp generate-package-archive commons-collections
|
130
|
-
less
|
129
|
+
less output/commons-collections/commons-collections.spec
|
131
130
|
|
132
131
|
commons-collection BuldRequires galaxy-kit, its archive contains only source files and it will install any produced .jar file in `/usr/lib/java`.
|
133
132
|
|
data/lib/gjp/archiver.rb
CHANGED
@@ -11,7 +11,9 @@ module Gjp
|
|
11
11
|
|
12
12
|
# generates an archive for the kit package
|
13
13
|
def archive_kit
|
14
|
-
|
14
|
+
destination_dir = File.join(@project.full_path, "output", "#{@project.name}-kit")
|
15
|
+
FileUtils.mkdir_p(destination_dir)
|
16
|
+
destination_file = File.join(destination_dir, "#{@project.name}-kit.tar.xz")
|
15
17
|
|
16
18
|
archive("kit", destination_file)
|
17
19
|
|
@@ -20,7 +22,9 @@ module Gjp
|
|
20
22
|
|
21
23
|
# generates an archive for a project's package based on its file list
|
22
24
|
def archive_package(name)
|
23
|
-
|
25
|
+
destination_dir = File.join(@project.full_path, "output", name)
|
26
|
+
FileUtils.mkdir_p(destination_dir)
|
27
|
+
destination_file = File.join(destination_dir, "#{name}.tar.xz")
|
24
28
|
|
25
29
|
archive(File.join("src", name), destination_file)
|
26
30
|
|
data/lib/gjp/cli.rb
CHANGED
@@ -93,7 +93,7 @@ module Gjp
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
subcommand "generate-build-script", "
|
96
|
+
subcommand "generate-build-script", "Create or refresh a build.sh file" do
|
97
97
|
parameter "NAME", "name of a package, that is, an src/ subdirectory name"
|
98
98
|
def execute
|
99
99
|
checking_exceptions do
|
@@ -108,7 +108,7 @@ module Gjp
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
subcommand "generate-kit-spec", "
|
111
|
+
subcommand "generate-kit-spec", "Create or refresh a spec file for the kit" do
|
112
112
|
def execute
|
113
113
|
checking_exceptions do
|
114
114
|
project = Gjp::Project.new(".")
|
@@ -121,7 +121,7 @@ module Gjp
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
subcommand "generate-kit-archive", "
|
124
|
+
subcommand "generate-kit-archive", "Create or refresh the kit tarball" do
|
125
125
|
def execute
|
126
126
|
checking_exceptions do
|
127
127
|
project = Gjp::Project.new(".")
|
@@ -131,7 +131,7 @@ module Gjp
|
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
subcommand "generate-package-spec", "
|
134
|
+
subcommand "generate-package-spec", "Create or refresh a spec file for a package" do
|
135
135
|
option ["-f", "--filter"], "FILTER", "filter files to be installed by this spec", :default => "*.jar"
|
136
136
|
parameter "NAME", "name of a package, that is, an src/ subdirectory name"
|
137
137
|
parameter "POM", "a pom file path or URI"
|
@@ -139,20 +139,15 @@ module Gjp
|
|
139
139
|
checking_exceptions do
|
140
140
|
project = Gjp::Project.new(".")
|
141
141
|
result_path, conflict_count = Gjp::SpecGenerator.new(project).generate_package_spec name, pom, filter
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
puts "Warning: #{conflict_count} unresolved conflicts"
|
146
|
-
end
|
147
|
-
else
|
148
|
-
$stderr.puts "file_list/#{name}_output not found. Ensure you have already run a" +
|
149
|
-
"\"gjp dry run\" and \"gjp finish\"."
|
142
|
+
puts "#{result_path} generated"
|
143
|
+
if conflict_count > 0
|
144
|
+
puts "Warning: #{conflict_count} unresolved conflicts"
|
150
145
|
end
|
151
146
|
end
|
152
147
|
end
|
153
148
|
end
|
154
149
|
|
155
|
-
subcommand "generate-package-archive", "
|
150
|
+
subcommand "generate-package-archive", "Create or refresh a package tarball" do
|
156
151
|
parameter "NAME", "name of a package, that is, an src/ subdirectory name"
|
157
152
|
def execute
|
158
153
|
checking_exceptions do
|
@@ -36,11 +36,15 @@ module Gjp
|
|
36
36
|
@runtime_dependency_ids = pom.runtime_dependency_ids
|
37
37
|
@description = cleanup_description(pom.description, 1500)
|
38
38
|
|
39
|
-
|
40
|
-
@outputs = File.
|
41
|
-
line
|
42
|
-
|
43
|
-
|
39
|
+
produced_file_list = File.join(project.full_path, "output", @name, "produced_file_list")
|
40
|
+
@outputs = if File.exist?(produced_file_list)
|
41
|
+
File.open(produced_file_list).readlines.map do |line|
|
42
|
+
line.strip
|
43
|
+
end.select do |line|
|
44
|
+
File.fnmatch? filter, File.basename(line.strip)
|
45
|
+
end
|
46
|
+
else
|
47
|
+
[]
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
data/lib/gjp/project.rb
CHANGED
@@ -38,19 +38,16 @@ module Gjp
|
|
38
38
|
Dir.chdir(dir) do
|
39
39
|
Gjp::Git.new(".").init
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
FileUtils.mkdir_p "src"
|
42
|
+
FileUtils.mkdir_p "kit"
|
43
43
|
|
44
44
|
# populate the project with templates and take a snapshot
|
45
45
|
project = Project.new(".")
|
46
46
|
|
47
47
|
template_manager = Gjp::TemplateManager.new
|
48
|
-
template_manager.copy "
|
49
|
-
template_manager.copy "file_lists", "."
|
48
|
+
template_manager.copy "output", "."
|
50
49
|
template_manager.copy "kit", "."
|
51
|
-
template_manager.copy "specs", "."
|
52
50
|
template_manager.copy "src", "."
|
53
|
-
template_manager.copy ".gitignore", ".gitignore"
|
54
51
|
|
55
52
|
project.take_snapshot "Template files added", :init
|
56
53
|
end
|
@@ -86,7 +83,7 @@ module Gjp
|
|
86
83
|
else
|
87
84
|
take_snapshot "Changes during dry-run"
|
88
85
|
|
89
|
-
|
86
|
+
update_produced_file_lists
|
90
87
|
take_snapshot "File list updates"
|
91
88
|
|
92
89
|
@git.revert_whole_directory("src", latest_tag(:dry_run_started))
|
@@ -101,19 +98,29 @@ module Gjp
|
|
101
98
|
|
102
99
|
# updates files that contain lists of the output files produced by
|
103
100
|
# the build of each package
|
104
|
-
def
|
105
|
-
each_package_directory do |
|
101
|
+
def update_produced_file_lists
|
102
|
+
each_package_directory do |name, path|
|
103
|
+
FileUtils.mkdir_p(File.join("output", name))
|
104
|
+
|
105
|
+
list_file = File.join("output", name, "produced_file_list")
|
106
|
+
tracked_files = if File.exists?(list_file)
|
107
|
+
File.readlines(list_file).map { |line| line.strip }
|
108
|
+
else
|
109
|
+
[]
|
110
|
+
end
|
111
|
+
|
106
112
|
files = (
|
107
113
|
@git.changed_files_since(latest_tag(:dry_run_started))
|
108
|
-
.select { |file| file.start_with?(
|
109
|
-
.map { |file|file[
|
114
|
+
.select { |file| file.start_with?(path) }
|
115
|
+
.map { |file|file[path.length + 1, file.length] }
|
116
|
+
.concat(tracked_files)
|
117
|
+
.uniq
|
110
118
|
.sort
|
111
119
|
)
|
112
120
|
|
113
|
-
log.debug("writing file list for #{
|
121
|
+
log.debug("writing file list for #{path}: #{files.to_s}")
|
114
122
|
|
115
|
-
|
116
|
-
File.open(list_path, "w+") do |file_list|
|
123
|
+
File.open(list_file, "w+") do |file_list|
|
117
124
|
files.each do |file|
|
118
125
|
file_list.puts file
|
119
126
|
end
|
@@ -185,7 +192,7 @@ module Gjp
|
|
185
192
|
Dir.foreach("src") do |entry|
|
186
193
|
if File.directory?(File.join(Dir.getwd, "src", entry)) and entry != "." and entry != ".."
|
187
194
|
directory = File.join("src", entry)
|
188
|
-
yield directory
|
195
|
+
yield entry, directory
|
189
196
|
end
|
190
197
|
end
|
191
198
|
end
|
data/lib/gjp/spec_generator.rb
CHANGED
@@ -10,18 +10,17 @@ module Gjp
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def generate_kit_spec
|
13
|
-
|
13
|
+
destination_dir = File.join(@project.full_path, "output", "#{@project.name}-kit")
|
14
|
+
FileUtils.mkdir_p(destination_dir)
|
15
|
+
spec_path = File.join(destination_dir, "#{@project.name}-kit.spec")
|
14
16
|
conflict_count = generate_merging("kit.spec", @project.get_binding, spec_path, :generate_kit_spec)
|
15
17
|
[spec_path, conflict_count]
|
16
18
|
end
|
17
19
|
|
18
20
|
def generate_package_spec(name, pom, filter)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
if not File.exist? list_file
|
23
|
-
return nil
|
24
|
-
end
|
21
|
+
destination_dir = File.join(@project.full_path, "output", name)
|
22
|
+
FileUtils.mkdir_p(destination_dir)
|
23
|
+
spec_path = File.join(destination_dir, "#{name}.spec")
|
25
24
|
|
26
25
|
adapter = Gjp::PackageSpecAdapter.new(@project, name, Gjp::Pom.new(pom), filter)
|
27
26
|
|
data/lib/gjp/version.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
*.gjp_user_edited
|
2
|
-
|
2
|
+
*.tar.xz
|
data/spec/lib/archiver_spec.rb
CHANGED
@@ -37,7 +37,7 @@ describe Gjp::Archiver do
|
|
37
37
|
|
38
38
|
archiver.archive_kit
|
39
39
|
@project.from_directory do
|
40
|
-
`tar -Jtf
|
40
|
+
`tar -Jtf output/test-project-kit/test-project-kit.tar.xz`.split.should include("kit_test")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -52,7 +52,7 @@ describe Gjp::Archiver do
|
|
52
52
|
|
53
53
|
archiver.archive_package "package-name"
|
54
54
|
@project.from_directory do
|
55
|
-
`tar -Jtf
|
55
|
+
`tar -Jtf output/package-name/package-name.tar.xz`.split.should include("src_test")
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
data/spec/lib/project_spec.rb
CHANGED
@@ -99,7 +99,7 @@ describe Gjp::Project do
|
|
99
99
|
@project.from_directory do
|
100
100
|
`git rev-list --all`.split("\n").length.should eq 5
|
101
101
|
File.read("src/abc/test").should eq "A\n"
|
102
|
-
File.readlines(File.join("
|
102
|
+
File.readlines(File.join("output", "abc", "produced_file_list")).should include("test2\n")
|
103
103
|
|
104
104
|
`git diff-tree --no-commit-id --name-only -r HEAD~`.split("\n").should_not include("src/abc/test2")
|
105
105
|
File.exists?("src/abc/test2").should be_false
|
@@ -135,7 +135,7 @@ describe Gjp::Project do
|
|
135
135
|
File.read("kit/test").should eq "A\n"
|
136
136
|
File.exists?("kit/test2").should be_false
|
137
137
|
|
138
|
-
File.exists?(File.join("
|
138
|
+
File.exists?(File.join("output", "abc", "produced_file_list")).should be_false
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
@@ -29,7 +29,7 @@ describe Gjp::SpecGenerator do
|
|
29
29
|
@spec_generator.generate_kit_spec.should be_true
|
30
30
|
|
31
31
|
@project.from_directory do
|
32
|
-
spec_lines = File.readlines(File.join("
|
32
|
+
spec_lines = File.readlines(File.join("output", "test-project-kit", "test-project-kit.spec"))
|
33
33
|
spec_lines.should include("Name: test-project-kit\n")
|
34
34
|
spec_lines.should include("Version: 1\n")
|
35
35
|
spec_lines.should include("Source0: %{name}.tar.xz\n")
|
@@ -42,7 +42,7 @@ describe Gjp::SpecGenerator do
|
|
42
42
|
test_file = File.join("kit", "test")
|
43
43
|
File.open(test_file, "w") { |io| io.puts "changed kit content test file" }
|
44
44
|
|
45
|
-
File.open(File.join("
|
45
|
+
File.open(File.join("output", "test-project-kit", "test-project-kit.spec"), "a") do |io|
|
46
46
|
io.write("nonconflicting line")
|
47
47
|
end
|
48
48
|
end
|
@@ -51,7 +51,7 @@ describe Gjp::SpecGenerator do
|
|
51
51
|
@spec_generator.generate_kit_spec.should be_true
|
52
52
|
|
53
53
|
@project.from_directory do
|
54
|
-
spec_lines = File.readlines(File.join("
|
54
|
+
spec_lines = File.readlines(File.join("output", "test-project-kit", "test-project-kit.spec"))
|
55
55
|
spec_lines.should include("Name: test-project-kit\n")
|
56
56
|
spec_lines.should include("Version: 2\n")
|
57
57
|
spec_lines.should include("Source0: %{name}.tar.xz\n")
|
@@ -65,7 +65,7 @@ describe Gjp::SpecGenerator do
|
|
65
65
|
test_file = File.join("kit", "test")
|
66
66
|
File.open(test_file, "w") { |io| io.puts "changed kit content test file" }
|
67
67
|
|
68
|
-
spec_path = File.join("
|
68
|
+
spec_path = File.join("output", "test-project-kit", "test-project-kit.spec")
|
69
69
|
spec_contents = File.read spec_path
|
70
70
|
|
71
71
|
spec_contents.gsub! /^Version:.*$/, "CONFLICTING!"
|
@@ -79,7 +79,7 @@ describe Gjp::SpecGenerator do
|
|
79
79
|
@spec_generator.generate_kit_spec.should be_true
|
80
80
|
|
81
81
|
@project.from_directory do
|
82
|
-
spec_lines = File.readlines(File.join("
|
82
|
+
spec_lines = File.readlines(File.join("output", "test-project-kit", "test-project-kit.spec"))
|
83
83
|
spec_lines.should include("Name: test-project-kit\n")
|
84
84
|
spec_lines.should include("Source0: %{name}.tar.xz\n")
|
85
85
|
spec_lines.should include("<<<<<<< newly generated\n")
|
@@ -115,7 +115,7 @@ describe Gjp::SpecGenerator do
|
|
115
115
|
@spec_generator.generate_package_spec "test", File.join("spec", "data", "nailgun", "pom.xml"), "*.jar"
|
116
116
|
|
117
117
|
@project.from_directory do
|
118
|
-
spec_lines = File.readlines(File.join("
|
118
|
+
spec_lines = File.readlines(File.join("output", "test", "test.spec"))
|
119
119
|
spec_lines.should include("Name: test\n")
|
120
120
|
spec_lines.should include("License: The Apache Software License, Version 2.0\n")
|
121
121
|
spec_lines.should include("Summary: Nailgun is a client, protocol, and server for running Java\n")
|
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.21.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -176,14 +176,12 @@ files:
|
|
176
176
|
- lib/gjp/template_manager.rb
|
177
177
|
- lib/gjp/version.rb
|
178
178
|
- lib/gjp/version_matcher.rb
|
179
|
-
- lib/template/.gitignore
|
180
|
-
- lib/template/archives/CONTENTS
|
181
|
-
- lib/template/file_lists/CONTENTS
|
182
179
|
- lib/template/kit.spec
|
183
180
|
- lib/template/kit/CONTENTS
|
184
181
|
- lib/template/kit/m2/settings.xml
|
182
|
+
- lib/template/output/.gitignore
|
183
|
+
- lib/template/output/CONTENTS
|
185
184
|
- lib/template/package.spec
|
186
|
-
- lib/template/specs/CONTENTS
|
187
185
|
- lib/template/src/CONTENTS
|
188
186
|
- spec/data/ant-super-simple-code/build.xml
|
189
187
|
- spec/data/ant-super-simple-code/build/HW.class
|
data/lib/template/specs/CONTENTS
DELETED