Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt script for python3 and https://central.sonatype.com/ #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Adapt script for python3 and https://central.sonatype.com/
Gerard Jongerhuis committed Dec 5, 2023
commit da94c7b0468f29138dc88170ca209a40b98de444
32 changes: 17 additions & 15 deletions make-pom.sh
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ fi

cd "$1"

for file in $(find -name "*.jar" | sed "s/^\.\///g"); do
for file in $(gfind -name "*.jar" | sed "s/^\.\///g"); do

VERSION=$(unzip -p - $file META-INF/maven/*/*/pom.properties 2>/dev/null | grep "^version" | cut -d '=' -f 2 | sed -e 's/[[:space:]]*$//')
ART=$(unzip -p - $file META-INF/maven/*/*/pom.properties 2>/dev/null | grep "^artifactId" | cut -d '=' -f 2 | sed -e 's/[[:space:]]*$//')
@@ -25,32 +25,33 @@ for file in $(find -name "*.jar" | sed "s/^\.\///g"); do
echo "</dependency>" >>pom.xml
echo "" >>pom.xml
else
SHA1=$(sha1sum $file)
SHA1=$(shasum $file)
shas=($SHA1)
#LOOKUPINFO=`lookup-jar.py $file $SHA1`

# call python script to lookup jar by SHA1 checksum on search.maven.org
LOOKUPINFO=$(
python - $file $SHA1 <<END
python - $file ${shas[0]} <<END
import json
import urllib2
from urllib.request import urlopen
import sys
import os

jar = sys.argv[1]
sha = sys.argv[2]

searchurl = 'http://search.maven.org/solrsearch/select?q=1:%22'+sha+'%22&rows=20&wt=json'
page = urllib2.urlopen(searchurl)
data = json.loads("".join(page.readlines()))
searchurl = 'https://central.sonatype.com/solrsearch/select?q=1:%22'+sha+'%22&rows=20&wt=json'
page = urlopen(searchurl)
data = json.loads(page.read())
if data["response"] and data["response"]["numFound"] == 1:
print "<!-- Found info on search.maven.org for "+jar+" -->\r\n"
jarinfo = data["response"]["docs"][0]
print '<dependency>\r\n'
print ' <groupId>'+jarinfo["g"]+'</groupId>\r\n'
print ' <artifactId>'+jarinfo["a"]+'</artifactId>\r\n'
print ' <version>'+jarinfo["v"]+'</version>\r\n'
print '</dependency>\r\n'
print '\r\n'
print("<!-- Found info on search.maven.org for "+jar+" -->\r\n")
jarinfo = data["response"]["docs"][0]
print('<dependency>\r\n')
print(' <groupId>'+jarinfo["g"]+'</groupId>\r\n')
print(' <artifactId>'+jarinfo["a"]+'</artifactId>\r\n')
print(' <version>'+jarinfo["v"]+'</version>\r\n')
print('</dependency>\r\n')
print('\r\n')

END
)
@@ -76,3 +77,4 @@ END
fi

done