rchandia@google.com | 96dc36b | 2011-09-09 17:31:05 +0000 | [diff] [blame] | 1 | source lib-maven-deploy.sh |
| 2 | |
| 3 | function finishAndCleanup () { |
| 4 | if [[ $thereHaveBeenErrors ]]; then |
| 5 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| 6 | echo "WARNING: Errors while deploying files, examine output above." |
| 7 | echo "Leaving intermediate files at:" |
| 8 | echo "$RANDOM_DIR" |
| 9 | for i in dev user servlet |
| 10 | do |
| 11 | echo "$jarExpandDir-${i}" |
| 12 | done |
| 13 | find $pomDir -name pom.xml |
| 14 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| 15 | else |
| 16 | # Clean up |
| 17 | rm -rf $RANDOM_DIR |
| 18 | for i in dev user servlet |
| 19 | do |
| 20 | rm -rf $jarExpandDir-${i} |
| 21 | done |
| 22 | # Remove POMs & ASCs, leaving only templates |
| 23 | find $pomDir -name pom.xml | xargs rm |
| 24 | fi |
| 25 | |
| 26 | } |
| 27 | |
| 28 | function die () { |
| 29 | thereHaveBeenErrors=1 |
| 30 | if [[ "$continueOnErrors" != "y" ]]; then |
| 31 | read -e -p"Error while deploying, ignore errors? (y/N): " -i "N" continueOnErrors |
| 32 | if [[ "$continueOnErrors" != "y" ]]; then |
| 33 | finishAndCleanup |
| 34 | exit 1 |
| 35 | fi |
| 36 | fi |
| 37 | } |
| 38 | |
| 39 | function warnJavaDoc () { |
| 40 | echo "WARNING: Could not deploy JavaDoc for $1. Continuing" |
| 41 | } |
| 42 | |
| 43 | # Appends to COMMIT_MESSAGE |
| 44 | function maven-gwt() { |
| 45 | local gwtMavenVersion=$1 |
| 46 | shift |
| 47 | local gwtSdkArchive=$1 |
| 48 | shift |
rchandia@google.com | 96dc36b | 2011-09-09 17:31:05 +0000 | [diff] [blame] | 49 | local mavenRepoUrl=$1 |
| 50 | shift |
| 51 | local mavenRepoId=$1 |
| 52 | shift |
| 53 | |
| 54 | if [[ "$mavenRepoUrl" == "" ]]; then |
| 55 | echo "ERROR: Incorrect parameters to maven-gwt" |
| 56 | exit 1 |
| 57 | fi |
| 58 | |
| 59 | if [[ "$mavenRepoId" == "" ]]; then |
| 60 | if [[ "`expr match $mavenRepoUrl "file://"`" == 0 ]]; then |
| 61 | echo "ERROR: maven-gwt: mavenRepoId is not specified, and the mavenRepoUrl is not local (does not start with file://)" |
| 62 | exit 1 |
| 63 | fi |
| 64 | # set a dummy repo id |
| 65 | mavenRepoId=local |
| 66 | fi |
| 67 | |
| 68 | set-random-dir |
| 69 | echo "Unzipping $gwtSdkArchive to $RANDOM_DIR" |
| 70 | unzip -q $gwtSdkArchive -d $RANDOM_DIR || exit 1 |
| 71 | |
| 72 | GWT_EXTRACT_DIR=`ls $RANDOM_DIR | tail -n1` |
| 73 | GWT_EXTRACT_DIR=$RANDOM_DIR/$GWT_EXTRACT_DIR |
| 74 | |
| 75 | JAVADOC_FILE_PATH=$RANDOM_DIR/gwt-javadoc.jar |
| 76 | jar cf $JAVADOC_FILE_PATH -C $GWT_EXTRACT_DIR/doc/javadoc . |
| 77 | |
| 78 | jarExpandDir=/tmp/tmp-jar-expand-dir-$RANDOM |
| 79 | |
| 80 | # Generate POMs with correct version |
| 81 | for template in `find $pomDir -name pom-template.xml` |
| 82 | do |
| 83 | dir=`dirname $template` |
| 84 | pushd $dir > /dev/null |
| 85 | sed "s|\${gwtVersion}|$gwtMavenVersion|g" pom-template.xml >pom.xml |
| 86 | popd > /dev/null |
| 87 | done |
| 88 | |
| 89 | # Remove bundled org/json classes from Request Factory jars |
| 90 | for i in server client |
| 91 | do |
| 92 | echo "Removing org.json classes from requestfactory-${i}" |
| 93 | zip -d $GWT_EXTRACT_DIR/requestfactory-${i}.jar org/json/* |
| 94 | done |
| 95 | |
| 96 | for i in dev user servlet |
| 97 | do |
| 98 | CUR_FILE=`ls $GWT_EXTRACT_DIR/gwt-${i}.jar` |
| 99 | |
| 100 | # Get rid of the INDEX.LIST file, since it's going to be out of date |
| 101 | # once we rename the jar files for Maven |
rchandia@google.com | b345264 | 2011-09-12 14:14:08 +0000 | [diff] [blame] | 102 | echo "Removing INDEX.LIST from gwt-${i}" |
rchandia@google.com | 96dc36b | 2011-09-09 17:31:05 +0000 | [diff] [blame] | 103 | zip -d $CUR_FILE META-INF/INDEX.LIST |
| 104 | |
| 105 | SOURCES_FILE=gwt-${i}-sources.jar |
| 106 | curExpandDir=$jarExpandDir-${i} |
| 107 | |
| 108 | rm -rf $curExpandDir |
| 109 | mkdir -p $curExpandDir |
| 110 | unzip -q $CUR_FILE -d $curExpandDir |
| 111 | chmod -R ugo+rwx $curExpandDir |
| 112 | pushd $curExpandDir > /dev/null |
| 113 | |
| 114 | rm -rf javafilelist |
| 115 | find . -name "*.java" -print > javafilelist |
| 116 | if [ -s javafilelist ]; then |
| 117 | jar cf $SOURCES_FILE @javafilelist |
| 118 | fi |
| 119 | popd > /dev/null |
| 120 | done |
| 121 | |
| 122 | # push parent poms |
| 123 | maven-deploy-file $mavenRepoUrl $mavenRepoId $pomDir/gwt/pom.xml $pomDir/gwt/pom.xml |
| 124 | |
| 125 | for i in dev user servlet |
| 126 | do |
| 127 | CUR_FILE=`ls $GWT_EXTRACT_DIR/gwt-${i}.jar` |
| 128 | gwtPomFile=$pomDir/gwt/gwt-$i/pom.xml |
| 129 | maven-deploy-file $mavenRepoUrl $mavenRepoId "$CUR_FILE" $gwtPomFile || die |
| 130 | maven-deploy-file $mavenRepoUrl $mavenRepoId "$JAVADOC_FILE_PATH" $gwtPomFile javadoc || warnJavaDoc "gwt-${i}" |
| 131 | |
| 132 | SOURCES_FILE=gwt-${i}-sources.jar |
| 133 | curExpandDir=$jarExpandDir-${i} |
| 134 | if [ -f $curExpandDir/$SOURCES_FILE ]; then |
| 135 | maven-deploy-file $mavenRepoUrl $mavenRepoId "$curExpandDir/$SOURCES_FILE" $gwtPomFile sources || die |
| 136 | fi |
| 137 | done |
| 138 | |
| 139 | # HACK: Deploy user sources jar as servlet sources even though it's a superset of the needed sources |
| 140 | maven-deploy-file $mavenRepoUrl $mavenRepoId "$jarExpandDir-user/gwt-user-sources.jar" $pomDir/gwt/gwt-servlet/pom.xml sources || die |
| 141 | |
| 142 | # Deploy RequestFactory jars |
| 143 | maven-deploy-file $mavenRepoUrl $mavenRepoId $pomDir/requestfactory/pom.xml $pomDir/requestfactory/pom.xml || die |
| 144 | |
| 145 | for i in client server apt |
| 146 | do |
| 147 | maven-deploy-file $mavenRepoUrl $mavenRepoId $GWT_EXTRACT_DIR/requestfactory-${i}.jar $pomDir/requestfactory/${i}/pom.xml || die |
| 148 | maven-deploy-file $mavenRepoUrl $mavenRepoId $GWT_EXTRACT_DIR/requestfactory-${i}-src.jar $pomDir/requestfactory/${i}/pom.xml sources || die |
| 149 | maven-deploy-file $mavenRepoUrl $mavenRepoId $JAVADOC_FILE_PATH $pomDir/requestfactory/${i}/pom.xml javadoc || warnJavaDoc "requestfactory-${i}" |
| 150 | done |
| 151 | |
| 152 | finishAndCleanup |
| 153 | } |
| 154 | |