fork download
  1. class Ideone {
  2.  
  3. static String getProjectVersion(String input){
  4. def m = input =~ /version:\h*(.+)/
  5. if (m) {
  6. return m.group(1);
  7. }
  8. return "Unknown"
  9. }
  10. static void main(String[] args) {
  11. String input1 = """\
  12. test: task ':test'
  13. version: 1.1.0.1
  14. targetCompatibility: 1.8
  15. """.stripIndent()
  16.  
  17. String input2 = """\
  18. test: task ':test'
  19. version: latest
  20. testResultsDirName: test-results
  21. targetCompatibility: 1.8
  22. """.stripIndent()
  23. println(getProjectVersion(input1))
  24. println(getProjectVersion(input2))
  25. }
  26. }
  27.  
Success #stdin #stdout 2.26s 119540KB
stdin
Standard input is empty
stdout
1.1.0.1
latest