How to prevent compilation of Groovy resource files

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

How to prevent compilation of Groovy resource files

Peter Niederwieser
Administrator
We have a logback.groovy file in src/main/resources that needs to be copied to the output directory as-is. How can we achieve this in (Groovy) Eclipse? Right now the file either gets compiled or, if we add an exclusion, doesn't appear in the output directory at all.

Cheers,
Peter
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent compilation of Groovy resource files

Andrew Eisenberg
That's a bit of a tough one.

If you were to remove the groovy nature from the project, then all
groovy files would be copied over to the output folder, but I don't
think that's what you want to do.  As of now, this is not currently
possible.

The behavior of the JavaBuilder is to copy over non-source files to
the output folder, to compile included source files, and to do nothing
for excluded source files.  In this situation, the behavior needs to
change.  This particular excluded groovy file needs to be handled
differently.

There are two reasonable fixes that I can imagine:

1. Change the behavior so that all excluded groovy files are copied to
the output folder.  Simple, but this is a departure from the behavior
of the JavaBuilder and may cause some surprises for users expecting
the old behavior.
2. Add a kind of user-configurable inclusion filter that specifies
which groovy files should be copied over into the output folder.  Then
add a CompilationParticipant that runs after compilation to perform
the copying. Although possible, this feels like overkill.

I'm trying to think of what the ramifications of #1 would be.  If we
choose to go this way, then I can have a fix out in a couple of hours.
 #2 would take a lot longer and I would not be able to get to it
immediately.

On Thu, Sep 9, 2010 at 10:44 AM, Peter Niederwieser <[hidden email]> wrote:

>
> We have a logback.groovy file in src/main/resources that needs to be copied
> to the output directory as-is. How can we achieve this in (Groovy) Eclipse?
> Right now the file either gets compiled or, if we add an exclusion, doesn't
> appear in the output directory at all.
>
> Cheers,
> Peter
> --
> View this message in context: http://groovy-eclipse-plugin.42567.n3.nabble.com/How-to-prevent-compilation-of-Groovy-resource-files-tp1447484p1447484.html
> Sent from the groovy-eclipse-plugin-user mailing list archive at Nabble.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


Reply | Threaded
Open this post in threaded view
|

Re: How to prevent compilation of Groovy resource files

Peter Niederwieser
Administrator
I'm not sure what's the best design for such a feature in Eclipse. All I can say is that it works out of the box in Maven and IDEA, and that there are several libraries that make use of Groovy config files. In our new project, we already use two such libraries: Logback (log4j successor), and Spock. For the time being, we can probably find workarounds (like configuring Logback with XML), but it would be nice if Groovy Eclipse provided a way to put Groovy config files on the class path.

Cheers,
Peter
Reply | Threaded
Open this post in threaded view
|

Re: How to prevent compilation of Groovy resource files

Andy Clement
Peter - do you know how maven and IDEA know that it is special?  Do
you believe that they don't see anything in a src/main/resources
folder as a source file for compilation?

Andy

On 10 September 2010 03:51, Peter Niederwieser <[hidden email]> wrote:

>
> I'm not sure what's the best design for such a feature in Eclipse. All I can
> say is that it works out of the box in Maven and IDEA, and that there are
> several libraries that make use of Groovy config files. In our new project,
> we already use two such libraries: Logback (log4j successor), and Spock. For
> the time being, we can probably find workarounds (like configuring Logback
> with XML), but it would be nice if Groovy Eclipse provided a way to put
> Groovy config files on the class path.
>
> Cheers,
> Peter
> --
> View this message in context: http://groovy-eclipse-plugin.42567.n3.nabble.com/How-to-prevent-compilation-of-Groovy-resource-files-tp1447484p1451634.html
> Sent from the groovy-eclipse-plugin-user mailing list archive at Nabble.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


Reply | Threaded
Open this post in threaded view
|

Re: How to prevent compilation of Groovy resource files

Andrew Eisenberg
There is already an enhancement request open for this.  I just added a
bit of a proposal of how we could go about implementing this.  I
imagine a workspace-wide filter that specifies regex's of script
files.  We'll prepopulate with standard maven resource folders, and
users can add their own.

These files would be reconciled, but not compiled.  This ensures that
content assist, etc would work for them, but that byte code would
never be produced.

See: http://jira.codehaus.org/browse/GRECLIPSE-714

On Fri, Sep 10, 2010 at 8:16 AM, Andy Clement <[hidden email]> wrote:

> Peter - do you know how maven and IDEA know that it is special?  Do
> you believe that they don't see anything in a src/main/resources
> folder as a source file for compilation?
>
> Andy
>
> On 10 September 2010 03:51, Peter Niederwieser <[hidden email]> wrote:
>>
>> I'm not sure what's the best design for such a feature in Eclipse. All I can
>> say is that it works out of the box in Maven and IDEA, and that there are
>> several libraries that make use of Groovy config files. In our new project,
>> we already use two such libraries: Logback (log4j successor), and Spock. For
>> the time being, we can probably find workarounds (like configuring Logback
>> with XML), but it would be nice if Groovy Eclipse provided a way to put
>> Groovy config files on the class path.
>>
>> Cheers,
>> Peter
>> --
>> View this message in context: http://groovy-eclipse-plugin.42567.n3.nabble.com/How-to-prevent-compilation-of-Groovy-resource-files-tp1447484p1451634.html
>> Sent from the groovy-eclipse-plugin-user mailing list archive at Nabble.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
>
>
>

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: How to prevent compilation of Groovy resource files

Peter Niederwieser
Administrator
In reply to this post by Andy Clement
Andy Clement wrote
Peter - do you know how maven and IDEA know that it is special?  Do
you believe that they don't see anything in a src/main/resources
folder as a source file for compilation?
For Maven it's simple: By default, the Java compiler plugin only looks into src/main(test)/java, GMaven only into src/main(test)/groovy, and the maven-resources-plugin only into src/main(test)/resources. Therefore, every file in the latter location is considered a resource.

IDEA doesn't have the concept of a resource folder. src/main(test)/resources is marked as a source folder, but maybe there is some special handling in place for projects imported from Maven. Haven't found an explicit option to control handling of Groovy files in src/main(test)/resources, but I guess they are never compiled (at least for Maven projects).

Cheers,
Peter