From 064d8a392ba36f2c419dcdcbd14b4bc5c26341fb Mon Sep 17 00:00:00 2001 From: Steven Rowe Date: Fri, 26 Oct 2012 19:39:31 +0000 Subject: [PATCH] LUCENE-4476: stage-maven-artifacts: prompt for credentials by default, rather than reading from settings.xml; and stop requiring (grand-)parent POMs' presence in the maven local repository git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1402630 13f79535-47bb-0310-9956-ffa450edef68 --- .../scripts/write.stage.maven.build.xml.pl | 94 +++++++++++++++---- lucene/common-build.xml | 40 ++++---- 2 files changed, 97 insertions(+), 37 deletions(-) diff --git a/dev-tools/scripts/write.stage.maven.build.xml.pl b/dev-tools/scripts/write.stage.maven.build.xml.pl index 4c780d97e63..c5e8aa851ff 100755 --- a/dev-tools/scripts/write.stage.maven.build.xml.pl +++ b/dev-tools/scripts/write.stage.maven.build.xml.pl @@ -12,6 +12,10 @@ # 2. The pathname of the Ant build script to be built. # 3. The pathname of common-build.xml, which will be imported # in the Ant build script to be built. +# 4. Whether to prompt for credentials, rather than consulting +# settings.xml: boolean, e.g. "true" or "false" +# 5. The ID of the target repository +# 6. The URL to the target repository # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -33,33 +37,72 @@ use strict; use warnings; use File::Basename; use File::Find; +use Cwd 'abs_path'; use File::Path qw(make_path); my $num_artifacts = 0; -my $maven_dist_dir = $ARGV[0]; +my $maven_dist_dir = abs_path($ARGV[0]); my $output_build_xml_file = $ARGV[1]; my $common_build_xml = $ARGV[2]; +my $m2_credentials_prompt = $ARGV[3]; +my $m2_repository_id = $ARGV[4]; +my $m2_repository_url = $ARGV[5]; if ($^O eq 'cygwin') { # Make sure Cygwin Perl can find the output path $output_build_xml_file = `cygpath -u "$output_build_xml_file"`; $output_build_xml_file =~ s/\s+$//; # Trim trailing whitespace $output_build_xml_file =~ s/^\s+//; # Trim leading whitespace } my ($output_file, $output_dir) = fileparse($output_build_xml_file); + +my @basepaths = (); +my $grandparent_pom = ''; +my @parent_poms = (); +sub find_poms; +File::Find::find({follow => 1, wanted => \&find_poms}, $maven_dist_dir); + +my $parent_pom_targets = ''; +if (@parent_poms) { + $parent_pom_targets = "\n"; + if ($grandparent_pom) { + $parent_pom_targets .= qq! \n!; + } + my $n = 0; + for my $parent_pom (@parent_poms) { + $parent_pom_targets .= qq! \n!; + ++$n; + } + $parent_pom_targets .= " \n"; +} + make_path($output_dir); open my $output_build_xml, ">$output_build_xml_file" or die "ERROR opening '$ARGV[1]' for writing: $!"; print $output_build_xml qq! - + !; -sub wanted; +my $credentials = ''; +if ($m2_credentials_prompt !~ /\A(?s:f(?:alse)?|no?)\z/) { + print $output_build_xml qq! + + WARNING: ON SOME PLATFORMS YOUR PASSPHRASE WILL BE ECHOED BACK\!\!\!\!\! + + + \n!; -File::Find::find({follow => 1, wanted => \&wanted}, $maven_dist_dir); + $credentials = q! + + !; +} + +for my $basepath (@basepaths) { + output_deploy_stanza($basepath); +} print $output_build_xml q! @@ -72,7 +115,7 @@ close $output_build_xml; print "Wrote '$output_build_xml_file' to stage $num_artifacts Maven artifacts.\n"; exit; -sub wanted { +sub find_poms { /^(.*)\.pom\z/s && do { my $pom_dir = $File::Find::dir; if ($^O eq 'cygwin') { # Output windows-style paths on Windows @@ -83,21 +126,36 @@ sub wanted { my $basefile = $_; $basefile =~ s/\.pom\z//; my $basepath = "$pom_dir/$basefile"; - my $pom_file = "$basepath.pom"; - my $jar_file = "$basepath.jar"; - my $war_file = "$basepath.war"; + push @basepaths, $basepath; - if (-f $war_file) { - print $output_build_xml qq! + if ($basefile =~ /grandparent/) { + $grandparent_pom = "$basepath.pom"; + } elsif ($basefile =~ /parent/) { + push @parent_poms, "$basepath.pom"; + } + } +} + +sub output_deploy_stanza { + my $basepath = shift; + my $pom_file = "$basepath.pom"; + my $jar_file = "$basepath.jar"; + my $war_file = "$basepath.war"; + + if (-f $war_file) { + print $output_build_xml qq! + $parent_pom_targets + $credentials \n!; - } elsif (-f $jar_file) { - print $output_build_xml qq! + } elsif (-f $jar_file) { + print $output_build_xml qq! + $parent_pom_targets @@ -106,16 +164,18 @@ sub wanted { + $credentials \n!; - } else { - print $output_build_xml qq! + } else { + print $output_build_xml qq! + $parent_pom_targets + $credentials \n!; - } + } - ++$num_artifacts; - }; + ++$num_artifacts; } diff --git a/lucene/common-build.xml b/lucene/common-build.xml index dbf8f911d1f..d1fd0f080b4 100644 --- a/lucene/common-build.xml +++ b/lucene/common-build.xml @@ -181,6 +181,7 @@ + @@ -458,37 +459,24 @@ + + + - + + + - - - - - - - - - - - - - - - - - - @@ -1391,14 +1379,25 @@ ${tests-output}/junit4-*.suites - per-JVM executed suites - + + + + + + + + + + + Invoking target stage-maven in ${output.build.xml} now... @@ -1808,6 +1807,7 @@ ${tests-output}/junit4-*.suites - per-JVM executed suites + WARNING: ON SOME PLATFORMS YOUR PASSPHRASE WILL BE ECHOED BACK!!!!!