How to add source folder to grails application

血红的双手。 提交于 2019-12-01 20:30:29

The answer is here:

http://ofps.oreilly.com/titles/9781449323936/chapter_configuration.html

To summarize, you can use configuration 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 the extra source folders, but I don't think it is enough for STS to know about the source folders. For that, you will have to continue updating the project's .classpath.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!