how to get Grails Plugin to include empty directories

35 views
Skip to first unread message

clr meno

unread,
Apr 17, 2017, 11:31:34 AM4/17/17
to Grails Dev Discuss
I have created a plugin to hold the conf directories since the same configurations apply to multiple applications. The issue is that when I include the plugin in the host application the empty folders under these configuration directories are not included.
For Example, if I have a folder ABC under grails-app/conf and this folder ABC has ABC1.properties and an empty folder ABC2, then the installed plugin only has ABC1.properties under ABC. 
I need the empty folder included as well. 
The host code has logic to create files in this empty folder which is currently failing as the folder doesn't exist. Any advise is much appreciated.

Sergio Michels

unread,
Apr 18, 2017, 9:00:07 PM4/18/17
to grails-de...@googlegroups.com
I'm not sure if I understood what you're trying to do with the configuration folder. 

By "host code" you mean your application code? When exactly you create files in the "ABC2" folder (by script, in runtime...)?

If your applications are aware that files should be created in that folder, why they can't create the folder if it not exists?

--
Sérgio Michels

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-discuss+unsub...@googlegroups.com.
To post to this group, send email to grails-dev-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/4b98a09c-f04d-4698-ba1d-297ef58a559e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeff Scott Brown

unread,
Apr 19, 2017, 5:09:24 PM4/19/17
to Grails Dev Discuss
It isn’t really clear to me what it is you are trying to accomplish
but which version of Grails you are using will be relevant. For
example, In Grails 1 and 2 there is an event hook that a plugin can
connect with to do things like create directories at plugin installation
time. In Grails 3 there is no such thing, but depending on the
particulars of what you are trying to accomplish, there would be
options.



JSB


--
Jeff Scott Brown
OCI Grails Practice Lead
Principal Software Engineer

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

Phill Nacelli

unread,
Apr 19, 2017, 9:46:12 PM4/19/17
to Grails Dev Discuss
This is a shot in the dark, but are you using GIT for your source version control? If so, is that what you mean as "the empty folders under these configuration directories are not included"?
Message has been deleted

clr meno

unread,
Apr 26, 2017, 6:00:52 PM4/26/17
to Grails Dev Discuss
Sorry for the delay in responding.

We have application specific config in separate directories and these directories are added under grails-app/conf.
For example:
grails-app
             -conf
                    - bookData
                          - bookFolder (this is an empty folder)
                          - bookConf.groovy

                    - encryptionData
                          - encrFolder (this is an empty folder)
                          - encrConf.groovy

These conf folders are in a plugin and the plugin is included in the main application through BuildConfig.groovy under
plugins{
      compile ':myPlugin'
}


But when the compilation of the main application completes, the plugin that gets added contains the following:

grails-app
             -conf
                    - bookData
                          - bookConf.groovy

                    - encryptionData
                          - encrConf.groovy

But I need it to include even the empty folders like given below:

grails-app
             -conf
                    - bookData
                          - bookFolder (this is an empty folder)
                          - bookConf.groovy

                    - encryptionData
                          - encrFolder (this is an empty folder)
                          - encrConf.groovy


Any advise is much appreciated

Jeff Scott Brown

unread,
Apr 27, 2017, 9:45:08 AM4/27/17
to Grails Dev Discuss
Because you mentioned BuildConfig.groovy, I assume you are using Grails
1 or 2. If that is the case, you could create the empty directory from
the plugin’s _Install.groovy script. The example at
http://docs.grails.org/2.5.6/guide/plugins.html#hookingIntoBuildEvents
does exactly that.

clr meno

unread,
Apr 28, 2017, 12:25:06 PM4/28/17
to Grails Dev Discuss
Yes I am using Grails 2.4.4. 
Is there a way to specify includeEmptyDirs= true while the plugin is included in BuildConfig.groovy so that the empty directories also get included and not omitted. 

Jeff Scott Brown

unread,
Apr 28, 2017, 12:35:07 PM4/28/17
to Grails Dev Discuss
On 28 Apr 2017, at 11:25, clr meno wrote:

> Yes I am using Grails 2.4.4.
> Is there a way to specify includeEmptyDirs= true while the plugin is
> included in BuildConfig.groovy so that the empty directories also get
> included and not omitted.
>

I don’t know what you mean by included. A plugin doesn’t generally
contain content that automatically gets contributed to the project
source code tree when a plugin is installed. If you want a certain
directory to exist in the application that is using the plugin, you
should either make that a documentation issue, or do something like use
the _Install.groovy script that I mentioned earlier.

clr meno

unread,
May 1, 2017, 7:24:00 AM5/1/17
to Grails Dev Discuss
Thanks a lot for your response Jeff.
My understanding of plugin is that it is similar to a jar file in java applications. Hence, I created a custom plugin and moved all the common configuration related files/folders to that plugin. So that every application that uses those configurations can just add the plugin. One of the conf folders has an empty directory so wanted to know if there is any option to include the exact folder structure including this empty directory. 

I will definitely try using _Install.groovy script but wanted to know if there was an alternative way to specify this while I added it in BuildConfig.groovy

clr meno

unread,
May 1, 2017, 12:03:49 PM5/1/17
to Grails Dev Discuss
Thanks a lot for all your responses.

I finally took the approach of checking the existence of the folder and creating a folder if it didn't exist. I made this change in the main application that included this plugin.
Reply all
Reply to author
Forward
0 new messages