You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Bryan Loofbourrow <br...@qpass.com> on 2006/08/02 20:05:26 UTC

How do I add a directory to the classpath visible to a Maven plugin?

Sorry if this is an elementary question, I am learning about Maven (2),
but I've certainly tried to do my homework.

I have a need to add a directory to the classpath that's visible to a
plugin I'm writing, and I don't see how to do it. All I see is stuff
that seems to assume:

- Maven controls the classpath, which it constructs from artifacts on
which you depend.
- You can make your own artifact types, and specify that they be added
to the classpath
- It appears that an artifact is assumed to be a file.
- That's the only way to get something onto the classpath.

I am hoping, of course, that at least one of these statements is false,
and that there's a way to add a directory (not a file) to a classpath.

Specifically, I am trying to use BEA Kodo 4, the enhancer, and it
appears to require that the directory containing the license.bea file be
on the classpath.

I grant that I could do this by hacking up a ClassLoader and invoking
the enhancer with that, or invoking the enhancer in a different JVM so
that I gain control over that classpath, but those approaches have other
difficulties, and certainly doesn't seem like the Maven Way. I figure
there's a right way to do this; I just haven't discovered it in the
documentation.

Thanks for any help or guidance.




Re: How do I add a directory to the classpath visible to a Maven plugin?

Posted by "David J. M. Karlsen" <da...@davidkarlsen.com>.
Bryan Loofbourrow wrote:
> Sorry if this is an elementary question, I am learning about Maven (2),
> but I've certainly tried to do my homework.
>
> I have a need to add a directory to the classpath that's visible to a
> plugin I'm writing, and I don't see how to do it. All I see is stuff
> that seems to assume:
>
> - Maven controls the classpath, which it constructs from artifacts on
> which you depend.
> - You can make your own artifact types, and specify that they be added
> to the classpath
> - It appears that an artifact is assumed to be a file.
> - That's the only way to get something onto the classpath.
>   
You could add it as a resource, but you may not want it to end in the 
jar archive, see
http://www.nabble.com/-discussion-idea--resource-scoping-tf2042404.html

where I reference an extension to the surefire plugin.
(Just realised the patch isn't right, so I'll fix that tomorrow.)

-- 
David J. M. Karlsen - +47 90 68 22 43
http://www.davidkarlsen.com
http://mp3.davidkarlsen.com



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


Re: How do I add a directory to the classpath visible to a Maven plugin?

Posted by "David J. M. Karlsen" <da...@davidkarlsen.com>.
Bryan Loofbourrow wrote:
> A plausible and clever idea, but it doesn't work. Nor did supplying a
> URLClassLoader with the directory. I'm guessing that there's code
> somewhere in the new Kodo that just walks the class path property and
> does its own thing to find the license file.
> 
> I did some experimentation with invoking the enhancer from the command
> line using kodoc.  If you put the bea.license file in a directory and
> add that directory to the classpath, everything works fine. If you put
> the bea.license file into a jar, at the root:
> 
>   [] jar -tf bea-license.jar
>   META-INF/
>   META-INF/MANIFEST.MF
>   License.bea
> 
> ...and put that jar on the classpath, Kodo does not find the license
> file.
> 
> So I think I'm back to the original problem: jars won't do it; how do I
> add an actual directory to a Maven classpath?

Could the build-helper help you:
http://mojo.codehaus.org/build-helper-maven-plugin/
?


-- 
David J. M. Karlsen - +47 90 68 22 43
http://www.davidkarlsen.com
http://mp3.davidkarlsen.com

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


RE: How do I add a directory to the classpath visible to a Maven plugin?

Posted by Bryan Loofbourrow <br...@qpass.com>.
A plausible and clever idea, but it doesn't work. Nor did supplying a
URLClassLoader with the directory. I'm guessing that there's code
somewhere in the new Kodo that just walks the class path property and
does its own thing to find the license file.

I did some experimentation with invoking the enhancer from the command
line using kodoc.  If you put the bea.license file in a directory and
add that directory to the classpath, everything works fine. If you put
the bea.license file into a jar, at the root:

  [] jar -tf bea-license.jar
  META-INF/
  META-INF/MANIFEST.MF
  License.bea

...and put that jar on the classpath, Kodo does not find the license
file.

So I think I'm back to the original problem: jars won't do it; how do I
add an actual directory to a Maven classpath?

-----Original Message-----
From: Barrie Treloar [mailto:baerrach@gmail.com] 
Sent: Wednesday, August 02, 2006 3:32 PM
To: Maven Users List
Subject: Re: How do I add a directory to the classpath visible to a
Maven plugin?

> Specifically, I am trying to use BEA Kodo 4, the enhancer, and it
> appears to require that the directory containing the license.bea file
be
> on the classpath.

>From my understanding stuff on the classpath is treated the same,
regardless of whether it came from a jar or a directory.

So if you put the license.bea inside a jar file so that it was at the
root directory of the archive it should be the same as attaching a
directory.

Then you could install that archive into your repository as
<dependecy>
  <groupId>com.bea</group
  <artifactId>kodo</artifactId>
  <classifier>license</classifier>
</dependency>

and then users of your plugin would need to have installed into their
local repository (or their company internal repository) the license
jar.

I'm guessing that you might even be able to check that this dependency
exists and provide a reasomable error message from your plugin if it
doesn't.

---------------------------------------------------------------------
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 do I add a directory to the classpath visible to a Maven plugin?

Posted by Barrie Treloar <ba...@gmail.com>.
> Specifically, I am trying to use BEA Kodo 4, the enhancer, and it
> appears to require that the directory containing the license.bea file be
> on the classpath.

>From my understanding stuff on the classpath is treated the same,
regardless of whether it came from a jar or a directory.

So if you put the license.bea inside a jar file so that it was at the
root directory of the archive it should be the same as attaching a
directory.

Then you could install that archive into your repository as
<dependecy>
  <groupId>com.bea</group
  <artifactId>kodo</artifactId>
  <classifier>license</classifier>
</dependency>

and then users of your plugin would need to have installed into their
local repository (or their company internal repository) the license
jar.

I'm guessing that you might even be able to check that this dependency
exists and provide a reasomable error message from your plugin if it
doesn't.

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