Open rwinch opened 7 years ago
This was a sketch of how it might look in groovy I did years back:
def sprDocs = [ '1.0.0.M1', '1.0.0', '1.0.1', '1.0.2', '1.1.0', '1.1.1', '1.1.2', '1.1.3', '1.1.4', '1.1.5', '1.1.x', '1.2.0', '1.2.1', '1.2.2', '1.2.3', '1.2.4', '1.2.5', '1.2.6', '1.2.7', '1.2.8', '1.2.9', '1.2.x',
'2.0.0', '2.0.1', '2.0.2', '2.0.3', '2.0.4', '2.0.5', '2.0.6', '2.0.7', '2.0.8', '2.0.x', '2.5.0', '2.5.1', '2.5.2', '2.5.3', '2.5.4', '2.5.5', '2.5.6.SEC03', '2.5.6', '2.5.x',
'3.0.0.M1', '3.0.0.M2', '3.0.0.M3', '3.0.0.M4', '3.0.0.RC1', '3.0.0.RC2', '3.0.0.RC3', '3.0.0.RELEASE', '3.0.1.RELEASE', '3.0.2.RELEASE', '3.0.3.RELEASE', '3.0.4.RELEASE', '3.0.5.RELEASE', '3.0.6.RELEASE', '3.0.6.RELEASE_to_3.1.0.BUILD-SNAPSHOT', '3.0.7.RELEASE', '3.0.x',
'3.1.0.M1', '3.1.0.M2', '3.1.0.RC1', '3.1.0.RC2', '3.1.0.RELEASE', '3.1.1.RELEASE', '3.1.2.RELEASE', '3.1.x', '3.2.0.BUILD-SNAPSHOT', '3.2.0.M1', 'current', 'upgrade']
def sprSchema = ['3.1.1.RELEASE', '3.2.0.BUILD-SNAPSHOT', '3.2.0.M1', 'current']
def secDocs = [ '2.0.7.RELEASE', '2.0.x', '3.0.7.RELEASE', '3.0.x', '3.1.1.RELEASE', '3.1.2.CI-SNAPSHOT', '3.1.x', 'current']
def secSchema = ['3.1.1.RELEASE', '3.1.2.CI-SNAPSHOT', 'current']
def intDocs = ['1.0.3.RELEASE', '1.0.x', '2.0.0.BUILD-SNAPSHOT', '2.0.0.M2', '2.0.0.M3', '2.0.0.M4', '2.0.0.M5', '2.0.0.M6', '2.0.0.M7', '2.0.0.RC1', '2.0.0.RC2', '2.0.0.RELEASE', '2.0.1.RELEASE', '2.0.2.RELEASE', '2.0.3.RELEASE', '2.0.4.RELEASE', '2.0.5.RELEASE', '2.0.6.RELEASE', '2.0.x', '2.1.0.BUILD-SNAPSHOT', '2.1.0.M1', '2.1.0.M2', '2.1.0.M3', '2.1.0.RC1', '2.1.0.RC2', '2.1.0.RELEASE', '2.1.1.BUILD-SNAPSHOT', '2.1.1.RELEASE', '2.1.2.BUILD-SNAPSHOT', '2.1.2.RELEASE', '2.1.3.RELEASE', '2.1.4.BUILD-SNAPSHOT', '2.1.x', '2.2.0.BUILD-SNAPSHOT', '2.2.0.M1', '2.2.0.M2', '2.2.0.M3', 'latest-ga']
def intSchema = ['2.1.0.BUILD-SNAPSHOT', '2.1.0.RELEASE', '2.1.1.BUILD-SNAPSHOT', '2.1.1.RELEASE', '2.1.2.BUILD-SNAPSHOT', '2.1.2.RELEASE', '2.1.3.RELEASE', '2.1.4.BUILD-SNAPSHOT', '2.2.0.BUILD-SNAPSHOT', '2.2.0.M1', '2.2.0.M2', '2.2.0.M3']
def aLargerThan = { a, b ->
if(!a) {
return !b
}
if(!b) {
return true
}
def aParts = a.split('\\.')
def bParts = b.split('\\.')
for(int i=0;i<aParts.length;i++) {
if(i > bParts.length-1) {
return true
}
def match = aParts[i].compareTo(bParts[i])
if(match != 0) {
return match > 0
}
}
bParts.length < aParts.length
}
def createLinks = { dirs ->
def linkToPath = [:]
dirs.each { dir ->
if(dir ==~ /(\d+\.?){3}(M\d+|RC\d+|RELEASE|\w+-SNAPSHOT|SEC\d+)?/) {
def ln = dir.replaceFirst(/(\d+\.\d+\.)\d(?:\.\w+(-SNAPSHOT))?.*/, '$1x$2')
def path = linkToPath[ln]
if(aLargerThan(dir,path))
linkToPath[ln] = dir
if(dir.endsWith('.RELEASE') && aLargerThan(dir,linkToPath['current']))
linkToPath['current'] = dir
if(dir.endsWith('-SNAPSHOT') && aLargerThan(dir,linkToPath['current-SNAPSHOT']))
linkToPath['current-SNAPSHOT'] = dir
}
}
linkToPath.each {
// instead of printing out this command it should be executed
println "ln -fs $it.value $it.key"
}
linkToPath
}
println '-'*5+' Spring Security'+'-'*5
println ' Security Docs'
createLinks(secDocs)
println ' Security Schema'
createLinks(secSchema)
println ''
println '-'*5+' Spring Integration'+'-'*5
println ' Integration Docs'
createLinks(intDocs)
println ' Security Docs'
createLinks(intSchema)
println ''
println '-'*5+' Spring Framwork'+'-'*5
println ' Spring Docs'
createLinks(sprDocs)
println ' Spring Schema'
createLinks(sprSchema)
'EOF'
Setup symlinks for current, current-SNAPSHOT, 4.x, etc