You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Kallin Nagelberg <ka...@gmail.com> on 2007/12/08 18:36:12 UTC

generating-sources missing resources

I'm trying to convert the source-generation of a legacy system into a
mavenized project. Basically I need to run a couple of java classes from an
already existing dependency (during the generate-sources phase I assume)
which should populate my source directories. The problem I'm having is that
it seems maven is ignoring my <resource> declarations during the
generate-sources phase. Is this normal? To run the two java classes requried
for source generation I'm using the exec-maven-plugin and it definitely
doesn't find my declared resources on it's classpath..

I've managed to find some hacks around this, like telling the
maven-resources-plugin to execute the 'resources' goal during
generate-sources, but that doesn't seem so clean to me, as it's probably
going to do it again during the generate-resources phase..

Any ideas?

Re: generating-sources missing resources

Posted by Wayne Fay <wa...@gmail.com>.
I would go ahead and make your code generator a full-blown Maven
plugin, as Nicolas assumed initially. I've done this myself a few
times and it is pretty simple. Then use the @parameter to specify the
location of your resources, and poof, you're done. Unless of course
you have a good reason for not doing this.

Wayne

On 12/8/07, Kallin Nagelberg <ka...@gmail.com> wrote:
> Thank you, I've forwarded the discussion to the codehaus mailing list to see
> what their opinion is on the matter.
>
> On Dec 8, 2007 3:47 PM, nicolas de loof <ni...@apache.org> wrote:
>
> > "enclosing project's dependencies as classpath" does not mean "enclosing
> > project classpath".
> > You have acces to all declared dependencies BUT not to the project
> > classes/ressources. (this may be a valuale enhancement to the plugin).
> >
> > Nico.
> >
> >
> > 2007/12/8, Kallin Nagelberg <ka...@gmail.com>:
> > >
> > > Thanks for the prompt reply.
> > >
> > > My code-generator (the java classes anyways) have been packaged as a
> > > regular
> > > jar artifact.
> > > I am using the Maven Exec Plug-In java goal,
> > > http://mojo.codehaus.org/exec-maven-plugin/java-mojo.html.
> > > It states 'Executes the supplied java class in the current VM with the
> > > enclosing project's dependencies as classpath.' That is accurate, as the
> > > plugin has no problems finding the classes in the pom's dependencies.
> > > However it doesn't seem to include the enclosing POM's resources..
> > > From the sounds of it this is likely an issue with the codehaus plugin
> > > more
> > > than a core maven issue. I'll pose this question on their mailing list
> > > also.
> > >
> > > Kal.
> > >
> > >
> > >
> > >
> > >
> > > On Dec 8, 2007 2:14 PM, nicolas de loof <ni...@gmail.com>
> > wrote:
> > >
> > > > Tell me if I understand well :
> > > >
> > > > your code-generator has been packaged as a Mojo and is used in another
> > > > project. It loads some config file from classpath to generate code.
> > > >
> > > > Maven plugins run in isolated classloaders, they have no acces to the
> > > > current project classpath.
> > > >
> > > > First option (the maven way) is to rework the code generator to use a
> > > > parametrized folder to load config files used in generation. You then
> > > just
> > > > have to set a new @parameter in the Mojo.
> > > >
> > > > Second option - if changing the legacy code is too complex - is to
> > setup
> > > a
> > > > new URLClassloader with the plugin classloader as parent and add the
> > > > project
> > > > resources folder. You can the load the generator class using this
> > > > classloader and invoke the "generate()" method by reflexion.
> > > >
> > > > Nico.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > 2007/12/8, Kallin Nagelberg <ka...@gmail.com>:
> > > > >
> > > > > I'm trying to convert the source-generation of a legacy system into
> > a
> > > > > mavenized project. Basically I need to run a couple of java classes
> > > from
> > > > > an
> > > > > already existing dependency (during the generate-sources phase I
> > > assume)
> > > > > which should populate my source directories. The problem I'm having
> > is
> > > > > that
> > > > > it seems maven is ignoring my <resource> declarations during the
> > > > > generate-sources phase. Is this normal? To run the two java classes
> > > > > requried
> > > > > for source generation I'm using the exec-maven-plugin and it
> > > definitely
> > > > > doesn't find my declared resources on it's classpath..
> > > > >
> > > > > I've managed to find some hacks around this, like telling the
> > > > > maven-resources-plugin to execute the 'resources' goal during
> > > > > generate-sources, but that doesn't seem so clean to me, as it's
> > > probably
> > > > > going to do it again during the generate-resources phase..
> > > > >
> > > > > Any ideas?
> > > > >
> > > >
> > >
> >
>

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


Re: generating-sources missing resources

Posted by Kallin Nagelberg <ka...@gmail.com>.
Thank you, I've forwarded the discussion to the codehaus mailing list to see
what their opinion is on the matter.

On Dec 8, 2007 3:47 PM, nicolas de loof <ni...@apache.org> wrote:

> "enclosing project's dependencies as classpath" does not mean "enclosing
> project classpath".
> You have acces to all declared dependencies BUT not to the project
> classes/ressources. (this may be a valuale enhancement to the plugin).
>
> Nico.
>
>
> 2007/12/8, Kallin Nagelberg <ka...@gmail.com>:
> >
> > Thanks for the prompt reply.
> >
> > My code-generator (the java classes anyways) have been packaged as a
> > regular
> > jar artifact.
> > I am using the Maven Exec Plug-In java goal,
> > http://mojo.codehaus.org/exec-maven-plugin/java-mojo.html.
> > It states 'Executes the supplied java class in the current VM with the
> > enclosing project's dependencies as classpath.' That is accurate, as the
> > plugin has no problems finding the classes in the pom's dependencies.
> > However it doesn't seem to include the enclosing POM's resources..
> > From the sounds of it this is likely an issue with the codehaus plugin
> > more
> > than a core maven issue. I'll pose this question on their mailing list
> > also.
> >
> > Kal.
> >
> >
> >
> >
> >
> > On Dec 8, 2007 2:14 PM, nicolas de loof <ni...@gmail.com>
> wrote:
> >
> > > Tell me if I understand well :
> > >
> > > your code-generator has been packaged as a Mojo and is used in another
> > > project. It loads some config file from classpath to generate code.
> > >
> > > Maven plugins run in isolated classloaders, they have no acces to the
> > > current project classpath.
> > >
> > > First option (the maven way) is to rework the code generator to use a
> > > parametrized folder to load config files used in generation. You then
> > just
> > > have to set a new @parameter in the Mojo.
> > >
> > > Second option - if changing the legacy code is too complex - is to
> setup
> > a
> > > new URLClassloader with the plugin classloader as parent and add the
> > > project
> > > resources folder. You can the load the generator class using this
> > > classloader and invoke the "generate()" method by reflexion.
> > >
> > > Nico.
> > >
> > >
> > >
> > >
> > >
> > > 2007/12/8, Kallin Nagelberg <ka...@gmail.com>:
> > > >
> > > > I'm trying to convert the source-generation of a legacy system into
> a
> > > > mavenized project. Basically I need to run a couple of java classes
> > from
> > > > an
> > > > already existing dependency (during the generate-sources phase I
> > assume)
> > > > which should populate my source directories. The problem I'm having
> is
> > > > that
> > > > it seems maven is ignoring my <resource> declarations during the
> > > > generate-sources phase. Is this normal? To run the two java classes
> > > > requried
> > > > for source generation I'm using the exec-maven-plugin and it
> > definitely
> > > > doesn't find my declared resources on it's classpath..
> > > >
> > > > I've managed to find some hacks around this, like telling the
> > > > maven-resources-plugin to execute the 'resources' goal during
> > > > generate-sources, but that doesn't seem so clean to me, as it's
> > probably
> > > > going to do it again during the generate-resources phase..
> > > >
> > > > Any ideas?
> > > >
> > >
> >
>

Re: generating-sources missing resources

Posted by nicolas de loof <ni...@apache.org>.
"enclosing project's dependencies as classpath" does not mean "enclosing
project classpath".
You have acces to all declared dependencies BUT not to the project
classes/ressources. (this may be a valuale enhancement to the plugin).

Nico.


