Skip to content

Instantly share code, notes, and snippets.

@rochaalexandre
Last active September 19, 2021 00:27
Show Gist options
  • Save rochaalexandre/020043465f683d575166b4328897531b to your computer and use it in GitHub Desktop.
Save rochaalexandre/020043465f683d575166b4328897531b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os
import subprocess
import sys
if __name__ == '__main__':
def run(c):
print 'running: %s' % c
return subprocess.check_call(c, shell=True)
assert len(sys.argv) > 1 and sys.argv[1].endswith('.git'), 'you must specify a git url to clone.'
sshUrl = sys.argv[1]
try:
run('git clone "{0}"'.format(sshUrl))
except:
print "non zero exist code but we proceed anyway.."
folder_name = sshUrl.split('.git')[0].split('/')[-1]
gradle_build = os.path.join(folder_name, 'build.gradle')
mvn_pom = os.path.join(folder_name, 'pom.xml')
mvn_exists = os.path.exists(mvn_pom)
gradle_exists = os.path.exists(gradle_build)
assert gradle_exists or mvn_exists, 'there must be a `build.gradle` or a `pom.xml` in the root of the folder %s.' % folder_name
if gradle_exists:
run('idea %s/build.gradle' % folder_name)
else:
run('idea %s/pom.xml' % folder_name)
@rochaalexandre
Copy link
Author

This Script is a modified version of the script used by Josh Long to unzip and open java projects with IntelliJ. The original script is in this link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment