You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Lewis, Eric" <Er...@ipi.ch> on 2009/10/01 13:59:05 UTC

How to add generated resources directory in a plugin

Hi

I'm writing a plugin which generates resources and also test resources.
How in my plugin can I add these directories to the sources paths and the test resources paths?
(Except for using the build-helper plugin)

Best regards,
Eric

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to add generated resources directory in a plugin

Posted by Roland Asmann <Ro...@cfc.at>.
Ouch... But like I said: I wasn't sure if it would work. We generate our 
sources and resources in separate folders.

OK, so it doesn't work this way... Maybe it is better to use your solution and 
add the source-folder to the resources. Either use the include, or (probably 
easier) the excludes (**/*.java). That should do the trick.


On Friday 02 October 2009 13:12, Werner Guttmann wrote:
> That does not really match what I am observing .. :-(.
>
> If I generate Java sources and resources into
>
> target/generated-sources/castor
>
> and use
>
> project.addCompileSourceRoot("target/generated-sources/castor")
>
> within the Maven plugin for Castor, Maven will include the generated
> Java classes during compilation and put the class files in
> target/classes of the project.
>
> As a result of this, users of the Maven plugin for Castor currently have
> to add the following section to their project POMs.
>
> <resources>
>    <resource>
>       <directory>target/generated-sources/castor</directory>
>       <includes>
>          <include>**/*.cdr</include>
>       </includes>
>    </resource>
>    <resource>
>       <directory>src/main/resources</directory>
>    </resource>
> </resources>
>
> to have those .castor.cdr Files copied to target/classes as well. As we
> all know, this is error-prone.
>
> As such, I tried to add code to the Maven plugin for Castor as follows:
>
> Resource resource = new Resource();
> resource.setDirectory( getResourceDestination().getAbsolutePath() );
> List<String> includes = new LinkedList<String>();
> includes.add( "**/*.cdr" );
> resource.setIncludes( includes );
> project.addResource( resource );
>
> Problem is that once I add that code, the Java source files start
> showing up in target/classes, which is not ideal.
>
> Any idea what's going wrong here ?
>
> Werner
>
> Roland Asmann wrote:
> > I believe this can work (not 100% sure, I generate into two different
> > directories for sources and resources), but you should probably ONLY use
> > the addCompileSourceRoot for your directory...
> >
> > The way I understand it, is that if you put sources & resources there,
> > they are compiled to the output dir. Java knows how to handle .java-files
> > --> convert them to classes, and how to handle anything else --> just
> > copy. If you use the resource-dir, maven will handle the copying and will
> > copy everything from the source to the target, without compiling.
> >
> > So, I presume you have used both calls I gave you, although you should
> > only use one.
> >
> > Hope this helps,
> >
> > On Thursday 01 October 2009 15:15, Werner Guttmann wrote:
> >> Hi Roland,
> >>
> >> does this pattern/recipe change if both resources and Java classes would
> >> be generated in the same directory. I have tried this a few days ago
> >> (trying to automate a few things for the castor-maven-plugin), and it
> >> seems like this does not really work.
> >>
> >> Assume you have a directory where you'll find ....
> >>
> >> - A.java
> >> - B.java
> >> - .castor.cdr
> >>
> >> where the last is a resource file. If I use above code snippets, I can
> >> see in the target folder after a plugin run and subsequent compilation
> >> the compiled Java classes, the resource file and the source files.
> >>
> >> How can I avoid the source files to be copy across ?
> >>
> >> Regards
> >> Werner
> >>
> >> Roland Asmann wrote:
> >>> Assuming you already have the maven-project as a variable in your
> >>> plugin (if not, add it!):
> >>>
> >>> project.addCompileSourceRoot("your output directory here");
> >>>
> >>>
> >>> And in the case of resources:
> >>>
> >>> Resource resource = new Resource();
> >>> resource.setDirectory("your output directory here");
> >>> resource.addInclude("**/*");
> >>> project.addResource(resource);
> >>>
> >>> On Thursday 01 October 2009 13:59, Lewis, Eric wrote:
> >>>> Hi
> >>>>
> >>>> I'm writing a plugin which generates resources and also test
> >>>> resources. How in my plugin can I add these directories to the sources
> >>>> paths and the test resources paths? (Except for using the build-helper
> >>>> plugin)
> >>>>
> >>>> Best regards,
> >>>> Eric
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>>> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org

-- 
Roland Asmann

CFC Informationssysteme Entwicklungsgesellschaft m.b.H
Bäckerstrasse 1/2/7
A-1010 Wien
FN 266155f, Handelsgericht Wien

Tel.: +43/1/513 88 77 - 27
Fax.: +43/1/513 88 62
Email: Roland.Asmann@cfc.at
Web: www.cfc.at

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to add generated resources directory in a plugin

Posted by Stevo Slavić <ss...@gmail.com>.
What I do until this <http://jira.codehaus.org/browse/CASTOR-2829> is
released as part of castor 1.3.1 is to add castor generates sources (.java)
via build helper plugin, and for the Castor resources configure build
resources to along with src/main/resource directory include
${project.build.directory}/generated-sources/castor directory with includes
section that has single include, **/.castor.cdr

Regards,
Stevo.

On Tue, Oct 6, 2009 at 10:15 AM, Roland Asmann <Ro...@cfc.at> wrote:

> Werber,
>
> Understandable. Then add the generated folder as a sources-folder and a
> resources-folder with a filter on '**/*.java'. I guess that would be the
> easiest way, in case more resource-types make it into this folder.
>
> Roland
>
>
> > Roland,
> >
> > I wish I had a choice, but I have to keep backwards-compatibility. Until
> > now, we used to offer one property on the Mojo to set the output path
> > (with a default of target/generated-sources/castor).
> >
> > Now, we are offering a second option for the resource files generated,
> > but I still have to cater for those expecting things in the old location.
> >
> > Werber
> >
> > Roland Asmann wrote:
> >> Read the part about editing the plugin again... If you're working on the
> >> actual castor-plugin, wouldn't it be easier to just separate the sources
> >> and
> >> resources instead of adding the resources with inclusion/exclusion
> >> rules?
> >>
> >>
> >> On Friday 02 October 2009 13:45, Werner Guttmann wrote:
> >>> Eric,
> >>>
> >>> the .castor.cdr files are a by-product of generating Java classes from
> >>> an XML schema using the XML code generator of Castor (through the Maven
> >>> plugin for Castor).
> >>>
> >>> Those resource files are being generated in
> >>> target/generated-sources/castor during code generation.
> >>>
> >>> I hopes this makes it clearer ....
> >>>
> >>> Werner
> >>>
> >>> Lewis, Eric wrote:
> >>>> Just out of curiosity: Is there a reason that you keep the .cdr files
> >>>> in
> >>>> src/main/java? IMHO you could have them in src/main/resources, since
> >>>> they
> >>>> end up in target/classes anyway.
> >>>>
> >>>> Best regards,
> >>>> Eric
> >>>>
> >>>>> -----Ursprüngliche Nachricht-----
> >>>>> Von: Werner Guttmann [mailto:wguttmn@codehaus.org]
> >>>>> Gesendet: Freitag, 2. Oktober 2009 13:13
> >>>>> An: Maven Users List
> >>>>> Betreff: Re: How to add generated resources directory in a plugin
> >>>>>
> >>>>> That does not really match what I am observing .. :-(.
> >>>>>
> >>>>> If I generate Java sources and resources into
> >>>>>
> >>>>> target/generated-sources/castor
> >>>>>
> >>>>> and use
> >>>>>
> >>>>> project.addCompileSourceRoot("target/generated-sources/castor")
> >>>>>
> >>>>> within the Maven plugin for Castor, Maven will include the generated
> >>>>> Java classes during compilation and put the class files in
> >>>>> target/classes of the project.
> >>>>>
> >>>>> As a result of this, users of the Maven plugin for Castor
> >>>>> currently have
> >>>>> to add the following section to their project POMs.
> >>>>>
> >>>>> <resources>
> >>>>>    <resource>
> >>>>>       <directory>target/generated-sources/castor</directory>
> >>>>>       <includes>
> >>>>>          <include>**/*.cdr</include>
> >>>>>       </includes>
> >>>>>    </resource>
> >>>>>    <resource>
> >>>>>       <directory>src/main/resources</directory>
> >>>>>    </resource>
> >>>>> </resources>
> >>>>>
> >>>>> to have those .castor.cdr Files copied to target/classes as
> >>>>> well. As we
> >>>>> all know, this is error-prone.
> >>>>>
> >>>>> As such, I tried to add code to the Maven plugin for Castor
> >>>>> as follows:
> >>>>>
> >>>>> Resource resource = new Resource();
> >>>>> resource.setDirectory( getResourceDestination().getAbsolutePath() );
> >>>>> List<String> includes = new LinkedList<String>();
> >>>>> includes.add( "**/*.cdr" );
> >>>>> resource.setIncludes( includes );
> >>>>> project.addResource( resource );
> >>>>>
> >>>>> Problem is that once I add that code, the Java source files start
> >>>>> showing up in target/classes, which is not ideal.
> >>>>>
> >>>>> Any idea what's going wrong here ?
> >>>>>
> >>>>> Werner
> >>>>>
> >>>>> Roland Asmann wrote:
> >>>>>> I believe this can work (not 100% sure, I generate into two
> >>>>> different
> >>>>>
> >>>>>> directories for sources and resources), but you should
> >>>>> probably ONLY use the
> >>>>>
> >>>>>> addCompileSourceRoot for your directory...
> >>>>>>
> >>>>>> The way I understand it, is that if you put sources &
> >>>>> resources there, they
> >>>>>
> >>>>>> are compiled to the output dir. Java knows how to handle
> >>>>> .java-files -->
> >>>>>
> >>>>>> convert them to classes, and how to handle anything else
> >>>>> --> just copy.
> >>>>>
> >>>>>> If you use the resource-dir, maven will handle the copying
> >>>>> and will copy
> >>>>>
> >>>>>> everything from the source to the target, without compiling.
> >>>>>>
> >>>>>> So, I presume you have used both calls I gave you, although
> >>>>> you should only
> >>>>>
> >>>>>> use one.
> >>>>>>
> >>>>>> Hope this helps,
> >>>>>>
> >>>>>> On Thursday 01 October 2009 15:15, Werner Guttmann wrote:
> >>>>>>> Hi Roland,
> >>>>>>>
> >>>>>>> does this pattern/recipe change if both resources and Java
> >>>>> classes would
> >>>>>
> >>>>>>> be generated in the same directory. I have tried this a
> >>>>> few days ago
> >>>>>
> >>>>>>> (trying to automate a few things for the
> >>>>> castor-maven-plugin), and it
> >>>>>
> >>>>>>> seems like this does not really work.
> >>>>>>>
> >>>>>>> Assume you have a directory where you'll find ....
> >>>>>>>
> >>>>>>> - A.java
> >>>>>>> - B.java
> >>>>>>> - .castor.cdr
> >>>>>>>
> >>>>>>> where the last is a resource file. If I use above code
> >>>>> snippets, I can
> >>>>>
> >>>>>>> see in the target folder after a plugin run and subsequent
> >>>>> compilation
> >>>>>
> >>>>>>> the compiled Java classes, the resource file and the source files.
> >>>>>>>
> >>>>>>> How can I avoid the source files to be copy across ?
> >>>>>>>
> >>>>>>> Regards
> >>>>>>> Werner
> >>>>>>>
> >>>>>>> Roland Asmann wrote:
> >>>>>>>> Assuming you already have the maven-project as a variable
> >>>>> in your plugin
> >>>>>
> >>>>>>>> (if not, add it!):
> >>>>>>>>
> >>>>>>>> project.addCompileSourceRoot("your output directory here");
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> And in the case of resources:
> >>>>>>>>
> >>>>>>>> Resource resource = new Resource();
> >>>>>>>> resource.setDirectory("your output directory here");
> >>>>>>>> resource.addInclude("**/*");
> >>>>>>>> project.addResource(resource);
> >>>>>>>>
> >>>>>>>> On Thursday 01 October 2009 13:59, Lewis, Eric wrote:
> >>>>>>>>> Hi
> >>>>>>>>>
> >>>>>>>>> I'm writing a plugin which generates resources and also
> >>>>> test resources.
> >>>>>
> >>>>>>>>> How in my plugin can I add these directories to the
> >>>>> sources paths and
> >>>>>
> >>>>>>>>> the test resources paths? (Except for using the
> >>>>> build-helper plugin)
> >>>>>
> >>>>>>>>> Best regards,
> >>>>>>>>> Eric
> >>>>> ---------------------------------------------------------------------
> >>>>>
> >>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>>>>>>>> For additional commands, e-mail: users-help@maven.apache.org
> >>>>> ---------------------------------------------------------------------
> >>>>>
> >>>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>>>>>> For additional commands, e-mail: users-help@maven.apache.org
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>>>> For additional commands, e-mail: users-help@maven.apache.org
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>>> For additional commands, e-mail: users-help@maven.apache.org
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: How to add generated resources directory in a plugin

Posted by Werner Guttmann <wg...@codehaus.org>.
Which is exactly what I ended up doing. Thanks for everybody's patience ...

Werner

Roland Asmann wrote:
> Werber,
> 
> Understandable. Then add the generated folder as a sources-folder and a
> resources-folder with a filter on '**/*.java'. I guess that would be the
> easiest way, in case more resource-types make it into this folder.
> 
> Roland
> 
> 
>> Roland,
>>
>> I wish I had a choice, but I have to keep backwards-compatibility. Until
>> now, we used to offer one property on the Mojo to set the output path
>> (with a default of target/generated-sources/castor).
>>
>> Now, we are offering a second option for the resource files generated,
>> but I still have to cater for those expecting things in the old location.
>>
>> Werber
>>
>> Roland Asmann wrote:
>>> Read the part about editing the plugin again... If you're working on the
>>> actual castor-plugin, wouldn't it be easier to just separate the sources
>>> and
>>> resources instead of adding the resources with inclusion/exclusion
>>> rules?
>>>
>>>
>>> On Friday 02 October 2009 13:45, Werner Guttmann wrote:
>>>> Eric,
>>>>
>>>> the .castor.cdr files are a by-product of generating Java classes from
>>>> an XML schema using the XML code generator of Castor (through the Maven
>>>> plugin for Castor).
>>>>
>>>> Those resource files are being generated in
>>>> target/generated-sources/castor during code generation.
>>>>
>>>> I hopes this makes it clearer ....
>>>>
>>>> Werner
>>>>
>>>> Lewis, Eric wrote:
>>>>> Just out of curiosity: Is there a reason that you keep the .cdr files
>>>>> in
>>>>> src/main/java? IMHO you could have them in src/main/resources, since
>>>>> they
>>>>> end up in target/classes anyway.
>>>>>
>>>>> Best regards,
>>>>> Eric
>>>>>
>>>>>> -----Ursprüngliche Nachricht-----
>>>>>> Von: Werner Guttmann [mailto:wguttmn@codehaus.org]
>>>>>> Gesendet: Freitag, 2. Oktober 2009 13:13
>>>>>> An: Maven Users List
>>>>>> Betreff: Re: How to add generated resources directory in a plugin
>>>>>>
>>>>>> That does not really match what I am observing .. :-(.
>>>>>>
>>>>>> If I generate Java sources and resources into
>>>>>>
>>>>>> target/generated-sources/castor
>>>>>>
>>>>>> and use
>>>>>>
>>>>>> project.addCompileSourceRoot("target/generated-sources/castor")
>>>>>>
>>>>>> within the Maven plugin for Castor, Maven will include the generated
>>>>>> Java classes during compilation and put the class files in
>>>>>> target/classes of the project.
>>>>>>
>>>>>> As a result of this, users of the Maven plugin for Castor
>>>>>> currently have
>>>>>> to add the following section to their project POMs.
>>>>>>
>>>>>> <resources>
>>>>>>    <resource>
>>>>>>       <directory>target/generated-sources/castor</directory>
>>>>>>       <includes>
>>>>>>          <include>**/*.cdr</include>
>>>>>>       </includes>
>>>>>>    </resource>
>>>>>>    <resource>
>>>>>>       <directory>src/main/resources</directory>
>>>>>>    </resource>
>>>>>> </resources>
>>>>>>
>>>>>> to have those .castor.cdr Files copied to target/classes as
>>>>>> well. As we
>>>>>> all know, this is error-prone.
>>>>>>
>>>>>> As such, I tried to add code to the Maven plugin for Castor
>>>>>> as follows:
>>>>>>
>>>>>> Resource resource = new Resource();
>>>>>> resource.setDirectory( getResourceDestination().getAbsolutePath() );
>>>>>> List<String> includes = new LinkedList<String>();
>>>>>> includes.add( "**/*.cdr" );
>>>>>> resource.setIncludes( includes );
>>>>>> project.addResource( resource );
>>>>>>
>>>>>> Problem is that once I add that code, the Java source files start
>>>>>> showing up in target/classes, which is not ideal.
>>>>>>
>>>>>> Any idea what's going wrong here ?
>>>>>>
>>>>>> Werner
>>>>>>
>>>>>> Roland Asmann wrote:
>>>>>>> I believe this can work (not 100% sure, I generate into two
>>>>>> different
>>>>>>
>>>>>>> directories for sources and resources), but you should
>>>>>> probably ONLY use the
>>>>>>
>>>>>>> addCompileSourceRoot for your directory...
>>>>>>>
>>>>>>> The way I understand it, is that if you put sources &
>>>>>> resources there, they
>>>>>>
>>>>>>> are compiled to the output dir. Java knows how to handle
>>>>>> .java-files -->
>>>>>>
>>>>>>> convert them to classes, and how to handle anything else
>>>>>> --> just copy.
>>>>>>
>>>>>>> If you use the resource-dir, maven will handle the copying
>>>>>> and will copy
>>>>>>
>>>>>>> everything from the source to the target, without compiling.
>>>>>>>
>>>>>>> So, I presume you have used both calls I gave you, although
>>>>>> you should only
>>>>>>
>>>>>>> use one.
>>>>>>>
>>>>>>> Hope this helps,
>>>>>>>
>>>>>>> On Thursday 01 October 2009 15:15, Werner Guttmann wrote:
>>>>>>>> Hi Roland,
>>>>>>>>
>>>>>>>> does this pattern/recipe change if both resources and Java
>>>>>> classes would
>>>>>>
>>>>>>>> be generated in the same directory. I have tried this a
>>>>>> few days ago
>>>>>>
>>>>>>>> (trying to automate a few things for the
>>>>>> castor-maven-plugin), and it
>>>>>>
>>>>>>>> seems like this does not really work.
>>>>>>>>
>>>>>>>> Assume you have a directory where you'll find ....
>>>>>>>>
>>>>>>>> - A.java
>>>>>>>> - B.java
>>>>>>>> - .castor.cdr
>>>>>>>>
>>>>>>>> where the last is a resource file. If I use above code
>>>>>> snippets, I can
>>>>>>
>>>>>>>> see in the target folder after a plugin run and subsequent
>>>>>> compilation
>>>>>>
>>>>>>>> the compiled Java classes, the resource file and the source files.
>>>>>>>>
>>>>>>>> How can I avoid the source files to be copy across ?
>>>>>>>>
>>>>>>>> Regards
>>>>>>>> Werner
>>>>>>>>
>>>>>>>> Roland Asmann wrote:
>>>>>>>>> Assuming you already have the maven-project as a variable
>>>>>> in your plugin
>>>>>>
>>>>>>>>> (if not, add it!):
>>>>>>>>>
>>>>>>>>> project.addCompileSourceRoot("your output directory here");
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> And in the case of resources:
>>>>>>>>>
>>>>>>>>> Resource resource = new Resource();
>>>>>>>>> resource.setDirectory("your output directory here");
>>>>>>>>> resource.addInclude("**/*");
>>>>>>>>> project.addResource(resource);
>>>>>>>>>
>>>>>>>>> On Thursday 01 October 2009 13:59, Lewis, Eric wrote:
>>>>>>>>>> Hi
>>>>>>>>>>
>>>>>>>>>> I'm writing a plugin which generates resources and also
>>>>>> test resources.
>>>>>>
>>>>>>>>>> How in my plugin can I add these directories to the
>>>>>> sources paths and
>>>>>>
>>>>>>>>>> the test resources paths? (Except for using the
>>>>>> build-helper plugin)
>>>>>>
>>>>>>>>>> Best regards,
>>>>>>>>>> Eric
>>>>>> ---------------------------------------------------------------------
>>>>>>
>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>>>>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>>> ---------------------------------------------------------------------
>>>>>>
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to add generated resources directory in a plugin

Posted by Roland Asmann <Ro...@cfc.at>.
Werber,

Understandable. Then add the generated folder as a sources-folder and a
resources-folder with a filter on '**/*.java'. I guess that would be the
easiest way, in case more resource-types make it into this folder.

Roland


> Roland,
>
> I wish I had a choice, but I have to keep backwards-compatibility. Until
> now, we used to offer one property on the Mojo to set the output path
> (with a default of target/generated-sources/castor).
>
> Now, we are offering a second option for the resource files generated,
> but I still have to cater for those expecting things in the old location.
>
> Werber
>
> Roland Asmann wrote:
>> Read the part about editing the plugin again... If you're working on the
>> actual castor-plugin, wouldn't it be easier to just separate the sources
>> and
>> resources instead of adding the resources with inclusion/exclusion
>> rules?
>>
>>
>> On Friday 02 October 2009 13:45, Werner Guttmann wrote:
>>> Eric,
>>>
>>> the .castor.cdr files are a by-product of generating Java classes from
>>> an XML schema using the XML code generator of Castor (through the Maven
>>> plugin for Castor).
>>>
>>> Those resource files are being generated in
>>> target/generated-sources/castor during code generation.
>>>
>>> I hopes this makes it clearer ....
>>>
>>> Werner
>>>
>>> Lewis, Eric wrote:
>>>> Just out of curiosity: Is there a reason that you keep the .cdr files
>>>> in
>>>> src/main/java? IMHO you could have them in src/main/resources, since
>>>> they
>>>> end up in target/classes anyway.
>>>>
>>>> Best regards,
>>>> Eric
>>>>
>>>>> -----Ursprüngliche Nachricht-----
>>>>> Von: Werner Guttmann [mailto:wguttmn@codehaus.org]
>>>>> Gesendet: Freitag, 2. Oktober 2009 13:13
>>>>> An: Maven Users List
>>>>> Betreff: Re: How to add generated resources directory in a plugin
>>>>>
>>>>> That does not really match what I am observing .. :-(.
>>>>>
>>>>> If I generate Java sources and resources into
>>>>>
>>>>> target/generated-sources/castor
>>>>>
>>>>> and use
>>>>>
>>>>> project.addCompileSourceRoot("target/generated-sources/castor")
>>>>>
>>>>> within the Maven plugin for Castor, Maven will include the generated
>>>>> Java classes during compilation and put the class files in
>>>>> target/classes of the project.
>>>>>
>>>>> As a result of this, users of the Maven plugin for Castor
>>>>> currently have
>>>>> to add the following section to their project POMs.
>>>>>
>>>>> <resources>
>>>>>    <resource>
>>>>>       <directory>target/generated-sources/castor</directory>
>>>>>       <includes>
>>>>>          <include>**/*.cdr</include>
>>>>>       </includes>
>>>>>    </resource>
>>>>>    <resource>
>>>>>       <directory>src/main/resources</directory>
>>>>>    </resource>
>>>>> </resources>
>>>>>
>>>>> to have those .castor.cdr Files copied to target/classes as
>>>>> well. As we
>>>>> all know, this is error-prone.
>>>>>
>>>>> As such, I tried to add code to the Maven plugin for Castor
>>>>> as follows:
>>>>>
>>>>> Resource resource = new Resource();
>>>>> resource.setDirectory( getResourceDestination().getAbsolutePath() );
>>>>> List<String> includes = new LinkedList<String>();
>>>>> includes.add( "**/*.cdr" );
>>>>> resource.setIncludes( includes );
>>>>> project.addResource( resource );
>>>>>
>>>>> Problem is that once I add that code, the Java source files start
>>>>> showing up in target/classes, which is not ideal.
>>>>>
>>>>> Any idea what's going wrong here ?
>>>>>
>>>>> Werner
>>>>>
>>>>> Roland Asmann wrote:
>>>>>> I believe this can work (not 100% sure, I generate into two
>>>>> different
>>>>>
>>>>>> directories for sources and resources), but you should
>>>>> probably ONLY use the
>>>>>
>>>>>> addCompileSourceRoot for your directory...
>>>>>>
>>>>>> The way I understand it, is that if you put sources &
>>>>> resources there, they
>>>>>
>>>>>> are compiled to the output dir. Java knows how to handle
>>>>> .java-files -->
>>>>>
>>>>>> convert them to classes, and how to handle anything else
>>>>> --> just copy.
>>>>>
>>>>>> If you use the resource-dir, maven will handle the copying
>>>>> and will copy
>>>>>
>>>>>> everything from the source to the target, without compiling.
>>>>>>
>>>>>> So, I presume you have used both calls I gave you, although
>>>>> you should only
>>>>>
>>>>>> use one.
>>>>>>
>>>>>> Hope this helps,
>>>>>>
>>>>>> On Thursday 01 October 2009 15:15, Werner Guttmann wrote:
>>>>>>> Hi Roland,
>>>>>>>
>>>>>>> does this pattern/recipe change if both resources and Java
>>>>> classes would
>>>>>
>>>>>>> be generated in the same directory. I have tried this a
>>>>> few days ago
>>>>>
>>>>>>> (trying to automate a few things for the
>>>>> castor-maven-plugin), and it
>>>>>
>>>>>>> seems like this does not really work.
>>>>>>>
>>>>>>> Assume you have a directory where you'll find ....
>>>>>>>
>>>>>>> - A.java
>>>>>>> - B.java
>>>>>>> - .castor.cdr
>>>>>>>
>>>>>>> where the last is a resource file. If I use above code
>>>>> snippets, I can
>>>>>
>>>>>>> see in the target folder after a plugin run and subsequent
>>>>> compilation
>>>>>
>>>>>>> the compiled Java classes, the resource file and the source files.
>>>>>>>
>>>>>>> How can I avoid the source files to be copy across ?
>>>>>>>
>>>>>>> Regards
>>>>>>> Werner
>>>>>>>
>>>>>>> Roland Asmann wrote:
>>>>>>>> Assuming you already have the maven-project as a variable
>>>>> in your plugin
>>>>>
>>>>>>>> (if not, add it!):
>>>>>>>>
>>>>>>>> project.addCompileSourceRoot("your output directory here");
>>>>>>>>
>>>>>>>>
>>>>>>>> And in the case of resources:
>>>>>>>>
>>>>>>>> Resource resource = new Resource();
>>>>>>>> resource.setDirectory("your output directory here");
>>>>>>>> resource.addInclude("**/*");
>>>>>>>> project.addResource(resource);
>>>>>>>>
>>>>>>>> On Thursday 01 October 2009 13:59, Lewis, Eric wrote:
>>>>>>>>> Hi
>>>>>>>>>
>>>>>>>>> I'm writing a plugin which generates resources and also
>>>>> test resources.
>>>>>
>>>>>>>>> How in my plugin can I add these directories to the
>>>>> sources paths and
>>>>>
>>>>>>>>> the test resources paths? (Except for using the
>>>>> build-helper plugin)
>>>>>
>>>>>>>>> Best regards,
>>>>>>>>> Eric
>>>>> ---------------------------------------------------------------------
>>>>>
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>> ---------------------------------------------------------------------
>>>>>
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to add generated resources directory in a plugin

Posted by Werner Guttmann <wg...@codehaus.org>.
Roland,

I wish I had a choice, but I have to keep backwards-compatibility. Until
now, we used to offer one property on the Mojo to set the output path
(with a default of target/generated-sources/castor).

Now, we are offering a second option for the resource files generated,
but I still have to cater for those expecting things in the old location.

Werber

Roland Asmann wrote:
> Read the part about editing the plugin again... If you're working on the 
> actual castor-plugin, wouldn't it be easier to just separate the sources and 
> resources instead of adding the resources with inclusion/exclusion rules?
> 
> 
> On Friday 02 October 2009 13:45, Werner Guttmann wrote:
>> Eric,
>>
>> the .castor.cdr files are a by-product of generating Java classes from
>> an XML schema using the XML code generator of Castor (through the Maven
>> plugin for Castor).
>>
>> Those resource files are being generated in
>> target/generated-sources/castor during code generation.
>>
>> I hopes this makes it clearer ....
>>
>> Werner
>>
>> Lewis, Eric wrote:
>>> Just out of curiosity: Is there a reason that you keep the .cdr files in
>>> src/main/java? IMHO you could have them in src/main/resources, since they
>>> end up in target/classes anyway.
>>>
>>> Best regards,
>>> Eric
>>>
>>>> -----Ursprüngliche Nachricht-----
>>>> Von: Werner Guttmann [mailto:wguttmn@codehaus.org]
>>>> Gesendet: Freitag, 2. Oktober 2009 13:13
>>>> An: Maven Users List
>>>> Betreff: Re: How to add generated resources directory in a plugin
>>>>
>>>> That does not really match what I am observing .. :-(.
>>>>
>>>> If I generate Java sources and resources into
>>>>
>>>> target/generated-sources/castor
>>>>
>>>> and use
>>>>
>>>> project.addCompileSourceRoot("target/generated-sources/castor")
>>>>
>>>> within the Maven plugin for Castor, Maven will include the generated
>>>> Java classes during compilation and put the class files in
>>>> target/classes of the project.
>>>>
>>>> As a result of this, users of the Maven plugin for Castor
>>>> currently have
>>>> to add the following section to their project POMs.
>>>>
>>>> <resources>
>>>>    <resource>
>>>>       <directory>target/generated-sources/castor</directory>
>>>>       <includes>
>>>>          <include>**/*.cdr</include>
>>>>       </includes>
>>>>    </resource>
>>>>    <resource>
>>>>       <directory>src/main/resources</directory>
>>>>    </resource>
>>>> </resources>
>>>>
>>>> to have those .castor.cdr Files copied to target/classes as
>>>> well. As we
>>>> all know, this is error-prone.
>>>>
>>>> As such, I tried to add code to the Maven plugin for Castor
>>>> as follows:
>>>>
>>>> Resource resource = new Resource();
>>>> resource.setDirectory( getResourceDestination().getAbsolutePath() );
>>>> List<String> includes = new LinkedList<String>();
>>>> includes.add( "**/*.cdr" );
>>>> resource.setIncludes( includes );
>>>> project.addResource( resource );
>>>>
>>>> Problem is that once I add that code, the Java source files start
>>>> showing up in target/classes, which is not ideal.
>>>>
>>>> Any idea what's going wrong here ?
>>>>
>>>> Werner
>>>>
>>>> Roland Asmann wrote:
>>>>> I believe this can work (not 100% sure, I generate into two
>>>> different
>>>>
>>>>> directories for sources and resources), but you should
>>>> probably ONLY use the
>>>>
>>>>> addCompileSourceRoot for your directory...
>>>>>
>>>>> The way I understand it, is that if you put sources &
>>>> resources there, they
>>>>
>>>>> are compiled to the output dir. Java knows how to handle
>>>> .java-files -->
>>>>
>>>>> convert them to classes, and how to handle anything else
>>>> --> just copy.
>>>>
>>>>> If you use the resource-dir, maven will handle the copying
>>>> and will copy
>>>>
>>>>> everything from the source to the target, without compiling.
>>>>>
>>>>> So, I presume you have used both calls I gave you, although
>>>> you should only
>>>>
>>>>> use one.
>>>>>
>>>>> Hope this helps,
>>>>>
>>>>> On Thursday 01 October 2009 15:15, Werner Guttmann wrote:
>>>>>> Hi Roland,
>>>>>>
>>>>>> does this pattern/recipe change if both resources and Java
>>>> classes would
>>>>
>>>>>> be generated in the same directory. I have tried this a
>>>> few days ago
>>>>
>>>>>> (trying to automate a few things for the
>>>> castor-maven-plugin), and it
>>>>
>>>>>> seems like this does not really work.
>>>>>>
>>>>>> Assume you have a directory where you'll find ....
>>>>>>
>>>>>> - A.java
>>>>>> - B.java
>>>>>> - .castor.cdr
>>>>>>
>>>>>> where the last is a resource file. If I use above code
>>>> snippets, I can
>>>>
>>>>>> see in the target folder after a plugin run and subsequent
>>>> compilation
>>>>
>>>>>> the compiled Java classes, the resource file and the source files.
>>>>>>
>>>>>> How can I avoid the source files to be copy across ?
>>>>>>
>>>>>> Regards
>>>>>> Werner
>>>>>>
>>>>>> Roland Asmann wrote:
>>>>>>> Assuming you already have the maven-project as a variable
>>>> in your plugin
>>>>
>>>>>>> (if not, add it!):
>>>>>>>
>>>>>>> project.addCompileSourceRoot("your output directory here");
>>>>>>>
>>>>>>>
>>>>>>> And in the case of resources:
>>>>>>>
>>>>>>> Resource resource = new Resource();
>>>>>>> resource.setDirectory("your output directory here");
>>>>>>> resource.addInclude("**/*");
>>>>>>> project.addResource(resource);
>>>>>>>
>>>>>>> On Thursday 01 October 2009 13:59, Lewis, Eric wrote:
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> I'm writing a plugin which generates resources and also
>>>> test resources.
>>>>
>>>>>>>> How in my plugin can I add these directories to the
>>>> sources paths and
>>>>
>>>>>>>> the test resources paths? (Except for using the
>>>> build-helper plugin)
>>>>
>>>>>>>> Best regards,
>>>>>>>> Eric
>>>> ---------------------------------------------------------------------
>>>>
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>> ---------------------------------------------------------------------
>>>>
>>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to add generated resources directory in a plugin

Posted by Roland Asmann <Ro...@cfc.at>.
Read the part about editing the plugin again... If you're working on the 
actual castor-plugin, wouldn't it be easier to just separate the sources and 
resources instead of adding the resources with inclusion/exclusion rules?


On Friday 02 October 2009 13:45, Werner Guttmann wrote:
> Eric,
>
> the .castor.cdr files are a by-product of generating Java classes from
> an XML schema using the XML code generator of Castor (through the Maven
> plugin for Castor).
>
> Those resource files are being generated in
> target/generated-sources/castor during code generation.
>
> I hopes this makes it clearer ....
>
> Werner
>
> Lewis, Eric wrote:
> > Just out of curiosity: Is there a reason that you keep the .cdr files in
> > src/main/java? IMHO you could have them in src/main/resources, since they
> > end up in target/classes anyway.
> >
> > Best regards,
> > Eric
> >
> >> -----Ursprüngliche Nachricht-----
> >> Von: Werner Guttmann [mailto:wguttmn@codehaus.org]
> >> Gesendet: Freitag, 2. Oktober 2009 13:13
> >> An: Maven Users List
> >> Betreff: Re: How to add generated resources directory in a plugin
> >>
> >> That does not really match what I am observing .. :-(.
> >>
> >> If I generate Java sources and resources into
> >>
> >> target/generated-sources/castor
> >>
> >> and use
> >>
> >> project.addCompileSourceRoot("target/generated-sources/castor")
> >>
> >> within the Maven plugin for Castor, Maven will include the generated
> >> Java classes during compilation and put the class files in
> >> target/classes of the project.
> >>
> >> As a result of this, users of the Maven plugin for Castor
> >> currently have
> >> to add the following section to their project POMs.
> >>
> >> <resources>
> >>    <resource>
> >>       <directory>target/generated-sources/castor</directory>
> >>       <includes>
> >>          <include>**/*.cdr</include>
> >>       </includes>
> >>    </resource>
> >>    <resource>
> >>       <directory>src/main/resources</directory>
> >>    </resource>
> >> </resources>
> >>
> >> to have those .castor.cdr Files copied to target/classes as
> >> well. As we
> >> all know, this is error-prone.
> >>
> >> As such, I tried to add code to the Maven plugin for Castor
> >> as follows:
> >>
> >> Resource resource = new Resource();
> >> resource.setDirectory( getResourceDestination().getAbsolutePath() );
> >> List<String> includes = new LinkedList<String>();
> >> includes.add( "**/*.cdr" );
> >> resource.setIncludes( includes );
> >> project.addResource( resource );
> >>
> >> Problem is that once I add that code, the Java source files start
> >> showing up in target/classes, which is not ideal.
> >>
> >> Any idea what's going wrong here ?
> >>
> >> Werner
> >>
> >> Roland Asmann wrote:
> >>> I believe this can work (not 100% sure, I generate into two
> >>
> >> different
> >>
> >>> directories for sources and resources), but you should
> >>
> >> probably ONLY use the
> >>
> >>> addCompileSourceRoot for your directory...
> >>>
> >>> The way I understand it, is that if you put sources &
> >>
> >> resources there, they
> >>
> >>> are compiled to the output dir. Java knows how to handle
> >>
> >> .java-files -->
> >>
> >>> convert them to classes, and how to handle anything else
> >>
> >> --> just copy.
> >>
> >>> If you use the resource-dir, maven will handle the copying
> >>
> >> and will copy
> >>
> >>> everything from the source to the target, without compiling.
> >>>
> >>> So, I presume you have used both calls I gave you, although
> >>
> >> you should only
> >>
> >>> use one.
> >>>
> >>> Hope this helps,
> >>>
> >>> On Thursday 01 October 2009 15:15, Werner Guttmann wrote:
> >>>> Hi Roland,
> >>>>
> >>>> does this pattern/recipe change if both resources and Java
> >>
> >> classes would
> >>
> >>>> be generated in the same directory. I have tried this a
> >>
> >> few days ago
> >>
> >>>> (trying to automate a few things for the
> >>
> >> castor-maven-plugin), and it
> >>
> >>>> seems like this does not really work.
> >>>>
> >>>> Assume you have a directory where you'll find ....
> >>>>
> >>>> - A.java
> >>>> - B.java
> >>>> - .castor.cdr
> >>>>
> >>>> where the last is a resource file. If I use above code
> >>
> >> snippets, I can
> >>
> >>>> see in the target folder after a plugin run and subsequent
> >>
> >> compilation
> >>
> >>>> the compiled Java classes, the resource file and the source files.
> >>>>
> >>>> How can I avoid the source files to be copy across ?
> >>>>
> >>>> Regards
> >>>> Werner
> >>>>
> >>>> Roland Asmann wrote:
> >>>>> Assuming you already have the maven-project as a variable
> >>
> >> in your plugin
> >>
> >>>>> (if not, add it!):
> >>>>>
> >>>>> project.addCompileSourceRoot("your output directory here");
> >>>>>
> >>>>>
> >>>>> And in the case of resources:
> >>>>>
> >>>>> Resource resource = new Resource();
> >>>>> resource.setDirectory("your output directory here");
> >>>>> resource.addInclude("**/*");
> >>>>> project.addResource(resource);
> >>>>>
> >>>>> On Thursday 01 October 2009 13:59, Lewis, Eric wrote:
> >>>>>> Hi
> >>>>>>
> >>>>>> I'm writing a plugin which generates resources and also
> >>
> >> test resources.
> >>
> >>>>>> How in my plugin can I add these directories to the
> >>
> >> sources paths and
> >>
> >>>>>> the test resources paths? (Except for using the
> >>
> >> build-helper plugin)
> >>
> >>>>>> Best regards,
> >>>>>> Eric
> >>
> >> ---------------------------------------------------------------------
> >>
> >>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>>>>> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >> ---------------------------------------------------------------------
> >>
> >>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>>> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org

-- 
Roland Asmann

CFC Informationssysteme Entwicklungsgesellschaft m.b.H
Bäckerstrasse 1/2/7
A-1010 Wien
FN 266155f, Handelsgericht Wien

Tel.: +43/1/513 88 77 - 27
Fax.: +43/1/513 88 62
Email: Roland.Asmann@cfc.at
Web: www.cfc.at

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


AW: AW: How to add generated resources directory in a plugin

Posted by "Lewis, Eric" <Er...@ipi.ch>.
Hi Werner

Yup, I had the same problem, but I'm generating my resources into target/generated-resources/xyz and then adding that to my build:

    Resource resource = new Resource();
    resource.setDirectory(targetDirectory.getAbsolutePath());
    resource.addInclude("**/*");
    if (createTestConfiguration) {
      mavenProject.addTestResource(resource);
    } else {
      mavenProject.addResource(resource);
    }

They will still end up in target/classes or target/test-classes.

Best regards,
Eric 

> -----Ursprüngliche Nachricht-----
> Von: Werner Guttmann [mailto:wguttmn@codehaus.org] 
> Gesendet: Freitag, 2. Oktober 2009 13:46
> An: Maven Users List
> Betreff: Re: AW: How to add generated resources directory in a plugin
> 
> Eric,
> 
> the .castor.cdr files are a by-product of generating Java classes from
> an XML schema using the XML code generator of Castor (through 
> the Maven
> plugin for Castor).
> 
> Those resource files are being generated in
> target/generated-sources/castor during code generation.
> 
> I hopes this makes it clearer ....
> 
> Werner
> 
> Lewis, Eric wrote:
> > Just out of curiosity: Is there a reason that you keep the 
> .cdr files in src/main/java?
> > IMHO you could have them in src/main/resources, since they 
> end up in target/classes anyway.
> > 
> > Best regards,
> > Eric 
> > 
> >> -----Ursprüngliche Nachricht-----
> >> Von: Werner Guttmann [mailto:wguttmn@codehaus.org] 
> >> Gesendet: Freitag, 2. Oktober 2009 13:13
> >> An: Maven Users List
> >> Betreff: Re: How to add generated resources directory in a plugin
> >>
> >> That does not really match what I am observing .. :-(.
> >>
> >> If I generate Java sources and resources into
> >>
> >> target/generated-sources/castor
> >>
> >> and use
> >>
> >> project.addCompileSourceRoot("target/generated-sources/castor")
> >>
> >> within the Maven plugin for Castor, Maven will include the 
> generated
> >> Java classes during compilation and put the class files in
> >> target/classes of the project.
> >>
> >> As a result of this, users of the Maven plugin for Castor 
> >> currently have
> >> to add the following section to their project POMs.
> >>
> >> <resources>
> >>    <resource>
> >>       <directory>target/generated-sources/castor</directory>
> >>       <includes>
> >>          <include>**/*.cdr</include>
> >>       </includes>
> >>    </resource>
> >>    <resource>
> >>       <directory>src/main/resources</directory>
> >>    </resource>
> >> </resources>
> >>
> >> to have those .castor.cdr Files copied to target/classes as 
> >> well. As we
> >> all know, this is error-prone.
> >>
> >> As such, I tried to add code to the Maven plugin for Castor 
> >> as follows:
> >>
> >> Resource resource = new Resource();
> >> resource.setDirectory( 
> getResourceDestination().getAbsolutePath() );
> >> List<String> includes = new LinkedList<String>();
> >> includes.add( "**/*.cdr" );
> >> resource.setIncludes( includes );
> >> project.addResource( resource );
> >>
> >> Problem is that once I add that code, the Java source files start
> >> showing up in target/classes, which is not ideal.
> >>
> >> Any idea what's going wrong here ?
> >>
> >> Werner
> >>
> >> Roland Asmann wrote:
> >>> I believe this can work (not 100% sure, I generate into two 
> >> different 
> >>> directories for sources and resources), but you should 
> >> probably ONLY use the 
> >>> addCompileSourceRoot for your directory...
> >>>
> >>> The way I understand it, is that if you put sources & 
> >> resources there, they 
> >>> are compiled to the output dir. Java knows how to handle 
> >> .java-files --> 
> >>> convert them to classes, and how to handle anything else 
> >> --> just copy.
> >>> If you use the resource-dir, maven will handle the copying 
> >> and will copy 
> >>> everything from the source to the target, without compiling.
> >>>
> >>> So, I presume you have used both calls I gave you, although 
> >> you should only 
> >>> use one.
> >>>
> >>> Hope this helps,
> >>>
> >>>
> >>> On Thursday 01 October 2009 15:15, Werner Guttmann wrote:
> >>>> Hi Roland,
> >>>>
> >>>> does this pattern/recipe change if both resources and Java 
> >> classes would
> >>>> be generated in the same directory. I have tried this a 
> >> few days ago
> >>>> (trying to automate a few things for the 
> >> castor-maven-plugin), and it
> >>>> seems like this does not really work.
> >>>>
> >>>> Assume you have a directory where you'll find ....
> >>>>
> >>>> - A.java
> >>>> - B.java
> >>>> - .castor.cdr
> >>>>
> >>>> where the last is a resource file. If I use above code 
> >> snippets, I can
> >>>> see in the target folder after a plugin run and subsequent 
> >> compilation
> >>>> the compiled Java classes, the resource file and the 
> source files.
> >>>>
> >>>> How can I avoid the source files to be copy across ?
> >>>>
> >>>> Regards
> >>>> Werner
> >>>>
> >>>> Roland Asmann wrote:
> >>>>> Assuming you already have the maven-project as a variable 
> >> in your plugin
> >>>>> (if not, add it!):
> >>>>>
> >>>>> project.addCompileSourceRoot("your output directory here");
> >>>>>
> >>>>>
> >>>>> And in the case of resources:
> >>>>>
> >>>>> Resource resource = new Resource();
> >>>>> resource.setDirectory("your output directory here");
> >>>>> resource.addInclude("**/*");
> >>>>> project.addResource(resource);
> >>>>>
> >>>>> On Thursday 01 October 2009 13:59, Lewis, Eric wrote:
> >>>>>> Hi
> >>>>>>
> >>>>>> I'm writing a plugin which generates resources and also 
> >> test resources.
> >>>>>> How in my plugin can I add these directories to the 
> >> sources paths and
> >>>>>> the test resources paths? (Except for using the 
> >> build-helper plugin)
> >>>>>> Best regards,
> >>>>>> Eric
> >>>>>>
> >>>>>>
> >> 
> ---------------------------------------------------------------------
> >>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>>>>> For additional commands, e-mail: users-help@maven.apache.org
> >> 
> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>>> For additional commands, e-mail: users-help@maven.apache.org
> >> 
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >>
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: AW: How to add generated resources directory in a plugin

Posted by Werner Guttmann <wg...@codehaus.org>.
Eric,

the .castor.cdr files are a by-product of generating Java classes from
an XML schema using the XML code generator of Castor (through the Maven
plugin for Castor).

Those resource files are being generated in
target/generated-sources/castor during code generation.

I hopes this makes it clearer ....

Werner

Lewis, Eric wrote:
> Just out of curiosity: Is there a reason that you keep the .cdr files in src/main/java?
> IMHO you could have them in src/main/resources, since they end up in target/classes anyway.
> 
> Best regards,
> Eric 
> 
>> -----Ursprüngliche Nachricht-----
>> Von: Werner Guttmann [mailto:wguttmn@codehaus.org] 
>> Gesendet: Freitag, 2. Oktober 2009 13:13
>> An: Maven Users List
>> Betreff: Re: How to add generated resources directory in a plugin
>>
>> That does not really match what I am observing .. :-(.
>>
>> If I generate Java sources and resources into
>>
>> target/generated-sources/castor
>>
>> and use
>>
>> project.addCompileSourceRoot("target/generated-sources/castor")
>>
>> within the Maven plugin for Castor, Maven will include the generated
>> Java classes during compilation and put the class files in
>> target/classes of the project.
>>
>> As a result of this, users of the Maven plugin for Castor 
>> currently have
>> to add the following section to their project POMs.
>>
>> <resources>
>>    <resource>
>>       <directory>target/generated-sources/castor</directory>
>>       <includes>
>>          <include>**/*.cdr</include>
>>       </includes>
>>    </resource>
>>    <resource>
>>       <directory>src/main/resources</directory>
>>    </resource>
>> </resources>
>>
>> to have those .castor.cdr Files copied to target/classes as 
>> well. As we
>> all know, this is error-prone.
>>
>> As such, I tried to add code to the Maven plugin for Castor 
>> as follows:
>>
>> Resource resource = new Resource();
>> resource.setDirectory( getResourceDestination().getAbsolutePath() );
>> List<String> includes = new LinkedList<String>();
>> includes.add( "**/*.cdr" );
>> resource.setIncludes( includes );
>> project.addResource( resource );
>>
>> Problem is that once I add that code, the Java source files start
>> showing up in target/classes, which is not ideal.
>>
>> Any idea what's going wrong here ?
>>
>> Werner
>>
>> Roland Asmann wrote:
>>> I believe this can work (not 100% sure, I generate into two 
>> different 
>>> directories for sources and resources), but you should 
>> probably ONLY use the 
>>> addCompileSourceRoot for your directory...
>>>
>>> The way I understand it, is that if you put sources & 
>> resources there, they 
>>> are compiled to the output dir. Java knows how to handle 
>> .java-files --> 
>>> convert them to classes, and how to handle anything else 
>> --> just copy.
>>> If you use the resource-dir, maven will handle the copying 
>> and will copy 
>>> everything from the source to the target, without compiling.
>>>
>>> So, I presume you have used both calls I gave you, although 
>> you should only 
>>> use one.
>>>
>>> Hope this helps,
>>>
>>>
>>> On Thursday 01 October 2009 15:15, Werner Guttmann wrote:
>>>> Hi Roland,
>>>>
>>>> does this pattern/recipe change if both resources and Java 
>> classes would
>>>> be generated in the same directory. I have tried this a 
>> few days ago
>>>> (trying to automate a few things for the 
>> castor-maven-plugin), and it
>>>> seems like this does not really work.
>>>>
>>>> Assume you have a directory where you'll find ....
>>>>
>>>> - A.java
>>>> - B.java
>>>> - .castor.cdr
>>>>
>>>> where the last is a resource file. If I use above code 
>> snippets, I can
>>>> see in the target folder after a plugin run and subsequent 
>> compilation
>>>> the compiled Java classes, the resource file and the source files.
>>>>
>>>> How can I avoid the source files to be copy across ?
>>>>
>>>> Regards
>>>> Werner
>>>>
>>>> Roland Asmann wrote:
>>>>> Assuming you already have the maven-project as a variable 
>> in your plugin
>>>>> (if not, add it!):
>>>>>
>>>>> project.addCompileSourceRoot("your output directory here");
>>>>>
>>>>>
>>>>> And in the case of resources:
>>>>>
>>>>> Resource resource = new Resource();
>>>>> resource.setDirectory("your output directory here");
>>>>> resource.addInclude("**/*");
>>>>> project.addResource(resource);
>>>>>
>>>>> On Thursday 01 October 2009 13:59, Lewis, Eric wrote:
>>>>>> Hi
>>>>>>
>>>>>> I'm writing a plugin which generates resources and also 
>> test resources.
>>>>>> How in my plugin can I add these directories to the 
>> sources paths and
>>>>>> the test resources paths? (Except for using the 
>> build-helper plugin)
>>>>>> Best regards,
>>>>>> Eric
>>>>>>
>>>>>>
>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>>>> For additional commands, e-mail: users-help@maven.apache.org
>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


AW: How to add generated resources directory in a plugin

Posted by "Lewis, Eric" <Er...@ipi.ch>.
Just out of curiosity: Is there a reason that you keep the .cdr files in src/main/java?
IMHO you could have them in src/main/resources, since they end up in target/classes anyway.

Best regards,
Eric 

> -----Ursprüngliche Nachricht-----
> Von: Werner Guttmann [mailto:wguttmn@codehaus.org] 
> Gesendet: Freitag, 2. Oktober 2009 13:13
> An: Maven Users List
> Betreff: Re: How to add generated resources directory in a plugin
> 
> That does not really match what I am observing .. :-(.
> 
> If I generate Java sources and resources into
> 
> target/generated-sources/castor
> 
> and use
> 
> project.addCompileSourceRoot("target/generated-sources/castor")
> 
> within the Maven plugin for Castor, Maven will include the generated
> Java classes during compilation and put the class files in
> target/classes of the project.
> 
> As a result of this, users of the Maven plugin for Castor 
> currently have
> to add the following section to their project POMs.
> 
> <resources>
>    <resource>
>       <directory>target/generated-sources/castor</directory>
>       <includes>
>          <include>**/*.cdr</include>
>       </includes>
>    </resource>
>    <resource>
>       <directory>src/main/resources</directory>
>    </resource>
> </resources>
> 
> to have those .castor.cdr Files copied to target/classes as 
> well. As we
> all know, this is error-prone.
> 
> As such, I tried to add code to the Maven plugin for Castor 
> as follows:
> 
> Resource resource = new Resource();
> resource.setDirectory( getResourceDestination().getAbsolutePath() );
> List<String> includes = new LinkedList<String>();
> includes.add( "**/*.cdr" );
> resource.setIncludes( includes );
> project.addResource( resource );
> 
> Problem is that once I add that code, the Java source files start
> showing up in target/classes, which is not ideal.
> 
> Any idea what's going wrong here ?
> 
> Werner
> 
> Roland Asmann wrote:
> > I believe this can work (not 100% sure, I generate into two 
> different 
> > directories for sources and resources), but you should 
> probably ONLY use the 
> > addCompileSourceRoot for your directory...
> > 
> > The way I understand it, is that if you put sources & 
> resources there, they 
> > are compiled to the output dir. Java knows how to handle 
> .java-files --> 
> > convert them to classes, and how to handle anything else 
> --> just copy.
> > If you use the resource-dir, maven will handle the copying 
> and will copy 
> > everything from the source to the target, without compiling.
> > 
> > So, I presume you have used both calls I gave you, although 
> you should only 
> > use one.
> > 
> > Hope this helps,
> > 
> > 
> > On Thursday 01 October 2009 15:15, Werner Guttmann wrote:
> >> Hi Roland,
> >>
> >> does this pattern/recipe change if both resources and Java 
> classes would
> >> be generated in the same directory. I have tried this a 
> few days ago
> >> (trying to automate a few things for the 
> castor-maven-plugin), and it
> >> seems like this does not really work.
> >>
> >> Assume you have a directory where you'll find ....
> >>
> >> - A.java
> >> - B.java
> >> - .castor.cdr
> >>
> >> where the last is a resource file. If I use above code 
> snippets, I can
> >> see in the target folder after a plugin run and subsequent 
> compilation
> >> the compiled Java classes, the resource file and the source files.
> >>
> >> How can I avoid the source files to be copy across ?
> >>
> >> Regards
> >> Werner
> >>
> >> Roland Asmann wrote:
> >>> Assuming you already have the maven-project as a variable 
> in your plugin
> >>> (if not, add it!):
> >>>
> >>> project.addCompileSourceRoot("your output directory here");
> >>>
> >>>
> >>> And in the case of resources:
> >>>
> >>> Resource resource = new Resource();
> >>> resource.setDirectory("your output directory here");
> >>> resource.addInclude("**/*");
> >>> project.addResource(resource);
> >>>
> >>> On Thursday 01 October 2009 13:59, Lewis, Eric wrote:
> >>>> Hi
> >>>>
> >>>> I'm writing a plugin which generates resources and also 
> test resources.
> >>>> How in my plugin can I add these directories to the 
> sources paths and
> >>>> the test resources paths? (Except for using the 
> build-helper plugin)
> >>>>
> >>>> Best regards,
> >>>> Eric
> >>>>
> >>>> 
> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>>> For additional commands, e-mail: users-help@maven.apache.org
> >> 
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to add generated resources directory in a plugin

Posted by Werner Guttmann <wg...@codehaus.org>.
That does not really match what I am observing .. :-(.

If I generate Java sources and resources into

target/generated-sources/castor

and use

project.addCompileSourceRoot("target/generated-sources/castor")

within the Maven plugin for Castor, Maven will include the generated
Java classes during compilation and put the class files in
target/classes of the project.

As a result of this, users of the Maven plugin for Castor currently have
to add the following section to their project POMs.

<resources>
   <resource>
      <directory>target/generated-sources/castor</directory>
      <includes>
         <include>**/*.cdr</include>
      </includes>
   </resource>
   <resource>
      <directory>src/main/resources</directory>
   </resource>
</resources>

to have those .castor.cdr Files copied to target/classes as well. As we
all know, this is error-prone.

As such, I tried to add code to the Maven plugin for Castor as follows:

Resource resource = new Resource();
resource.setDirectory( getResourceDestination().getAbsolutePath() );
List<String> includes = new LinkedList<String>();
includes.add( "**/*.cdr" );
resource.setIncludes( includes );
project.addResource( resource );

Problem is that once I add that code, the Java source files start
showing up in target/classes, which is not ideal.

Any idea what's going wrong here ?

Werner

Roland Asmann wrote:
> I believe this can work (not 100% sure, I generate into two different 
> directories for sources and resources), but you should probably ONLY use the 
> addCompileSourceRoot for your directory...
> 
> The way I understand it, is that if you put sources & resources there, they 
> are compiled to the output dir. Java knows how to handle .java-files --> 
> convert them to classes, and how to handle anything else --> just copy.
> If you use the resource-dir, maven will handle the copying and will copy 
> everything from the source to the target, without compiling.
> 
> So, I presume you have used both calls I gave you, although you should only 
> use one.
> 
> Hope this helps,
> 
> 
> On Thursday 01 October 2009 15:15, Werner Guttmann wrote:
>> Hi Roland,
>>
>> does this pattern/recipe change if both resources and Java classes would
>> be generated in the same directory. I have tried this a few days ago
>> (trying to automate a few things for the castor-maven-plugin), and it
>> seems like this does not really work.
>>
>> Assume you have a directory where you'll find ....
>>
>> - A.java
>> - B.java
>> - .castor.cdr
>>
>> where the last is a resource file. If I use above code snippets, I can
>> see in the target folder after a plugin run and subsequent compilation
>> the compiled Java classes, the resource file and the source files.
>>
>> How can I avoid the source files to be copy across ?
>>
>> Regards
>> Werner
>>
>> Roland Asmann wrote:
>>> Assuming you already have the maven-project as a variable in your plugin
>>> (if not, add it!):
>>>
>>> project.addCompileSourceRoot("your output directory here");
>>>
>>>
>>> And in the case of resources:
>>>
>>> Resource resource = new Resource();
>>> resource.setDirectory("your output directory here");
>>> resource.addInclude("**/*");
>>> project.addResource(resource);
>>>
>>> On Thursday 01 October 2009 13:59, Lewis, Eric wrote:
>>>> Hi
>>>>
>>>> I'm writing a plugin which generates resources and also test resources.
>>>> How in my plugin can I add these directories to the sources paths and
>>>> the test resources paths? (Except for using the build-helper plugin)
>>>>
>>>> Best regards,
>>>> Eric
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to add generated resources directory in a plugin

Posted by Roland Asmann <Ro...@cfc.at>.
I believe this can work (not 100% sure, I generate into two different 
directories for sources and resources), but you should probably ONLY use the 
addCompileSourceRoot for your directory...

The way I understand it, is that if you put sources & resources there, they 
are compiled to the output dir. Java knows how to handle .java-files --> 
convert them to classes, and how to handle anything else --> just copy.
If you use the resource-dir, maven will handle the copying and will copy 
everything from the source to the target, without compiling.

So, I presume you have used both calls I gave you, although you should only 
use one.

Hope this helps,


On Thursday 01 October 2009 15:15, Werner Guttmann wrote:
> Hi Roland,
>
> does this pattern/recipe change if both resources and Java classes would
> be generated in the same directory. I have tried this a few days ago
> (trying to automate a few things for the castor-maven-plugin), and it
> seems like this does not really work.
>
> Assume you have a directory where you'll find ....
>
> - A.java
> - B.java
> - .castor.cdr
>
> where the last is a resource file. If I use above code snippets, I can
> see in the target folder after a plugin run and subsequent compilation
> the compiled Java classes, the resource file and the source files.
>
> How can I avoid the source files to be copy across ?
>
> Regards
> Werner
>
> Roland Asmann wrote:
> > Assuming you already have the maven-project as a variable in your plugin
> > (if not, add it!):
> >
> > project.addCompileSourceRoot("your output directory here");
> >
> >
> > And in the case of resources:
> >
> > Resource resource = new Resource();
> > resource.setDirectory("your output directory here");
> > resource.addInclude("**/*");
> > project.addResource(resource);
> >
> > On Thursday 01 October 2009 13:59, Lewis, Eric wrote:
> >> Hi
> >>
> >> I'm writing a plugin which generates resources and also test resources.
> >> How in my plugin can I add these directories to the sources paths and
> >> the test resources paths? (Except for using the build-helper plugin)
> >>
> >> Best regards,
> >> Eric
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org

-- 
Roland Asmann

CFC Informationssysteme Entwicklungsgesellschaft m.b.H
Bäckerstrasse 1/2/7
A-1010 Wien
FN 266155f, Handelsgericht Wien

Tel.: +43/1/513 88 77 - 27
Fax.: +43/1/513 88 62
Email: Roland.Asmann@cfc.at
Web: www.cfc.at

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to add generated resources directory in a plugin

Posted by Werner Guttmann <we...@gmx.net>.
Hi Roland,

does this pattern/recipe change if both resources and Java classes would
be generated in the same directory. I have tried this a few days ago
(trying to automate a few things for the castor-maven-plugin), and it
seems like this does not really work.

Assume you have a directory where you'll find ....

- A.java
- B.java
- .castor.cdr

where the last is a resource file. If I use above code snippets, I can
see in the target folder after a plugin run and subsequent compilation
the compiled Java classes, the resource file and the source files.

How can I avoid the source files to be copy across ?

Regards
Werner

Roland Asmann wrote:
> Assuming you already have the maven-project as a variable in your plugin (if 
> not, add it!):
> 
> project.addCompileSourceRoot("your output directory here");
> 
> 
> And in the case of resources:
> 
> Resource resource = new Resource();
> resource.setDirectory("your output directory here");
> resource.addInclude("**/*");
> project.addResource(resource);
> 
> 
> 
> On Thursday 01 October 2009 13:59, Lewis, Eric wrote:
>> Hi
>>
>> I'm writing a plugin which generates resources and also test resources.
>> How in my plugin can I add these directories to the sources paths and the
>> test resources paths? (Except for using the build-helper plugin)
>>
>> Best regards,
>> Eric
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to add generated resources directory in a plugin

Posted by Roland Asmann <Ro...@cfc.at>.
Assuming you already have the maven-project as a variable in your plugin (if 
not, add it!):

project.addCompileSourceRoot("your output directory here");


And in the case of resources:

Resource resource = new Resource();
resource.setDirectory("your output directory here");
resource.addInclude("**/*");
project.addResource(resource);



On Thursday 01 October 2009 13:59, Lewis, Eric wrote:
> Hi
>
> I'm writing a plugin which generates resources and also test resources.
> How in my plugin can I add these directories to the sources paths and the
> test resources paths? (Except for using the build-helper plugin)
>
> Best regards,
> Eric
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org

-- 
Roland Asmann

CFC Informationssysteme Entwicklungsgesellschaft m.b.H
Bäckerstrasse 1/2/7
A-1010 Wien
FN 266155f, Handelsgericht Wien

Tel.: +43/1/513 88 77 - 27
Fax.: +43/1/513 88 62
Email: Roland.Asmann@cfc.at
Web: www.cfc.at

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org