You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2010/10/08 19:44:19 UTC
svn commit: r1005922 - in /db/derby/code/trunk: build.xml buildrelease
java/build/org/apache/derbyPreBuild/PropertyPrompt.java
Author: rhillegas
Date: Fri Oct 8 17:44:18 2010
New Revision: 1005922
URL: http://svn.apache.org/viewvc?rev=1005922&view=rev
Log:
DERBY-2573: Move credentials prompting into the master release target.
Added:
db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertyPrompt.java (with props)
Modified:
db/derby/code/trunk/build.xml
db/derby/code/trunk/buildrelease
Modified: db/derby/code/trunk/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/build.xml?rev=1005922&r1=1005921&r2=1005922&view=diff
==============================================================================
--- db/derby/code/trunk/build.xml (original)
+++ db/derby/code/trunk/build.xml Fri Oct 8 17:44:18 2010
@@ -524,6 +524,7 @@
</target>
<target name="prebuild">
+ <mkdir dir="${out.dir}"/>
<ant dir="${derby.build.src.dir}/org/apache/derbyPreBuild"/>
</target>
@@ -2456,7 +2457,8 @@ you should not have to do this.
</target>
<!-- do most of the ant calls to prepare a release -->
- <target name="prepareforrelease" depends="checkdocsroot,checkpgppassphrase,checksvncredentials,checkstateremoved,checksanenotset,cleanalljars,cleandocs,clobber,cleanreleasefiles">
+ <target name="prepareforrelease" depends="checkdocsroot,promptforreleaseproperties,checkstateremoved,checksanenotset,cleanalljars,cleandocs,clobber,cleanreleasefiles">
+
<!-- other possible checks? maybe no checked out files? -->
<!-- maybe try to force a doc build? call to ant release will check for docs out -->
<!-- assume svn update has been done to the desired level -->
@@ -2498,6 +2500,40 @@ you should not have to do this.
<antcall target="cleanstate"/>
</target>
+ <!--
+ Prompt for release-building inputs if they were not specified in properties already
+
+ This target must be called in a dependency list rather than via antcall. That is
+ because properties set in dependent targets percolate back up to the caller.
+ Properties set in antcalled targets are wiped out when you return to the caller.
+
+ Sneaky, very, very sneaky.
+ -->
+ <target name="promptforreleaseproperties" depends="prebuild">
+
+ <taskdef
+ name="promptForProperty"
+ classname="org.apache.derbyPreBuild.PropertyPrompt"
+ classpath="${out.dir}"
+ />
+
+ <promptForProperty
+ propertyName="svn.username"
+ prompt="Enter your Apache subversion username > "
+ />
+
+ <promptForProperty
+ propertyName="svn.password"
+ prompt="Enter your Apache subversion password > "
+ />
+
+ <promptForProperty
+ propertyName="pgp.passphrase"
+ prompt="Enter your pgp passphrase > "
+ />
+
+ </target>
+
<target name="checkstateremoved" depends="state.exists">
<fail message="Cannot build a release; please remove java/engine/state.properties by running ant cleanstate (or run ant clobber)">
<condition>
@@ -2521,31 +2557,6 @@ you should not have to do this.
</fail>
</target>
- <target name="checksvncredentials">
- <!-- make sure that subversion credentials are set -->
- <fail message="Cannot build a release; svn.username and/or svn.password are not set. These are the credentials you use to commit work to the Apache repositories.">
- <condition>
- <not>
- <and>
- <isset property="svn.username"/>
- <isset property="svn.password"/>
- </and>
- </not>
- </condition>
- </fail>
- </target>
-
- <target name="checkpgppassphrase">
- <!-- make sure that signature credentials are set -->
- <fail message="Cannot build a release; pgp.passphrase is not set. This is the passphrase needed to sign release artifacts.">
- <condition>
- <not>
- <isset property="pgp.passphrase"/>
- </not>
- </condition>
- </fail>
- </target>
-
<target name="checksanenotset">
<!-- check that sane is *not* set elsewhere, e.g. $HOME/ant.properties -->
<echo level="info" message="sane : ${sane}"/>
@@ -2563,4 +2574,6 @@ you should not have to do this.
<target name="cleanalljars">
<delete dir="${jarsdist.dir}"/>
</target>
+
+
</project>
Modified: db/derby/code/trunk/buildrelease
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/buildrelease?rev=1005922&r1=1005921&r2=1005922&view=diff
==============================================================================
--- db/derby/code/trunk/buildrelease (original)
+++ db/derby/code/trunk/buildrelease Fri Oct 8 17:44:18 2010
@@ -38,15 +38,10 @@ export docLib=$DOCS_ROOT/lib
export CLASSPATH=$docLib/fop.jar:$docLib/avalon-framework-cvs-20020806.jar:$docLib/batik.jar
export ANT_OPTS="-Xmx512m"
-
-read -p "Enter your Apache subversion username > " subversionUserName
-read -p "Enter your Apache subversion password > " subversionPassword
-read -p "Enter your pgp passphrase > " pgpPassphrase
-
###############################################################
#
echo Building release distributions...
#
###############################################################
-ant "-Ddocs.root=$DOCS_ROOT" "-Dpgp.passphrase=$pgpPassphrase" "-Dsvn.username=$subversionUserName" "-Dsvn.password=$subversionPassword" -quiet release
+ant "-Ddocs.root=$DOCS_ROOT" -quiet release
Added: db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertyPrompt.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertyPrompt.java?rev=1005922&view=auto
==============================================================================
--- db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertyPrompt.java (added)
+++ db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertyPrompt.java Fri Oct 8 17:44:18 2010
@@ -0,0 +1,158 @@
+/*
+
+ Derby - Class org.apache.derbyPreBuild.PropertyPrompt
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+package org.apache.derbyPreBuild;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.util.Hashtable;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.PropertyHelper;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Property;
+
+/**
+ * <p>
+ * This is an ant Task which prompts the user for a property's value
+ * and sets it if the property hasn't been set already.
+ * </p>
+ */
+public class PropertyPrompt extends Task
+{
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // CONSTANTS
+ //
+ /////////////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // STATE
+ //
+ /////////////////////////////////////////////////////////////////////////
+
+ private String _propertyName;
+ private String _prompt;
+
+ private Hashtable _propertiesSnapshot;
+
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // CONSTRUCTORS
+ //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * <p>
+ * Let Ant conjure us out of thin air.
+ * </p>
+ */
+ public PropertyPrompt() {}
+
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // Task BEHAVIOR
+ //
+ /////////////////////////////////////////////////////////////////////////
+
+
+ /** <p>Let Ant set the name of the property.</p>*/
+ public void setPropertyName( String propertyName ) { _propertyName = propertyName; }
+
+ /** <p>Let Ant set the prompt to be used in case the property isn't set.</p>*/
+ public void setPrompt( String prompt ) { _prompt = prompt; }
+
+ /**
+ * <p>
+ * Prompt for and set a property if it isn't already set.
+ * </p>
+ */
+ public void execute()
+ throws BuildException
+ {
+ _propertiesSnapshot = PropertyHelper.getPropertyHelper( getProject() ).getProperties();
+
+ if ( _propertiesSnapshot.get( _propertyName ) == null ) { promptAndSet(); }
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // MINIONS
+ //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * <p>
+ * Prompt for and set the property.
+ * </p>
+ */
+ private void promptAndSet()
+ throws BuildException
+ {
+ try {
+ String value = promptForInput( _prompt );
+
+ setProperty( _propertyName, value );
+
+ } catch (Exception e)
+ {
+ throw new BuildException( "Error prompting and setting property " + _propertyName + ": " + e.getMessage() );
+ }
+
+ }
+
+ /**
+ * <p>
+ * Prompt the user for a line of input.
+ * </p>
+ */
+ private String promptForInput( String promptString )
+ throws IOException
+ {
+ log( promptString, Project.MSG_WARN );
+
+ BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
+
+ return br.readLine();
+ }
+
+ /**
+ * <p>
+ * Set an ant property.
+ * </p>
+ */
+ private void setProperty( String name, String value )
+ throws BuildException
+ {
+ Property property = new Property();
+
+ property.setName( name );
+ property.setValue( value );
+
+ property.setProject( getProject() );
+ property.execute();
+ }
+
+}
+
Propchange: db/derby/code/trunk/java/build/org/apache/derbyPreBuild/PropertyPrompt.java
------------------------------------------------------------------------------
svn:eol-style = native