@@ -11,8 +11,6 @@ require 'open-uri'
1111require 'git'
1212require 'find'
1313
14- include Rake ::DSL
15-
1614Rake . application . instance_variable_set ( :@name , 'go' )
1715orig_verbose = verbose
1816verbose ( false )
@@ -271,16 +269,13 @@ ie_generator.generate_type_mapping(
271269
272270desc 'Generate Javadocs'
273271task 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' )
277274 out = 'bazel-bin/java/src/org/openqa/selenium/grid/all-javadocs.jar'
278275
279276 cmd = %(cd build/docs/api/java && jar xf "../../../../#{ out } " 2>&1)
280277 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 )
284279
285280 File . open ( 'build/docs/api/java/stylesheet.css' , 'a' ) do |file |
286281 file . write ( <<~STYLE
@@ -341,28 +336,28 @@ end
341336
342337task 'release-java' : %i[ java-release-zip publish-maven ]
343338
339+ # TODO: just set the environment variables that maven is asking for
344340def 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
349344 puts 'Fetching m2 user and pass from environment variables.'
350- user = ENV [ 'SEL_M2_USER' ]
351- pass = ENV [ 'SEL_M2_PASS' ]
352345 return [ user , pass ]
353346 end
347+
348+ puts 'Fetching m2 user and pass from /.m2/settings.xml.'
354349 settings = File . read ( "#{ Dir . home } /.m2/settings.xml" )
355350 found_section = false
356351 settings . each_line do |line |
357352 if !found_section
358353 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 ]
363358 end
359+ break if user && pass
364360 end
365-
366361 [ user , pass ]
367362end
368363
@@ -822,7 +817,9 @@ namespace :dotnet do
822817 api_key = ENV . fetch ( 'GITHUB_TOKEN' , nil )
823818 github_push_url = 'https://nuget.pkg.github.com/seleniumhq/index.json'
824819 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 ( ' ' ) } "
826823 end
827824
828825 [ "./bazel-bin/dotnet/src/webdriver/Selenium.WebDriver.#{ dotnet_version } .nupkg" ,
@@ -1049,7 +1046,7 @@ end
10491046namespace :all do
10501047 desc 'Update all API Documentation'
10511048 task :docs do
1052- FileUtils . rm_rf ( 'build/docs/api' ) if Dir . exist? ( 'build/docs/api' )
1049+ FileUtils . rm_rf ( 'build/docs/api' )
10531050
10541051 Rake ::Task [ 'java:docs' ] . invoke ( true )
10551052 Rake ::Task [ 'py:docs' ] . invoke ( true )
@@ -1222,12 +1219,14 @@ def updated_version(current, desired = nil, nightly = nil)
12221219 end
12231220end
12241221
1222+ # TODO: make this less insane
1223+ # rubocop:disable all
12251224def update_gh_pages
12261225 origin_reference = @git . current_branch
12271226 origin_reference ||= begin
12281227 # This allows updating docs from a tagged commit instead of a branch
12291228 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' ) }
12311230 tag ? tag . name : raise ( StandardError , 'Must be on a tagged commit or at the HEAD of a branch to update API Docs' )
12321231 end
12331232
@@ -1283,6 +1282,7 @@ def update_gh_pages
12831282 @git . checkout ( origin_reference )
12841283 true
12851284end
1285+ # rubocop:disable all
12861286
12871287def restore_git ( origin_reference )
12881288 puts 'Stashing docs changes for gh-pages'
0 commit comments