Created
November 3, 2010 15:55
-
-
Save xlson/661256 to your computer and use it in GitHub Desktop.
Finding file ending and classifier of release artifacts in groovy using regexp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fileNames = '''groovycsv-0.2-javadoc.jar.asc | |
| groovycsv-0.2-javadoc.jar.asc | |
| groovycsv-0.2-sources.jar.asc | |
| groovycsv-0.2.ear.asc'''.split("\n") | |
| def project = new Expando() | |
| project.name = 'groovycsv' | |
| def version='0.2' | |
| def findClassifierPattern = /$project.name-$version(?:-(.+))?\.(\w+\.asc)/ | |
| for(filename in fileNames) { | |
| assert filename ==~ findClassifierPattern | |
| (filename =~ findClassifierPattern).find { full, classifier, fileEnding -> | |
| println "Full: $full" | |
| println "Classifier: $classifier" | |
| println "File ending: $fileEnding" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment