realityforge-buildr 1.5.11 → 1.5.16
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.
- checksums.yaml +4 -4
- data/addon/buildr/api_diff_tool.rb +77 -0
- data/addon/buildr/checkstyle.rb +1 -1
- data/addon/buildr/release_tool.rb +279 -0
- data/addon/buildr/shade.rb +1 -21
- data/lib/buildr.rb +1 -0
- data/lib/buildr/ide/idea.rb +34 -27
- data/lib/buildr/java/commands.rb +1 -1
- data/lib/buildr/java/publish.rb +262 -0
- data/lib/buildr/packaging/artifact.rb +2 -3
- data/lib/buildr/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bb76fb200fe200d5778bc6b4122991ccbea6825da382f688dd07afa06b4305d
|
4
|
+
data.tar.gz: ba1bf6ce47d21b286c346bd9561d0191e93997041ba99fc36240ade14f58e421
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60f9fa50cec1fe1c4a6a806cf8687443963e36891000c0addeb2694204c6950933cde7fe28eb1d9df019207a3e9c380c8df8964858c8bafe6d36300808040289
|
7
|
+
data.tar.gz: 5890f8221a6f8cb2a8e1462cb1d1b88f0f95df67f37a75eb85c37eb173b450a99b02d2d811b9d84035b7cecabc59bd9e1e5e73486cf3e72069922db739a1243e
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Buildr
|
2
|
+
class ApiDiffTool
|
3
|
+
class << self
|
4
|
+
def generate_differences_report(artifact_coordinate, old_version, new_version, new_file, output_file, options = {})
|
5
|
+
revapi = Buildr.artifact('org.realityforge.revapi.diff:revapi-diff:jar:all:0.08')
|
6
|
+
revapi.invoke
|
7
|
+
|
8
|
+
old_artifact = Buildr.artifact("#{artifact_coordinate}:#{old_version}")
|
9
|
+
old_artifact.invoke
|
10
|
+
|
11
|
+
unless new_file
|
12
|
+
new_artifact = Buildr.artifact("#{artifact_coordinate}:#{new_version}")
|
13
|
+
new_artifact.invoke
|
14
|
+
new_file = new_artifact.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
FileUtils.mkdir_p File.dirname(output_file)
|
18
|
+
|
19
|
+
args = []
|
20
|
+
args << Java::Commands.path_to_bin('java')
|
21
|
+
args << '-jar'
|
22
|
+
args << revapi.to_s
|
23
|
+
args << '--old-api'
|
24
|
+
args << "#{artifact_coordinate}:#{old_version}::#{old_artifact.to_s}"
|
25
|
+
if options[:support_libs]
|
26
|
+
options[:support_libs].each do |lib|
|
27
|
+
args << '--old-api-support'
|
28
|
+
args << lib.to_s
|
29
|
+
end
|
30
|
+
end
|
31
|
+
args << '--new-api'
|
32
|
+
args << "#{artifact_coordinate}:#{new_version}::#{new_file}"
|
33
|
+
if options[:support_libs]
|
34
|
+
options[:support_libs].each do |lib|
|
35
|
+
args << '--new-api-support'
|
36
|
+
args << lib.to_s
|
37
|
+
end
|
38
|
+
end
|
39
|
+
args << '--output-file'
|
40
|
+
args << output_file.to_s
|
41
|
+
|
42
|
+
sh args.join(' ')
|
43
|
+
if File.exist?(output_file)
|
44
|
+
data = JSON.parse(IO.read(output_file, :encoding => 'UTF-8'))
|
45
|
+
FileUtils.rm_f output_file if data.empty?
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def update_differences_report(artifact_coordinate, old_version, new_version, new_file, output_directory, options = {})
|
50
|
+
output_file = "#{output_directory}/#{old_version}-#{new_version}.json"
|
51
|
+
generate_differences_report(artifact_coordinate, old_version, new_version, new_file, output_file, options)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_differences_report(artifact_coordinate, old_version, new_version, new_file, output_directory, options = {})
|
55
|
+
report_file = "#{output_directory}/#{old_version}-#{new_version}.json"
|
56
|
+
tmp = nil
|
57
|
+
begin
|
58
|
+
tmp = Tempfile.open("#{old_version}-#{new_version}.json")
|
59
|
+
tmp.close
|
60
|
+
generate_differences_report(artifact_coordinate, old_version, new_version, new_file, tmp.path, options)
|
61
|
+
|
62
|
+
report_content = File.exist?(report_file) ? IO.read(report_file, :encoding => 'UTF-8') : ''
|
63
|
+
test_content = File.exist?(tmp.path) ? IO.read(tmp.path, :encoding => 'UTF-8') : ''
|
64
|
+
if report_content != test_content
|
65
|
+
if File.exist?(report_file)
|
66
|
+
raise "Differences report at #{report_file} does not record the correct set differences between #{old_version} and #{new_version} for #{artifact_coordinate}"
|
67
|
+
else
|
68
|
+
raise "No differences report at #{report_file} but differences exist between #{old_version} and #{new_version} for #{artifact_coordinate}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
ensure
|
72
|
+
tmp.close unless tmp.nil?
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/addon/buildr/checkstyle.rb
CHANGED
@@ -220,7 +220,7 @@ module Buildr
|
|
220
220
|
project.task('checkstyle:xml') do
|
221
221
|
puts 'Checkstyle: Analyzing source code...'
|
222
222
|
mkdir_p File.dirname(project.checkstyle.xml_output_file)
|
223
|
-
source_paths = project.checkstyle.complete_source_paths.select{|p| !p.start_with?(project._(:generated).to_s)}
|
223
|
+
source_paths = project.checkstyle.complete_source_paths.select{|p| !p.start_with?(project._(:target, :generated).to_s)}
|
224
224
|
source_paths = source_paths.collect{|p|::Buildr::Util.relative_path(File.expand_path(p.to_s), project.base_dir)}
|
225
225
|
Buildr::Checkstyle.checkstyle(project.checkstyle.configuration_file,
|
226
226
|
project.checkstyle.format,
|
@@ -0,0 +1,279 @@
|
|
1
|
+
#
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
+
# you may not use this file except in compliance with the License.
|
4
|
+
# You may obtain a copy of the License at
|
5
|
+
#
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
#
|
14
|
+
|
15
|
+
module Buildr
|
16
|
+
class ReleaseTool
|
17
|
+
class << self
|
18
|
+
def define_release_task(options = {})
|
19
|
+
task_name = options[:task_name] || 'perform_release'
|
20
|
+
description = options[:description] || 'Perform a release'
|
21
|
+
workspace_dir = options[:workspace_dir] || File.dirname(Buildr.application.buildfile.to_s)
|
22
|
+
|
23
|
+
ENV['PREVIOUS_PRODUCT_VERSION'] = nil if ENV['PREVIOUS_PRODUCT_VERSION'].to_s == ''
|
24
|
+
ENV['PRODUCT_VERSION'] = nil if ENV['PRODUCT_VERSION'].to_s == ''
|
25
|
+
|
26
|
+
desc description
|
27
|
+
task task_name do
|
28
|
+
in_dir(workspace_dir) do
|
29
|
+
yield ReleaseTool.new
|
30
|
+
end
|
31
|
+
if ENV['STAGE']
|
32
|
+
if ENV['LAST_STAGE'] == ENV['STAGE']
|
33
|
+
puts "LAST_STAGE specified '#{ENV['LAST_STAGE']}', later stages were skipped"
|
34
|
+
else
|
35
|
+
raise "Invalid STAGE specified '#{ENV['STAGE']}' that did not match any stage"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def derive_versions_from_changelog(options = {})
|
42
|
+
ENV['PREVIOUS_PRODUCT_VERSION'] ||= IO.read('CHANGELOG.md')[/^### \[v(\d+\.\d+(\.\d+)?)\]/, 1] || '0.00'
|
43
|
+
ENV['PRODUCT_VERSION'] ||= derive_next_version(ENV['PREVIOUS_PRODUCT_VERSION'], options)
|
44
|
+
end
|
45
|
+
|
46
|
+
def derive_next_version(current_version, options = {})
|
47
|
+
return options[:next_version_action].call(current_version) if options[:next_version_action]
|
48
|
+
version_parts = current_version.split('.')
|
49
|
+
"#{version_parts[0]}.#{sprintf('%02d', version_parts[1].to_i + 1)}#{version_parts.length > 2 ? ".#{version_parts[2]}" : ''}"
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def in_dir(dir)
|
55
|
+
current = Dir.pwd
|
56
|
+
begin
|
57
|
+
Dir.chdir(dir)
|
58
|
+
yield
|
59
|
+
ensure
|
60
|
+
Dir.chdir(current)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def extract_version_from_changelog(options = {})
|
66
|
+
stage('ExtractVersion', 'Extract the last version from CHANGELOG.md and derive next version unless specified', :always_run => true) do
|
67
|
+
Buildr::ReleaseTool.derive_versions_from_changelog(options)
|
68
|
+
# Also initialize release date if required
|
69
|
+
ENV['RELEASE_DATE'] ||= Time.now.strftime('%Y-%m-%d')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def zapwhite
|
74
|
+
stage('ZapWhite', 'Ensure that zapwhite produces no changes') do
|
75
|
+
sh 'bundle exec zapwhite'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def ensure_git_clean
|
80
|
+
stage('GitClean', 'Ensure there is nothing to commit and the working tree is clean') do
|
81
|
+
status_output = `git status -s 2>&1`.strip
|
82
|
+
raise 'Uncommitted changes in git repository. Please commit them prior to release.' if 0 != status_output.size
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def verify_no_todo
|
87
|
+
stage('TodoScan', 'Verify that there are no TODO notes in codebase') do
|
88
|
+
task('todos:scan').invoke
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def cleanup_staging
|
93
|
+
stage('StagingCleanup', 'Remove artifacts from staging repository') do
|
94
|
+
task('staging:cleanup').invoke
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def build(options = {})
|
99
|
+
additional_tasks = options[:additional_tasks] || ''
|
100
|
+
stage('Build', 'Build the project to ensure that the tests pass') do
|
101
|
+
sh "bundle exec buildr clean package #{additional_tasks} install PRODUCT_VERSION=#{ENV['PRODUCT_VERSION']}#{ENV['TEST'].nil? ? '' : " TEST=#{ENV['TEST']}"}#{Buildr.application.options.trace ? ' --trace' : ''}"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def patch_changelog(repository_name, options = {})
|
106
|
+
stage('PatchChangelog', 'Patch the changelog to update from previous release') do
|
107
|
+
changelog = IO.read('CHANGELOG.md')
|
108
|
+
from = '0.00' == ENV['PREVIOUS_PRODUCT_VERSION'] ? `git rev-list --max-parents=0 HEAD`.strip : "v#{ENV['PREVIOUS_PRODUCT_VERSION']}"
|
109
|
+
|
110
|
+
header = "### [v#{ENV['PRODUCT_VERSION']}](https://github.com/#{repository_name}/tree/v#{ENV['PRODUCT_VERSION']}) (#{ENV['RELEASE_DATE']}) · [Full Changelog](https://github.com/spritz/spritz/compare/#{from}...v#{ENV['PRODUCT_VERSION']})"
|
111
|
+
|
112
|
+
sub_header_text = ''
|
113
|
+
|
114
|
+
api_diff_directory = options[:api_diff_directory]
|
115
|
+
api_diff_filename = api_diff_directory ? "#{api_diff_directory}/#{ENV['PREVIOUS_PRODUCT_VERSION']}-#{ENV['PRODUCT_VERSION']}.json" : nil
|
116
|
+
if api_diff_filename && File.exist?(api_diff_filename)
|
117
|
+
|
118
|
+
api_diff_site = options[:api_diff_website]
|
119
|
+
if api_diff_site
|
120
|
+
header += " · [API Differences](#{api_diff_site}old=#{ENV['PREVIOUS_PRODUCT_VERSION']}&new=#{ENV['PRODUCT_VERSION']})"
|
121
|
+
end
|
122
|
+
|
123
|
+
changes = JSON.parse(IO.read(api_diff_filename))
|
124
|
+
non_breaking_changes = changes.select { |j| j['classification']['SOURCE'] == 'NON_BREAKING' }.size
|
125
|
+
potentially_breaking_changes = changes.select { |j| j['classification']['SOURCE'] == 'POTENTIALLY_BREAKING' }.size
|
126
|
+
breaking_changes = changes.select { |j| j['classification']['SOURCE'] == 'BREAKING' }.size
|
127
|
+
change_descriptions = []
|
128
|
+
change_descriptions << "#{non_breaking_changes} non breaking API change#{1 == non_breaking_changes ? '' : 's'}" unless 0 == non_breaking_changes
|
129
|
+
change_descriptions << "#{potentially_breaking_changes} potentially breaking API change#{1 == potentially_breaking_changes ? '' : 's'}" unless 0 == potentially_breaking_changes
|
130
|
+
change_descriptions << "#{breaking_changes} breaking API change#{1 == breaking_changes ? '' : 's'}" unless 0 == breaking_changes
|
131
|
+
|
132
|
+
if change_descriptions.size > 0
|
133
|
+
description = "The release includes "
|
134
|
+
if 1 == change_descriptions.size
|
135
|
+
description += "#{change_descriptions[0]}"
|
136
|
+
elsif 2 == change_descriptions.size
|
137
|
+
description += "#{change_descriptions[0]} and #{change_descriptions[1]}"
|
138
|
+
else
|
139
|
+
description += "#{change_descriptions[0]}, #{change_descriptions[1]} and #{change_descriptions[2]}"
|
140
|
+
end
|
141
|
+
|
142
|
+
sub_header_text = description
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
header_suffix = options[:header_suffix]
|
147
|
+
header += header_suffix if header_suffix
|
148
|
+
header += "\n\n#{sub_header_text}" unless sub_header_text.empty?
|
149
|
+
header += "\n"
|
150
|
+
|
151
|
+
header += <<CONTENT
|
152
|
+
|
153
|
+
Changes in this release:
|
154
|
+
CONTENT
|
155
|
+
|
156
|
+
IO.write('CHANGELOG.md', changelog.gsub("### Unreleased\n", header))
|
157
|
+
|
158
|
+
sh 'git reset 2>&1 1> /dev/null'
|
159
|
+
sh 'git add CHANGELOG.md'
|
160
|
+
sh 'git commit -m "Update CHANGELOG.md in preparation for release"'
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def patch_maven_version_in_readme
|
165
|
+
stage('PatchReadme', 'Patch the README to update from previous release') do
|
166
|
+
contents = IO.read('README.md')
|
167
|
+
contents = contents.
|
168
|
+
gsub("<version>#{ENV['PREVIOUS_PRODUCT_VERSION']}</version>", "<version>#{ENV['PRODUCT_VERSION']}</version>").
|
169
|
+
gsub("/#{ENV['PREVIOUS_PRODUCT_VERSION']}/", "/#{ENV['PRODUCT_VERSION']}/").
|
170
|
+
gsub("-#{ENV['PREVIOUS_PRODUCT_VERSION']}-", "-#{ENV['PRODUCT_VERSION']}-")
|
171
|
+
IO.write('README.md', contents)
|
172
|
+
|
173
|
+
sh 'git reset 2>&1 1> /dev/null'
|
174
|
+
sh 'git add README.md'
|
175
|
+
sh 'git commit -m "Update README.md in preparation for release"'
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def tag_project
|
180
|
+
stage('TagProject', 'Tag the project') do
|
181
|
+
sh "git tag v#{ENV['PRODUCT_VERSION']}"
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def stage_release(options = {})
|
186
|
+
release_to = options[:release_to] || (raise "StageRelease stage must specify :release_to configuration")
|
187
|
+
stage('StageRelease', 'Stage the release') do
|
188
|
+
IO.write('_buildr.rb', "repositories.release_to = #{release_to.inspect}")
|
189
|
+
sh 'bundle exec buildr clean upload TEST=no GWT=no'
|
190
|
+
sh 'rm -f _buildr.rb'
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def maven_central_publish(options = {})
|
195
|
+
additional_tasks = options[:additional_tasks] || ''
|
196
|
+
stage('MavenCentralPublish', 'Publish artifacts to Maven Central') do
|
197
|
+
sh "bundle exec buildr clean mcrt:publish_if_tagged #{additional_tasks} TEST=no GWT=no"
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def patch_changelog_post_release
|
202
|
+
stage('PatchChangelogPostRelease', 'Patch the changelog post release to prepare for next development iteration') do
|
203
|
+
changelog = IO.read('CHANGELOG.md')
|
204
|
+
changelog = changelog.gsub("# Change Log\n", <<HEADER)
|
205
|
+
# Change Log
|
206
|
+
|
207
|
+
### Unreleased
|
208
|
+
HEADER
|
209
|
+
IO.write('CHANGELOG.md', changelog)
|
210
|
+
|
211
|
+
`bundle exec zapwhite`
|
212
|
+
sh 'git add CHANGELOG.md'
|
213
|
+
sh 'git commit -m "Update CHANGELOG.md in preparation for next development iteration"'
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
def push_changes
|
218
|
+
stage('PushChanges', 'Push changes to git repository') do
|
219
|
+
sh 'git push'
|
220
|
+
sh 'git push --tags'
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def github_release(repository_name)
|
225
|
+
stage('GithubRelease', 'Create a Release on GitHub') do
|
226
|
+
changelog = IO.read('CHANGELOG.md')
|
227
|
+
start = changelog.index("### [v#{ENV['PRODUCT_VERSION']}]")
|
228
|
+
raise "Unable to locate version #{ENV['PRODUCT_VERSION']} in change log" if -1 == start
|
229
|
+
start = changelog.index("\n", start)
|
230
|
+
start = changelog.index("\n", start + 1)
|
231
|
+
|
232
|
+
end_index = changelog.index('### [v', start)
|
233
|
+
end_index = changelog.length if end_index.nil?
|
234
|
+
|
235
|
+
changes = changelog[start, end_index - start]
|
236
|
+
|
237
|
+
changes = changes.strip
|
238
|
+
|
239
|
+
tag = "v#{ENV['PRODUCT_VERSION']}"
|
240
|
+
|
241
|
+
version_parts = ENV['PRODUCT_VERSION'].split('.')
|
242
|
+
prerelease = '0' == version_parts[0]
|
243
|
+
|
244
|
+
require 'octokit'
|
245
|
+
|
246
|
+
client = Octokit::Client.new(:netrc => true, :auto_paginate => true)
|
247
|
+
client.login
|
248
|
+
client.create_release(repository_name, tag, :name => tag, :body => changes, :draft => false, :prerelease => prerelease)
|
249
|
+
|
250
|
+
candidates = client.list_milestones(repository_name).select { |m| m[:title].to_s == tag }
|
251
|
+
unless candidates.empty?
|
252
|
+
milestone = candidates[0]
|
253
|
+
unless milestone[:state] == 'closed'
|
254
|
+
client.update_milestone(repository_name, milestone[:number], :state => 'closed')
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def stage(stage_name, description, options = {})
|
261
|
+
if ENV['STAGE'].nil? || ENV['STAGE'] == stage_name || options[:always_run]
|
262
|
+
puts "🚀 Release Stage: #{stage_name} - #{description}"
|
263
|
+
begin
|
264
|
+
yield
|
265
|
+
rescue Exception => e
|
266
|
+
puts '💣 Error completing stage.'
|
267
|
+
puts "Fix the error and re-run release process passing: STAGE=#{stage_name}#{ ENV['PREVIOUS_PRODUCT_VERSION'] ? " PREVIOUS_PRODUCT_VERSION=#{ENV['PREVIOUS_PRODUCT_VERSION']}" : ''}#{ ENV['PREVIOUS_PRODUCT_VERSION'] ? " PRODUCT_VERSION=#{ENV['PRODUCT_VERSION']}" : ''}"
|
268
|
+
raise e
|
269
|
+
end
|
270
|
+
ENV['STAGE'] = nil unless options[:always_run]
|
271
|
+
elsif !ENV['STAGE'].nil?
|
272
|
+
puts "Skipping Stage: #{stage_name} - #{description}"
|
273
|
+
end
|
274
|
+
if ENV['LAST_STAGE'] == stage_name
|
275
|
+
ENV['STAGE'] = ENV['LAST_STAGE']
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
data/addon/buildr/shade.rb
CHANGED
@@ -15,27 +15,7 @@
|
|
15
15
|
module Buildr
|
16
16
|
# Provides the shade method.
|
17
17
|
module Shade
|
18
|
-
|
19
18
|
class << self
|
20
|
-
|
21
|
-
# The specs for requirements
|
22
|
-
def dependencies
|
23
|
-
%w(
|
24
|
-
net.sourceforge.pmd:pmd-core:jar:6.11.0
|
25
|
-
net.sourceforge.pmd:pmd-java:jar:6.11.0
|
26
|
-
net.sourceforge.pmd:pmd-java8:jar:6.11.0
|
27
|
-
jaxen:jaxen:jar:1.1.6
|
28
|
-
commons-io:commons-io:jar:2.6
|
29
|
-
com.beust:jcommander:jar:1.72
|
30
|
-
org.ow2.asm:asm:jar:7.1
|
31
|
-
com.google.code.gson:gson:jar:2.8.5
|
32
|
-
net.java.dev.javacc:javacc:jar:5.0
|
33
|
-
net.sourceforge.saxon:saxon:jar:9.1.0.8
|
34
|
-
org.apache.commons:commons-lang3:jar:3.8.1
|
35
|
-
org.antlr:antlr4-runtime:jar:4.7
|
36
|
-
)
|
37
|
-
end
|
38
|
-
|
39
19
|
def shade(input_jar, output_jar, relocations = {})
|
40
20
|
|
41
21
|
shaded_jar = (input_jar.to_s + '-shaded')
|
@@ -51,7 +31,7 @@ module Buildr
|
|
51
31
|
args << '--output'
|
52
32
|
args << shaded_jar.to_s
|
53
33
|
relocations.each_pair do |k, v|
|
54
|
-
args << "-r#{k}
|
34
|
+
args << "-r#{k}=#{v}"
|
55
35
|
end
|
56
36
|
|
57
37
|
sh args.join(' ')
|
data/lib/buildr.rb
CHANGED
@@ -50,6 +50,7 @@ require 'buildr/core/test'
|
|
50
50
|
require 'buildr/java/commands'
|
51
51
|
require 'buildr/core/transports'
|
52
52
|
require 'buildr/java/pom'
|
53
|
+
require 'buildr/java/publish'
|
53
54
|
require 'buildr/core/doc'
|
54
55
|
require 'buildr/packaging/version_requirement'
|
55
56
|
require 'buildr/packaging/artifact_namespace'
|
data/lib/buildr/ide/idea.rb
CHANGED
@@ -117,7 +117,7 @@ module Buildr #:nodoc:
|
|
117
117
|
|
118
118
|
def create_component(name, attrs = {})
|
119
119
|
target = StringIO.new
|
120
|
-
Builder::XmlMarkup.new(:target => target, :indent => 2).component({:name => name}.merge(attrs)) do |xml|
|
120
|
+
Builder::XmlMarkup.new(:target => target, :indent => 2).component({ :name => name }.merge(attrs)) do |xml|
|
121
121
|
yield xml if block_given?
|
122
122
|
end
|
123
123
|
Buildr::IntellijIdea.new_document(target.string).root
|
@@ -219,7 +219,7 @@ module Buildr #:nodoc:
|
|
219
219
|
end
|
220
220
|
|
221
221
|
def annotation_paths
|
222
|
-
@annotation_paths ||= [buildr_project._(:source, :main, :annotations)].select {|p| File.exist?(p)}
|
222
|
+
@annotation_paths ||= [buildr_project._(:source, :main, :annotations)].select { |p| File.exist?(p) }
|
223
223
|
end
|
224
224
|
|
225
225
|
def main_source_directories
|
@@ -349,7 +349,7 @@ module Buildr #:nodoc:
|
|
349
349
|
name = options[:name] || 'Web'
|
350
350
|
default_webroots = {}
|
351
351
|
default_webroots[buildr_project._(:source, :main, :webapp)] = '/' if File.exist?(buildr_project._(:source, :main, :webapp))
|
352
|
-
buildr_project.assets.paths.each {|p| default_webroots[p] = '/' }
|
352
|
+
buildr_project.assets.paths.each { |p| default_webroots[p] = '/' }
|
353
353
|
webroots = options[:webroots] || default_webroots
|
354
354
|
default_deployment_descriptors = []
|
355
355
|
%w(web.xml sun-web.xml glassfish-web.xml jetty-web.xml geronimo-web.xml context.xml weblogic.xml jboss-deployment-structure.xml jboss-web.xml ibm-web-bnd.xml ibm-web-ext.xml ibm-web-ext-pme.xml).
|
@@ -375,7 +375,7 @@ module Buildr #:nodoc:
|
|
375
375
|
end
|
376
376
|
end
|
377
377
|
end
|
378
|
-
default_enable_jsf = webroots.keys.any?{|webroot| File.exist?("#{webroot}/WEB-INF/faces-config.xml")}
|
378
|
+
default_enable_jsf = webroots.keys.any? { |webroot| File.exist?("#{webroot}/WEB-INF/faces-config.xml") }
|
379
379
|
enable_jsf = options[:enable_jsf].nil? ? default_enable_jsf : options[:enable_jsf]
|
380
380
|
enable_jsf = false if buildr_project.root_project.ipr? && buildr_project.root_project.ipr.version >= '13'
|
381
381
|
f.facet(:type => 'jsf', :name => 'JSF') do |jsf|
|
@@ -404,8 +404,8 @@ module Buildr #:nodoc:
|
|
404
404
|
provider = options[:provider_enabled]
|
405
405
|
else
|
406
406
|
provider = nil
|
407
|
-
{'org.hibernate.ejb.HibernatePersistence' => 'Hibernate',
|
408
|
-
|
407
|
+
{ 'org.hibernate.ejb.HibernatePersistence' => 'Hibernate',
|
408
|
+
'org.eclipse.persistence.jpa.PersistenceProvider' => 'EclipseLink' }.
|
409
409
|
each_pair do |match, candidate_provider|
|
410
410
|
deployment_descriptors.each do |descriptor|
|
411
411
|
if File.exist?(descriptor) && /#{Regexp.escape(match)}/ =~ IO.read(descriptor)
|
@@ -608,7 +608,7 @@ module Buildr #:nodoc:
|
|
608
608
|
unless paths.empty?
|
609
609
|
xml.tag!('annotation-paths') do |xml|
|
610
610
|
paths.each do |path|
|
611
|
-
xml.root(:url=> file_path(path))
|
611
|
+
xml.root(:url => file_path(path))
|
612
612
|
end
|
613
613
|
end
|
614
614
|
end
|
@@ -618,14 +618,14 @@ module Buildr #:nodoc:
|
|
618
618
|
xml.content(:url => 'file://$MODULE_DIR$') do
|
619
619
|
# Source folders
|
620
620
|
[
|
621
|
-
{:dirs => (self.main_source_directories.dup - self.main_generated_source_directories)},
|
622
|
-
{:dirs => self.main_generated_source_directories, :generated => true},
|
623
|
-
{:type => 'resource', :dirs => (self.main_resource_directories.dup - self.main_generated_resource_directories)},
|
624
|
-
{:type => 'resource', :dirs => self.main_generated_resource_directories, :generated => true},
|
625
|
-
{:test => true, :dirs => (self.test_source_directories - self.test_generated_source_directories)},
|
626
|
-
{:test => true, :dirs => self.test_generated_source_directories, :generated => true},
|
627
|
-
{:test => true, :type => 'resource', :dirs => (self.test_resource_directories - self.test_generated_resource_directories)},
|
628
|
-
{:test => true, :type => 'resource', :dirs => self.test_generated_resource_directories, :generated => true},
|
621
|
+
{ :dirs => (self.main_source_directories.dup - self.main_generated_source_directories) },
|
622
|
+
{ :dirs => self.main_generated_source_directories, :generated => true },
|
623
|
+
{ :type => 'resource', :dirs => (self.main_resource_directories.dup - self.main_generated_resource_directories) },
|
624
|
+
{ :type => 'resource', :dirs => self.main_generated_resource_directories, :generated => true },
|
625
|
+
{ :test => true, :dirs => (self.test_source_directories - self.test_generated_source_directories) },
|
626
|
+
{ :test => true, :dirs => self.test_generated_source_directories, :generated => true },
|
627
|
+
{ :test => true, :type => 'resource', :dirs => (self.test_resource_directories - self.test_generated_resource_directories) },
|
628
|
+
{ :test => true, :type => 'resource', :dirs => self.test_generated_resource_directories, :generated => true },
|
629
629
|
].each do |content|
|
630
630
|
content[:dirs].map { |dir| dir.to_s }.compact.sort.uniq.each do |dir|
|
631
631
|
options = {}
|
@@ -658,14 +658,14 @@ module Buildr #:nodoc:
|
|
658
658
|
end
|
659
659
|
|
660
660
|
def generate_project_dependency(xml, other_project, export, test = false)
|
661
|
-
attribs = {:type => 'module', 'module-name' => other_project}
|
661
|
+
attribs = { :type => 'module', 'module-name' => other_project }
|
662
662
|
attribs[:exported] = '' if export
|
663
663
|
attribs[:scope] = 'TEST' if test
|
664
664
|
xml.orderEntry attribs
|
665
665
|
end
|
666
666
|
|
667
667
|
def generate_module_lib(xml, path, export, source_path, annotations_path, test = false)
|
668
|
-
attribs = {:type => 'module-library'}
|
668
|
+
attribs = { :type => 'module-library' }
|
669
669
|
attribs[:exported] = '' if export
|
670
670
|
attribs[:scope] = 'TEST' if test
|
671
671
|
xml.orderEntry attribs do
|
@@ -691,7 +691,7 @@ module Buildr #:nodoc:
|
|
691
691
|
net = []
|
692
692
|
all = self.excluded_directories.map { |dir| buildr_project._(dir.to_s) }.sort_by { |d| d.size }
|
693
693
|
all.each_with_index do |dir, i|
|
694
|
-
unless all[0
|
694
|
+
unless all[0...i].find { |other| dir =~ /^#{other}/ }
|
695
695
|
net << dir
|
696
696
|
end
|
697
697
|
end
|
@@ -725,6 +725,10 @@ module Buildr #:nodoc:
|
|
725
725
|
@jdk_version ||= buildr_project.compile.options.source || '1.7'
|
726
726
|
end
|
727
727
|
|
728
|
+
def compiler_configuration_options
|
729
|
+
@compiler_configuration_options ||= {}
|
730
|
+
end
|
731
|
+
|
728
732
|
def nonnull_assertions?
|
729
733
|
@nonnull_assertions.nil? ? true : !!@nonnull_assertions
|
730
734
|
end
|
@@ -781,7 +785,7 @@ module Buildr #:nodoc:
|
|
781
785
|
|
782
786
|
def add_postgres_data_source(name, options = {})
|
783
787
|
if options[:url].nil? && options[:database]
|
784
|
-
|
788
|
+
default_url = "jdbc:postgresql://#{(options[:host] || '127.0.0.1')}:#{(options[:port] || '5432')}/#{options[:database]}"
|
785
789
|
end
|
786
790
|
|
787
791
|
params = {
|
@@ -901,7 +905,7 @@ module Buildr #:nodoc:
|
|
901
905
|
}
|
902
906
|
classpath = options[:classpath] || []
|
903
907
|
xml.tag!('data-source', data_source_options) do |xml|
|
904
|
-
xml.tag!('synchronize', (options[:synchronize]||'true'))
|
908
|
+
xml.tag!('synchronize', (options[:synchronize] || 'true'))
|
905
909
|
xml.tag!('jdbc-driver', options[:driver]) if options[:driver]
|
906
910
|
xml.tag!('jdbc-url', options[:url]) if options[:url]
|
907
911
|
xml.tag!('user-name', options[:username]) if options[:username]
|
@@ -1002,7 +1006,7 @@ module Buildr #:nodoc:
|
|
1002
1006
|
end
|
1003
1007
|
end
|
1004
1008
|
|
1005
|
-
def add_exploded_ear_artifact(project, options ={})
|
1009
|
+
def add_exploded_ear_artifact(project, options = {})
|
1006
1010
|
artifact_name = to_artifact_name(project, options)
|
1007
1011
|
|
1008
1012
|
add_artifact(artifact_name, 'exploded-ear', build_on_make(options)) do |xml|
|
@@ -1478,7 +1482,7 @@ module Buildr #:nodoc:
|
|
1478
1482
|
buildr_project.projects.select { |subp| subp.iml? }.each do |subproject|
|
1479
1483
|
module_path = subproject.base_dir.gsub(/^#{buildr_project.base_dir}\//, '')
|
1480
1484
|
path = "#{module_path}/#{subproject.iml.name}.iml"
|
1481
|
-
attribs = {:fileurl => "file://$PROJECT_DIR$/#{path}", :filepath => "$PROJECT_DIR$/#{path}"}
|
1485
|
+
attribs = { :fileurl => "file://$PROJECT_DIR$/#{path}", :filepath => "$PROJECT_DIR$/#{path}" }
|
1482
1486
|
if subproject.iml.group == true
|
1483
1487
|
attribs[:group] = subproject.parent.name.gsub(':', '/')
|
1484
1488
|
elsif !subproject.iml.group.nil?
|
@@ -1528,7 +1532,7 @@ module Buildr #:nodoc:
|
|
1528
1532
|
end
|
1529
1533
|
|
1530
1534
|
def data_sources_component
|
1531
|
-
create_composite_component('DataSourceManagerImpl', {:format => 'xml', :hash => '3208837817'}, self.data_sources)
|
1535
|
+
create_composite_component('DataSourceManagerImpl', { :format => 'xml', :hash => '3208837817' }, self.data_sources)
|
1532
1536
|
end
|
1533
1537
|
|
1534
1538
|
def artifacts_component
|
@@ -1538,6 +1542,9 @@ module Buildr #:nodoc:
|
|
1538
1542
|
def compiler_configuration_component
|
1539
1543
|
lambda do
|
1540
1544
|
create_component('CompilerConfiguration') do |component|
|
1545
|
+
compiler_configuration_options.each_pair do |k, v|
|
1546
|
+
component.option :name => k, :value => v
|
1547
|
+
end
|
1541
1548
|
component.addNotNullAssertions :enabled => 'false' unless nonnull_assertions?
|
1542
1549
|
component.wildcardResourcePatterns do |xml|
|
1543
1550
|
wildcard_resource_patterns.each do |pattern|
|
@@ -1554,8 +1561,8 @@ module Buildr #:nodoc:
|
|
1554
1561
|
disabled = []
|
1555
1562
|
Buildr.projects.each do |prj|
|
1556
1563
|
next unless prj.iml?
|
1557
|
-
main_processor = !!prj.compile.options[:processor] || prj.compile.options[:processor].nil?
|
1558
|
-
test_processor = !!prj.test.compile.options[:processor] || prj.test.compile.options[:processor].nil?
|
1564
|
+
main_processor = !!prj.compile.options[:processor] || (prj.compile.options[:processor].nil? && !(prj.compile.options[:processor_path] || []).empty?)
|
1565
|
+
test_processor = !!prj.test.compile.options[:processor] || (prj.test.compile.options[:processor].nil? && !(prj.test.compile.options[:processor_path] || []).empty?)
|
1559
1566
|
if main_processor || test_processor
|
1560
1567
|
xml.profile(:name => "#{prj.name}", :enabled => true) do
|
1561
1568
|
xml.sourceOutputDir :name => 'generated/processors/main/java' if main_processor
|
@@ -1597,7 +1604,7 @@ module Buildr #:nodoc:
|
|
1597
1604
|
resolve_path_from_base(path, '$PROJECT_DIR$')
|
1598
1605
|
end
|
1599
1606
|
|
1600
|
-
|
1607
|
+
private
|
1601
1608
|
|
1602
1609
|
def default_code_sight_excludes
|
1603
1610
|
%w(
|
@@ -1717,7 +1724,7 @@ module Buildr #:nodoc:
|
|
1717
1724
|
].compact
|
1718
1725
|
|
1719
1726
|
files.each do |ideafile|
|
1720
|
-
module_dir =
|
1727
|
+
module_dir = File.dirname(ideafile.filename)
|
1721
1728
|
idea.enhance do |task|
|
1722
1729
|
mkdir_p module_dir
|
1723
1730
|
info "Writing #{ideafile.filename}"
|
data/lib/buildr/java/commands.rb
CHANGED
@@ -70,7 +70,7 @@ module Java
|
|
70
70
|
paths = cp.map do |c|
|
71
71
|
File.directory?(c) && !c.end_with?('/') ? "#{c}/" : c.to_s
|
72
72
|
end
|
73
|
-
manifest = Buildr::Packaging::Java::Manifest.new([{'Class-Path' => paths.map{|p|
|
73
|
+
manifest = Buildr::Packaging::Java::Manifest.new([{'Class-Path' => paths.map{|p| CGI.escape(p)}.join(" ")}])
|
74
74
|
tjar = Tempfile.new(%w[javacmd .jar])
|
75
75
|
Zip::OutputStream.open(tjar.path) do |zos|
|
76
76
|
zos.put_next_entry('META-INF/MANIFEST.MF')
|
@@ -0,0 +1,262 @@
|
|
1
|
+
#
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
+
# you may not use this file except in compliance with the License.
|
4
|
+
# You may obtain a copy of the License at
|
5
|
+
#
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
#
|
14
|
+
|
15
|
+
require 'net/http'
|
16
|
+
require 'net/https'
|
17
|
+
require 'json'
|
18
|
+
|
19
|
+
module Buildr
|
20
|
+
class MavenCentral
|
21
|
+
class << self
|
22
|
+
def define_publish_tasks(options = {})
|
23
|
+
candidate_branches = options[:branches] || %w(master)
|
24
|
+
desc 'Publish release on maven central'
|
25
|
+
task 'mcrt:publish' do
|
26
|
+
project = options[:project] || Buildr.projects[0].root_project
|
27
|
+
profile_name = options[:profile_name] || (raise ':profile_name not specified when defining tasks')
|
28
|
+
username = options[:username] || (raise ':username name not specified when defining tasks')
|
29
|
+
password = options[:password] || ENV['MAVEN_CENTRAL_PASSWORD'] || (raise "Unable to locate environment variable with name 'MAVEN_CENTRAL_PASSWORD'")
|
30
|
+
MavenCentral.buildr_release(project, profile_name, username, password)
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'Publish release to maven central iff current HEAD is a tag'
|
34
|
+
task 'mcrt:publish_if_tagged' do
|
35
|
+
tag = MavenCentral.get_head_tag_if_any
|
36
|
+
if tag.nil?
|
37
|
+
puts 'Current HEAD is not a tag. Skipping publish step.'
|
38
|
+
else
|
39
|
+
puts "Current HEAD is a tag: #{tag}"
|
40
|
+
if MavenCentral.is_tag_on_candidate_branches?(tag, candidate_branches)
|
41
|
+
task('mcrt:publish').invoke
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_head_tag_if_any
|
48
|
+
version = `git describe --exact-match --tags 2>&1`
|
49
|
+
if 0 == $?.exitstatus && version =~ /^v[0-9]/ && (ENV['TRAVIS_BUILD_ID'].nil? || ENV['TRAVIS_TAG'].to_s != '')
|
50
|
+
version.strip
|
51
|
+
else
|
52
|
+
nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def is_tag_on_branch?(tag, branch)
|
57
|
+
output = `git tag --merged #{branch} 2>&1`
|
58
|
+
tags = output.split
|
59
|
+
tags.include?(tag)
|
60
|
+
end
|
61
|
+
|
62
|
+
def is_tag_on_candidate_branches?(tag, branches)
|
63
|
+
sh 'git fetch origin'
|
64
|
+
branches.each do |branch|
|
65
|
+
if is_tag_on_branch?(tag, branch)
|
66
|
+
puts "Tag #{tag} is on branch: #{branch}"
|
67
|
+
return true
|
68
|
+
elsif is_tag_on_branch?(tag, "origin/#{branch}")
|
69
|
+
puts "Tag #{tag} is on branch: origin/#{branch}"
|
70
|
+
return true
|
71
|
+
else
|
72
|
+
puts "Tag #{tag} is not on branches: #{branch} or origin/#{branch}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
false
|
76
|
+
end
|
77
|
+
|
78
|
+
def buildr_release(project, profile_name, username, password)
|
79
|
+
release_to_url = Buildr.repositories.release_to[:url]
|
80
|
+
release_to_username = Buildr.repositories.release_to[:username]
|
81
|
+
release_to_password = Buildr.repositories.release_to[:password]
|
82
|
+
|
83
|
+
begin
|
84
|
+
Buildr.repositories.release_to[:url] = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
|
85
|
+
Buildr.repositories.release_to[:username] = username
|
86
|
+
Buildr.repositories.release_to[:password] = password
|
87
|
+
|
88
|
+
project.task(':package').invoke
|
89
|
+
|
90
|
+
r = MavenCentral.new
|
91
|
+
r.username = username
|
92
|
+
r.password = password
|
93
|
+
r.user_agent = "Buildr-#{Buildr::VERSION}"
|
94
|
+
while r.get_staging_repositories(profile_name, false).size != 0
|
95
|
+
puts 'Another project currently staging. Waiting for other repository to complete. Please visit the website https://oss.sonatype.org/index.html#stagingRepositories to view the other staging attempts.'
|
96
|
+
sleep 1
|
97
|
+
end
|
98
|
+
puts "Beginning upload to staging repository #{profile_name}"
|
99
|
+
|
100
|
+
project.task(':upload').invoke
|
101
|
+
|
102
|
+
r.release_sole_auto_staging(profile_name)
|
103
|
+
ensure
|
104
|
+
Buildr.repositories.release_to[:url] = release_to_url
|
105
|
+
Buildr.repositories.release_to[:username] = release_to_username
|
106
|
+
Buildr.repositories.release_to[:password] = release_to_password
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
attr_writer :username
|
112
|
+
|
113
|
+
def username
|
114
|
+
@username || (raise 'Username not yet specified')
|
115
|
+
end
|
116
|
+
|
117
|
+
attr_writer :password
|
118
|
+
|
119
|
+
def password
|
120
|
+
@password || (raise 'Password not yet specified')
|
121
|
+
end
|
122
|
+
|
123
|
+
attr_writer :user_agent
|
124
|
+
|
125
|
+
def user_agent
|
126
|
+
@user_agent || "Ruby-#{RUBY_VERSION}"
|
127
|
+
end
|
128
|
+
|
129
|
+
def get_staging_repositories(profile_name, ignore_transitioning_repositories = true)
|
130
|
+
result = get_request('https://oss.sonatype.org/service/local/staging/profile_repositories')
|
131
|
+
result = JSON.parse(result)
|
132
|
+
result['data'].select do |repo|
|
133
|
+
repo['profileName'] == profile_name &&
|
134
|
+
repo['userId'] == self.username &&
|
135
|
+
repo['userAgent'] == self.user_agent &&
|
136
|
+
(!ignore_transitioning_repositories || !repo['transitioning']) &&
|
137
|
+
get_my_ip_addresses.any? { |a| a == repo['ipAddress'] }
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def get_my_ip_addresses
|
142
|
+
addresses = Socket.ip_address_list.collect { |a| a.ip_address.to_s }
|
143
|
+
commands = [
|
144
|
+
"dig +short myip.opendns.com @resolver1.opendns.com",
|
145
|
+
"curl ifconfig.me",
|
146
|
+
"curl icanhazip.com",
|
147
|
+
"curl ipecho.net/plain",
|
148
|
+
"curl ifconfig.co",
|
149
|
+
"dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'\"' '{ print $2 }'"
|
150
|
+
]
|
151
|
+
commands.each do |cmd|
|
152
|
+
begin
|
153
|
+
addresses << `#{cmd}`.strip
|
154
|
+
rescue Exception
|
155
|
+
# ignored
|
156
|
+
end
|
157
|
+
end
|
158
|
+
urls = %w[http://www.myexternalip.com/raw https://diagnostic.opendns.com/myip]
|
159
|
+
urls.each do |url|
|
160
|
+
begin
|
161
|
+
addresses << Net::HTTP.get(URI(url)).strip
|
162
|
+
rescue Exception
|
163
|
+
# ignored
|
164
|
+
end
|
165
|
+
end
|
166
|
+
begin
|
167
|
+
addresses << JSON.parse(Net::HTTP.get(URI('https://api.ipify.org?format=json')))['ip']
|
168
|
+
rescue Exception
|
169
|
+
# ignored
|
170
|
+
end
|
171
|
+
addresses.sort.uniq
|
172
|
+
end
|
173
|
+
|
174
|
+
def close_repository(repository_id, description)
|
175
|
+
post_request('https://oss.sonatype.org/service/local/staging/bulk/close',
|
176
|
+
JSON.pretty_generate('data' => { 'description' => description, 'stagedRepositoryIds' => [repository_id] }))
|
177
|
+
end
|
178
|
+
|
179
|
+
def promote_repository(repository_id, description)
|
180
|
+
post_request('https://oss.sonatype.org/service/local/staging/bulk/promote',
|
181
|
+
JSON.pretty_generate('data' => { 'autoDropAfterRelease' => true,
|
182
|
+
'description' => description,
|
183
|
+
'stagedRepositoryIds' => [repository_id] }))
|
184
|
+
end
|
185
|
+
|
186
|
+
def drop_repository(repository_id, description)
|
187
|
+
post_request('https://oss.sonatype.org/service/local/staging/bulk/drop',
|
188
|
+
JSON.pretty_generate('data' => { 'description' => description, 'stagedRepositoryIds' => [repository_id] }))
|
189
|
+
end
|
190
|
+
|
191
|
+
def release_sole_auto_staging(profile_name)
|
192
|
+
candidates = get_staging_repositories(profile_name)
|
193
|
+
if candidates.empty?
|
194
|
+
raise 'Release process unable to find any staging repositories.'
|
195
|
+
elsif 1 != candidates.size
|
196
|
+
raise 'Release process found multiple staging repositories that could be the release just uploaded. Please visit the website https://oss.sonatype.org/index.html#stagingRepositories and manually complete the release.'
|
197
|
+
else
|
198
|
+
candidate = candidates[0]
|
199
|
+
puts "Requesting close of staging repository #{profile_name}:#{candidate['repositoryId']}"
|
200
|
+
begin
|
201
|
+
close_repository(candidate['repositoryId'], "Closing repository for #{profile_name}")
|
202
|
+
rescue Exception => e
|
203
|
+
puts "#{e.class.name}: #{e.message}"
|
204
|
+
puts e.backtrace.join("\n")
|
205
|
+
raise 'Failed to close repository. It is likely that the release does not conform to Maven Central release requirements. Please visit the website https://oss.sonatype.org/index.html#stagingRepositories and manually complete the release.'
|
206
|
+
end
|
207
|
+
while get_staging_repositories(profile_name).size == 0
|
208
|
+
puts 'Waiting for repository to close...'
|
209
|
+
sleep 1
|
210
|
+
end
|
211
|
+
puts "Requesting promotion of staging repository #{profile_name}:#{candidate['repositoryId']}"
|
212
|
+
begin
|
213
|
+
promote_repository(candidate['repositoryId'], "Promoting repository for #{profile_name}")
|
214
|
+
rescue Exception => e
|
215
|
+
puts "#{e.class.name}: #{e.message}"
|
216
|
+
puts e.backtrace.join("\n")
|
217
|
+
raise 'Failed to promote repository. Please visit the website https://oss.sonatype.org/index.html#stagingRepositories and manually complete the release.'
|
218
|
+
end
|
219
|
+
repositories = get_staging_repositories(profile_name, false)
|
220
|
+
while repositories.size == 1
|
221
|
+
puts 'Waiting for repository to be promoted...'
|
222
|
+
sleep 1
|
223
|
+
if repositories[0]['notifications'] != 0
|
224
|
+
raise 'Failed to promote repository. Please visit the website https://oss.sonatype.org/index.html#stagingRepositories and manually complete the release.'
|
225
|
+
end
|
226
|
+
repositories = get_staging_repositories(profile_name, false)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
private
|
232
|
+
|
233
|
+
def create_http(uri)
|
234
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
235
|
+
http.use_ssl = true
|
236
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
237
|
+
http
|
238
|
+
end
|
239
|
+
|
240
|
+
def setup_standard_request(request)
|
241
|
+
request['Accept'] = 'application/json,application/vnd.siesta-error-v1+json,application/vnd.siesta-validation-errors-v1+json'
|
242
|
+
request.basic_auth(self.username, self.password)
|
243
|
+
request.add_field('User-Agent', self.user_agent)
|
244
|
+
end
|
245
|
+
|
246
|
+
def get_request(url)
|
247
|
+
uri = URI.parse(url)
|
248
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
249
|
+
setup_standard_request(request)
|
250
|
+
create_http(uri).request(request).body
|
251
|
+
end
|
252
|
+
|
253
|
+
def post_request(url, content)
|
254
|
+
uri = URI.parse(url)
|
255
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
256
|
+
setup_standard_request(request)
|
257
|
+
request.add_field('Content-Type', 'application/json')
|
258
|
+
request.body = content
|
259
|
+
create_http(uri).request(request).body
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
@@ -246,9 +246,8 @@ module Buildr #:nodoc:
|
|
246
246
|
# Username/password may be part of URI, or separate entities.
|
247
247
|
uri = URI.parse(upload_to[:url].clone)
|
248
248
|
uri.path = uri.path + '/' unless uri.path[-1] == '/'
|
249
|
-
|
250
|
-
uri.
|
251
|
-
uri.password = URI.encode(upload_to[:password], to_escape) if upload_to[:password]
|
249
|
+
uri.user = CGI.escape(upload_to[:username]) if upload_to[:username]
|
250
|
+
uri.password = CGI.escape(upload_to[:password]) if upload_to[:password]
|
252
251
|
|
253
252
|
path = group.gsub('.', '/') + "/#{id}/#{version}/#{upload_name}"
|
254
253
|
|
data/lib/buildr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: realityforge-buildr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Apache Buildr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- NOTICE
|
183
183
|
- README.md
|
184
184
|
- Rakefile
|
185
|
+
- addon/buildr/api_diff_tool.rb
|
185
186
|
- addon/buildr/checkstyle-report.xsl
|
186
187
|
- addon/buildr/checkstyle.rb
|
187
188
|
- addon/buildr/git_auto_version.rb
|
@@ -189,6 +190,7 @@ files:
|
|
189
190
|
- addon/buildr/gwt.rb
|
190
191
|
- addon/buildr/jacoco.rb
|
191
192
|
- addon/buildr/pmd.rb
|
193
|
+
- addon/buildr/release_tool.rb
|
192
194
|
- addon/buildr/shade.rb
|
193
195
|
- addon/buildr/single_intermediate_layout.rb
|
194
196
|
- addon/buildr/spotbugs.rb
|
@@ -220,6 +222,7 @@ files:
|
|
220
222
|
- lib/buildr/java/doc.rb
|
221
223
|
- lib/buildr/java/packaging.rb
|
222
224
|
- lib/buildr/java/pom.rb
|
225
|
+
- lib/buildr/java/publish.rb
|
223
226
|
- lib/buildr/java/test_result.rb
|
224
227
|
- lib/buildr/java/tests.rb
|
225
228
|
- lib/buildr/packaging/archive.rb
|