@@ -11,8 +11,6 @@ require 'open-uri'
11
11
require 'git'
12
12
require 'find'
13
13
14
- include Rake ::DSL
15
-
16
14
Rake . application . instance_variable_set ( :@name , 'go' )
17
15
orig_verbose = verbose
18
16
verbose ( false )
@@ -271,16 +269,13 @@ ie_generator.generate_type_mapping(
271
269
272
270
desc 'Generate Javadocs'
273
271
task javadocs : %i[ //java/src/org/openqa/selenium/grid:all-javadocs ] do
274
- rm_rf 'build/docs/api/java'
275
- mkdir_p 'build/docs/api/java'
276
-
272
+ FileUtils . rm_rf ( 'build/docs/api/java' )
273
+ FileUtils . mkdir_p ( 'build/docs/api/java' )
277
274
out = 'bazel-bin/java/src/org/openqa/selenium/grid/all-javadocs.jar'
278
275
279
276
cmd = %(cd build/docs/api/java && jar xf "../../../../#{ out } " 2>&1)
280
277
cmd = cmd . tr ( '/' , '\\' ) . tr ( ':' , ';' ) if SeleniumRake ::Checks . windows?
281
-
282
- ok = system ( cmd )
283
- ok or raise 'could not unpack javadocs'
278
+ raise 'could not unpack javadocs' unless system ( cmd )
284
279
285
280
File . open ( 'build/docs/api/java/stylesheet.css' , 'a' ) do |file |
286
281
file . write ( <<~STYLE
@@ -341,28 +336,28 @@ end
341
336
342
337
task 'release-java' : %i[ java-release-zip publish-maven ]
343
338
339
+ # TODO: just set the environment variables that maven is asking for
344
340
def read_m2_user_pass
345
- # First check env vars, then the settings.xml config inside .m2
346
- user = nil
347
- pass = nil
348
- if ENV [ 'SEL_M2_USER' ] && ENV [ 'SEL_M2_PASS' ]
341
+ user = ENV . fetch ( 'SEL_M2_USER' , nil )
342
+ pass = ENV . fetch ( 'SEL_M2_PASS' , nil )
343
+ if user && pass
349
344
puts 'Fetching m2 user and pass from environment variables.'
350
- user = ENV [ 'SEL_M2_USER' ]
351
- pass = ENV [ 'SEL_M2_PASS' ]
352
345
return [ user , pass ]
353
346
end
347
+
348
+ puts 'Fetching m2 user and pass from /.m2/settings.xml.'
354
349
settings = File . read ( "#{ Dir . home } /.m2/settings.xml" )
355
350
found_section = false
356
351
settings . each_line do |line |
357
352
if !found_section
358
353
found_section = line . include? '<id>sonatype-nexus-staging</id>'
359
- elsif user . nil? && line . include? ( '<username>' )
360
- user = line . split ( ' <username>' ) [ 1 ] . split ( '</' ) [ 0 ]
361
- elsif pass . nil? && line . include? ( '<password>' )
362
- pass = line . split ( ' <password>' ) [ 1 ] . split ( '</' ) [ 0 ]
354
+ elsif line . include? ( '<username>' )
355
+ user = line [ %r{ <username>(.*?)</username>} , 1 ]
356
+ elsif line . include? ( '<password>' )
357
+ pass = line [ %r{ <password>(.*?)</password>} , 1 ]
363
358
end
359
+ break if user && pass
364
360
end
365
-
366
361
[ user , pass ]
367
362
end
368
363
@@ -822,7 +817,9 @@ namespace :dotnet do
822
817
api_key = ENV . fetch ( 'GITHUB_TOKEN' , nil )
823
818
github_push_url = 'https://nuget.pkg.github.com/seleniumhq/index.json'
824
819
push_destination = 'github'
825
- sh "dotnet nuget add source --username seleniumhq --password #{ api_key } --store-password-in-clear-text --name #{ push_destination } #{ github_push_url } "
820
+ flags = [ '--username' , 'seleniumhq' , '--password' , api_key , '--store-password-in-clear-text' , '--name' ,
821
+ push_destination , github_push_url ]
822
+ sh "dotnet nuget add source #{ flags . join ( ' ' ) } "
826
823
end
827
824
828
825
[ "./bazel-bin/dotnet/src/webdriver/Selenium.WebDriver.#{ dotnet_version } .nupkg" ,
@@ -1049,7 +1046,7 @@ end
1049
1046
namespace :all do
1050
1047
desc 'Update all API Documentation'
1051
1048
task :docs do
1052
- FileUtils . rm_rf ( 'build/docs/api' ) if Dir . exist? ( 'build/docs/api' )
1049
+ FileUtils . rm_rf ( 'build/docs/api' )
1053
1050
1054
1051
Rake ::Task [ 'java:docs' ] . invoke ( true )
1055
1052
Rake ::Task [ 'py:docs' ] . invoke ( true )
@@ -1222,12 +1219,14 @@ def updated_version(current, desired = nil, nightly = nil)
1222
1219
end
1223
1220
end
1224
1221
1222
+ # TODO: make this less insane
1223
+ # rubocop:disable all
1225
1224
def update_gh_pages
1226
1225
origin_reference = @git . current_branch
1227
1226
origin_reference ||= begin
1228
1227
# This allows updating docs from a tagged commit instead of a branch
1229
1228
puts 'commit is not at HEAD, checking for matching tag'
1230
- tag = @git . tags . detect { |tag | tag . sha == @git . revparse ( 'HEAD' ) }
1229
+ tag = @git . tags . detect { |t | t . sha == @git . revparse ( 'HEAD' ) }
1231
1230
tag ? tag . name : raise ( StandardError , 'Must be on a tagged commit or at the HEAD of a branch to update API Docs' )
1232
1231
end
1233
1232
@@ -1283,6 +1282,7 @@ def update_gh_pages
1283
1282
@git . checkout ( origin_reference )
1284
1283
true
1285
1284
end
1285
+ # rubocop:disable all
1286
1286
1287
1287
def restore_git ( origin_reference )
1288
1288
puts 'Stashing docs changes for gh-pages'
0 commit comments