Permalink
Browse files

monorepo treatment

  • Loading branch information...
paul-hammant committed Feb 8, 2017
1 parent 8e03c38 commit c04edeedcc84d3ba0a8fb7f43a62ea4cdd9100dd
Showing with 546 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. 0 coverage-report/{pom.xml → pom-template.xml}
  3. 0 jooby-akka/{pom.xml → pom-template.xml}
  4. 0 jooby-archetype/{pom.xml → pom-template.xml}
  5. 0 jooby-archetype/src/main/resources/archetype-resources/{pom.xml → pom-template.xml}
  6. 0 jooby-assets-autoprefixer/{pom.xml → pom-template.xml}
  7. 0 jooby-assets-babel/{pom.xml → pom-template.xml}
  8. 0 jooby-assets-clean-css/{pom.xml → pom-template.xml}
  9. 0 jooby-assets-closure-compiler/{pom.xml → pom-template.xml}
  10. 0 jooby-assets-csslint/{pom.xml → pom-template.xml}
  11. 0 jooby-assets-j2v8/{pom.xml → pom-template.xml}
  12. 0 jooby-assets-jscs/{pom.xml → pom-template.xml}
  13. 0 jooby-assets-jshint/{pom.xml → pom-template.xml}
  14. 0 jooby-assets-less/{pom.xml → pom-template.xml}
  15. 0 jooby-assets-less4j/{pom.xml → pom-template.xml}
  16. 0 jooby-assets-ng-annotate/{pom.xml → pom-template.xml}
  17. 0 jooby-assets-nodejs/{pom.xml → pom-template.xml}
  18. 0 jooby-assets-requirejs/{pom.xml → pom-template.xml}
  19. 0 jooby-assets-rollup/{pom.xml → pom-template.xml}
  20. 0 jooby-assets-sass/{pom.xml → pom-template.xml}
  21. 0 jooby-assets-svg-sprites/{pom.xml → pom-template.xml}
  22. 0 jooby-assets-svg-symbol/{pom.xml → pom-template.xml}
  23. 0 jooby-assets-uglify/{pom.xml → pom-template.xml}
  24. 0 jooby-assets-yui-compressor/{pom.xml → pom-template.xml}
  25. 0 jooby-assets/{pom.xml → pom-template.xml}
  26. 0 jooby-aws/{pom.xml → pom-template.xml}
  27. 0 jooby-banner/{pom.xml → pom-template.xml}
  28. 0 jooby-bom/{pom.xml → pom-template.xml}
  29. 0 jooby-caffeine/{pom.xml → pom-template.xml}
  30. 0 jooby-camel/{pom.xml → pom-template.xml}
  31. 0 jooby-cassandra/{pom.xml → pom-template.xml}
  32. 0 jooby-commons-email/{pom.xml → pom-template.xml}
  33. 0 jooby-couchbase/{pom.xml → pom-template.xml}
  34. 0 jooby-crash/{pom.xml → pom-template.xml}
  35. 0 jooby-csl/{pom.xml → pom-template.xml}
  36. 0 jooby-dist/{pom.xml → pom-template.xml}
  37. 0 jooby-ebean/{pom.xml → pom-template.xml}
  38. 0 jooby-ehcache/{pom.xml → pom-template.xml}
  39. 0 jooby-elasticsearch/{pom.xml → pom-template.xml}
  40. 0 jooby-executor/{pom.xml → pom-template.xml}
  41. 0 jooby-flyway/{pom.xml → pom-template.xml}
  42. 0 jooby-ftl/{pom.xml → pom-template.xml}
  43. 0 jooby-gradle-plugin/{pom.xml → pom-template.xml}
  44. 0 jooby-gson/{pom.xml → pom-template.xml}
  45. 0 jooby-guava-cache/{pom.xml → pom-template.xml}
  46. 0 jooby-hazelcast/{pom.xml → pom-template.xml}
  47. 0 jooby-hbm/{pom.xml → pom-template.xml}
  48. 0 jooby-hbm4/{pom.xml → pom-template.xml}
  49. 0 jooby-hbs/{pom.xml → pom-template.xml}
  50. 0 jooby-hbv/{pom.xml → pom-template.xml}
  51. 0 jooby-jackson/{pom.xml → pom-template.xml}
  52. 0 jooby-jade/{pom.xml → pom-template.xml}
  53. 0 jooby-jdbc/{pom.xml → pom-template.xml}
  54. 0 jooby-jdbi/{pom.xml → pom-template.xml}
  55. 0 jooby-jedis/{pom.xml → pom-template.xml}
  56. 0 jooby-jetty/{pom.xml → pom-template.xml}
  57. 0 jooby-jongo/{pom.xml → pom-template.xml}
  58. 0 jooby-jooq/{pom.xml → pom-template.xml}
  59. 0 jooby-maven-plugin/{pom.xml → pom-template.xml}
  60. 0 jooby-metrics/{pom.xml → pom-template.xml}
  61. 0 jooby-mongodb-rx/{pom.xml → pom-template.xml}
  62. 0 jooby-mongodb/{pom.xml → pom-template.xml}
  63. 0 jooby-morphia/{pom.xml → pom-template.xml}
  64. 0 jooby-netty/{pom.xml → pom-template.xml}
  65. 0 jooby-pac4j/{pom.xml → pom-template.xml}
  66. 0 jooby-pebble/{pom.xml → pom-template.xml}
  67. 0 jooby-quartz/{pom.xml → pom-template.xml}
  68. 0 jooby-querydsl/{pom.xml → pom-template.xml}
  69. 0 jooby-raml/{pom.xml → pom-template.xml}
  70. 0 jooby-reactor/{pom.xml → pom-template.xml}
  71. 0 jooby-run/{pom.xml → pom-template.xml}
  72. 0 jooby-rxjava-jdbc/{pom.xml → pom-template.xml}
  73. 0 jooby-rxjava/{pom.xml → pom-template.xml}
  74. 0 jooby-scanner/{pom.xml → pom-template.xml}
  75. 0 jooby-servlet/{pom.xml → pom-template.xml}
  76. 0 jooby-sitemap/{pom.xml → pom-template.xml}
  77. 0 jooby-spec/{pom.xml → pom-template.xml}
  78. 0 jooby-spymemcached/{pom.xml → pom-template.xml}
  79. 0 jooby-swagger/{pom.xml → pom-template.xml}
  80. 0 jooby-thymeleaf/{pom.xml → pom-template.xml}
  81. 0 jooby-unbescape/{pom.xml → pom-template.xml}
  82. 0 jooby-undertow/{pom.xml → pom-template.xml}
  83. 0 jooby-whoops/{pom.xml → pom-template.xml}
  84. 0 jooby/{pom.xml → pom-template.xml}
  85. +84 −0 mr/all_poms.txt
  86. +130 −0 mr/checkout.py
  87. +329 −0 mr/dependency-graph.dot
  88. 0 pom.xml → pom-template.xml
