|
hi,
I have a suggested change to the create-app and create-plugin scripts. I was looking into creating a samples directory under my plugin under which the plugin samples could live. But when I run "grails create-app myapp" from the PLUGINDIR/samples directory (where PLUGINDIR is my plugin's directory), I end up with PLUGINDIR/myapp, rather than PLUGINDIR/samples/myapp. After a little debugging, I found that the reason is that GrailsScriptRunner.establishBaseDir() is walking up the parent directory tree to locate a "grails-app" directory, which it'll find in PLUGINDIR as PLUGINDIR/grails-app. And so that explains why the application is created in the "wrong" directory. What I'd like to suggest is that we add the following to the top of CreateApp.groovy: // Ensure that the application is created in the current directory System.setProperty("base.dir", new File("").absolutePath) This will ensure that applications are always created relative to the local path. While we could alternatively change how GrailsScriptRunner works, I believe that it works properly in the 80% case and the change is only needed for cases such as these. I'd like to also suggest an identical modification to CreatePlugin.groovy to create a plugin within an application directory structure, which I'd also run into in the past. Best, - Daiji ____________________________________________________________________________________ Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games. http://sims.yahoo.com/ --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
Yes I came across this myself:
I have integration tests that create new apps, copy over some domain classes, etc, install the plugin and then run "grails test-app/run-webtest" on the created apps. But due to this issue I needed to make the dir where the new apps are created a dir outside of the plugin dir (in fact ../tmp, relative to the plugin dir). Actually, I don't know whether you've tried it with a nested app within a Grails app dir, Daiji, but you may find - even if you can create it - that it causes problems with your plugins. The reason being that some of the Grails code scans the file-/class-path for resources recursively, and can complain if there appear to be duplicate resources. This might be the case, for example if you have <plugindir>/MyGrailsPlugin.groovy and <plugindir>/samples/one/plugins/<pluginname>/MyGrailsPlugin.groovy. Maybe that won't be a problem for you but it was for me. I do think your suggestion is still valid, though :-) But here's an alternative: change the SVN structure from <grails-pluginname>/trunk/<plugindir> to <grails-pluginname>/trunk/<grails-pluginname>/<plugindir>. So actually introduce repetition with the repeated "grails-pluginname" under trunk. That way it provides the option of more "top-level" folders under the trunk, eg, "samples". Just a thought :-) D T wrote: > hi, > > I have a suggested change to the create-app and create-plugin scripts. > > I was looking into creating a samples directory under my plugin under > which the plugin samples could live. But when I run "grails create-app > myapp" from the PLUGINDIR/samples directory (where PLUGINDIR is my > plugin's directory), I end up with PLUGINDIR/myapp, rather than > PLUGINDIR/samples/myapp. After a little debugging, I found that the > reason is that GrailsScriptRunner.establishBaseDir() is walking up the > parent directory tree to locate a "grails-app" directory, which it'll > find in PLUGINDIR as PLUGINDIR/grails-app. > > And so that explains why the application is created in the "wrong" > directory. > > What I'd like to suggest is that we add the following to the top of > CreateApp.groovy: > > // Ensure that the application is created in the current directory > System.setProperty("base.dir", new File("").absolutePath) > > This will ensure that applications are always created relative to the > local path. While we could alternatively change how GrailsScriptRunner > works, I believe that it works properly in the 80% case and the change > is only needed for cases such as these. > > I'd like to also suggest an identical modification to > CreatePlugin.groovy to create a plugin within an application directory > structure, which I'd also run into in the past. > > Best, > > - Daiji > > > > > > ____________________________________________________________________________________ > Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games. > http://sims.yahoo.com/ > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by D T-2
After making the tweak in my own version of Grails, my program seems to
work okay where the app is nested in a plugin. I haven't tried the reverse yet, which I think is a valid development process (start out with an app, then refactor code into a plugin under the plugins dir, then pull out the plugin code to somewhere else). I'm actually a bit less concerned with how it comes out in SVN than I am about the directories on my own machine... but I guess this won't work so great from Eclipse when you want to have separate projects for the plugin and the application and load them both. See, I'm trying to find a way to manage this better (plugin code and sample app code as I develop newer versions of the plugin and as I upgrade between Grails versions). But I don't think any IDE should dictate what we do and don't support, either. So if nobody minds or has a strong opinion on the matter, I'll go ahead and make this change. Best, - Daiji Maurice Nicholson wrote: > Yes I came across this myself: > > I have integration tests that create new apps, copy over some domain > classes, etc, install the plugin and then run "grails > test-app/run-webtest" on the created apps. > > But due to this issue I needed to make the dir where the new apps are > created a dir outside of the plugin dir (in fact ../tmp, relative to > the plugin dir). > > Actually, I don't know whether you've tried it with a nested app > within a Grails app dir, Daiji, but you may find - even if you can > create it - that it causes problems with your plugins. The reason > being that some of the Grails code scans the file-/class-path for > resources recursively, and can complain if there appear to be > duplicate resources. This might be the case, for example if you have > <plugindir>/MyGrailsPlugin.groovy and > <plugindir>/samples/one/plugins/<pluginname>/MyGrailsPlugin.groovy. > > Maybe that won't be a problem for you but it was for me. > > I do think your suggestion is still valid, though :-) > > But here's an alternative: > > change the SVN structure from <grails-pluginname>/trunk/<plugindir> to > <grails-pluginname>/trunk/<grails-pluginname>/<plugindir>. So actually > introduce repetition with the repeated "grails-pluginname" under > trunk. That way it provides the option of more "top-level" folders > under the trunk, eg, "samples". > > Just a thought :-) > > > D T wrote: >> hi, >> >> I have a suggested change to the create-app and create-plugin scripts. >> >> I was looking into creating a samples directory under my plugin under >> which the plugin samples could live. But when I run "grails >> create-app myapp" from the PLUGINDIR/samples directory (where >> PLUGINDIR is my plugin's directory), I end up with PLUGINDIR/myapp, >> rather than PLUGINDIR/samples/myapp. After a little debugging, I >> found that the reason is that GrailsScriptRunner.establishBaseDir() >> is walking up the parent directory tree to locate a "grails-app" >> directory, which it'll find in PLUGINDIR as PLUGINDIR/grails-app. >> >> And so that explains why the application is created in the "wrong" >> directory. >> >> What I'd like to suggest is that we add the following to the top of >> CreateApp.groovy: >> >> // Ensure that the application is created in the current directory >> System.setProperty("base.dir", new File("").absolutePath) >> >> This will ensure that applications are always created relative to the >> local path. While we could alternatively change how >> GrailsScriptRunner works, I believe that it works properly in the 80% >> case and the change is only needed for cases such as these. >> >> I'd like to also suggest an identical modification to >> CreatePlugin.groovy to create a plugin within an application >> directory structure, which I'd also run into in the past. >> >> Best, >> >> - Daiji >> >> >> >> >> >> ____________________________________________________________________________________ >> >> Moody friends. Drama queens. Your life? Nope! - their life, your >> story. Play Sims Stories at Yahoo! Games. >> http://sims.yahoo.com/ >> --------------------------------------------------------------------- >> To unsubscribe from this list please visit: >> >> http://xircles.codehaus.org/manage_email >> >> >> > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > > > ____________________________________________________________________________________ Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center. http://autos.yahoo.com/green_center/ --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | Edit this page |
