Skip to content

Instantly share code, notes, and snippets.

@barata0
Created April 10, 2013 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barata0/5357749 to your computer and use it in GitHub Desktop.
Save barata0/5357749 to your computer and use it in GitHub Desktop.
List all Domain Classes without a Controller in GRAILS
import static groovy.io.FileType.FILES
def appFolderName = 'C:/Users/me/grails-base-folder/'
def appFolder = new File(appFolderName)
def domainFolder = new File(appFolder, "grails-app/domain")
def controllersFolder = new File(appFolder, "grails-app/controllers")
def listAllGroovyFiles(folder) {
def files = []
folder.eachFileRecurse(FILES) { f ->
if(f.name.endsWith('.groovy')) {
files << f
}
}
files
}
def domainFiles = listAllGroovyFiles(domainFolder)
def controllersFiles = listAllGroovyFiles(controllersFolder)
def dif = domainFiles.collect {f -> f.absolutePath - domainFolder.absolutePath - '.groovy'} - controllersFiles.collect {f -> (f.absolutePath - controllersFolder.absolutePath - 'Controller.groovy')}
dif = dif.collect {(it[1..it.size()-1]).replaceAll('\\\\', '.')}
dif.join(' ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment