How to add source folder to grails app
I am using STS to develop a Grails application and I need to use a bunch of classes there generated by the wsimport utility. In order not to mix the source with the autogenerated source, I want to add a separate directory and put the generated classes there, for example:
grails-project
|
|-- .classpath
|-- .groovy
|-- .project
|-- .settings
|-- application.properties
|-- grails-app
|-- lib
|-- scripts
|-- src
| |-- groovy
| |-- java
| `-- wsimport <- where I want to make additional source folder
|-- target
|-- target-eclipse
|-- test
`-- web-app
I can add a new classpath entry to the .classpath file and STS will recognize the sources, but what should I do with Grails? Do I need to specify it in some config file or something?
source to share
The answer is here:
http://ofps.oreilly.com/titles/9781449323936/chapter_configuration.html
To summarize, you can use the config like this:
extraSrcDirs = ["$basedir/src/extra1", "$basedir/src/extra2", ...]
eventCompileStart = {
for (String path in extraSrcDirs) {
projectCompiler.srcDirectories << path
}
copyResources buildSettings.resourcesDir
}
eventCreateWarStart = { warName, stagingDir ->
copyResources "$stagingDir/WEB-INF/classes"
}
private copyResources(destination) {
ant.copy(todir: destination,
failonerror: false,
preservelastmodified: true) {
for (String path in extraSrcDirs) {
fileset(dir: path) {
exclude(name: '*.groovy')
exclude(name: '*.java')
}
}
}
}
This will let the grails compiler know about additional source folders, but I don't think STS knows enough about source folders. To do this, you need to continue updating the .classpath project.
source to share