View
@@ -20,3 +20,6 @@ bin
*.versionsBackup
pom.xml.versionsBackup
jacoco.exec
# Monorepo tech needs us to hide
pom.xml
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -0,0 +1,84 @@
./coverage-report/pom-template.xml
./jooby/pom-template.xml
./jooby-akka/pom-template.xml
./jooby-archetype/pom-template.xml
./jooby-archetype/src/main/resources/archetype-resources/pom-template.xml
./jooby-assets/pom-template.xml
./jooby-assets-autoprefixer/pom-template.xml
./jooby-assets-babel/pom-template.xml
./jooby-assets-clean-css/pom-template.xml
./jooby-assets-closure-compiler/pom-template.xml
./jooby-assets-csslint/pom-template.xml
./jooby-assets-j2v8/pom-template.xml
./jooby-assets-jscs/pom-template.xml
./jooby-assets-jshint/pom-template.xml
./jooby-assets-less/pom-template.xml
./jooby-assets-less4j/pom-template.xml
./jooby-assets-ng-annotate/pom-template.xml
./jooby-assets-nodejs/pom-template.xml
./jooby-assets-requirejs/pom-template.xml
./jooby-assets-rollup/pom-template.xml
./jooby-assets-sass/pom-template.xml
./jooby-assets-svg-sprites/pom-template.xml
./jooby-assets-svg-symbol/pom-template.xml
./jooby-assets-uglify/pom-template.xml
./jooby-assets-yui-compressor/pom-template.xml
./jooby-aws/pom-template.xml
./jooby-banner/pom-template.xml
./jooby-bom/pom-template.xml
./jooby-caffeine/pom-template.xml
./jooby-camel/pom-template.xml
./jooby-cassandra/pom-template.xml
./jooby-commons-email/pom-template.xml
./jooby-couchbase/pom-template.xml
./jooby-crash/pom-template.xml
./jooby-csl/pom-template.xml
./jooby-dist/pom-template.xml
./jooby-ebean/pom-template.xml
./jooby-ehcache/pom-template.xml
./jooby-elasticsearch/pom-template.xml
./jooby-executor/pom-template.xml
./jooby-flyway/pom-template.xml
./jooby-ftl/pom-template.xml
./jooby-gradle-plugin/pom-template.xml
./jooby-gson/pom-template.xml
./jooby-guava-cache/pom-template.xml
./jooby-hazelcast/pom-template.xml
./jooby-hbm/pom-template.xml
./jooby-hbm4/pom-template.xml
./jooby-hbs/pom-template.xml
./jooby-hbv/pom-template.xml
./jooby-jackson/pom-template.xml
./jooby-jade/pom-template.xml
./jooby-jdbc/pom-template.xml
./jooby-jdbi/pom-template.xml
./jooby-jedis/pom-template.xml
./jooby-jetty/pom-template.xml
./jooby-jongo/pom-template.xml
./jooby-jooq/pom-template.xml
./jooby-maven-plugin/pom-template.xml
./jooby-metrics/pom-template.xml
./jooby-mongodb/pom-template.xml
./jooby-mongodb-rx/pom-template.xml
./jooby-morphia/pom-template.xml
./jooby-netty/pom-template.xml
./jooby-pac4j/pom-template.xml
./jooby-pebble/pom-template.xml
./jooby-quartz/pom-template.xml
./jooby-querydsl/pom-template.xml
./jooby-raml/pom-template.xml
./jooby-reactor/pom-template.xml
./jooby-run/pom-template.xml
./jooby-rxjava/pom-template.xml
./jooby-rxjava-jdbc/pom-template.xml
./jooby-scanner/pom-template.xml
./jooby-servlet/pom-template.xml
./jooby-sitemap/pom-template.xml
./jooby-spec/pom-template.xml
./jooby-spymemcached/pom-template.xml
./jooby-swagger/pom-template.xml
./jooby-thymeleaf/pom-template.xml
./jooby-unbescape/pom-template.xml
./jooby-undertow/pom-template.xml
./jooby-whoops/pom-template.xml
./pom-template.xml
View
@@ -0,0 +1,130 @@
#!/usr/bin/python
import os
import sys
import shutil
from subprocess import call
def needThis(neededModule, depMap, neededModules2):
if neededModule in depMap:
for dependency in depMap[neededModule]:
needThis(dependency, depMap, neededModules2)
neededModules2[neededModule] = True
def writepom(pom_template):
dirname = os.path.dirname(pom_template)
with open(pom_template) as f:
if os.path.exists(dirname + '/pom.xml'):
os.chmod(dirname + '/pom.xml', 0755)
with open(dirname + '/pom.xml', 'w') as the_pom:
lines = f.readlines()
for line in lines:
if line.strip().startswith("<module>") and line.strip().endswith("</module>"):
sub_project = line.strip()[8:]
sub_project = sub_project[:sub_project.index("<")]
f_path = dirname + "/" + sub_project
if os.path.exists(f_path + '/pom.xml') or os.path.exists(f_path + '/pom-template.xml'):
the_pom.write(line)
else:
the_pom.write(line)
os.chmod(dirname + '/pom.xml', 0444)
def recursive_delete_if_empty(path):
"""Recursively delete empty directories; return True
if everything was deleted."""
if not os.path.isdir(path):
# If you also want to delete some files like desktop.ini, check
# for that here, and return True if you delete them.
return False
# Note that the list comprehension here is necessary, a
# generator expression would shortcut and we don't want that!
if all([recursive_delete_if_empty(os.path.join(path, filename))
for filename in os.listdir(path)]):
# Either there was nothing here or it was all deleted
os.rmdir(path)
return True
else:
return False
neededModules = {}
depMap = {}
# passed in args into dict
for ix, arg in enumerate(sys.argv):
if ix > 0:
neededModules[arg] = True
# crunch dot graph into Python dict
with open("mr/dependency-graph.dot") as dot:
lines = dot.readlines()
for line in lines:
line = line.replace("\"","")
if " -> " in line:
parts = line.split(" -> ")
lpart = parts[0].split(":")[1]
rpart = parts[1].split(":")[1]
if lpart not in depMap:
depMap[lpart] = {}
depMap[lpart][rpart] = True
# penultimate list of deps we need, tree into flat
neededModules2 = {}
for neededModule in neededModules:
needThis(neededModule, depMap, neededModules2)
# we always need these
sparse_checkout = "/.gitignore\n/.gitattributes\n/checkstyle.xml\n/LICENSE\n/mr/*\n/README.md\n/pom-template.xml\n"
with open("mr/all_poms.txt") as allpoms:
lines = allpoms.readlines()
for line in lines:
hit = False
for neededModule in neededModules2:
if "/"+neededModule+"/" in line:
sparse_checkout += line[1:]
sparse_checkout += line[1:].replace("pom-template.xml","src/*")
# Redo sparse-checkout file
with open('.git/info/sparse-checkout', 'w') as sc:
if len(sys.argv) == 1:
sc.write("/*")
else:
sc.write(sparse_checkout)
# Remove old pom files
for root, dirs, files in os.walk("."):
for currentFile in files:
path_join = os.path.join(root, currentFile)
if path_join.endswith("/pom.xml"):
os.remove(path_join)
# sparse re-checkout
call(["git", "checkout", "--"])
# Write new pom files if approriate
for root, dirs, files in os.walk("."):
for currentFile in files:
fullpath = os.path.join(root, currentFile)
if fullpath.endswith("/pom-template.xml"):
writepom(fullpath)
# Delete orphaned target folders and Intellij .iml files
dirs_to_delete = []
files_to_delete = []
for root, dirs, files in os.walk("."):
for currentDir in dirs:
fullpath = os.path.join(root, currentDir)
if fullpath.endswith("/target") and not os.path.exists(os.path.dirname(fullpath) + '/pom.xml'):
dirs_to_delete.append(fullpath)
for currentFile in files:
fullpath = os.path.join(root, currentFile)
if fullpath.endswith(".iml") and not os.path.exists(os.path.dirname(fullpath) + '/pom.xml'):
files_to_delete.append(fullpath)
for fullpath in dirs_to_delete:
shutil.rmtree(fullpath)
for fullpath in files_to_delete:
os.remove(fullpath)
recursive_delete_if_empty(".")
Oops, something went wrong.

0 comments on commit c04edee

Please sign in to comment.