gjp 0.14.1 → 0.15.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -16,17 +16,19 @@ Easiest install is via RubyGems:
16
16
 
17
17
  Main workflow subcommands:
18
18
  * `gjp init` inits a new gjp project in the current directory, generating minimal directories and files;
19
- * `gjp gather` starts a new gathering phase, to add files to the packages you want to create. You should place source files in src/<orgId:artifactId:version>, and binary dependency files in kit/;
20
- * `gjp dry-run` starts a new dry-run phase, where you attempt to build your package. Any change to src/ will be reverted after you call `gjp finish`
19
+ * `gjp gather` starts a gathering phase, to add source and kit files. You should place source files in src/<package name> and binary dependency files in kit/;
20
+ * `gjp dry-run` starts a dry-run phase, to attempt a build. Any change to src/ will be reverted after you call `gjp finish`;
21
+ * `gjp mvn` during a dry run, locates and runs Maven from any directory in kit/, using options to force repository in kit/m2 and settings in kit/m2/settings.xml;
22
+ * `gjp status` prints the current phase;
21
23
  * `gjp finish` ends the current phase;
22
- * `gjp mvn` locates and runs Maven from any directory in kit/, using options to force repository in kit/m2 and settings in kit/m2/settings.xml. Use during dry runs;
23
- superuser privileges;
24
- * `gjp generate-kit-spec` creates or refreshes a spec file for the kit package. Use when you are finished gathering and dry-running;
25
- * `gjp generate-kit-archive` creates or refreshes an archive file for the kit package. Use when you are finished gathering and dry-running;
26
- * `gjp generate-source-archive NAME` creates or refreshes an archive file for source package NAME. Use when you are finished gathering and dry-running;
24
+ * `gjp generate-kit-spec` creates or refreshes a spec file for the kit. Use after `gjp finish`;
25
+ * `gjp generate-kit-archive` creates or refreshes an archive file for the kit. Use after `gjp finish`;
26
+ * `gjp generate-package-spec NAME POM` creates or refreshes a spec file for the package in src/<NAME>. Use after `gjp finish`;
27
+ * `gjp generate-package-archive NAME` creates or refreshes an archive file for package in src/<NAME>. Use after `gjp finish`;
27
28
 
28
29
  Optional workflow subcommands:
29
30
  * `gjp set-up-nonet-user` sets up a user named `nonet` without Internet access you can use for networkless dry runs. Requires `iptables` and
31
+ superuser privileges;
30
32
  * `gjp tear-down-nonet-user` removes a user previously created by gjp;
31
33
 
32
34
  Other available tools:
data/lib/gjp.rb CHANGED
@@ -12,6 +12,7 @@ require "gjp/source_address_getter"
12
12
  require "gjp/source_getter"
13
13
  require "gjp/parent_pom_getter"
14
14
  require "gjp/maven_runner"
15
+ require "gjp/package_spec_adapter"
15
16
  require "gjp/scaffolder"
16
17
  require "gjp/archiver"
17
18
 
@@ -27,12 +27,12 @@ module Gjp
27
27
 
28
28
  # generates an archive for a project's source package based on
29
29
  # its file list
30
- def archive_src(name)
30
+ def archive_package(name)
31
31
  list_file = File.join(@project.full_path, "file_lists/#{name}_input")
32
32
  if not File.exist? list_file
33
33
  return nil
34
34
  end
35
- destination_file = File.join(@project.full_path, "archives/#{@project.name}-#{name}.tar.xz")
35
+ destination_file = File.join(@project.full_path, "archives/#{name}.tar.xz")
36
36
 
37
37
  @project.from_directory File.join("src", name) do
38
38
  archive list_file, destination_file
@@ -40,30 +40,30 @@ module Gjp
40
40
  def execute
41
41
  Gjp::Project.init(".")
42
42
  puts "Project inited, now gathering."
43
- puts "Any file added to kit/ will be added to the kit package."
44
- puts "Any file added to src/<orgId_artifactId_version> will be added to the corresponding package."
45
- puts "Note that .gitignore files are honored!"
46
- puts "When you are ready to test a dry-run build, use \"gjp dry-run\"."
43
+ explain_gathering
47
44
  end
48
45
  end
49
46
 
50
- subcommand "gather", "Starts a gathering phase, add source and kit files to project" do
47
+ subcommand "gather", "Starts a gathering phase, to add source and kit files" do
51
48
  def execute
52
49
  if Gjp::Project.new(".").gather
53
50
  puts "Now gathering."
54
- puts "Any file added to kit/ will be added to the kit package."
55
- puts "Any file added to src/<orgId_artifactId_version> will be added to the corresponding package."
56
- puts "Note that .gitignore files are honored!"
57
- puts "When you are ready to test a dry-run build, use \"gjp dry-run\"."
51
+ explain_gathering
58
52
  end
59
53
  end
60
54
  end
61
55
 
62
- subcommand "dry-run", "Starts a dry-run phase, attempt build to add dependencies to kit." do
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
63
63
  def execute
64
64
  if Gjp::Project.new(".").dry_run
65
65
  puts "Now dry-running, please start your build."
66
- puts "Any file added to kit/, presumably downloaded dependencies, will be added to the kit package."
66
+ puts "Any file added to kit/, presumably downloaded dependencies, will be added to the kit."
67
67
  puts "The src/ directory and all files in it will be brought back to the current state when finished."
68
68
  puts "Note that .gitignore files are honored!"
69
69
  puts "To run a Maven from the kit, use \"gjp mvn\"."
@@ -73,7 +73,7 @@ module Gjp
73
73
  end
74
74
  end
75
75
 
76
- subcommand "mvn", "Runs Maven from the kit" do
76
+ subcommand "mvn", "Locates and runs Maven from any directory in kit/" do
77
77
  parameter "[MAVEN OPTIONS] ...", "mvn options", :attribute_name => "dummy"
78
78
 
79
79
  # override parsing in order to pipe everything to mvn
@@ -84,7 +84,9 @@ module Gjp
84
84
  def execute
85
85
  begin
86
86
  project = Gjp::Project.new(".")
87
- Gjp::MavenRunner.new(project).mvn(@maven_options)
87
+ result = Gjp::MavenRunner.new(project).mvn(@maven_options)
88
+ puts "Real commandline was:"
89
+ puts "#{result}"
88
90
  rescue Gjp::MavenNotFoundException
89
91
  puts "mvn executable not found in kit/ or any of its subdirectories, gather it"
90
92
  end
@@ -97,7 +99,7 @@ module Gjp
97
99
  end
98
100
  end
99
101
 
100
- subcommand "finish", "Finishes the current phase" do
102
+ subcommand "finish", "Ends the current phase" do
101
103
  def execute
102
104
  result = Gjp::Project.new(".").finish
103
105
  if result == :gathering
@@ -109,15 +111,15 @@ module Gjp
109
111
  end
110
112
  end
111
113
 
112
- subcommand "generate-kit-spec", "Scaffolds or refreshes a spec file for the kit package" do
114
+ subcommand "generate-kit-spec", "Scaffolds or refreshes a spec file for the kit" do
113
115
  def execute
114
116
  project = Gjp::Project.new(".")
115
- result_path = Gjp::Scaffolder.new(project).scaffold_kit_spec
117
+ result_path = Gjp::Scaffolder.new(project).generate_kit_spec
116
118
  puts "#{result_path} generated"
117
119
  end
118
120
  end
119
121
 
120
- subcommand "generate-kit-archive", "Archives contents of the kit package in a tarball" do
122
+ subcommand "generate-kit-archive", "Archives contents of kit in archives/" do
121
123
  def execute
122
124
  project = Gjp::Project.new(".")
123
125
  result_path = Gjp::Archiver.new(project).archive_kit
@@ -131,15 +133,31 @@ module Gjp
131
133
  end
132
134
  end
133
135
 
134
- subcommand "generate-src-archive", "Archives contents of one src package in a tarball" do
135
- parameter "NAME", "name of a package in src/"
136
+ subcommand "generate-package-spec", "Scaffolds or refreshes a spec file for a package" do
137
+ option ["-f", "--filter"], "FILTER", "filter files to be installed by this spec", :default => "*.jar"
138
+ parameter "NAME", "name of a package, that is, an src/ subdirectory name"
139
+ parameter "POM", "a pom file path or URI"
140
+ def execute
141
+ project = Gjp::Project.new(".")
142
+ result_path = Gjp::Scaffolder.new(project).generate_package_spec name, pom, filter
143
+ if result_path != nil
144
+ puts "#{result_path} generated"
145
+ else
146
+ "The file_list/#{name}_output file was not found. Ensure you have already run a" +
147
+ "dry run and ensure you ended that phase with \"gjp finish\"."
148
+ end
149
+ end
150
+ end
151
+
152
+ subcommand "generate-package-archive", "Archives contents of a package in archives/" do
153
+ parameter "NAME", "name of a package, that is, an src/ subdirectory name"
136
154
  def execute
137
155
  project = Gjp::Project.new(".")
138
- result_path = Gjp::Archiver.new(project).archive_src name
156
+ result_path = Gjp::Archiver.new(project).archive_package name
139
157
  if result_path != nil
140
158
  puts "#{result_path} generated"
141
159
  else
142
- "The file_list/#{name}_input file was not found. Ensure you already added content to " +
160
+ "The file_list/#{name}_input file was not found. Ensure you have already added content to " +
143
161
  "src/#{name} during a gathering phase, and ensure you ended that phase with \"gjp finish\"."
144
162
  end
145
163
  end
@@ -54,7 +54,12 @@ module Gjp
54
54
  if maven_commandline == nil
55
55
  raise MavenNotFoundException
56
56
  end
57
- Process.wait(Process.spawn("#{maven_commandline} #{options.join(' ')}"))
57
+
58
+ full_commandline = "#{maven_commandline} #{options.join(' ')}"
59
+ log.debug full_commandline
60
+
61
+ Process.wait(Process.spawn(full_commandline))
62
+ full_commandline
58
63
  end
59
64
  end
60
65
 
@@ -0,0 +1,47 @@
1
+ # encoding: UTF-8
2
+
3
+ module Gjp
4
+ # encapsulates details of a package needed by the spec file
5
+ # retrieving them from other objects
6
+ class PackageSpecAdapter
7
+ attr_reader :name
8
+ attr_reader :version
9
+ attr_reader :license
10
+ attr_reader :summary
11
+ attr_reader :url
12
+ attr_reader :project_name
13
+ attr_reader :group_id
14
+ attr_reader :artifact_id
15
+ attr_reader :version
16
+ attr_reader :runtime_dependency_ids
17
+ attr_reader :description
18
+ attr_reader :outputs
19
+
20
+ def initialize(project, package_name, pom, filter)
21
+ @name = package_name
22
+ @version = pom.version
23
+ @license = pom.license_name
24
+ clean_description = pom.description.gsub(/[\s]+/, ' ').strip
25
+ @summary = clean_description[0..60].gsub(/\s\w+$/, '...')
26
+ @url = pom.url
27
+ @project_name = project.name
28
+ @group_id = pom.group_id
29
+ @artifact_id = pom.artifact_id
30
+ @version = pom.version
31
+ @runtime_dependency_ids = pom.runtime_dependency_ids
32
+ @description = clean_description
33
+
34
+ output_list = File.join(project.full_path, "file_lists", "#{@name}_output")
35
+ @outputs = File.open(output_list).readlines.map do |line|
36
+ line.strip
37
+ end.select do |line|
38
+ File.fnmatch? filter, File.basename(line.strip)
39
+ end
40
+ end
41
+
42
+ def get_binding
43
+ binding
44
+ end
45
+ end
46
+ end
47
+
@@ -30,6 +30,24 @@ module Gjp
30
30
  @doc.xpath("project/version/text()").to_s
31
31
  end
32
32
 
33
+ def description
34
+ @doc.xpath("project/description/text()").to_s
35
+ end
36
+
37
+ def url
38
+ @doc.xpath("project/url/text()").to_s
39
+ end
40
+
41
+ def license_name
42
+ @doc.xpath("project/licenses/license/name/text()").to_s
43
+ end
44
+
45
+ def runtime_dependency_ids
46
+ result = @doc.xpath("project/dependencies/dependency[not(optional='true') and not(scope='provided') and not(scope='test') and not(scope='system')]").map do |element|
47
+ [element.xpath("groupId/text()").to_s, element.xpath("artifactId/text()").to_s, element.xpath("version/text()").to_s]
48
+ end
49
+ end
50
+
33
51
  def parent_group_id
34
52
  @doc.xpath("project/parent/groupId/text()").to_s
35
53
  end
@@ -77,7 +77,7 @@ module Gjp
77
77
 
78
78
  # starts a dry running phase: files added to the kit will
79
79
  # be added to packages, while sources will be reset at the
80
- # end
80
+ # current state when finished
81
81
  def dry_run
82
82
  from_directory do
83
83
  status = get_status
@@ -130,11 +130,11 @@ module Gjp
130
130
 
131
131
  # updates one of the files that tracks changes in src/ directories form a certain tag
132
132
  # list_name is the name of the list of files to update, there will be one for each
133
- # package in src/
133
+ # package (subdirectory) in src/
134
134
  def update_changed_src_file_list(list_name, tag)
135
135
  Dir.foreach("src") do |entry|
136
- if File.directory?(File.join(Dir.getwd, "src", entry)) and entry =~ /([^:\/]+:[^:]+:[^:]+)$/
137
- update_changed_file_list(File.join("src", entry), "#{$1}_#{list_name.to_s}", tag)
136
+ if File.directory?(File.join(Dir.getwd, "src", entry)) and entry != "." and entry != ".."
137
+ update_changed_file_list(File.join("src", entry), "#{entry}_#{list_name.to_s}", tag)
138
138
  end
139
139
  end
140
140
  end
@@ -143,7 +143,7 @@ module Gjp
143
143
  def update_changed_file_list(directory, file_name, tag)
144
144
  list_file = File.join("file_lists", file_name)
145
145
  tracked_files = if File.exists?(list_file)
146
- File.readlines(list_file)
146
+ File.readlines(list_file).map { |line| line.strip }
147
147
  else
148
148
  []
149
149
  end
@@ -151,10 +151,10 @@ module Gjp
151
151
  new_tracked_files = (
152
152
  `git diff-tree --no-commit-id --name-only -r #{latest_tag(tag)} HEAD`.split("\n")
153
153
  .select { |file| file.start_with?(directory) }
154
- .map { |file|file[directory.length + 1, file.length] }
154
+ .map { |file|file[directory.length + 1, file.length] }
155
155
  .concat(tracked_files)
156
- .sort
157
156
  .uniq
157
+ .sort
158
158
  )
159
159
 
160
160
  log.debug("writing file list for #{directory}: #{new_tracked_files.to_s}")
@@ -171,7 +171,7 @@ module Gjp
171
171
  def take_snapshot(message, tag = nil)
172
172
  log.debug "committing with message: #{message}"
173
173
 
174
- `git rm -r --cached .`
174
+ `git rm -r --cached --ignore-unmatch .`
175
175
  `git add .`
176
176
  `git commit -m "#{message}"`
177
177
 
@@ -9,30 +9,52 @@ module Gjp
9
9
  @project = project
10
10
  end
11
11
 
12
- def scaffold_kit_spec
13
- @project.from_directory do
14
- spec_path = File.join("specs", "#{@project.name}-kit.spec")
12
+ def generate_kit_spec
13
+ spec_path = File.join("specs", "#{@project.name}-kit.spec")
14
+ generate_merging "kit.spec", @project.get_binding, spec_path, :generate_kit_spec
15
+ spec_path
16
+ end
17
+
18
+ def generate_package_spec(name, pom, filter)
19
+ spec_path = File.join("specs", "#{name}.spec")
20
+
21
+ list_file = File.join(@project.full_path, "file_lists/#{name}_output")
22
+ if not File.exist? list_file
23
+ return nil
24
+ end
25
+
26
+ adapter = Gjp::PackageSpecAdapter.new(@project, name, Gjp::Pom.new(pom), filter)
15
27
 
16
- TemplateManager.new.generate "kit.spec", @project.get_binding, "#{spec_path}.new_scaffold"
28
+ generate_merging "package.spec", adapter.get_binding, spec_path, "scaffold_#{name}_spec"
17
29
 
18
- already_scaffolded = @project.latest_tag(:scaffold_kit_spec) != ""
19
- already_existing = File.exist? spec_path
30
+ spec_path
31
+ end
32
+
33
+ # generates a file in result_path from template together with binding.
34
+ # if a file already exists at that position, 3-way merge it with the
35
+ # version with the latest tag specified. Takes a snapshot in the end
36
+ # for future merges
37
+ def generate_merging(template, binding, result_path, tag)
38
+ @project.from_directory do
39
+ TemplateManager.new.generate template, binding, "#{result_path}.new_scaffold"
40
+
41
+ already_scaffolded = @project.latest_tag(tag) != ""
42
+ already_existing = File.exist? result_path
20
43
 
21
44
  if already_scaffolded and already_existing
22
45
  # 3-way merge
