Sharing files between projects

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Sharing files between projects

Nicholas Wittstruck
Hi everyone,

I have a couple of projects that access the same files during development and production. Currently these files are located in the web-app directory of each project, I'm accessing them via servletContext.getRealPath("…").

I would now like to put these files into a common directory. Is there any best practice for this? Every solution I came up with works either good in development or when compiled as a war, but not in both cases.

Does anybody have a good idea? Thanks!

Nicholas
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Sharing files between projects

Miles

Would a plugin be applicable? You can include that relative to your projects and you can productionize it latest using an appropriate artifact repository.

Sent from my tablet apologies for unusual brevity

On 22 May 2013 16:19, "Nicholas Wittstruck" <[hidden email]> wrote:
Hi everyone,

I have a couple of projects that access the same files during development and production. Currently these files are located in the web-app directory of each project, I'm accessing them via servletContext.getRealPath("…").

I would now like to put these files into a common directory. Is there any best practice for this? Every solution I came up with works either good in development or when compiled as a war, but not in both cases.

Does anybody have a good idea? Thanks!

Nicholas
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Sharing files between projects

xunitc
In reply to this post by Nicholas Wittstruck
Hi.
Maybe you can put all these files in a folder, and write a shell to
copy them to every app.
Or maybe you can use an env in os. Like myfolder=/home/me/myconfig
Then use
def config = System.getenv().myfolder;
println(config);

2013/5/22 Nicholas Wittstruck <[hidden email]>:

> Hi everyone,
>
> I have a couple of projects that access the same files during development and production. Currently these files are located in the web-app directory of each project, I'm accessing them via servletContext.getRealPath("…").
>
> I would now like to put these files into a common directory. Is there any best practice for this? Every solution I came up with works either good in development or when compiled as a war, but not in both cases.
>
> Does anybody have a good idea? Thanks!
>
> Nicholas
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>



--
Xunitc.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Xunitc
Reply | Threaded
Open this post in threaded view
|

Re: Sharing files between projects

Nicholas Wittstruck
In reply to this post by Nicholas Wittstruck
By the way, this is what I came up with, but I wanted to know if there is a better solution:

eventPackagingEnd = {
    println "Copying files to classpath"
    ant.copy(todir: classesDirPath + "/files", overwrite: true) {
        fileset(dir:"../files",includes:"**")
    }
}

new ClassPathResource("files/...").getFile()

On 22.05.2013, at 17:07, Nicholas Wittstruck <[hidden email]> wrote:

> Hi everyone,
>
> I have a couple of projects that access the same files during development and production. Currently these files are located in the web-app directory of each project, I'm accessing them via servletContext.getRealPath("…").
>
> I would now like to put these files into a common directory. Is there any best practice for this? Every solution I came up with works either good in development or when compiled as a war, but not in both cases.
>
> Does anybody have a good idea? Thanks!
>
> Nicholas


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Sharing files between projects

sergiomichels
Isn't better to wrap this in a jar or a plugin?

--
Sérgio Michels


On Wed, May 22, 2013 at 12:45 PM, Nicholas Wittstruck <[hidden email]> wrote:
By the way, this is what I came up with, but I wanted to know if there is a better solution:

eventPackagingEnd = {
    println "Copying files to classpath"
    ant.copy(todir: classesDirPath + "/files", overwrite: true) {
        fileset(dir:"../files",includes:"**")
    }
}

new ClassPathResource("files/...").getFile()

On 22.05.2013, at 17:07, Nicholas Wittstruck <[hidden email]> wrote:

> Hi everyone,
>
> I have a couple of projects that access the same files during development and production. Currently these files are located in the web-app directory of each project, I'm accessing them via servletContext.getRealPath("…").
>
> I would now like to put these files into a common directory. Is there any best practice for this? Every solution I came up with works either good in development or when compiled as a war, but not in both cases.
>
> Does anybody have a good idea? Thanks!
>
> Nicholas


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Sharing files between projects

Corum, Michael
In reply to this post by Nicholas Wittstruck
A plugin comes to mind right away.  We've developed several plugins for our own purposes and use them across applications.  Also, if you want something at a lower level (things in the /src tree), you might just make a simple Maven library and store it in a proxy server like Sonatype Nexus.  You can refer to those in the BuildConfig.groovy as well.

I would recommend reading the Grails documentation, especially in the area of dependency management.

Mike

-----Original Message-----
From: Nicholas Wittstruck [mailto:[hidden email]]
Sent: Wednesday, May 22, 2013 10:46 AM
To: [hidden email]
Subject: [grails-user] Re: Sharing files between projects

By the way, this is what I came up with, but I wanted to know if there is a better solution:

eventPackagingEnd = {
    println "Copying files to classpath"
    ant.copy(todir: classesDirPath + "/files", overwrite: true) {
        fileset(dir:"../files",includes:"**")
    }
}

new ClassPathResource("files/...").getFile()

On 22.05.2013, at 17:07, Nicholas Wittstruck <[hidden email]> wrote:

> Hi everyone,
>
> I have a couple of projects that access the same files during development and production. Currently these files are located in the web-app directory of each project, I'm accessing them via servletContext.getRealPath("...").
>
> I would now like to put these files into a common directory. Is there any best practice for this? Every solution I came up with works either good in development or when compiled as a war, but not in both cases.
>
> Does anybody have a good idea? Thanks!
>
> Nicholas


---------------------------------------------------------------------
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


Reply | Threaded
Open this post in threaded view
|

Re: Sharing files between projects

johnr
In reply to this post by Nicholas Wittstruck
You could use a git submodule or svn external to pull the files in
through source control.  A plugin seems like a more natural fit,
though.

On Wed, May 22, 2013 at 11:45 AM, Nicholas Wittstruck
<[hidden email]> wrote:

> By the way, this is what I came up with, but I wanted to know if there is a better solution:
>
> eventPackagingEnd = {
>     println "Copying files to classpath"
>     ant.copy(todir: classesDirPath + "/files", overwrite: true) {
>         fileset(dir:"../files",includes:"**")
>     }
> }
>
> new ClassPathResource("files/...").getFile()
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Sharing files between projects

Nicholas Wittstruck
The projects are already sharing a plugin, so that's probably a good idea :) I've moved the files to src/groovy and that works, but is there any chance that I can move the files to src/files? I'd like to separate them.


On 22.05.2013, at 18:29, John Reuning <[hidden email]> wrote:

> You could use a git submodule or svn external to pull the files in
> through source control.  A plugin seems like a more natural fit,
> though.
>
> On Wed, May 22, 2013 at 11:45 AM, Nicholas Wittstruck
> <[hidden email]> wrote:
>> By the way, this is what I came up with, but I wanted to know if there is a better solution:
>>
>> eventPackagingEnd = {
>>    println "Copying files to classpath"
>>    ant.copy(todir: classesDirPath + "/files", overwrite: true) {
>>        fileset(dir:"../files",includes:"**")
>>    }
>> }
>>
>> new ClassPathResource("files/...").getFile()
>>
>
> ---------------------------------------------------------------------
> 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