Posted By

laurenceosx on 08/11/12


Tagged

groovy


Versions (?)

Groovy Gradle create-dirs


 / Published in: Groovy
 

Groovy Gradle create-dirs

  1. apply plugin: 'groovy'
  2.  
  3. buildscript {
  4. // for debug
  5. project.ext.swingWaitRaw = javax.swing.SwingUtilities.&invokeAndWait;
  6. project.ext.isEdt = javax.swing.SwingUtilities.&isEventDispatchThread;
  7. project.ext.swingWait = { aRunnable -> // prevent exception if in edtThread
  8. if( isEdt() ) { aRunnable.run(); } else { swingWaitRaw(aRunnable) };
  9. }
  10. project.ext.swingLater = javax.swing.SwingUtilities.&invokeLater;
  11. project.ext.gi = { aObjToInspect -> swingWait {
  12. groovy.inspect.swingui.ObjectBrowser.inspect(aObjToInspect) } }
  13. project.ext.kgi = { // kill gi windows
  14. swingWait({
  15. java.awt.Frame.getFrames().each {
  16. if (it.title == 'Groovy Object Browser') {
  17. it.visible = false;
  18. it.dispose();
  19. }
  20. }
  21. }) // end swingWait
  22. }; // end kgi
  23. } // end buildscript
  24.  
  25. dependencies {
  26. groovy localGroovy()
  27. }
  28.  
  29. task 'create-dirs' << {
  30. /* Example Output:
  31. $ gradle create-dirs
  32. :create-dirs
  33. src/main/resources
  34. src/main/java
  35. src/main/groovy
  36. src/test/resources
  37. src/test/java
  38. src/test/groovy
  39. */
  40.  
  41. project.sourceSets*.each {
  42. it.allSource.srcDirs.each {
  43. println "$it" - "${projectDir}${File.separator}";
  44. if ( !(it.exists()) )
  45. it.mkdirs();
  46. }
  47. }
  48. }
  49.  
  50. task "hello-world" << {
  51. println "Hello World"
  52. }

Report this snippet  

You need to login to post a comment.