23
- `git show #{@project.latest_tag(:scaffold_kit_spec)}:#{spec_path} > #{spec_path}.old_scaffold`
24
- `git merge-file --ours #{spec_path} #{spec_path}.old_scaffold #{spec_path}.new_scaffold`
25
- File.delete "#{spec_path}.new_scaffold"
26
- File.delete "#{spec_path}.old_scaffold"
46
+ `git show #{@project.latest_tag(tag)}:#{result_path} > #{result_path}.old_scaffold`
47
+ `git merge-file --ours #{result_path} #{result_path}.old_scaffold #{result_path}.new_scaffold`
48
+ File.delete "#{result_path}.new_scaffold"
49
+ File.delete "#{result_path}.old_scaffold"
27
50
  else
28
51
  # just replace
29
- File.rename "#{spec_path}.new_scaffold", spec_path
52
+ File.rename "#{result_path}.new_scaffold", result_path
30
53
  end
31
54
 
32
- @project.take_snapshot "Kit spec scaffolded", :scaffold_kit_spec
33
-
34
- spec_path
55
+ @project.take_snapshot "Kit spec scaffolded", tag
35
56
  end
36
57
  end
58
+
37
59
  end
38
60
  end
@@ -18,7 +18,7 @@ module Gjp
18
18
  end
19
19
 
20
20
  def generate(template_name, object_binding, destination_path)
21
- erb = ERB.new File.read(File.join(template_path, template_name))
21
+ erb = ERB.new File.read(File.join(template_path, template_name)), nil, "<>"
22
22
  File.open(destination_path, "w") { |io| io.write erb.result(object_binding) }
23
23
  end
24
24
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Gjp
4
- VERSION = "0.14.1"
4
+ VERSION = "0.15.7"
5
5
  end
@@ -44,10 +44,12 @@ be installed on end users' systems.
44
44
 
45
45
  %install
46
46
  install -d -m 0755 %{buildroot}%{_datadir}/gjp/%{name}/
47
+ mv README.SUSE ../
47
48
  cp -a * %{buildroot}%{_datadir}/gjp/%{name}/
48
49
 
49
50
  %files
50
51
  %defattr(-,root,root)
52
+ %doc ../README.SUSE
51
53
  %{_datadir}/gjp
52
54
  %{_datadir}/gjp/%{name}/
53
55
 
@@ -0,0 +1,4 @@
1
+ Contents of this package are automatically packaged by the gjp program in order
2
+ to build other Java packages from source. They are not needed after rpm files
3
+ are created, so this package should only be used by the Build Service and
4
+ should never be installed on end users' systems.
@@ -0,0 +1,54 @@
1
+ #
2
+ # spec file for "<%= name %>"
3
+ #
4
+ # Copyright (c) <%= Time.now.year %> <%= Etc.getlogin %>
5
+ #
6
+ # All modifications and additions to the file contributed by third parties
7
+ # remain the property of their copyright owners, unless otherwise agreed
8
+ # upon. The license for this file, and modifications and additions to the
9
+ # file, is the same license as for the pristine package itself (unless the
10
+ # license for the pristine package is not an Open Source License, in which
11
+ # case the license is the MIT License). An "Open Source License" is a
12
+ # license that conforms to the Open Source Definition (Version 1.9)
13
+ # published by the Open Source Initiative.
14
+
15
+ # Please submit bugfixes or comments via http://bugs.opensuse.org/
16
+ #
17
+
18
+ Name: <%= name %>
19
+ Version: <%= version %>
20
+ Release: 1
21
+ License: <%= license %>
22
+ Summary: <%= summary %>
23
+ Url: <%= url %>
24
+ Group: Development/Libraries/Java
25
+ Source0: %{name}.tar.xz
26
+ BuildRoot: %{_tmppath}/%{name}-%{version}-build
27
+ BuildRequires: <%= project_name %>-kit
28
+ BuildArch: noarch
29
+ Provides: mvn(<%= group_id %>:<%= artifact_id %>) == <%= version %>
30
+ <% runtime_dependency_ids.each do |dependency_id| %>
31
+ Requires: mvn(<%= dependency_id[0] %>:<%= dependency_id[1] %>) <% if dependency_id[3] != nil %>==<%= dependency_id[3] %><% end %>
32
+ <% end %>
33
+
34
+ %description
35
+ <%= description %>
36
+
37
+ %prep
38
+ %setup -q -c
39
+
40
+ %build
41
+ ./build.sh
42
+
43
+ %install
44
+ <% outputs.each do |output| %>
45
+ cp -a <%= output %> %{buildroot}%{_javadir}/<%= File.basename(output) %>
46
+ <% end %>
47
+
48
+ %files
49
+ %defattr(-,root,root)
50
+ <% outputs.each do |output| %>
51
+ cp -a <%= output %> %{buildroot}%{_javadir}/<%= File.basename(output) %>
52
+ <% end %>
53
+
54
+ %changelog
@@ -43,17 +43,17 @@ describe Gjp::Archiver do
43
43
  end
44
44
  end
45
45
 
46
- describe "#archive_src" do
47
- it "archives a source package files" do
46
+ describe "#archive_package" do
47
+ it "archives a package files" do
48
48
  @project.from_directory do
49
49
  Dir.mkdir(File.join("src", "a:b:c"))
50
50
  File.open(File.join("src", "a:b:c", "src_test"), "w") { |io| io.puts "test content" }
51
51
  end
52
52
  @project.finish
53
53
 
54
- archiver.archive_src "a:b:c"
54
+ archiver.archive_package "a:b:c"
55
55
  @project.from_directory do
56
- `tar -Jtf archives/test-project-a:b:c.tar.xz`.split.should include("src_test")
56
+ `tar -Jtf archives/a:b:c.tar.xz`.split.should include("src_test")
57
57
  end
58
58
  end
59
59
  end
@@ -3,55 +3,75 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Gjp::Pom do
6
- [ File.join("spec", "data", "commons-logging", "pom.xml"),
7
- 'http://search.maven.org/remotecontent?filepath=commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom'].each do |loc|
6
+ let(:pom) { Gjp::Pom.new(File.join("spec", "data", "commons-logging", "pom.xml")) }
8
7
 
9
- let(:pom) { Gjp::Pom.new(loc) }
8
+ describe "#connection_address" do
9
+ it "reads the SCM connection address" do
10
+ pom.connection_address.should eq "svn:http://svn.apache.org/repos/asf/commons/proper/logging/tags/commons-logging-1.1.1"
11
+ end
12
+
13
+ it "reads the SCM connection address from a remote repository" do
14
+ pom.connection_address.should eq "svn:http://svn.apache.org/repos/asf/commons/proper/logging/tags/commons-logging-1.1.1"
15
+ end
16
+ end
17
+
18
+ describe "#group_id" do
19
+ it "reads the group id" do
20
+ pom.group_id.should eq "commons-logging"
21
+ end
22
+ end
23
+
24
+ describe "#artifact_id" do
25
+ it "reads the artifact id" do
26
+ pom.artifact_id.should eq "commons-logging"
27
+ end
28
+ end
10
29
 
11
- describe "#connection_address" do
12
- it "reads the SCM connection address" do
13
- pom.connection_address.should eq "svn:http://svn.apache.org/repos/asf/commons/proper/logging/tags/commons-logging-1.1.1"
14
- end
30
+ describe "#version" do
31
+ it "reads the version" do
32
+ pom.version.should eq "1.1.1"
33
+ end
34
+ end
15
35
 
16
- it "reads the SCM connection address from a remote repository" do
17
- pom.connection_address.should eq "svn:http://svn.apache.org/repos/asf/commons/proper/logging/tags/commons-logging-1.1.1"
18
- end
36
+ describe "#description" do
37
+ it "reads the description" do
38
+ pom.description.should eq "Commons Logging is a thin adapter allowing configurable bridging to other,\n well known logging systems."
19
39
  end
40
+ end
20
41
 
21
- describe "#group_id" do
22
- it "reads the group id" do
23
- pom.group_id.should eq "commons-logging"
24
- end
42
+ describe "#url" do
43
+ it "reads the url" do
44
+ pom.url.should eq "http://commons.apache.org/logging"
25
45
  end
46
+ end
26
47
 
27
- describe "#artifact_id" do
28
- it "reads the artifact id" do
29
- pom.artifact_id.should eq "commons-logging"
30
- end
48
+ describe "#license_name" do
49
+ it "reads the license name" do
50
+ pom.license_name.should eq ""
31
51
  end
52
+ end
32
53
 
33
- describe "#version" do
34
- it "reads the version" do
35
- pom.version.should eq "1.1.1"
36
- end
54
+ describe "#runtime_dependency_ids" do
55
+ it "reads the dependency maven ids" do
56
+ pom.runtime_dependency_ids.should eq []
37
57
  end
58
+ end
38
59
 
39
- describe "#parent_group_id" do
40
- it "reads the parent's group id" do
41
- pom.parent_group_id.should eq "org.apache.commons"
42
- end
60
+ describe "#parent_group_id" do
61
+ it "reads the parent's group id" do
62
+ pom.parent_group_id.should eq "org.apache.commons"
43
63
  end
64
+ end
44
65
 
45
- describe "#parent_artifact_id" do
46
- it "reads the parent's artifact id" do
47
- pom.parent_artifact_id.should eq "commons-parent"
48
- end
66
+ describe "#parent_artifact_id" do
67
+ it "reads the parent's artifact id" do
68
+ pom.parent_artifact_id.should eq "commons-parent"
49
69
  end
70
+ end
50
71
 
51
- describe "#parent_version" do
52
- it "reads the parent's version" do
53
- pom.parent_version.should eq "5"
54
- end
72
+ describe "#parent_version" do
73
+ it "reads the parent's version" do
74
+ pom.parent_version.should eq "5"
55
75
  end
56
76
  end
57
77
  end
@@ -111,8 +111,8 @@ describe Gjp::Project do
111
111
  describe "#finish" do
112
112
  it "ends the current gathering phase" do
113
113
  @project.from_directory do
114
- Dir.mkdir("src/a:b:c")
115
- `touch src/a\:b\:c/test`
114
+ Dir.mkdir("src/abc")
115
+ `touch src/abc/test`
116
116
  `touch kit/test`
117
117
  end
118
118
 
@@ -121,16 +121,16 @@ describe Gjp::Project do
121
121
 
122
122
  @project.from_directory do
123
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/a:b:c/test")
125
- File.readlines(File.join("file_lists", "a:b:c_input")).should include("test\n")
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
126
  File.readlines(File.join("file_lists","kit")).should include("test\n")
127
127
  end
128
128
  end
129
129
 
130
130
  it "ends the current dry-run phase" do
131
131
  @project.from_directory do
132
- Dir.mkdir("src/a:b:c")
133
- `echo A > src/a\:b\:c/test`
132
+ Dir.mkdir("src/abc")
133
+ `echo A > src/abc/test`
134
134
  end
135
135
 
136
136
  @project.finish.should eq :gathering
@@ -138,8 +138,8 @@ describe Gjp::Project do
138
138
  @project.dry_run.should be_true
139
139
 
140
140
  @project.from_directory do
141
- `echo B > src/a\:b\:c/test`
142
- `touch src/a\:b\:c/test2`
141
+ `echo B > src/abc/test`
142
+ `touch src/abc/test2`
143
143
  `touch kit/test`
144
144
  end
145
145
 
@@ -148,12 +148,12 @@ describe Gjp::Project do
148
148
 
149
149
  @project.from_directory do
150
150
  `git rev-list --all`.split("\n").length.should eq 9
151
- File.read("src/a:b:c/test").should eq "A\n"
152
- File.readlines(File.join("file_lists", "a:b:c_output")).should include("test2\n")
153
- File.readlines(File.join("file_lists", "a:b:c_input")).should_not include("test2\n")
151
+ File.read("src/abc/test").should eq "A\n"
152
+ 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
154
 
155
- `git diff-tree --no-commit-id --name-only -r HEAD~2`.split("\n").should_not include("src/a:b:c/test2")
156
- File.exists?("src/a:b:c/test2").should be_false
155
+ `git diff-tree --no-commit-id --name-only -r HEAD~2`.split("\n").should_not include("src/abc/test2")
156
+ File.exists?("src/abc/test2").should be_false
157
157
  File.readlines(File.join("file_lists", "kit")).should include("test\n")
158
158
  end
159
159
  end
@@ -24,9 +24,9 @@ describe Gjp::Scaffolder do
24
24
  FileUtils.rm_rf(@project_path)
25
25
  end
26
26
 
27
- describe "#scaffold_kit_spec" do
27
+ describe "#generate_kit_spec" do
28
28
  it "scaffolds the first version" do
29
- @scaffolder.scaffold_kit_spec.should be_true
29
+ @scaffolder.generate_kit_spec.should be_true
30
30
 
31
31
  @project.from_directory do
32
32
  spec_lines = File.readlines(File.join("specs", "test-project-kit.spec"))
@@ -36,7 +36,7 @@ describe Gjp::Scaffolder do
36
36
  end
37
37
  end
38
38
  it "scaffolds a second version" do
39
- @scaffolder.scaffold_kit_spec.should be_true
39
+ @scaffolder.generate_kit_spec.should be_true
40
40
  @project.dry_run
