@@ -92,15 +92,13 @@ task '//java/test/org/openqa/selenium/environment/webserver:webserver:uber' => [
9292 '//java/test/org/openqa/selenium/environment:webserver'
9393]
9494
95- # Java targets required for release. These should all be java_export targets.
96- # Generated from: bazel query 'kind(maven_publish, set(//java/... //third_party/...))' | sort
95+ # use #java_release_targets to access this list
9796JAVA_RELEASE_TARGETS = %w[
9897 //java/src/org/openqa/selenium/chrome:chrome.publish
9998 //java/src/org/openqa/selenium/chromium:chromium.publish
100- //java/src/org/openqa/selenium/devtools/v131:v131 .publish
99+ //java/src/org/openqa/selenium/devtools/v134:v134 .publish
101100 //java/src/org/openqa/selenium/devtools/v132:v132.publish
102101 //java/src/org/openqa/selenium/devtools/v133:v133.publish
103- //java/src/org/openqa/selenium/devtools/v85:v85.publish
104102 //java/src/org/openqa/selenium/edge:edge.publish
105103 //java/src/org/openqa/selenium/firefox:firefox.publish
106104 //java/src/org/openqa/selenium/grid/sessionmap/jdbc:jdbc.publish
@@ -120,6 +118,34 @@ JAVA_RELEASE_TARGETS = %w[
120118 //java/src/org/openqa/selenium:core.publish
121119] . freeze
122120
121+ def java_release_targets
122+ @targets_verified ||= verify_java_release_targets
123+
124+ JAVA_RELEASE_TARGETS
125+ end
126+
127+ def verify_java_release_targets
128+ query = 'kind(maven_publish, set(//java/... //third_party/...))'
129+ current_targets = [ ]
130+
131+ Bazel . execute ( 'query' , [ ] , query ) do |output |
132+ current_targets = output . lines . map ( &:strip ) . reject ( &:empty? ) . select { |line | line . start_with? ( '//' ) }
133+ end
134+
135+ missing_targets = current_targets - JAVA_RELEASE_TARGETS
136+ extra_targets = JAVA_RELEASE_TARGETS - current_targets
137+
138+ return if missing_targets . empty? && extra_targets . empty?
139+
140+ error_message = 'Java release targets are out of sync with Bazel query results.'
141+
142+ error_message += "\n Missing targets: #{ missing_targets . join ( ', ' ) } " unless missing_targets . empty?
143+
144+ error_message += "\n Obsolete targets: #{ extra_targets . join ( ', ' ) } " unless extra_targets . empty?
145+
146+ raise error_message
147+ end
148+
123149# Notice that because we're using rake, anything you can do in a normal rake
124150# build can also be done here. For example, here we set the default task
125151task default : [ :grid ]
364390
365391desc 'Install jars to local m2 directory'
366392task :'maven-install' do
367- JAVA_RELEASE_TARGETS . each do |p |
393+ java_release_targets . each do |p |
368394 Bazel . execute ( 'run' ,
369395 [ '--stamp' ,
370396 '--define' ,
@@ -826,7 +852,7 @@ namespace :java do
826852 desc 'Build Java Client Jars'
827853 task :build do |_task , arguments |
828854 args = arguments . to_a . compact
829- JAVA_RELEASE_TARGETS . each { |target | Bazel . execute ( 'build' , args , target ) }
855+ java_release_targets . each { |target | Bazel . execute ( 'build' , args , target ) }
830856 end
831857
832858 desc 'Build Grid Server'
@@ -873,7 +899,7 @@ namespace :java do
873899 Rake ::Task [ 'java:package' ] . invoke ( '--config=release' )
874900 Rake ::Task [ 'java:build' ] . invoke ( '--config=release' )
875901 # Because we want to `run` things, we can't use the `release` config
876- JAVA_RELEASE_TARGETS . each { |target | Bazel . execute ( 'run' , [ '--config=release' ] , target ) }
902+ java_release_targets . each { |target | Bazel . execute ( 'run' , [ '--config=release' ] , target ) }
877903 end
878904
879905 desc 'Install jars to local m2 directory'
@@ -894,22 +920,19 @@ namespace :java do
894920
895921 file_path = 'MODULE.bazel'
896922 content = File . read ( file_path )
897- # For some reason ./go wrapper is not outputting from Open3, so cannot use Bazel class directly
898- output = `bazel run @maven//:outdated`
899-
900- output . scan ( /\S + \[ \S +-alpha\] / ) . each do |match |
901- puts "WARNING — Cannot automatically update alpha version of: #{ match } "
923+ output = nil
924+ Bazel . execute ( 'run' , [ ] , '@maven//:outdated' ) do |out |
925+ output = out
902926 end
903927
904928 versions = output . scan ( /(\S +) \[ \S + -> (\S +)\] / ) . to_h
905929 versions . each do |artifact , version |
906930 if artifact . match? ( 'graphql' )
931+ # https://github.com/graphql-java/graphql-java/discussions/3187
907932 puts 'WARNING — Cannot automatically update graphql'
908933 next
909934 end
910-
911- replacement = artifact . include? ( 'googlejavaformat' ) ? "#{ artifact } :jar:#{ version } " : "#{ artifact } :#{ version } "
912- content . gsub! ( /#{ artifact } :(jar:)?\d +\. \d +[^\\ "]+/ , replacement )
935+ content . sub! ( /#{ Regexp . escape ( artifact ) } :([\d .-]+(?:[-.]?[A-Za-z0-9]+)*)/ , "#{ artifact } :#{ version } " )
913936 end
914937 File . write ( file_path , content )
915938
@@ -1087,34 +1110,38 @@ namespace :all do
10871110 commit! ( 'Update selenium manager version' , [ 'common/selenium_manager.bzl' ] )
10881111
10891112 Rake ::Task [ 'java:update' ] . invoke
1090- commit! ( 'Update Maven Dependencies' , [ 'java/maven_deps.bzl ' , 'java/maven_install.json' ] )
1113+ commit! ( 'Update Maven Dependencies' , [ 'MODULE.bazel ' , 'java/maven_install.json' ] )
10911114
10921115 Rake ::Task [ 'authors' ] . invoke
10931116 commit! ( 'Update authors file' , [ 'AUTHORS' ] )
10941117
10951118 # Note that this does not include Rust version changes that are handled in separate rake:version task
10961119 # TODO: These files are all defined in other tasks; remove duplication
10971120 Rake ::Task [ 'all:version' ] . invoke ( version )
1098- commit! ( "FIX CHANGELOGS BEFORE MERGING!\n \n Update versions and change logs to release Selenium #{ java_version } " ,
1099- [ 'dotnet/CHANGELOG' ,
1100- 'dotnet/selenium-dotnet-version.bzl' ,
1101- 'java/CHANGELOG' ,
1121+ commit! ( "Update Version in all bindings to #{ java_version } " ,
1122+ [ 'dotnet/selenium-dotnet-version.bzl' ,
11021123 'java/version.bzl' ,
1103- 'javascript/node/selenium-webdriver/CHANGES.md ' ,
1124+ 'javascript/node/selenium-webdriver/BUILD.bazel ' ,
11041125 'javascript/node/selenium-webdriver/package.json' ,
11051126 'py/docs/source/conf.py' ,
1127+ 'py/pyproject.toml' ,
11061128 'py/selenium/__init__.py' ,
11071129 'py/selenium/webdriver/__init__.py' ,
11081130 'py/BUILD.bazel' ,
1109- 'py/CHANGES' ,
11101131 'rb/lib/selenium/webdriver/version.rb' ,
1111- 'rb/CHANGES' ,
11121132 'rb/Gemfile.lock' ,
1113- 'rust/CHANGELOG.md' ,
11141133 'rust/BUILD.bazel' ,
11151134 'rust/Cargo.Bazel.lock' ,
11161135 'rust/Cargo.toml' ,
11171136 'rust/Cargo.lock' ] )
1137+
1138+ commit! ( "FIX CHANGELOGS BEFORE MERGING! #{ java_version } " ,
1139+ [ 'dotnet/CHANGELOG' ,
1140+ 'java/CHANGELOG' ,
1141+ 'javascript/node/selenium-webdriver/CHANGES.md' ,
1142+ 'py/CHANGES' ,
1143+ 'rb/CHANGES' ,
1144+ 'rust/CHANGELOG.md' ] )
11181145 end
11191146
11201147 desc 'Update all versions'
@@ -1191,16 +1218,25 @@ end
11911218
11921219def update_changelog ( version , language , path , changelog , header )
11931220 tag = previous_tag ( version , language )
1194- log = if language == 'javascript'
1195- `git --no-pager log #{ tag } ...HEAD --pretty=format:"- %s" --reverse #{ path } `
1196- else
1197- `git --no-pager log #{ tag } ...HEAD --pretty=format:"* %s" --reverse #{ path } `
1198- end
1199- commits = log . split ( '>>>' ) . map { |entry |
1200- lines = entry . split ( "\n " )
1201- lines . reject! { |line | line . match? ( /^(----|Co-authored|Signed-off)/ ) || line . empty? }
1202- lines . join ( "\n " )
1203- } . join ( "\n >>>" )
1221+ bullet = language == 'javascript' ? '- ' : '* '
1222+ commit_delimiter = '===DELIM==='
1223+ tags_to_remove = /\[ (dotnet|rb|py|java|js|rust)\] :?\s ?/
1224+
1225+ command = "git --no-pager log #{ tag } ...HEAD --pretty=format:\" %s%n%b#{ commit_delimiter } \" --reverse #{ path } "
1226+ puts "Executing git command: #{ command } "
1227+
1228+ log = `#{ command } `
1229+
1230+ commits = log . split ( commit_delimiter ) . map { |commit |
1231+ lines = commit . gsub ( tags_to_remove , '' ) . strip . lines . map ( &:chomp )
1232+ subject = "#{ bullet } #{ lines [ 0 ] } "
1233+
1234+ body = lines [ 1 ..]
1235+ . reject { |line | line . match? ( /^(----|Co-authored|Signed-off)/ ) || line . empty? }
1236+ . map { |line | " > #{ line } " }
1237+ . join ( "\n " )
1238+ body . empty? ? subject : "#{ subject } \n #{ body } "
1239+ } . join ( "\n " )
12041240
12051241 File . open ( changelog , 'r+' ) do |file |
12061242 new_content = "#{ header } \n #{ commits } \n \n #{ file . read } "
0 commit comments