Skip to content

Commit fd31a5f

Browse files
committed
have Rakefile read ~/.m2/settings.xml for maven credentials, horrible xml parsing but ¯\_(ツ)_/¯ doesn't look like i can use third party gems in our Rakefile
1 parent 02e40f1 commit fd31a5f

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

Rakefile

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,31 @@ task :release => JAVA_RELEASE_TARGETS + [
523523
cp Rake::Task['//java/client/src/org/openqa/selenium:client-combined:zip'].out, "build/dist/selenium-java-#{version}.zip"
524524
end
525525

526+
def read_user_pass_from_m2_settings
527+
settings = File.read(ENV['HOME'] + "/.m2/settings.xml")
528+
found_section = false
529+
user = nil
530+
pass = nil
531+
settings.each_line do |line|
532+
if !found_section
533+
found_section = line.include? "<id>sonatype-nexus-staging</id>"
534+
else
535+
if user == nil and line.include? "<username>"
536+
user = line.split("<username>")[1].split("</")[0]
537+
elsif pass == nil and line.include? "<password>"
538+
pass = line.split("<password>")[1].split("</")[0]
539+
end
540+
end
541+
end
542+
543+
return [user, pass]
544+
end
545+
526546
task :'publish-maven' => JAVA_RELEASE_TARGETS do |t|
527547
t.prerequisites.each do |p|
528548
if JAVA_RELEASE_TARGETS.include?(p)
529-
Buck::buck_cmd.call('publish', ['--remote-repo', 'https://oss.sonatype.org/service/local/staging/deploy/maven2', '--include-source', p])
549+
creds = read_user_pass_from_m2_settings()
550+
Buck::buck_cmd.call('publish', ['--remote-repo', 'https://oss.sonatype.org/service/local/staging/deploy/maven2', '--include-source', '-u', creds[0], '-p', creds[1], p])
530551
end
531552
end
532553
end

0 commit comments

Comments
 (0)