Bug 510072: Scripts & tool for publishing to Maven Central should
migrate to releng git

- baseline filtering also for JDT & PDE
diff --git a/releng/EnrichPoms/publishJDT.sh b/releng/EnrichPoms/publishJDT.sh
index 7ab71ac..c6254e5 100644
--- a/releng/EnrichPoms/publishJDT.sh
+++ b/releng/EnrichPoms/publishJDT.sh
@@ -14,6 +14,9 @@
 REPO=${REPO_BASE}/repo-${REPO_ID}
 JDT=org/eclipse/jdt
 
+# load versions from the baseline (to avoid illegal double-upload):
+source ${WORKSPACE}/baseline.txt
+
 if [ ! -d ${REPO} ]
 then
 	echo "No repo at ${REPO}"
@@ -40,31 +43,47 @@
 
 /bin/mkdir .log
 
+function same_as_baseline() {
+	simple=`basename $1`
+	name=`echo $simple | sed -e "s|\(.*\)-.*|\1|" | tr '.' '_'`
+	version=`echo $simple | sed -e "s|.*-\(.*\).pom|\1|"`
+	if [ "`eval echo \\${VERSION_$name}`" == "$version" ]
+	then
+		return 0
+	else
+		return 1
+	fi
+}
+
 for pomFile in org/eclipse/jdt/*/*/*.pom
 do
-  file=`echo $pomFile | sed -e "s|\(.*\)\.pom|\1.jar|"`
-  sourcesFile=`echo $pomFile | sed -e "s|\(.*\)\.pom|\1-sources.jar|"`
-  javadocFile=`echo $pomFile | sed -e "s|\(.*\)\.pom|\1-javadoc.jar|"`
-
-  echo "${MVN} -f jdt-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file -Durl=${URL} -DrepositoryId=${REPO} -Dfile=${file} -DpomFile=${pomFile}"
-  
-  ${MVN} -f jdt-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file \
-     -Durl=${URL} -DrepositoryId=${REPO} \
-     -Dfile=${file} -DpomFile=${pomFile} \
-     >> .log/artifact-upload.txt
-     
-  echo -e "\t${sourcesFile}"
-  ${MVN} -f jdt-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file \
-     -Durl=${URL} -DrepositoryId=${REPO} \
-     -Dfile=${sourcesFile} -DpomFile=${pomFile} -Dclassifier=sources \
-     >> .log/sources-upload.txt
-  
-  echo -e "\t${javadocFile}"
-  ${MVN} -f jdt-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file \
-     -Durl=${URL} -DrepositoryId=${REPO} \
-     -Dfile=${javadocFile} -DpomFile=${pomFile} -Dclassifier=javadoc \
-     >> .log/javadoc-upload.txt
-
+  if same_as_baseline $pomFile
+  then
+	  echo "Skipping file $pomFile which is already present in the baseline"
+  else
+	  file=`echo $pomFile | sed -e "s|\(.*\)\.pom|\1.jar|"`
+	  sourcesFile=`echo $pomFile | sed -e "s|\(.*\)\.pom|\1-sources.jar|"`
+	  javadocFile=`echo $pomFile | sed -e "s|\(.*\)\.pom|\1-javadoc.jar|"`
+	
+	  echo "${MVN} -f jdt-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file -Durl=${URL} -DrepositoryId=${REPO} -Dfile=${file} -DpomFile=${pomFile}"
+	  
+	  ${MVN} -f jdt-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file \
+	     -Durl=${URL} -DrepositoryId=${REPO} \
+	     -Dfile=${file} -DpomFile=${pomFile} \
+	     >> .log/artifact-upload.txt
+	     
+	  echo -e "\t${sourcesFile}"
+	  ${MVN} -f jdt-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file \
+	     -Durl=${URL} -DrepositoryId=${REPO} \
+	     -Dfile=${sourcesFile} -DpomFile=${pomFile} -Dclassifier=sources \
+	     >> .log/sources-upload.txt
+	  
+	  echo -e "\t${javadocFile}"
+	  ${MVN} -f jdt-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file \
+	     -Durl=${URL} -DrepositoryId=${REPO} \
+	     -Dfile=${javadocFile} -DpomFile=${pomFile} -Dclassifier=javadoc \
+	     >> .log/javadoc-upload.txt
+  fi
 done
 
 /bin/ls -la .log