41
41
  Dir.chdir(@project_path) do
42
42
  test_file = File.join("kit", "test")
@@ -48,7 +48,7 @@ describe Gjp::Scaffolder do
48
48
  end
49
49
  @project.gather
50
50
 
51
- @scaffolder.scaffold_kit_spec.should be_true
51
+ @scaffolder.generate_kit_spec.should be_true
52
52
 
53
53
  @project.from_directory do
54
54
  spec_lines = File.readlines(File.join("specs", "test-project-kit.spec"))
@@ -59,7 +59,7 @@ describe Gjp::Scaffolder do
59
59
  end
60
60
  end
61
61
  it "scaffolds a conflicting version" do
62
- @scaffolder.scaffold_kit_spec.should be_true
62
+ @scaffolder.generate_kit_spec.should be_true
63
63
  @project.dry_run
64
64
  Dir.chdir(@project_path) do
65
65
  test_file = File.join("kit", "test")
@@ -76,7 +76,7 @@ describe Gjp::Scaffolder do
76
76
  end
77
77
  @project.gather
78
78
 
79
- @scaffolder.scaffold_kit_spec.should be_true
79
+ @scaffolder.generate_kit_spec.should be_true
80
80
 
81
81
  @project.from_directory do
82
82
  spec_lines = File.readlines(File.join("specs", "test-project-kit.spec"))
@@ -86,9 +86,41 @@ describe Gjp::Scaffolder do
86
86
  spec_lines.should_not include("Version: #{`git rev-parse --short #{@project.latest_tag(:dry_run_finished)}`}")
87
87
  end
88
88
  end
89
- it "returns error if the phase is incorrect" do
90
- @project.dry_run
91
- @scaffolder.scaffold_kit_spec.should be_false
89
+ end
90
+
91
+ describe "#generate_package_spec" do
92
+ it "scaffolds the first version" do
93
+
94
+ @project.from_directory do
95
+ FileUtils.mkdir_p File.join("src", "test", "out")
96
+ (1..5).each do |i|
97
+ `touch src/test/test#{i}.java`
98
+ end
99
+ @project.dry_run
100
+
101
+ (1..5).each do |i|
102
+ `touch src/test/test#{i}.class`
103
+ end
104
+
105
+ (1..5).each do |i|
106
+ `touch src/test/out/test#{i}.jar`
107
+ end
108
+
109
+ @project.finish
110
+ end
111
+
112
+ @scaffolder.generate_package_spec "test", File.join("spec", "data", "nailgun", "pom.xml"), "*.jar"
113
+
114
+ @project.from_directory do
115
+ spec_lines = File.readlines(File.join("specs", "test.spec"))
116
+ spec_lines.should include("Name: test\n")
117
+ spec_lines.should include("License: The Apache Software License, Version 2.0\n")
118
+ spec_lines.should include("Summary: Nailgun is a client, protocol, and server for running Java...\n")
119
+ spec_lines.should include("Url: http://martiansoftware.com/nailgun\n")
120
+ spec_lines.should include("BuildRequires: #{@project.name}-kit\n")
121
+ spec_lines.should include("Provides: mvn(com.martiansoftware:nailgun-all) == 0.9.1\n")
122
+ spec_lines.should include("cp -a out/test3.jar %{buildroot}%{_javadir}/test3.jar\n")
123
+ end
92
124
  end
93
125
  end
94
126
  end
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.14.1
4
+ version: 0.15.7
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-09-02 00:00:00.000000000 Z
12
+ date: 2013-10-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -163,6 +163,7 @@ files:
163
163
  - lib/gjp/logger.rb
164
164
  - lib/gjp/maven_runner.rb
165
165
  - lib/gjp/maven_website.rb
166
+ - lib/gjp/package_spec_adapter.rb
166
167
  - lib/gjp/parent_pom_getter.rb
167
168
  - lib/gjp/pom.rb
168
169
  - lib/gjp/pom_getter.rb
@@ -177,7 +178,9 @@ files:
177
178
  - lib/template/file_lists/CONTENTS
178
179
  - lib/template/kit.spec
179
180
  - lib/template/kit/CONTENTS
181
+ - lib/template/kit/README.SUSE
180
182
  - lib/template/kit/m2/settings.xml
183
+ - lib/template/package.spec
181
184
  - lib/template/specs/CONTENTS
182
185
  - lib/template/src/CONTENTS
183
186
  - spec/data/ant-super-simple-code/build.xml