gjp 0.17.1 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +21 -30
- data/integration-tests/commons-io.sh +3 -4
- data/lib/gjp/archiver.rb +8 -18
- data/lib/gjp/cli.rb +15 -48
- data/lib/gjp/project.rb +35 -68
- data/lib/gjp/version.rb +1 -1
- data/lib/template/archives/CONTENTS +1 -1
- data/lib/template/file_lists/CONTENTS +2 -2
- data/spec/lib/archiver_spec.rb +5 -6
- data/spec/lib/maven_runner_spec.rb +0 -3
- data/spec/lib/project_spec.rb +9 -55
- data/spec/lib/scaffolder_spec.rb +4 -3
- metadata +2 -2
data/README.md
CHANGED
@@ -36,11 +36,11 @@ Building a package with `gjp` is quite unusual — this is a [deliberate choice]
|
|
36
36
|
The basic process is:
|
37
37
|
|
38
38
|
* a `gjp` project is created;
|
39
|
-
* sources are added
|
40
|
-
* any other file that is needed for the build, except the JDK, is added in binary form (jars, the Maven executable,
|
41
|
-
* a build is attempted
|
42
|
-
* `gjp` produces spec files for two packages: one for the project itself and one for
|
43
|
-
* kit and project packages can be submitted to [OBS](http://en.opensuse.org/openSUSE:Build_Service). Project package will rebuild cleanly because it needs no Internet access - all files were already downloaded during the dry-run above and are included in the kit.
|
39
|
+
* package sources are added in `src/<package name>`;
|
40
|
+
* any other file that is needed for the build, except the JDK, is added in binary form (jars, the Maven executable, plugins, etc.) in `kit/`. In `gjp` a **kit** is a set of binary files that satisfies all build dependencies in a `gjp` project;
|
41
|
+
* a build is attempted and during the build, `gjp` keeps track of file changes. When it finishes, `gjp` restores `src/` in its original state, making it a "repeatable dry-run build". `gjp` will retain any files that were automatically downloaded by Maven or other similar tools in `kit/`, along with other binary build dependencies, and create a list of files produced by the build for later spec generation;
|
42
|
+
* `gjp` produces spec files for two packages: one for the project itself and one for the kit needed to build it;
|
43
|
+
* kit and project packages can be submitted to [OBS](http://en.opensuse.org/openSUSE:Build_Service). Project package will rebuild cleanly because it needs no Internet access - all files were already downloaded during the dry-run phase above and are included in the kit.
|
44
44
|
|
45
45
|
Note that:
|
46
46
|
|
@@ -50,15 +50,9 @@ 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
|
-
In `gjp`, the build process can be in one of the following phases at any given moment:
|
54
|
-
|
55
|
-
* **gathering**: in this phase you add sources and kit files. New projects start in this phase, you can always enter it later with `gjp gather`;
|
56
|
-
* **dry-running**: in this phase you attempt a build. Any change in the sources will be reverted after it ends, while files added to the kit will be retained. You can enter this phase with `gjp dry-run`;
|
57
|
-
* **finishing**: in this phase `gjp` generates specs and archive files. You can enter it running `gjp finish`;
|
58
|
-
|
59
53
|
### Sample project (commons-io)
|
60
54
|
|
61
|
-
#### Initialization and
|
55
|
+
#### Initialization and project setup
|
62
56
|
|
63
57
|
Ceate a new `gjp` project, in this example named "galaxy":
|
64
58
|
|
@@ -66,7 +60,7 @@ Ceate a new `gjp` project, in this example named "galaxy":
|
|
66
60
|
cd galaxy
|
67
61
|
gjp init
|
68
62
|
|
69
|
-
`gjp init`
|
63
|
+
`gjp init` generates a folder structure and assumes you respect it, in particular, you should place all your projects' source files in `src/`. Every `src/` subfolder will become a separate package named after the folder itself, so use the following commands to create a `commons-collections` folders and populate it:
|
70
64
|
|
71
65
|
cd src
|
72
66
|
mkdir commons-collections
|
@@ -85,18 +79,23 @@ Now let's move to the kit (which, unsurprisingly, should be placed in the `kit/`
|
|
85
79
|
|
86
80
|
This is actually everything needed to do a first dry-run build.
|
87
81
|
|
88
|
-
#### First dry-run
|
82
|
+
#### First dry-run build
|
89
83
|
|
90
84
|
Let's call `gjp dry-run` to let `gjp` know we are building and then call Maven. Note that `gjp mvn` is used instead of plain `mvn`: `gjp` will take care of locating the Maven installation in `kit/` and ensure it will store all downloaded files there.
|
91
85
|
|
92
86
|
gjp dry-run
|
93
87
|
cd src/commons-collections/commons-collections-3.2.1-src/
|
94
88
|
gjp mvn package
|
89
|
+
|
90
|
+
Success! Now we have to tell gjp to return in normal mode:
|
91
|
+
|
95
92
|
gjp finish
|
96
93
|
|
97
|
-
|
94
|
+
At this point `gjp` restored `src/` as it was before the build and listed outputs in `file_lists/commons-collections_output`. Those will be used later to compile the `%install` and `%files` sections of the project spec.
|
95
|
+
|
96
|
+
This should be sufficient to be able to repeat the build on a machine with no Internet access, but what if we wanted to be 100% sure of that?
|
98
97
|
|
99
|
-
#### Second, networkless, dry-run
|
98
|
+
#### Second, networkless, dry-run build
|
100
99
|
|
101
100
|
`gjp` has a subcommand to setup a `nonet` user without Internet access, courtesy of `iptables`. You can simply retry the build using that user to see if it works. Note that the following commands will alter group permissions to allow both your current user and `nonet` to work on the same files.
|
102
101
|
|
@@ -108,17 +107,18 @@ Success! At this point `gjp` took note of all needed files, and restored `src/`
|
|
108
107
|
gjp mvn package
|
109
108
|
chmod -R g+rw .
|
110
109
|
exit
|
110
|
+
gjp finish
|
111
111
|
|
112
112
|
The above is obviously not mandatory, but it can be useful for debugging purposes.
|
113
113
|
|
114
|
-
####
|
114
|
+
#### Adding a build.sh file
|
115
115
|
|
116
116
|
One last thing before generating packages is to setup a build script. By default `gjp` will generate a spec file which assumes a `build.sh` script in the source folder of your project that contains all commands needed to build the package itself. At the moment, this needs to be done manually, but it will hopefully be automated in a future release.
|
117
117
|
|
118
|
-
Let's
|
118
|
+
Let's just create it:
|
119
119
|
|
120
|
-
|
121
|
-
vi
|
120
|
+
cd ../../..
|
121
|
+
vi src/commons-collections/build.sh
|
122
122
|
|
123
123
|
Add the following lines:
|
124
124
|
|
@@ -127,10 +127,6 @@ Add the following lines:
|
|
127
127
|
../../../kit/apache-maven-3.1.0/bin/mvn -Dmaven.repo.local=`readlink -e ../../../kit/m2` -s`readlink -e ../../../kit/m2/settings.xml` package
|
128
128
|
|
129
129
|
Note that `build.sh` gets called from the `gjp` project root, hence the `cd` line, and the Maven line was taken directly from `gjp mvn` output above and pasted verbatim.
|
130
|
-
Now complete the gathering:
|
131
|
-
|
132
|
-
gjp finish
|
133
|
-
cd ../../..
|
134
130
|
|
135
131
|
#### Generating archives and spec files
|
136
132
|
|
@@ -154,10 +150,7 @@ You can then generate the project spec and archive files provided you have a pom
|
|
154
150
|
gjp generate-package-archive commons-collections
|
155
151
|
less specs/commons-collections.spec
|
156
152
|
|
157
|
-
commons-collection BuldRequires galaxy-kit, its archive contains only source files and it will install any produced .jar file in `/usr/lib/java`.
|
158
|
-
|
159
|
-
less file_lists/commons-collections_input
|
160
|
-
less file_lists/commons-collections_output
|
153
|
+
commons-collection BuldRequires galaxy-kit, its archive contains only source files and it will install any produced .jar file in `/usr/lib/java`.
|
161
154
|
|
162
155
|
Packages are ready to be submitted to an OBS project. As OBS integration is not yet implemented, refer to OBS documentation to do that.
|
163
156
|
|
@@ -184,8 +177,6 @@ You are advised to use [Maven Central](http://search.maven.org/) to search for s
|
|
184
177
|
|
185
178
|
### Troubleshooting
|
186
179
|
|
187
|
-
To know in which phase you are in, use `gjp status`.
|
188
|
-
|
189
180
|
`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 freely as long as the `gjp` tags are preserved. You can also delete commits and tags, effectively rewiding gjp history (just make sure to delete all tags pointing to a certain commit when you discard it).
|
190
181
|
|
191
182
|
## Motivation
|
@@ -22,15 +22,14 @@ cd ..
|
|
22
22
|
gjp dry-run
|
23
23
|
cd src/commons-collections/commons-collections-3.2.1-src/
|
24
24
|
gjp mvn package
|
25
|
+
gjp finish
|
25
26
|
|
26
|
-
|
27
|
-
cat
|
27
|
+
cd ../../..
|
28
|
+
cat >src/commons-collections/build.sh << "EOF"
|
28
29
|
#!/bin/sh
|
29
30
|
cd src/commons-collections/commons-collections-3.2.1-src/
|
30
31
|
../../../kit/apache-maven-3.1.0/bin/mvn -Dmaven.repo.local=`readlink -e ../../../kit/m2` -s`readlink -e ../../../kit/m2/settings.xml` package
|
31
32
|
EOF
|
32
|
-
gjp finish
|
33
|
-
cd ../../..
|
34
33
|
|
35
34
|
gjp generate-kit-spec
|
36
35
|
gjp generate-kit-archive
|
data/lib/gjp/archiver.rb
CHANGED
@@ -9,39 +9,29 @@ module Gjp
|
|
9
9
|
@project = project
|
10
10
|
end
|
11
11
|
|
12
|
-
# generates an archive for the
|
12
|
+
# generates an archive for the kit package
|
13
13
|
def archive_kit
|
14
|
-
list_file = File.join(@project.full_path, "file_lists/kit")
|
15
|
-
if not File.exist? list_file
|
16
|
-
return nil
|
17
|
-
end
|
18
14
|
destination_file = File.join(@project.full_path, "archives/#{@project.name}-kit.tar.xz")
|
19
15
|
|
20
|
-
|
21
|
-
archive list_file, destination_file
|
22
|
-
end
|
16
|
+
archive("kit", destination_file)
|
23
17
|
|
24
18
|
Pathname.new(destination_file).relative_path_from Pathname.new(@project.full_path)
|
25
19
|
end
|
26
20
|
|
27
21
|
# generates an archive for a project's package based on its file list
|
28
22
|
def archive_package(name)
|
29
|
-
list_file = File.join(@project.full_path, "file_lists/#{name}_input")
|
30
|
-
if not File.exist? list_file
|
31
|
-
return nil
|
32
|
-
end
|
33
23
|
destination_file = File.join(@project.full_path, "archives/#{name}.tar.xz")
|
34
24
|
|
35
|
-
|
36
|
-
archive list_file, destination_file
|
37
|
-
end
|
25
|
+
archive(File.join("src", name), destination_file)
|
38
26
|
|
39
27
|
Pathname.new(destination_file).relative_path_from Pathname.new(@project.full_path)
|
40
28
|
end
|
41
29
|
|
42
|
-
#
|
43
|
-
def archive(
|
44
|
-
|
30
|
+
# archives a folder's contents to the destination file
|
31
|
+
def archive(folder, destination_file)
|
32
|
+
@project.from_directory folder do
|
33
|
+
`tar -cJf #{destination_file} *`
|
34
|
+
end
|
45
35
|
end
|
46
36
|
end
|
47
37
|
end
|
data/lib/gjp/cli.rb
CHANGED
@@ -39,36 +39,22 @@ module Gjp
|
|
39
39
|
subcommand "init", "Inits a gjp project in the current directory" do
|
40
40
|
def execute
|
41
41
|
Gjp::Project.init(".")
|
42
|
-
puts "Project inited
|
43
|
-
|
42
|
+
puts "Project inited."
|
43
|
+
puts "Any file added to kit/ will be added to the kit package."
|
44
|
+
puts "Any file added to src/<name> will be added to the corresponding package."
|
45
|
+
puts "When you are ready to test a build, use \"gjp dry-run\"."
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
47
|
-
subcommand "
|
48
|
-
def execute
|
49
|
-
if Gjp::Project.new(".").gather
|
50
|
-
puts "Now gathering."
|
51
|
-
explain_gathering
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def explain_gathering
|
57
|
-
puts "Any file added to kit/ will be added to the kit package."
|
58
|
-
puts "Any file added to src/<name> will be added to the corresponding package."
|
59
|
-
puts "When you are ready to test a build, use \"gjp dry-run\"."
|
60
|
-
end
|
61
|
-
|
62
|
-
subcommand "dry-run", "Starts a dry-run phase, to attempt a build" do
|
49
|
+
subcommand "dry-run", "Starts a dry-run build" do
|
63
50
|
def execute
|
64
51
|
if Gjp::Project.new(".").dry_run
|
65
52
|
puts "Now dry-running, please start your build."
|
66
53
|
puts "Any file added to kit/, presumably downloaded dependencies, will be added to the kit."
|
67
54
|
puts "The src/ directory and all files in it will be brought back to the current state when finished."
|
68
55
|
puts "Note that .gitignore files are honored!"
|
69
|
-
puts "To run
|
70
|
-
puts "To
|
71
|
-
puts "To finalize this dry run, use \"gjp finish\"."
|
56
|
+
puts "To run Maven from the kit, use \"gjp mvn\"."
|
57
|
+
puts "To end this dry run, use \"gjp finish\"."
|
72
58
|
end
|
73
59
|
end
|
74
60
|
end
|
@@ -88,25 +74,17 @@ module Gjp
|
|
88
74
|
puts "Real commandline was:"
|
89
75
|
puts "#{result}"
|
90
76
|
rescue Gjp::MavenNotFoundException
|
91
|
-
puts "mvn executable not found in kit/ or any of its subdirectories
|
77
|
+
puts "mvn executable not found in kit/ or any of its subdirectories"
|
92
78
|
end
|
93
79
|
end
|
94
80
|
end
|
95
81
|
|
96
|
-
subcommand "
|
97
|
-
def execute
|
98
|
-
puts "Now #{Gjp::Project.new(".").get_status.to_s}"
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
subcommand "finish", "Ends the current phase" do
|
82
|
+
subcommand "finish", "Ends the current dry-run" do
|
103
83
|
def execute
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
puts "
|
108
|
-
puts "Feel free to edit them if needed."
|
109
|
-
puts "You can start a dry run build with \"gjp dry-run\" or add more files with \"gjp gather\"."
|
84
|
+
if Gjp::Project.new(".").finish
|
85
|
+
puts "Dry-run finished."
|
86
|
+
else
|
87
|
+
puts "No dry-run is in progress."
|
110
88
|
end
|
111
89
|
end
|
112
90
|
end
|
@@ -123,13 +101,7 @@ module Gjp
|
|
123
101
|
def execute
|
124
102
|
project = Gjp::Project.new(".")
|
125
103
|
result_path = Gjp::Archiver.new(project).archive_kit
|
126
|
-
|
127
|
-
puts "#{result_path} generated"
|
128
|
-
else
|
129
|
-
"The file_list/kit file was not found. Ensure you already added content to kit/ " +
|
130
|
-
"during a gathering and/or dry-running phase, and ensure you ended that phase " +
|
131
|
-
"with \"gjp finish\"."
|
132
|
-
end
|
104
|
+
puts "#{result_path} generated"
|
133
105
|
end
|
134
106
|
end
|
135
107
|
|
@@ -154,12 +126,7 @@ module Gjp
|
|
154
126
|
def execute
|
155
127
|
project = Gjp::Project.new(".")
|
156
128
|
result_path = Gjp::Archiver.new(project).archive_package name
|
157
|
-
|
158
|
-
puts "#{result_path} generated"
|
159
|
-
else
|
160
|
-
"The file_list/#{name}_input file was not found. Ensure you have already added content to " +
|
161
|
-
"src/#{name} during a gathering phase, and ensure you ended that phase with \"gjp finish\"."
|
162
|
-
end
|
129
|
+
puts "#{result_path} generated"
|
163
130
|
end
|
164
131
|
end
|
165
132
|
|
data/lib/gjp/project.rb
CHANGED
@@ -8,7 +8,7 @@ module Gjp
|
|
8
8
|
include Logger
|
9
9
|
|
10
10
|
# list of possible statuses
|
11
|
-
@@statuses = [:
|
11
|
+
@@statuses = [:dry_running]
|
12
12
|
|
13
13
|
attr_accessor :full_path
|
14
14
|
|
@@ -45,8 +45,8 @@ module Gjp
|
|
45
45
|
Dir.mkdir "src"
|
46
46
|
Dir.mkdir "kit"
|
47
47
|
|
48
|
-
#
|
49
|
-
Project.new(".")
|
48
|
+
# populate the project with templates and take a snapshot
|
49
|
+
project = Project.new(".")
|
50
50
|
|
51
51
|
template_manager = Gjp::TemplateManager.new
|
52
52
|
template_manager.copy "archives", "."
|
@@ -54,25 +54,9 @@ module Gjp
|
|
54
54
|
template_manager.copy "kit", "."
|
55
55
|
template_manager.copy "specs", "."
|
56
56
|
template_manager.copy "src", "."
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# starts a gathering phase, all files added to the project
|
61
|
-
# will be added to packages (including kit)
|
62
|
-
def gather
|
63
|
-
from_directory do
|
64
|
-
status = get_status
|
65
|
-
if status == :gathering
|
66
|
-
return false
|
67
|
-
elsif status == :dry_running
|
68
|
-
finish
|
69
|
-
end
|
70
57
|
|
71
|
-
|
72
|
-
take_snapshot "Gathering started", :gathering_started
|
58
|
+
project.take_snapshot "Template files added", :init
|
73
59
|
end
|
74
|
-
|
75
|
-
true
|
76
60
|
end
|
77
61
|
|
78
62
|
# starts a dry running phase: files added to kit/ will be added
|
@@ -83,8 +67,6 @@ module Gjp
|
|
83
67
|
status = get_status
|
84
68
|
if status == :dry_running
|
85
69
|
return false
|
86
|
-
elsif status == :gathering
|
87
|
-
finish
|
88
70
|
end
|
89
71
|
|
90
72
|
set_status :dry_running
|
@@ -99,22 +81,10 @@ module Gjp
|
|
99
81
|
def finish
|
100
82
|
from_directory do
|
101
83
|
status = get_status
|
102
|
-
if status == :
|
103
|
-
take_snapshot "Changes during gathering"
|
104
|
-
|
105
|
-
update_changed_file_list "kit", "kit", :gathering_started
|
106
|
-
update_changed_src_file_list :input, :gathering_started
|
107
|
-
take_snapshot "File list updates"
|
108
|
-
|
109
|
-
set_status nil
|
110
|
-
take_snapshot "Gathering finished", :gathering_finished
|
111
|
-
|
112
|
-
:gathering
|
113
|
-
elsif status == :dry_running
|
84
|
+
if status == :dry_running
|
114
85
|
take_snapshot "Changes during dry-run"
|
115
86
|
|
116
|
-
|
117
|
-
update_changed_src_file_list :output, :dry_run_started
|
87
|
+
update_output_file_lists
|
118
88
|
take_snapshot "File list updates"
|
119
89
|
|
120
90
|
revert "src", :dry_run_started
|
@@ -123,45 +93,42 @@ module Gjp
|
|
123
93
|
set_status nil
|
124
94
|
take_snapshot "Dry run finished", :dry_run_finished
|
125
95
|
|
126
|
-
|
96
|
+
return true
|
127
97
|
end
|
128
98
|
end
|
99
|
+
false
|
129
100
|
end
|
130
101
|
|
131
|
-
# updates
|
132
|
-
#
|
133
|
-
|
134
|
-
def update_changed_src_file_list(list_name, tag)
|
102
|
+
# updates files that contain lists of the output files produced by
|
103
|
+
# the build of each package
|
104
|
+
def update_output_file_lists
|
135
105
|
Dir.foreach("src") do |entry|
|
136
106
|
if File.directory?(File.join(Dir.getwd, "src", entry)) and entry != "." and entry != ".."
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
tracked_files = if File.exists?(list_file)
|
146
|
-
File.readlines(list_file).map { |line| line.strip }
|
147
|
-
else
|
148
|
-
[]
|
149
|
-
end
|
150
|
-
|
151
|
-
new_tracked_files = (
|
152
|
-
`git diff-tree --no-commit-id --name-only -r #{latest_tag(tag)} HEAD`.split("\n")
|
153
|
-
.select { |file| file.start_with?(directory) }
|
154
|
-
.map { |file|file[directory.length + 1, file.length] }
|
155
|
-
.concat(tracked_files)
|
156
|
-
.uniq
|
157
|
-
.sort
|
158
|
-
)
|
159
|
-
|
160
|
-
log.debug("writing file list for #{directory}: #{new_tracked_files.to_s}")
|
107
|
+
directory = File.join("src", entry)
|
108
|
+
file_name = "#{entry}_output"
|
109
|
+
list_file = File.join("file_lists", file_name)
|
110
|
+
tracked_files = if File.exists?(list_file)
|
111
|
+
File.readlines(list_file).map { |line| line.strip }
|
112
|
+
else
|
113
|
+
[]
|
114
|
+
end
|
161
115
|
|
162
|
-
|
163
|
-
|
164
|
-
|
116
|
+
new_tracked_files = (
|
117
|
+
`git diff-tree --no-commit-id --name-only -r #{latest_tag(:dry_run_started)} HEAD`.split("\n")
|
118
|
+
.select { |file| file.start_with?(directory) }
|
119
|
+
.map { |file|file[directory.length + 1, file.length] }
|
120
|
+
.concat(tracked_files)
|
121
|
+
.uniq
|
122
|
+
.sort
|
123
|
+
)
|
124
|
+
|
125
|
+
log.debug("writing file list for #{directory}: #{new_tracked_files.to_s}")
|
126
|
+
|
127
|
+
File.open(list_file, "w+") do |file_list|
|
128
|
+
new_tracked_files.each do |file|
|
129
|
+
file_list.puts file
|
130
|
+
end
|
131
|
+
end
|
165
132
|
end
|
166
133
|
end
|
167
134
|
end
|
data/lib/gjp/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
gjp will generate source archives for packages here.
|
2
2
|
|
3
|
-
Those should not be edited by hand, rather you
|
3
|
+
Those should not be edited by hand, rather you should edit the files themselves from the kit and src/<package name> folders.
|
@@ -1,3 +1,3 @@
|
|
1
|
-
gjp will generate file lists
|
1
|
+
gjp will generate file lists its internal use here.
|
2
2
|
|
3
|
-
You
|
3
|
+
You should not edit them manually.
|
data/spec/lib/archiver_spec.rb
CHANGED
@@ -21,9 +21,8 @@ describe Gjp::Archiver do
|
|
21
21
|
it "archives a list of files" do
|
22
22
|
@project.from_directory do
|
23
23
|
File.open("test", "w") { |io| io.puts "test content" }
|
24
|
-
File.open("test_list", "w") { |io| io.puts "test" }
|
25
24
|
|
26
|
-
archiver.archive "
|
25
|
+
archiver.archive ".", "test.tar.xz"
|
27
26
|
`tar -Jtf test.tar.xz`.split.should include("test")
|
28
27
|
end
|
29
28
|
end
|
@@ -46,14 +45,14 @@ describe Gjp::Archiver do
|
|
46
45
|
describe "#archive_package" do
|
47
46
|
it "archives a package files" do
|
48
47
|
@project.from_directory do
|
49
|
-
Dir.mkdir(File.join("src", "
|
50
|
-
File.open(File.join("src", "
|
48
|
+
Dir.mkdir(File.join("src", "package-name"))
|
49
|
+
File.open(File.join("src", "package-name", "src_test"), "w") { |io| io.puts "test content" }
|
51
50
|
end
|
52
51
|
@project.finish
|
53
52
|
|
54
|
-
archiver.archive_package "
|
53
|
+
archiver.archive_package "package-name"
|
55
54
|
@project.from_directory do
|
56
|
-
`tar -Jtf archives/
|
55
|
+
`tar -Jtf archives/package-name.tar.xz`.split.should include("src_test")
|
57
56
|
end
|
58
57
|
end
|
59
58
|
end
|
@@ -59,7 +59,6 @@ describe Gjp::MavenRunner do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def mock_maven_executable
|
62
|
-
@project.gather
|
63
62
|
Dir.chdir(@project_path) do
|
64
63
|
@bin_dir = File.join("kit", "mvn", "bin")
|
65
64
|
FileUtils.mkdir_p(@bin_dir)
|
@@ -67,7 +66,5 @@ describe Gjp::MavenRunner do
|
|
67
66
|
File.open(@maven_executable, "w") { |io| io.puts "echo $0 $*>test_out" }
|
68
67
|
File.chmod(0777, @maven_executable)
|
69
68
|
end
|
70
|
-
|
71
|
-
@project.finish
|
72
69
|
end
|
73
70
|
end
|
data/spec/lib/project_spec.rb
CHANGED
@@ -48,21 +48,14 @@ describe Gjp::Project do
|
|
48
48
|
|
49
49
|
src_path = File.join(@project_path, "src")
|
50
50
|
Dir.exists?(src_path).should be_true
|
51
|
-
|
52
|
-
@project.from_directory do
|
53
|
-
@project.latest_tag(:gathering_started).should eq "gjp_gathering_started_1"
|
54
|
-
`git rev-list --all`.split("\n").length.should eq 1
|
55
|
-
end
|
56
|
-
|
57
|
-
@project.get_status.should eq :gathering
|
58
51
|
end
|
59
52
|
end
|
60
53
|
|
61
54
|
describe "#set_status" do
|
62
55
|
it "stores a project's status flag" do
|
63
56
|
@project.from_directory do
|
64
|
-
@project.set_status :
|
65
|
-
File.exists?(".
|
57
|
+
@project.set_status :dry_running
|
58
|
+
File.exists?(".dry_running").should be_true
|
66
59
|
end
|
67
60
|
end
|
68
61
|
end
|
@@ -70,9 +63,9 @@ describe Gjp::Project do
|
|
70
63
|
describe "#get_status" do
|
71
64
|
it "gets a project's status flag" do
|
72
65
|
@project.from_directory do
|
73
|
-
@project.get_status.should eq :gathering
|
74
|
-
@project.set_status nil
|
75
66
|
@project.get_status.should be_nil
|
67
|
+
@project.set_status :dry_running
|
68
|
+
@project.get_status.should eq :dry_running
|
76
69
|
end
|
77
70
|
end
|
78
71
|
end
|
@@ -90,78 +83,39 @@ describe Gjp::Project do
|
|
90
83
|
end
|
91
84
|
end
|
92
85
|
|
93
|
-
describe "#gather" do
|
94
|
-
it "starts a gathering phase" do
|
95
|
-
@project.finish.should eq :gathering
|
96
|
-
|
97
|
-
@project.from_directory do
|
98
|
-
`touch src/test`
|
99
|
-
end
|
100
|
-
|
101
|
-
@project.gather.should be_true
|
102
|
-
|
103
|
-
@project.from_directory do
|
104
|
-
@project.get_status.should eq :gathering
|
105
|
-
`git rev-list --all`.split("\n").length.should eq 5
|
106
|
-
`git diff-tree --no-commit-id --name-only -r HEAD`.split("\n").should include("src/test")
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
86
|
describe "#finish" do
|
112
|
-
it "ends the current gathering phase" do
|
113
|
-
@project.from_directory do
|
114
|
-
Dir.mkdir("src/abc")
|
115
|
-
`touch src/abc/test`
|
116
|
-
`touch kit/test`
|
117
|
-
end
|
118
|
-
|
119
|
-
@project.finish.should eq :gathering
|
120
|
-
@project.get_status.should be_nil
|
121
|
-
|
122
|
-
@project.from_directory do
|
123
|
-
`git rev-list --all`.split("\n").length.should eq 4
|
124
|
-
`git diff-tree --no-commit-id --name-only -r HEAD~2`.split("\n").should include("src/abc/test")
|
125
|
-
File.readlines(File.join("file_lists", "abc_input")).should include("test\n")
|
126
|
-
File.readlines(File.join("file_lists","kit")).should include("test\n")
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
87
|
it "ends the current dry-run phase" do
|
131
88
|
@project.from_directory do
|
132
89
|
Dir.mkdir("src/abc")
|
133
90
|
`echo A > src/abc/test`
|
134
91
|
end
|
135
92
|
|
136
|
-
@project.finish.should
|
93
|
+
@project.finish.should be_false
|
137
94
|
|
138
95
|
@project.dry_run.should be_true
|
139
96
|
|
140
97
|
@project.from_directory do
|
141
98
|
`echo B > src/abc/test`
|
142
99
|
`touch src/abc/test2`
|
143
|
-
`touch kit/test`
|
144
100
|
end
|
145
101
|
|
146
|
-
@project.finish.should
|
102
|
+
@project.finish.should be_true
|
147
103
|
@project.get_status.should be_nil
|
148
104
|
|
149
105
|
@project.from_directory do
|
150
|
-
`git rev-list --all`.split("\n").length.should eq
|
106
|
+
`git rev-list --all`.split("\n").length.should eq 6
|
151
107
|
File.read("src/abc/test").should eq "A\n"
|
152
108
|
File.readlines(File.join("file_lists", "abc_output")).should include("test2\n")
|
153
|
-
File.readlines(File.join("file_lists", "abc_input")).should_not include("test2\n")
|
154
109
|
|
155
110
|
`git diff-tree --no-commit-id --name-only -r HEAD~2`.split("\n").should_not include("src/abc/test2")
|
156
111
|
File.exists?("src/abc/test2").should be_false
|
157
|
-
File.readlines(File.join("file_lists", "kit")).should include("test\n")
|
158
112
|
end
|
159
113
|
end
|
160
114
|
end
|
161
115
|
|
162
116
|
describe "#dry_run" do
|
163
117
|
it "starts a dry running phase" do
|
164
|
-
@project.finish.should
|
118
|
+
@project.finish.should be_false
|
165
119
|
|
166
120
|
@project.from_directory do
|
167
121
|
`touch src/test`
|
@@ -171,7 +125,7 @@ describe Gjp::Project do
|
|
171
125
|
|
172
126
|
@project.from_directory do
|
173
127
|
@project.get_status.should eq :dry_running
|
174
|
-
`git rev-list --all`.split("\n").length.should eq
|
128
|
+
`git rev-list --all`.split("\n").length.should eq 2
|
175
129
|
`git diff-tree --no-commit-id --name-only -r HEAD`.split("\n").should include("src/test")
|
176
130
|
end
|
177
131
|
end
|
data/spec/lib/scaffolder_spec.rb
CHANGED
@@ -15,7 +15,6 @@ describe Gjp::Scaffolder do
|
|
15
15
|
test_file = File.join("kit", "test")
|
16
16
|
File.open(test_file, "w") { |io| io.puts "kit content test file" }
|
17
17
|
end
|
18
|
-
@project.gather
|
19
18
|
|
20
19
|
@scaffolder = Gjp::Scaffolder.new(@project)
|
21
20
|
end
|
@@ -26,6 +25,9 @@ describe Gjp::Scaffolder do
|
|
26
25
|
|
27
26
|
describe "#generate_kit_spec" do
|
28
27
|
it "scaffolds the first version" do
|
28
|
+
@project.dry_run
|
29
|
+
@project.finish
|
30
|
+
|
29
31
|
@scaffolder.generate_kit_spec.should be_true
|
30
32
|
|
31
33
|
@project.from_directory do
|
@@ -46,7 +48,7 @@ describe Gjp::Scaffolder do
|
|
46
48
|
io.write("nonconflicting line")
|
47
49
|
end
|
48
50
|
end
|
49
|
-
@project.
|
51
|
+
@project.finish
|
50
52
|
|
51
53
|
@scaffolder.generate_kit_spec.should be_true
|
52
54
|
|
@@ -74,7 +76,6 @@ describe Gjp::Scaffolder do
|
|
74
76
|
io.write(spec_contents)
|
75
77
|
end
|
76
78
|
end
|
77
|
-
@project.gather
|
78
79
|
|
79
80
|
@scaffolder.generate_kit_spec.should be_true
|
80
81
|
|
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.18.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: 2013-10-
|
12
|
+
date: 2013-10-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|