You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Geoffrey De Smet <ge...@gmail.com> on 2007/04/23 15:58:14 UTC

Dynamic jar manifest classpath based on groupId, artifactId and version in repository

Hi all,

With the assembly plugin I can put all my module jars in repository like 
structure:

/repo/org/ggg/ggg-core/1.0/ggg-core-1.0.jar
/repo/org/ggg/ggg-ftp-app/1.0/ggg-ftp-app-1.0.jar depends on ggg-core
/repo/org/ggg/ggg-http-app/1.0/ggg-http-app-1.0.jar depends on ggg-core

I've configured the maven-jar-plugin as such:
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
         <configuration>
           <archive>
             <manifest>
               <mainClass>org.ggg.ftpapp.FtpMain</mainClass>
               <addClasspath>true</addClasspath>
             </manifest>
           </archive>
         </configuration>
       </plugin>

And now the manifest contains an entry
"ggg-core-1.0.jar".
The problem is that this needs to be 
"../../../../org/ggg/ggg-core/1.0/ggg-core-1.0.jar"

How I make that happen?

-- 
With kind regards,
Geoffrey De Smet


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


Re: Dynamic jar manifest classpath based on groupId, artifactId and version in repository

Posted by Geoffrey De Smet <ge...@gmail.com>.


Jerome Lacoste schreef:
> On 4/23/07, Geoffrey De Smet <ge...@gmail.com> wrote:
>> I also have a dependency on spring-core:
>> /repo/org/springframework/spring-core/2.0.2/spring-core-2.0.2.jar
>>
>> So I need a different classpathPrefix depending on the dependency.
> 
> what is your use case ?
> 
> I am not sure that the repository-like structure allowed by the
> assembly plugin was designed to allow you to run your app from the
> generated repository.
> 
> Some suggestions:
> 1- don't assemble as a maven repository (do you really need it ?)
For the sake of namespacing, yes:
/org/foo/bar-1.0.jar
/org/doo/bar-1.0.jar
are 2 different jars, with different classes.

> 2- don't depend on the generated classpath (e.g. use a wrapper to
> start your app)
You mean a shell script? Then we need to keep 2 verions in sync: 
wrapper.bat and wrapper.sh.

Or do you mean a wrapper jar? We have separate processes that reuse the 
same jars and want to minimize network traffic.

How can we avoid having to rewrite the classpath with each dependency 
change in this case?

> 3- rewrite the generated classpath once your repository has been created.
In the jar? Problem is we need the groupId of each artifact.

> 4- patch the jar plugin to accept a classpath generator that matches
> your requirement
That would be the full solution.

> 
> I would pick option 1 or 3.
> 
> Cheers,
> 
> J

With kind regards,
Geoffrey De Smet


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


Re: Dynamic jar manifest classpath based on groupId, artifactId and version in repository

Posted by Jerome Lacoste <je...@gmail.com>.
On 4/23/07, Geoffrey De Smet <ge...@gmail.com> wrote:
> I also have a dependency on spring-core:
> /repo/org/springframework/spring-core/2.0.2/spring-core-2.0.2.jar
>
> So I need a different classpathPrefix depending on the dependency.

what is your use case ?

I am not sure that the repository-like structure allowed by the
assembly plugin was designed to allow you to run your app from the
generated repository.

Some suggestions:
1- don't assemble as a maven repository (do you really need it ?)
2- don't depend on the generated classpath (e.g. use a wrapper to
start your app)
3- rewrite the generated classpath once your repository has been created.
4- patch the jar plugin to accept a classpath generator that matches
your requirement

I would pick option 1 or 3.

Cheers,

J

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


Re: Dynamic jar manifest classpath based on groupId, artifactId and version in repository

Posted by Geoffrey De Smet <ge...@gmail.com>.
I also have a dependency on spring-core:
/repo/org/springframework/spring-core/2.0.2/spring-core-2.0.2.jar

So I need a different classpathPrefix depending on the dependency.


With kind regards,
Geoffrey De Smet

Ian Springer schreef:
> Hi,
> 
> Add:
> 
> <classpathPrefix>../../../../org/ggg/ggg-core/1.0/</classpathPrefix>
> 
> as a child element of the <manifest> element.
> 
> Ian
> 
> Geoffrey De Smet wrote:
>> Hi all,
>>
>> With the assembly plugin I can put all my module jars in repository 
>> like structure:
>>
>> /repo/org/ggg/ggg-core/1.0/ggg-core-1.0.jar
>> /repo/org/ggg/ggg-ftp-app/1.0/ggg-ftp-app-1.0.jar depends on ggg-core
>> /repo/org/ggg/ggg-http-app/1.0/ggg-http-app-1.0.jar depends on ggg-core
>>
>> I've configured the maven-jar-plugin as such:
>>       <plugin>
>>         <groupId>org.apache.maven.plugins</groupId>
>>         <artifactId>maven-jar-plugin</artifactId>
>>         <configuration>
>>           <archive>
>>             <manifest>
>>               <mainClass>org.ggg.ftpapp.FtpMain</mainClass>
>>               <addClasspath>true</addClasspath>
>>             </manifest>
>>           </archive>
>>         </configuration>
>>       </plugin>
>>
>> And now the manifest contains an entry
>> "ggg-core-1.0.jar".
>> The problem is that this needs to be 
>> "../../../../org/ggg/ggg-core/1.0/ggg-core-1.0.jar"
>>
>> How I make that happen?
>>


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


Re: Dynamic jar manifest classpath based on groupId, artifactId and version in repository

Posted by Ian Springer <ia...@redhat.com>.
Hi,

Add:

<classpathPrefix>../../../../org/ggg/ggg-core/1.0/</classpathPrefix>

as a child element of the <manifest> element.

Ian

Geoffrey De Smet wrote:
> Hi all,
> 
> With the assembly plugin I can put all my module jars in repository like 
> structure:
> 
> /repo/org/ggg/ggg-core/1.0/ggg-core-1.0.jar
> /repo/org/ggg/ggg-ftp-app/1.0/ggg-ftp-app-1.0.jar depends on ggg-core
> /repo/org/ggg/ggg-http-app/1.0/ggg-http-app-1.0.jar depends on ggg-core
> 
> I've configured the maven-jar-plugin as such:
>       <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-jar-plugin</artifactId>
>         <configuration>
>           <archive>
>             <manifest>
>               <mainClass>org.ggg.ftpapp.FtpMain</mainClass>
>               <addClasspath>true</addClasspath>
>             </manifest>
>           </archive>
>         </configuration>
>       </plugin>
> 
> And now the manifest contains an entry
> "ggg-core-1.0.jar".
> The problem is that this needs to be 
> "../../../../org/ggg/ggg-core/1.0/ggg-core-1.0.jar"
> 
> How I make that happen?
> 


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