Quantcast

Manipulating the build's classpath programmatically (in a custom mojo)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Manipulating the build's classpath programmatically (in a custom mojo)

Alex Ruiz-3
Greetings,

I know this is not the Maven way, but I need to add a bunch of jars to a
build's classpath. The problem is those jars cannot be distributed in any
way, and they are so many, that adding them as dependencies is just too
overwhelming. Plus the jar names and/or number of jars can change at any
time.

I'm writing a little maven plugin for this, but I don't know how to add them
to the current classpath. Any pointers will be greatly appreciated :)

Thanks,
-Alex
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Manipulating the build's classpath programmatically (in a custom mojo)

Jemos Infra
I think this question was answered recently in the list and involved
using extensions.

http://maven.apache.org/guides/mini/guide-using-extensions.html

Regards,

M.

On Thu, 2010-05-06 at 22:29 -0700, Alex Ruiz wrote:

> Greetings,
>
> I know this is not the Maven way, but I need to add a bunch of jars to a
> build's classpath. The problem is those jars cannot be distributed in any
> way, and they are so many, that adding them as dependencies is just too
> overwhelming. Plus the jar names and/or number of jars can change at any
> time.
>
> I'm writing a little maven plugin for this, but I don't know how to add them
> to the current classpath. Any pointers will be greatly appreciated :)
>
> Thanks,
> -Alex



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Manipulating the build's classpath programmatically (in a custom mojo)

Alex Ruiz-3
Thanks, but I think that that doesn't answer my question. I just need a
programmatic way to add jars to the build classpath.

Cheers,
-Alex

On Fri, May 7, 2010 at 1:21 AM, Jemos Infra <[hidden email]>wrote:

> I think this question was answered recently in the list and involved
> using extensions.
>
> http://maven.apache.org/guides/mini/guide-using-extensions.html
>
> Regards,
>
> M.
>
> On Thu, 2010-05-06 at 22:29 -0700, Alex Ruiz wrote:
> > Greetings,
> >
> > I know this is not the Maven way, but I need to add a bunch of jars to a
> > build's classpath. The problem is those jars cannot be distributed in any
> > way, and they are so many, that adding them as dependencies is just too
> > overwhelming. Plus the jar names and/or number of jars can change at any
> > time.
> >
> > I'm writing a little maven plugin for this, but I don't know how to add
> them
> > to the current classpath. Any pointers will be greatly appreciated :)
> >
> > Thanks,
> > -Alex
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Manipulating the build's classpath programmatically (in a custom mojo)

Wayne Fay
> Thanks, but I think that that doesn't answer my question. I just need a
> programmatic way to add jars to the build classpath.

I doubt you'll find many (any?) people on this list who have done this.

IMO you are better off simply deploying all those dependencies to a
corporate repo and using proper compile-time dependencies. Working
with Maven is generally a better idea than working against it.

Perhaps you should take a minute and tell us more details about your
project before heading down this path -- what jars must be on the
build classpath, where are they coming from, why are there so many,
and why does the list change continuously?

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Manipulating the build's classpath programmatically (in a custom mojo)

Ron Wheeler
In reply to this post by Alex Ruiz-3
Create a single project that has these dependencies in it ArtifactId
="bunch-of-jars" version =${app.version} set in the parent POM.
Set the project up to create a consolidated single jar file that has all
of the latest crap in it (create jar-with-dependencies)

Make the rest of your POMs depend on the application level variable
${app.version} so they do not have to change their single dependency
when one of the libraries inside "bunch-of-jars" changes.

In your project poms, you declare the bunch-of-jars scope = "provided"
if you want to share it or "compile" if you want the libraries in your
project output WAR or JAR or whatever.

You might want to break it down into families if there are lots of jars.

Makes your life much simpler and lets you control your libraries in one
spot.

We do this with a series of library jars
-spring-hibernate-mysql-tomcat.jar for the technology core
-shared-libraries.jar for all the wonderful tools from Apache and others
-our-shared-libraries for the wonderful tools that we build
-jsf-library.jar for the JSF tools that some of our apps need.

We have more but you can see the pattern.

A webapp that runs on Tomcat and uses JSF would have about 4-6
dependencies and they would all have the same version (the application
level release number) which is set in the parent ${app.version} so there
is almost no maintenance of the project POMs as the libraries change or
as we move from snapshot to release to next snapshot and release and so on.
Just pick the right parent POM in the project POM's parent section and
you get the right set of dependencies and produce the right version of
the project artifact with the right name.

I hope that this saves you from trying to beat Maven into submission.
You can bend it a long way but I would be afraid that when it snaps back
someone will get hurt.
It is much better to go along with Maven's design.


Ron


On 07/05/2010 11:13 AM, Alex Ruiz wrote:

> Thanks, but I think that that doesn't answer my question. I just need a
> programmatic way to add jars to the build classpath.
>
> Cheers,
> -Alex
>
> On Fri, May 7, 2010 at 1:21 AM, Jemos Infra<[hidden email]>wrote:
>
>    
>> I think this question was answered recently in the list and involved
>> using extensions.
>>
>> http://maven.apache.org/guides/mini/guide-using-extensions.html
>>
>> Regards,
>>
>> M.
>>
>> On Thu, 2010-05-06 at 22:29 -0700, Alex Ruiz wrote:
>>      
>>> Greetings,
>>>
>>> I know this is not the Maven way, but I need to add a bunch of jars to a
>>> build's classpath. The problem is those jars cannot be distributed in any
>>> way, and they are so many, that adding them as dependencies is just too
>>> overwhelming. Plus the jar names and/or number of jars can change at any
>>> time.
>>>
>>> I'm writing a little maven plugin for this, but I don't know how to add
>>>        
>> them
>>      
>>> to the current classpath. Any pointers will be greatly appreciated :)
>>>
>>> Thanks,
>>> -Alex
>>>        
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>>      
>    


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...