/* Build or update the CU filenames table. * * This script is called at the time of each build job submission. * The cufile table is used both for finding external program * names for RUN statements, as well as for times when lists * of compile unit source files are needed, for example for * reports and for submitting Analyst build jobs. * * This default implementation just uses a regular expression * to match .p, .w, and .cls files on the project propath setting. * * To create your own, copy this into a file named "cufilenames.groovy" * (all lowercase) into the configuration scripts directory. * (See the user guide for more information on Analyst configuration scripts.) * */ import com.joanju.cg.db.CuFileTable def refsession = org.prorefactor.refactor.RefactorSession.instance def propath = refsession.progressSettings.propath.tokenize(',').sort() // Look for any propath entries that are subdirectories of other // propath entries, just to avoid processing the same directories twice. def prevPart = '' for (i in 0 ..< propath.size()) { if (prevPart && propath[i].startsWith(prevPart)) propath[i] = '' else prevPart = propath[i] } propath -= '' // removes all '' entries //Regular expression: switch to case-insensitive, //and check for .p, .w, .cls file name extension. final CUPATTERN = ~/(?i:(.*\.)(p|w|cls)$)/ // Iterate through the propath directories, and add all CU // files to the cufile table. propath.each{ dirname -> def dir = new File(dirname) if (dir.exists() && dir.isDirectory()) { dir.eachFileRecurse{ file -> if (CUPATTERN.matcher(file.name)) { CuFileTable.insertIfNew(file.canonicalPath) } } } }