1#!/bin/bash 2#run this script from google-cloud-java directory 3# google-cloud-java$ ./generation/diff_files.sh 4# not using set -e because failing diff command is ok 5# latest repositories Id -> comgooglecloud-5570, comgoogleapi-5038, comgoogleanalytics-1052 6# this script must be run on a branch which does not have any snapshot versions in it 7 8## HOW TO USE THIS SCRIPT ## 9# 1. Run the stage job for google-cloud-java, on a branch which does not have any snapshot versions in it. 10# 2. Search the stage job logs for 11# a. 'comgooglecloud' (the result will be like "comgooglecloud-5570") 12# b. 'comgoogleapi' (the result will be like "comgoogleapi-5038") 13# c. 'comgoogleanalytics' (the result will be like "comgoogleanalytics-1052") 14# 3. Update them below under the variables `cloudRepoId`, `apiRepoId`, `analyticsRepoId` 15# 4. Run ./generation/diff_files.sh 16 17# Output of this script are 2 files (actually generated by diff_directory.sh) -> 18# 1. diff-files-summary.txt : This will show success for artifacts which have same files on maven-central and sonatype, 19# and if they differ, it will show a diff failure message along with the names of the files that differ. 20# 2. total-diff.txt : For every artifact, this will show 4 things: 21 # a. Sonatype directory URL 22 # b. Files that exist on sonatype (with version omitted, since we only care about the file generated) 23 # c. Maven directory URL 24 # d. Files that exist on Maven (with version omitted, since we only care about the file generated) 25# This script calls ./generation/diff_directory.sh for every pair, but you do not need to do anything for it. You just need to run this script. 26# Search total-diff.txt for any artifact, and it will show you a complete scenario, what all files exist etc etc. 27 28cloudRepoId=comgooglecloud-5570 29apiRepoId=comgoogleapi-5038 30analyticsRepoId=comgoogleanalytics-1052 31 32#-maxDepth 2 will just loop over all the packages we have, like java-vision etc, not maven submodules within it 33#-maxDepth 3 and 4 output same number of modules (more than 2 ofcourse) so 3 is covering all the modules 34for module in $(find . -mindepth 1 -maxdepth 3 -name pom.xml | sort | xargs dirname); do 35 36 if [[ "${module}" = *gapic-libraries-bom ]]; then 37 continue 38 fi 39 40 if [[ "${module}" = *samples* ]]; then 41 continue 42 fi 43 44 #these modules do not exist on maven-central yet 45 if [[ "${module}" = *beyondcorp* ]]; then 46 continue 47 fi 48 49 pom_file="${module}/pom.xml" 50 groupId_line=$(grep --max-count=1 'groupId' "${pom_file}") 51 artifactId_line=$(grep --max-count=1 'artifactId' "${pom_file}") 52 version_line=$(grep --max-count=1 'x-version-update' "${pom_file}") 53 54 #strip off everything from version line except digits and . to get the version 55 version=$(echo "$version_line" | cut -d '>' -f 2 | cut -d '<' -f 1) 56 57 prefix=" <groupId>" 58 suffix="</groupId>" 59 string=${groupId_line} 60 new_string=${string#"$prefix"} 61 groupId=${new_string%"$suffix"} 62 63 prefix=" <artifactId>" 64 suffix="</artifactId>" 65 string=${artifactId_line} 66 new_string=${string#"$prefix"} 67 artifactId=${new_string%"$suffix"} 68 69 if [[ "${groupId}" == *grafeas* ]]; then 70 continue 71 fi 72 73 if [[ "${groupId}" == *google.cloud* ]]; then 74 maven_version=$(curl -s "https://repo1.maven.org/maven2/com/google/cloud/${artifactId}/maven-metadata.xml" | grep --max-count=1 'latest') 75 maven_latest_version=$(echo "$maven_version" | cut -d '>' -f 2 | cut -d '<' -f 1) 76 77 sonatypeURL="https://google.oss.sonatype.org/content/repositories/${cloudRepoId}/com/google/cloud/${artifactId}/${version}" 78 mavenURL="https://repo1.maven.org/maven2/com/google/cloud/${artifactId}/${maven_latest_version}" 79 80 ./generation/diff_directory.sh ${mavenURL} ${sonatypeURL} ${artifactId} ${cloudRepoId} 81 fi 82 83 if [[ "${groupId}" == *grpc* ]]; then 84 maven_version=$(curl -s "https://repo1.maven.org/maven2/com/google/api/grpc/${artifactId}/maven-metadata.xml" | grep --max-count=1 'latest') 85 maven_latest_version=$(echo "$maven_version" | cut -d '>' -f 2 | cut -d '<' -f 1) 86 87 sonatypeURL="https://google.oss.sonatype.org/content/repositories/${apiRepoId}/com/google/api/grpc/${artifactId}/${version}" 88 mavenURL="https://repo1.maven.org/maven2/com/google/api/grpc/${artifactId}/${maven_latest_version}" 89 90 ./generation/diff_directory.sh ${mavenURL} ${sonatypeURL} ${artifactId} ${apiRepoId} 91 fi 92 93 if [[ "${groupId}" == *analytics* ]]; then 94 maven_version=$(curl -s "https://repo1.maven.org/maven2/com/google/analytics/${artifactId}/maven-metadata.xml" | grep --max-count=1 'latest') 95 maven_latest_version=$(echo "$maven_version" | cut -d '>' -f 2 | cut -d '<' -f 1) 96 97 sonatypeURL="https://google.oss.sonatype.org/content/repositories/${analyticsRepoId}/com/google/analytics/${artifactId}/${version}" 98 mavenURL="https://repo1.maven.org/maven2/com/google/analytics/${artifactId}/${maven_latest_version}" 99 100 ./generation/diff_directory.sh ${mavenURL} ${sonatypeURL} ${artifactId} ${analyticsRepoId} 101 fi 102done 103