mirror of https://github.com/apache/lucene.git
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
This commit is contained in:
parent
42f27adc1a
commit
064d8a392b
|
@ -12,6 +12,10 @@
|
||||||
# 2. The pathname of the Ant build script to be built.
|
# 2. The pathname of the Ant build script to be built.
|
||||||
# 3. The pathname of common-build.xml, which will be imported
|
# 3. The pathname of common-build.xml, which will be imported
|
||||||
# in the Ant build script to be built.
|
# 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
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
# contributor license agreements. See the NOTICE file distributed with
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
@ -33,33 +37,72 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
use File::Find;
|
use File::Find;
|
||||||
|
use Cwd 'abs_path';
|
||||||
use File::Path qw(make_path);
|
use File::Path qw(make_path);
|
||||||
|
|
||||||
my $num_artifacts = 0;
|
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 $output_build_xml_file = $ARGV[1];
|
||||||
my $common_build_xml = $ARGV[2];
|
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
|
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 = `cygpath -u "$output_build_xml_file"`;
|
||||||
$output_build_xml_file =~ s/\s+$//; # Trim trailing whitespace
|
$output_build_xml_file =~ s/\s+$//; # Trim trailing whitespace
|
||||||
$output_build_xml_file =~ s/^\s+//; # Trim leading whitespace
|
$output_build_xml_file =~ s/^\s+//; # Trim leading whitespace
|
||||||
}
|
}
|
||||||
my ($output_file, $output_dir) = fileparse($output_build_xml_file);
|
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 = "<parent-poms>\n";
|
||||||
|
if ($grandparent_pom) {
|
||||||
|
$parent_pom_targets .= qq! <artifact:pom id="grandparent" file="$grandparent_pom"/>\n!;
|
||||||
|
}
|
||||||
|
my $n = 0;
|
||||||
|
for my $parent_pom (@parent_poms) {
|
||||||
|
$parent_pom_targets .= qq! <artifact:pom id="parent.$n" file="$parent_pom"/>\n!;
|
||||||
|
++$n;
|
||||||
|
}
|
||||||
|
$parent_pom_targets .= " </parent-poms>\n";
|
||||||
|
}
|
||||||
|
|
||||||
make_path($output_dir);
|
make_path($output_dir);
|
||||||
open my $output_build_xml, ">$output_build_xml_file"
|
open my $output_build_xml, ">$output_build_xml_file"
|
||||||
or die "ERROR opening '$ARGV[1]' for writing: $!";
|
or die "ERROR opening '$ARGV[1]' for writing: $!";
|
||||||
|
|
||||||
print $output_build_xml qq!<?xml version="1.0"?>
|
print $output_build_xml qq!<?xml version="1.0"?>
|
||||||
<project>
|
<project xmlns:artifact="antlib:org.apache.maven.artifact.ant">
|
||||||
<import file="${common_build_xml}"/>
|
<import file="${common_build_xml}"/>
|
||||||
|
|
||||||
<target name="stage-maven" depends="install-maven-tasks">
|
<target name="stage-maven" depends="install-maven-tasks">
|
||||||
<sequential>
|
<sequential>
|
||||||
!;
|
!;
|
||||||
|
|
||||||
sub wanted;
|
my $credentials = '';
|
||||||
|
if ($m2_credentials_prompt !~ /\A(?s:f(?:alse)?|no?)\z/) {
|
||||||
|
print $output_build_xml qq!
|
||||||
|
<input message="Enter $m2_repository_id username: >" addproperty="m2.repository.username"/>
|
||||||
|
<echo>WARNING: ON SOME PLATFORMS YOUR PASSPHRASE WILL BE ECHOED BACK\!\!\!\!\!</echo>
|
||||||
|
<input message="Enter $m2_repository_id password: >" addproperty="m2.repository.password">
|
||||||
|
<handler type="secure"/>
|
||||||
|
</input>\n!;
|
||||||
|
|
||||||
File::Find::find({follow => 1, wanted => \&wanted}, $maven_dist_dir);
|
$credentials = q!<credentials>
|
||||||
|
<authentication username="${m2.repository.username}" password="${m2.repository.password}"/>
|
||||||
|
</credentials>!;
|
||||||
|
}
|
||||||
|
|
||||||
|
for my $basepath (@basepaths) {
|
||||||
|
output_deploy_stanza($basepath);
|
||||||
|
}
|
||||||
|
|
||||||
print $output_build_xml q!
|
print $output_build_xml q!
|
||||||
</sequential>
|
</sequential>
|
||||||
|
@ -72,7 +115,7 @@ close $output_build_xml;
|
||||||
print "Wrote '$output_build_xml_file' to stage $num_artifacts Maven artifacts.\n";
|
print "Wrote '$output_build_xml_file' to stage $num_artifacts Maven artifacts.\n";
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
sub wanted {
|
sub find_poms {
|
||||||
/^(.*)\.pom\z/s && do {
|
/^(.*)\.pom\z/s && do {
|
||||||
my $pom_dir = $File::Find::dir;
|
my $pom_dir = $File::Find::dir;
|
||||||
if ($^O eq 'cygwin') { # Output windows-style paths on Windows
|
if ($^O eq 'cygwin') { # Output windows-style paths on Windows
|
||||||
|
@ -83,6 +126,18 @@ sub wanted {
|
||||||
my $basefile = $_;
|
my $basefile = $_;
|
||||||
$basefile =~ s/\.pom\z//;
|
$basefile =~ s/\.pom\z//;
|
||||||
my $basepath = "$pom_dir/$basefile";
|
my $basepath = "$pom_dir/$basefile";
|
||||||
|
push @basepaths, $basepath;
|
||||||
|
|
||||||
|
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 $pom_file = "$basepath.pom";
|
||||||
my $jar_file = "$basepath.jar";
|
my $jar_file = "$basepath.jar";
|
||||||
my $war_file = "$basepath.war";
|
my $war_file = "$basepath.war";
|
||||||
|
@ -90,14 +145,17 @@ sub wanted {
|
||||||
if (-f $war_file) {
|
if (-f $war_file) {
|
||||||
print $output_build_xml qq!
|
print $output_build_xml qq!
|
||||||
<m2-deploy pom.xml="${pom_file}" jar.file="${war_file}">
|
<m2-deploy pom.xml="${pom_file}" jar.file="${war_file}">
|
||||||
|
$parent_pom_targets
|
||||||
<artifact-attachments>
|
<artifact-attachments>
|
||||||
<attach file="${pom_file}.asc" type="pom.asc"/>
|
<attach file="${pom_file}.asc" type="pom.asc"/>
|
||||||
<attach file="${war_file}.asc" type="war.asc"/>
|
<attach file="${war_file}.asc" type="war.asc"/>
|
||||||
</artifact-attachments>
|
</artifact-attachments>
|
||||||
|
$credentials
|
||||||
</m2-deploy>\n!;
|
</m2-deploy>\n!;
|
||||||
} elsif (-f $jar_file) {
|
} elsif (-f $jar_file) {
|
||||||
print $output_build_xml qq!
|
print $output_build_xml qq!
|
||||||
<m2-deploy pom.xml="${pom_file}" jar.file="${jar_file}">
|
<m2-deploy pom.xml="${pom_file}" jar.file="${jar_file}">
|
||||||
|
$parent_pom_targets
|
||||||
<artifact-attachments>
|
<artifact-attachments>
|
||||||
<attach file="${basepath}-sources.jar" classifier="sources"/>
|
<attach file="${basepath}-sources.jar" classifier="sources"/>
|
||||||
<attach file="${basepath}-javadoc.jar" classifier="javadoc"/>
|
<attach file="${basepath}-javadoc.jar" classifier="javadoc"/>
|
||||||
|
@ -106,16 +164,18 @@ sub wanted {
|
||||||
<attach file="${basepath}-sources.jar.asc" classifier="sources" type="jar.asc"/>
|
<attach file="${basepath}-sources.jar.asc" classifier="sources" type="jar.asc"/>
|
||||||
<attach file="${basepath}-javadoc.jar.asc" classifier="javadoc" type="jar.asc"/>
|
<attach file="${basepath}-javadoc.jar.asc" classifier="javadoc" type="jar.asc"/>
|
||||||
</artifact-attachments>
|
</artifact-attachments>
|
||||||
|
$credentials
|
||||||
</m2-deploy>\n!;
|
</m2-deploy>\n!;
|
||||||
} else {
|
} else {
|
||||||
print $output_build_xml qq!
|
print $output_build_xml qq!
|
||||||
<m2-deploy pom.xml="${pom_file}">
|
<m2-deploy pom.xml="${pom_file}">
|
||||||
|
$parent_pom_targets
|
||||||
<artifact-attachments>
|
<artifact-attachments>
|
||||||
<attach file="${pom_file}.asc" type="pom.asc"/>
|
<attach file="${pom_file}.asc" type="pom.asc"/>
|
||||||
</artifact-attachments>
|
</artifact-attachments>
|
||||||
|
$credentials
|
||||||
</m2-deploy>\n!;
|
</m2-deploy>\n!;
|
||||||
}
|
}
|
||||||
|
|
||||||
++$num_artifacts;
|
++$num_artifacts;
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,6 +181,7 @@
|
||||||
<makeurl file="${maven.dist.dir}" property="m2.repository.url" validate="false"/>
|
<makeurl file="${maven.dist.dir}" property="m2.repository.url" validate="false"/>
|
||||||
<property name="m2.repository.private.key" value="${user.home}/.ssh/id_dsa"/>
|
<property name="m2.repository.private.key" value="${user.home}/.ssh/id_dsa"/>
|
||||||
<property name="m2.repository.id" value="local"/>
|
<property name="m2.repository.id" value="local"/>
|
||||||
|
<property name="m2.credentials.prompt" value="true"/>
|
||||||
|
|
||||||
<property name="jflex.home" location="${common.dir}"/>
|
<property name="jflex.home" location="${common.dir}"/>
|
||||||
|
|
||||||
|
@ -458,32 +459,19 @@
|
||||||
|
|
||||||
<macrodef name="m2-deploy" description="Builds a Maven artifact">
|
<macrodef name="m2-deploy" description="Builds a Maven artifact">
|
||||||
<element name="artifact-attachments" optional="yes"/>
|
<element name="artifact-attachments" optional="yes"/>
|
||||||
|
<element name="parent-poms" optional="yes"/>
|
||||||
|
<element name="credentials" optional="yes"/>
|
||||||
<attribute name="pom.xml"/>
|
<attribute name="pom.xml"/>
|
||||||
<attribute name="jar.file" default="${build.dir}/${final.name}.jar"/>
|
<attribute name="jar.file" default="${build.dir}/${final.name}.jar"/>
|
||||||
<sequential>
|
<sequential>
|
||||||
<artifact:install-provider artifactId="wagon-ssh" version="1.0-beta-7"/>
|
<artifact:install-provider artifactId="wagon-ssh" version="1.0-beta-7"/>
|
||||||
|
<parent-poms/>
|
||||||
<artifact:pom id="maven.project" file="@{pom.xml}"/>
|
<artifact:pom id="maven.project" file="@{pom.xml}"/>
|
||||||
<artifact:deploy file="@{jar.file}">
|
<artifact:deploy file="@{jar.file}">
|
||||||
<artifact-attachments/>
|
<artifact-attachments/>
|
||||||
<remoteRepository id="${m2.repository.id}" url="${m2.repository.url}"/>
|
<remoteRepository id="${m2.repository.id}" url="${m2.repository.url}">
|
||||||
<pom refid="maven.project"/>
|
<credentials/>
|
||||||
</artifact:deploy>
|
</remoteRepository>
|
||||||
</sequential>
|
|
||||||
</macrodef>
|
|
||||||
|
|
||||||
<macrodef name="m2-deploy-with-pom-template" description="Builds a Maven artifact given a POM template">
|
|
||||||
<attribute name="pom.xml"/>
|
|
||||||
<attribute name="jar.file"/>
|
|
||||||
<sequential>
|
|
||||||
<copy file="@{pom.xml}" tofile="${maven.build.dir}/pom.xml" overwrite="true">
|
|
||||||
<filterset begintoken="@" endtoken="@">
|
|
||||||
<filter token="version" value="${version}"/>
|
|
||||||
</filterset>
|
|
||||||
</copy>
|
|
||||||
<artifact:install-provider artifactId="wagon-ssh" version="1.0-beta-7"/>
|
|
||||||
<artifact:pom id="maven.project" file="${maven.build.dir}/pom.xml" />
|
|
||||||
<artifact:deploy file="@{jar.file}">
|
|
||||||
<remoteRepository id="${m2.repository.id}" url="${m2.repository.url}"/>
|
|
||||||
<pom refid="maven.project"/>
|
<pom refid="maven.project"/>
|
||||||
</artifact:deploy>
|
</artifact:deploy>
|
||||||
</sequential>
|
</sequential>
|
||||||
|
@ -1391,14 +1379,25 @@ ${tests-output}/junit4-*.suites - per-JVM executed suites
|
||||||
<sequential>
|
<sequential>
|
||||||
<property name="output.build.xml" location="${build.dir}/stage_maven_build.xml"/>
|
<property name="output.build.xml" location="${build.dir}/stage_maven_build.xml"/>
|
||||||
<property name="dev-tools.scripts.dir" value="../dev-tools/scripts"/>
|
<property name="dev-tools.scripts.dir" value="../dev-tools/scripts"/>
|
||||||
<exec dir="." executable="${perl.exe}" failonerror="true" outputproperty="stage.maven.script.output">
|
<exec dir="." executable="${perl.exe}" failonerror="false" outputproperty="stage.maven.script.output"
|
||||||
|
resultproperty="stage.maven.script.success">
|
||||||
<arg value="-CSD"/>
|
<arg value="-CSD"/>
|
||||||
<arg value="${dev-tools.scripts.dir}/write.stage.maven.build.xml.pl"/>
|
<arg value="${dev-tools.scripts.dir}/write.stage.maven.build.xml.pl"/>
|
||||||
<arg value="${maven.dist.dir}"/> <!-- Maven distribution artifacts directory -->
|
<arg value="${maven.dist.dir}"/> <!-- Maven distribution artifacts directory -->
|
||||||
<arg value="${output.build.xml}"/> <!-- Ant build file to be written -->
|
<arg value="${output.build.xml}"/> <!-- Ant build file to be written -->
|
||||||
<arg value="${common.dir}/common-build.xml"/> <!-- Imported from the ant file to be written -->
|
<arg value="${common.dir}/common-build.xml"/> <!-- Imported from the ant file to be written -->
|
||||||
|
<arg value="${m2.credentials.prompt}"/>
|
||||||
|
<arg value="${m2.repository.id}"/>
|
||||||
|
<arg value="${m2.repository.url}"/>
|
||||||
</exec>
|
</exec>
|
||||||
<echo message="${stage.maven.script.output}"/>
|
<echo message="${stage.maven.script.output}"/>
|
||||||
|
<fail message="maven stage script failed!">
|
||||||
|
<condition>
|
||||||
|
<not>
|
||||||
|
<equals arg1="${stage.maven.script.success}" arg2="0"/>
|
||||||
|
</not>
|
||||||
|
</condition>
|
||||||
|
</fail>
|
||||||
</sequential>
|
</sequential>
|
||||||
<echo>Invoking target stage-maven in ${output.build.xml} now...</echo>
|
<echo>Invoking target stage-maven in ${output.build.xml} now...</echo>
|
||||||
<ant target="stage-maven" antfile="${output.build.xml}" inheritall="false">
|
<ant target="stage-maven" antfile="${output.build.xml}" inheritall="false">
|
||||||
|
@ -1808,6 +1807,7 @@ ${tests-output}/junit4-*.suites - per-JVM executed suites
|
||||||
<available property="gpg.input.handler" classname="org.apache.tools.ant.input.SecureInputHandler"
|
<available property="gpg.input.handler" classname="org.apache.tools.ant.input.SecureInputHandler"
|
||||||
value="org.apache.tools.ant.input.SecureInputHandler"/>
|
value="org.apache.tools.ant.input.SecureInputHandler"/>
|
||||||
<!--else:--><property name="gpg.input.handler" value="org.apache.tools.ant.input.DefaultInputHandler"/>
|
<!--else:--><property name="gpg.input.handler" value="org.apache.tools.ant.input.DefaultInputHandler"/>
|
||||||
|
<echo>WARNING: ON SOME PLATFORMS YOUR PASSPHRASE WILL BE ECHOED BACK!!!!!</echo>
|
||||||
<input message="Enter GPG keystore password: >" addproperty="gpg.passphrase">
|
<input message="Enter GPG keystore password: >" addproperty="gpg.passphrase">
|
||||||
<handler classname="${gpg.input.handler}" />
|
<handler classname="${gpg.input.handler}" />
|
||||||
</input>
|
</input>
|
||||||
|
|
Loading…
Reference in New Issue