diff --git a/releng/EnrichPoms/publishPDE.sh b/releng/EnrichPoms/publishPDE.sh
index 8592f0a..3495885 100644
--- a/releng/EnrichPoms/publishPDE.sh
+++ b/releng/EnrichPoms/publishPDE.sh
@@ -14,6 +14,9 @@
 REPO=${REPO_BASE}/repo-${REPO_ID}
 PDE=org/eclipse/pde
 
+# load versions from the baseline (to avoid illegal double-upload):
+source ${WORKSPACE}/baseline.txt
+
 if [ ! -d ${REPO} ]
 then
 	echo "No repo at ${REPO}"
@@ -40,31 +43,47 @@
 
 /bin/mkdir .log
 
+function same_as_baseline() {
+	simple=`basename $1`
+	name=`echo $simple | sed -e "s|\(.*\)-.*|\1|" | tr '.' '_'`
+	version=`echo $simple | sed -e "s|.*-\(.*\).pom|\1|"`
+	if [ "`eval echo \\${VERSION_$name}`" == "$version" ]
+	then
+		return 0
+	else
+		return 1
+	fi
+}
+
 for pomFile in org/eclipse/pde/*/*/*.pom
 do
-  file=`echo $pomFile | sed -e "s|\(.*\)\.pom|\1.jar|"`
-  sourcesFile=`echo $pomFile | sed -e "s|\(.*\)\.pom|\1-sources.jar|"`
-  javadocFile=`echo $pomFile | sed -e "s|\(.*\)\.pom|\1-javadoc.jar|"`
-
-  echo "${MVN} -f pde-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file -Durl=${URL} -DrepositoryId=${REPO} -Dfile=${file} -DpomFile=${pomFile}"
-  
-  ${MVN} -V -X -e -f pde-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file \
-     -Durl=${URL} -DrepositoryId=${REPO} \
-     -Dfile=${file} -DpomFile=${pomFile} \
-     >> .log/artifact-upload.txt
-     
-  echo -e "\t${sourcesFile}"
-  ${MVN} -V -X -e -f pde-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file \
-     -Durl=${URL} -DrepositoryId=${REPO} \
-     -Dfile=${sourcesFile} -DpomFile=${pomFile} -Dclassifier=sources \
-     >> .log/sources-upload.txt
-  
-  echo -e "\t${javadocFile}"
-  ${MVN} -V -X -e -f pde-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file \
-     -Durl=${URL} -DrepositoryId=${REPO} \
-     -Dfile=${javadocFile} -DpomFile=${pomFile} -Dclassifier=javadoc \
-     >> .log/javadoc-upload.txt
-
+  if same_as_baseline $pomFile
+  then
+	echo "Skipping file $pomFile which is already present in the baseline"
+  else
+	  file=`echo $pomFile | sed -e "s|\(.*\)\.pom|\1.jar|"`
+	  sourcesFile=`echo $pomFile | sed -e "s|\(.*\)\.pom|\1-sources.jar|"`
+	  javadocFile=`echo $pomFile | sed -e "s|\(.*\)\.pom|\1-javadoc.jar|"`
+	
+	  echo "${MVN} -f pde-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file -Durl=${URL} -DrepositoryId=${REPO} -Dfile=${file} -DpomFile=${pomFile}"
+	  
+	  ${MVN} -V -X -e -f pde-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file \
+	     -Durl=${URL} -DrepositoryId=${REPO} \
+	     -Dfile=${file} -DpomFile=${pomFile} \
+	     >> .log/artifact-upload.txt
+	     
+	  echo -e "\t${sourcesFile}"
+	  ${MVN} -V -X -e -f pde-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file \
+	     -Durl=${URL} -DrepositoryId=${REPO} \
+	     -Dfile=${sourcesFile} -DpomFile=${pomFile} -Dclassifier=sources \
+	     >> .log/sources-upload.txt
+	  
+	  echo -e "\t${javadocFile}"
+	  ${MVN} -V -X -e -f pde-pom.xml -s ${SETTINGS} gpg:sign-and-deploy-file \
+	     -Durl=${URL} -DrepositoryId=${REPO} \
+	     -Dfile=${javadocFile} -DpomFile=${pomFile} -Dclassifier=javadoc \
+	     >> .log/javadoc-upload.txt
+  fi
 done
 
 /bin/ls -la .log