You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Alex Soto <ap...@gmail.com> on 2007/02/21 01:03:25 UTC

how to make a module's resources available to a plugin

Hi,

I'm wrapping some existing code in a maven plugin.  What I'd like to
do is make the module's resources available to the plugin.  So for
example, there is a properties file in src/main/resources.  When the
code my plugin wraps looks up the properties file, it should find it
via the classpath.  I've specified a <resources> tag in the module's
<build> section of the pom as such:

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>


However, to debug things, I print the classpath in my plugin via
System.getProperty("java.class.path") and the classpath does not
include the target dir or anything else that is in the context of the
module that is executing the plugin.

Anyone have any ideas?

Thanks,
Alex

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


Re: how to make a module's resources available to a plugin

Posted by Jiaqi Guo <cy...@gmail.com>.
The classpath of project belongs to project, not plugin. While I believe 
you can create you own ClassLoader based on 
project.getXXXXXClasspathElements() and find resources from there.

I used to have a small Mojo running something with project's classpath
http://fisheye3.cenqua.com/browse/cyclops-group/trunk/arapaho/arapaho-maven-plugin/src/main/java/com/cyclopsgroup/arapaho/maven/RunJettyMojo.java?r=1738
http://fisheye3.cenqua.com/browse/cyclops-group/trunk/arapaho/arapaho-maven-plugin/src/main/java/com/cyclopsgroup/arapaho/maven/ClassLoaderUtils.java?r=1738

You'll need to find resources with this special ClassLoader, and this 
classpath won't appear in System.getProperty("java.class.path").

Hope this helps.



Regards
-Jiaqi


Alex Soto wrote:
> Hi,
>
> I'm wrapping some existing code in a maven plugin.  What I'd like to
> do is make the module's resources available to the plugin.  So for
> example, there is a properties file in src/main/resources.  When the
> code my plugin wraps looks up the properties file, it should find it
> via the classpath.  I've specified a <resources> tag in the module's
> <build> section of the pom as such:
>
>        <resources>
>            <resource>
>                <directory>src/main/resources</directory>
>                <filtering>true</filtering>
>            </resource>
>        </resources>
>
>
> However, to debug things, I print the classpath in my plugin via
> System.getProperty("java.class.path") and the classpath does not
> include the target dir or anything else that is in the context of the
> module that is executing the plugin.
>
> Anyone have any ideas?
>
> Thanks,
> Alex
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 


Jiaqi Guo

http://www.cyclopsgroup.org
jiaqi.guo@gmail.com


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