default.txt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env groovy
  2. package model
  3. import groovy.transform.CompileStatic
  4. import java.util.List as MyList
  5. trait Distributable {
  6. void distribute(String version) {}
  7. }
  8. @CompileStatic
  9. class Distribution implements Distributable {
  10. double number = 1234.234 / 567
  11. def otherNumber = 3 / 4
  12. boolean archivable = condition ?: true
  13. def ternary = a ? b : c
  14. String name = "Guillaume"
  15. Closure description = null
  16. List<DownloadPackage> packages = []
  17. String regex = ~/.*foo.*/
  18. String multi = '''
  19. multi line string
  20. ''' + """
  21. now with double quotes and ${gstring}
  22. """ + $/
  23. even with dollar slashy strings
  24. /$
  25. /**
  26. * description method
  27. * @param cl the closure
  28. */
  29. void description(Closure cl) { this.description = cl }
  30. void version(String name, Closure versionSpec) {
  31. def closure = { println "hi" } as Runnable
  32. MyList ml = [1, 2, [a: 1, b:2,c :3]]
  33. for (ch in "name") {}
  34. // single line comment
  35. DownloadPackage pkg = new DownloadPackage(version: name)
  36. check that: true
  37. label:
  38. def clone = versionSpec.rehydrate(pkg, pkg, pkg)
  39. /*
  40. now clone() in a multiline comment
  41. */
  42. clone()
  43. packages.add(pkg)
  44. assert 4 / 2 == 2
  45. }
  46. }