2007/12/8, Kallin Nagelberg <ka...@gmail.com>:
>
> Thanks for the prompt reply.
>
> My code-generator (the java classes anyways) have been packaged as a
> regular
> jar artifact.
> I am using the Maven Exec Plug-In java goal,
> http://mojo.codehaus.org/exec-maven-plugin/java-mojo.html.
> It states 'Executes the supplied java class in the current VM with the
> enclosing project's dependencies as classpath.' That is accurate, as the
> plugin has no problems finding the classes in the pom's dependencies.
> However it doesn't seem to include the enclosing POM's resources..
> From the sounds of it this is likely an issue with the codehaus plugin
> more
> than a core maven issue. I'll pose this question on their mailing list
> also.
>
> Kal.
>
>
>
>
>
> On Dec 8, 2007 2:14 PM, nicolas de loof <ni...@gmail.com> wrote:
>
> > Tell me if I understand well :
> >
> > your code-generator has been packaged as a Mojo and is used in another
> > project. It loads some config file from classpath to generate code.
> >
> > Maven plugins run in isolated classloaders, they have no acces to the
> > current project classpath.
> >
> > First option (the maven way) is to rework the code generator to use a
> > parametrized folder to load config files used in generation. You then
> just
> > have to set a new @parameter in the Mojo.
> >
> > Second option - if changing the legacy code is too complex - is to setup
> a
> > new URLClassloader with the plugin classloader as parent and add the
> > project
> > resources folder. You can the load the generator class using this
> > classloader and invoke the "generate()" method by reflexion.
> >
> > Nico.
> >
> >
> >
> >
> >
> > 2007/12/8, Kallin Nagelberg <ka...@gmail.com>:
> > >
> > > I'm trying to convert the source-generation of a legacy system into a
> > > mavenized project. Basically I need to run a couple of java classes
> from
> > > an
> > > already existing dependency (during the generate-sources phase I
> assume)
> > > which should populate my source directories. The problem I'm having is
> > > that
> > > it seems maven is ignoring my <resource> declarations during the
> > > generate-sources phase. Is this normal? To run the two java classes
> > > requried
> > > for source generation I'm using the exec-maven-plugin and it
> definitely
> > > doesn't find my declared resources on it's classpath..
> > >
> > > I've managed to find some hacks around this, like telling the
> > > maven-resources-plugin to execute the 'resources' goal during
> > > generate-sources, but that doesn't seem so clean to me, as it's
> probably
> > > going to do it again during the generate-resources phase..
> > >
> > > Any ideas?
> > >
> >
>

new to the list: archetype with substitutions [Virus checked]

Posted by Wo...@atosorigin.com.
Hi Maven experts,                   (this is the second try to send to the
list, delete it, if you saw the first.)

What I want to do, I am almost sure, has someone done before:

I need to create achetypes, one for a parent project, a subproject for the
some jar files, one for the interface definition, and one for web use, web
admin.

In a batch they are createed side by side with something like this:


call mvn archetype:create -DarchetypeGroupId=MYGROUPID
-DarchetypeArtifactId=my-parent -DarchetypeVersion=0.2.1-SNAPSHOT
-DgroupId=%PACKAGE% -DartifactId=parent

call mvn archetype:create -DarchetypeGroupId=MYGROUPID
-DarchetypeArtifactId=my-opm -DarchetypeVersion=0.1.0-SNAPSHOT
-DgroupId=%PACKAGE% -DartifactId=%SYS_NAME%-opm

call mvn archetype:create -DarchetypeGroupId=MYGROUPID
-DarchetypeArtifactId=my-opm -DarchetypeVersion=0.1.0-SNAPSHOT
-DgroupId=%PACKAGE% -DartifactId=%SYS_NAME%-common

call mvn archetype:create -DarchetypeGroupId=MYGROUPID
-DarchetypeArtifactId=my-opm -DarchetypeVersion=0.1.0-SNAPSHOT
-DgroupId=%PACKAGE% -DartifactId=%SYS_NAME%-interface


All the created pom.xml should contain a <parent></parent> automatically
referencing the parent just created. Even better would be that the project
structure (main/java/...) reflects the MYGROUPID structure.

Maven  VELOCITY may be the tools to accomblish this.

Is there an example how to do something like this? Is there a better way ?
Is a stupid idea in the first place ?
Any pointers apreciated !

mit freundlichen Grüßen/best regards

Wolfgang Schrecker

"Database design  is still largely subjective in nature;"
from C.J. Date: Database In Depth p. 137
 --
--------------------------------------------------

Atos Worldline Processing GmbH
Hahnstrasse 25
60528 Frankfurt/Main
Germany
Phone: +49 69/6657-1176
mailto:Wolfgang.Schrecker@atosorigin.com
http://www.atosworldline.com

Geschäftsführer: Erik Munk Koefoed
Aufsichtsratsvorsitzender: Didier Dhennin
Sitz der Gesellschaft: Frankfurt/Main
Handelsregister: Frankfurt/Main HRB 40 417

--------------------------------------------------

Atos Worldline Processing GmbH
Hahnstraße 25
60528 Frankfurt/Main
Germany
Phone: +49 69/6657-1176
Fax :
mailto: Wolfgang.Schrecker@atosorigin.com
http://www.atosworldline.com

Geschäftsführer: Erik Munk Koefoed
Aufsichtsratsvorsitzender: Didier Dhennin
Sitz der Gesellschaft: Frankfurt/Main
Handelsregister: Frankfurt/Main HRB 40 417


* * * * * * * * L E G A L    D I S C L A I M E R * * * * * * * *
This e-mail is destined for the above mentioned recipient. In case you
received this e-mail by accident, we would appreciate it if you could
contact the sender and delete all copies stored on your computer.
Please be aware that the security and confidentiality of electronic data
transmitted by e-mail is not completely guaranteed and that data may be seen,
copied, downloaded or changed by third persons during transmission.
Atos Origin accepts no liability for the security and confidentiality of
data and documents sent by e-mail. Please make sure that all important
messages will be confirmed in writing by means of a telefax or a letter.
* * * * * * * * L E G A L    D I S C L A I M E R * * * * * * * *

Re: generating-sources missing resources

Posted by Kallin Nagelberg <ka...@gmail.com>.
Thanks for the prompt reply.

My code-generator (the java classes anyways) have been packaged as a regular
jar artifact.
I am using the Maven Exec Plug-In java goal,
http://mojo.codehaus.org/exec-maven-plugin/java-mojo.html.
It states 'Executes the supplied java class in the current VM with the
enclosing project's dependencies as classpath.' That is accurate, as the
plugin has no problems finding the classes in the pom's dependencies.
However it doesn't seem to include the enclosing POM's resources..
>From the sounds of it this is likely an issue with the codehaus plugin more
than a core maven issue. I'll pose this question on their mailing list also.

Kal.





On Dec 8, 2007 2:14 PM, nicolas de loof <ni...@gmail.com> wrote:

> Tell me if I understand well :
>
> your code-generator has been packaged as a Mojo and is used in another
> project. It loads some config file from classpath to generate code.
>
> Maven plugins run in isolated classloaders, they have no acces to the
> current project classpath.
>
> First option (the maven way) is to rework the code generator to use a
> parametrized folder to load config files used in generation. You then just
> have to set a new @parameter in the Mojo.
>
> Second option - if changing the legacy code is too complex - is to setup a
> new URLClassloader with the plugin classloader as parent and add the
> project
> resources folder. You can the load the generator class using this
> classloader and invoke the "generate()" method by reflexion.
>
> Nico.
>
>
>
>
>
> 2007/12/8, Kallin Nagelberg <ka...@gmail.com>:
> >
> > I'm trying to convert the source-generation of a legacy system into a
> > mavenized project. Basically I need to run a couple of java classes from
> > an
> > already existing dependency (during the generate-sources phase I assume)
> > which should populate my source directories. The problem I'm having is
> > that
> > it seems maven is ignoring my <resource> declarations during the
> > generate-sources phase. Is this normal? To run the two java classes
> > requried
> > for source generation I'm using the exec-maven-plugin and it definitely
> > doesn't find my declared resources on it's classpath..
> >
> > I've managed to find some hacks around this, like telling the
> > maven-resources-plugin to execute the 'resources' goal during
> > generate-sources, but that doesn't seem so clean to me, as it's probably
> > going to do it again during the generate-resources phase..
> >
> > Any ideas?
> >
>

Re: generating-sources missing resources

Posted by nicolas de loof <ni...@gmail.com>.
Tell me if I understand well :

your code-generator has been packaged as a Mojo and is used in another
project. It loads some config file from classpath to generate code.

Maven plugins run in isolated classloaders, they have no acces to the
current project classpath.

First option (the maven way) is to rework the code generator to use a
parametrized folder to load config files used in generation. You then just
have to set a new @parameter in the Mojo.

Second option - if changing the legacy code is too complex - is to setup a
new URLClassloader with the plugin classloader as parent and add the project
resources folder. You can the load the generator class using this
classloader and invoke the "generate()" method by reflexion.

Nico.





2007/12/8, Kallin Nagelberg <ka...@gmail.com>:
>
> I'm trying to convert the source-generation of a legacy system into a
> mavenized project. Basically I need to run a couple of java classes from
> an
> already existing dependency (during the generate-sources phase I assume)
> which should populate my source directories. The problem I'm having is
> that
> it seems maven is ignoring my <resource> declarations during the
> generate-sources phase. Is this normal? To run the two java classes
> requried
> for source generation I'm using the exec-maven-plugin and it definitely
> doesn't find my declared resources on it's classpath..
>
> I've managed to find some hacks around this, like telling the
> maven-resources-plugin to execute the 'resources' goal during
> generate-sources, but that doesn't seem so clean to me, as it's probably
> going to do it again during the generate-resources phase..
>
> Any ideas?
>