You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Fredrik Vraalsen <fr...@vraalsen.no> on 2006/05/09 09:37:37 UTC

classpath in jar manifest

Hi,

I'm moving a project from maven 1.1 to 2.0, but I've hit a problem with 
specifying the classpath in the manifest file in my main application jar 
and was wondering if someone here could help.

Basically, I wish to add some resource directories to the classpath, in 
addition to the jar dependencies.  The reason why I cannot put the 
resources in a jar is that they are being read by the JDIC web browser 
component (https://jdic.dev.java.net/) - in effect Mozilla or IE, which 
do not understand jar files. ;-)

In maven 1.1, I was able to do this with the following in 
project.properties:

     maven.jar.manifest.classpath.add=true
     maven.jar.classpath=help/ resources/

This would create a single Class-Path: entry in the manifest file.

I've been reading 
http://maven.apache.org/guides/mini/guide-manifest.html and have tried

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-jar-plugin</artifactId>
   <configuration>
     <archive>
       <manifest>
         <mainClass>splash.Splasher</mainClass>
         <addClasspath>true</addClasspath>
       </manifest>
       <manifestEntries>
         <Class-Path>help/ resources/</Class-Path>
       </manifestEntries>
     </archive>
   </configuration>
</plugin>

However, this ends up creating _two_ Class-Path: entries in the manifest 
file, which is not allowed.

Is there a way to get this to work in maven 2.0?  I'm using maven 2.0.4.


Best regards,

Fredrik Vraalsen

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


Re: classpath in jar manifest

Posted by afsilva <an...@pol.pt>.
Hi,

It's a strange behaviour indeed.

having "Class-path", the entry is added to the manifest, but with duplicate
"Class-Path" entry.

Correcting the capitalization to "Class-Path" it works perfectly!!

thanks guys!! =)


baerrach wrote:
> 
> On Wed, Jul 9, 2008 at 7:44 AM, Wayne Fay <wa...@gmail.com> wrote:
>> I suspect your problem is due to improper capitalization:
>>>                        <manifestEntries>
>>> <Class-path>resources/</Class-path>
>>>                        </manifestEntries>
>>
>> I believe this should be <Class-Path>.
> 
> This is what I use:
> 
>         <plugin>
>           <groupId>org.apache.maven.plugins</groupId>
>           <artifactId>maven-jar-plugin</artifactId>
>           <configuration>
>             <archive>
>               <manifestEntries>
>                 <Class-Path>config/</Class-Path>
>               </manifestEntries>
>               <manifest>
>                 <mainClass>fully.qualified.path.to.Main</mainClass>
>                 <addClasspath>true</addClasspath>
>                 <classpathPrefix>lib/</classpathPrefix>
>               </manifest>
>             </archive>
>           </configuration>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/classpath-in-jar-manifest-tp4295266p18368538.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: classpath in jar manifest

Posted by Barrie Treloar <ba...@gmail.com>.
On Wed, Jul 9, 2008 at 7:44 AM, Wayne Fay <wa...@gmail.com> wrote:
> I suspect your problem is due to improper capitalization:
>>                        <manifestEntries>
>> <Class-path>resources/</Class-path>
>>                        </manifestEntries>
>
> I believe this should be <Class-Path>.

This is what I use:

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <configuration>
            <archive>
              <manifestEntries>
                <Class-Path>config/</Class-Path>
              </manifestEntries>
              <manifest>
                <mainClass>fully.qualified.path.to.Main</mainClass>
                <addClasspath>true</addClasspath>
                <classpathPrefix>lib/</classpathPrefix>
              </manifest>
            </archive>
          </configuration>

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


Re: classpath in jar manifest

Posted by Wayne Fay <wa...@gmail.com>.
I suspect your problem is due to improper capitalization:
>                        <manifestEntries>
> <Class-path>resources/</Class-path>
>                        </manifestEntries>

I believe this should be <Class-Path>.

Wayne

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


Re: classpath in jar manifest

Posted by Dennis Lundberg <de...@apache.org>.
Reporting your configuration here, since this list dumps all attachments.


<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-jar-plugin</artifactId>
	<version>2.2</version>
	<configuration>
		<finalName>${project.build.finalName}</finalName>
		<archive>
			<addMavenDescriptor>false</addMavenDescriptor>
			<manifest>
				<addClasspath>true</addClasspath>
				<mainClass>
					com.afsilva.main.AppMainFrame
				</mainClass>
				<addDefaultSpecificationEntries>
					true
				</addDefaultSpecificationEntries>
				<addDefaultImplementationEntries>
					true
				</addDefaultImplementationEntries>
			</manifest>
			<manifestEntries>
				<Class-path>resources/</Class-path>
			</manifestEntries>
		</archive>
	</configuration>
</plugin>


What is the problem you are experiencing?


afsilva wrote:
> Hi,
> 
> My configuration is in the attached file.
> 
> http://www.nabble.com/file/p18345472/pom.xml pom.xml 
> 
> Thanks for the response.
> 
> 
> Dennis Lundberg-2 wrote:
>> What's your configuration?
>>
>> afsilva wrote:
>>> Hi
>>>
>>> this is an old message, I guess the problem is suposed to be solved. But
>>> the
>>> fact is that I'm observing the same strange behaviour with the 2.3
>>> version
>>> of the maven archiver.
>>>
>>> Can anyone give me a hint about this?
>>>
>>>
>>>
>>> baerrach wrote:
>>>> On 8/15/06, Barrie Treloar <ba...@gmail.com> wrote:
>>>>> On 5/11/06, George Zhao <gx...@hotmail.com> wrote:
>>>>>> We saw the same issue here (two Class-Path entries).
>>>>>>
>>>>>> But if we set <addClasspath> to false and put all the known classpath
>>>>> there,
>>>>>> we can generate one Class-Path entry - not a pretty solution through.
>>>>>>
>>>>>> Anybody over there has other workaround for this issue(I believe it is
>>>>> a
>>>>>> bug)?
>>>>> This appears to be fixed in the trunk of maven-jar-plugin.
>>>>> I'm not sure if the snapshot version has the fix in it.
>>>>> It wasn't until I installed a local build of the trunk that this
>>>>> problem went away.
>>>>>
>>>> The fix is included maven-archiver-2.2-SNAPSHOT.
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>
>>>>
>>>>
>>
>> -- 
>> Dennis Lundberg
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>>
> 


-- 
Dennis Lundberg

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


Re: classpath in jar manifest

Posted by afsilva <an...@pol.pt>.
Hi,

My configuration is in the attached file.

http://www.nabble.com/file/p18345472/pom.xml pom.xml 

Thanks for the response.


Dennis Lundberg-2 wrote:
> 
> What's your configuration?
> 
> afsilva wrote:
>> Hi
>> 
>> this is an old message, I guess the problem is suposed to be solved. But
>> the
>> fact is that I'm observing the same strange behaviour with the 2.3
>> version
>> of the maven archiver.
>> 
>> Can anyone give me a hint about this?
>> 
>> 
>> 
>> baerrach wrote:
>>> On 8/15/06, Barrie Treloar <ba...@gmail.com> wrote:
>>>> On 5/11/06, George Zhao <gx...@hotmail.com> wrote:
>>>>> We saw the same issue here (two Class-Path entries).
>>>>>
>>>>> But if we set <addClasspath> to false and put all the known classpath
>>>> there,
>>>>> we can generate one Class-Path entry - not a pretty solution through.
>>>>>
>>>>> Anybody over there has other workaround for this issue(I believe it is
>>>> a
>>>>> bug)?
>>>> This appears to be fixed in the trunk of maven-jar-plugin.
>>>> I'm not sure if the snapshot version has the fix in it.
>>>> It wasn't until I installed a local build of the trunk that this
>>>> problem went away.
>>>>
>>> The fix is included maven-archiver-2.2-SNAPSHOT.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>>
>> 
> 
> 
> -- 
> Dennis Lundberg
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/classpath-in-jar-manifest-tp4295266p18345472.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: classpath in jar manifest

Posted by Dennis Lundberg <de...@apache.org>.
What's your configuration?

afsilva wrote:
> Hi
> 
> this is an old message, I guess the problem is suposed to be solved. But the
> fact is that I'm observing the same strange behaviour with the 2.3 version
> of the maven archiver.
> 
> Can anyone give me a hint about this?
> 
> 
> 
> baerrach wrote:
>> On 8/15/06, Barrie Treloar <ba...@gmail.com> wrote:
>>> On 5/11/06, George Zhao <gx...@hotmail.com> wrote:
>>>> We saw the same issue here (two Class-Path entries).
>>>>
>>>> But if we set <addClasspath> to false and put all the known classpath
>>> there,
>>>> we can generate one Class-Path entry - not a pretty solution through.
>>>>
>>>> Anybody over there has other workaround for this issue(I believe it is
>>> a
>>>> bug)?
>>> This appears to be fixed in the trunk of maven-jar-plugin.
>>> I'm not sure if the snapshot version has the fix in it.
>>> It wasn't until I installed a local build of the trunk that this
>>> problem went away.
>>>
>> The fix is included maven-archiver-2.2-SNAPSHOT.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>>
> 


-- 
Dennis Lundberg

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


Re: classpath in jar manifest

Posted by afsilva <an...@pol.pt>.
Hi

this is an old message, I guess the problem is suposed to be solved. But the
fact is that I'm observing the same strange behaviour with the 2.3 version
of the maven archiver.

Can anyone give me a hint about this?



baerrach wrote:
> 
> On 8/15/06, Barrie Treloar <ba...@gmail.com> wrote:
>> On 5/11/06, George Zhao <gx...@hotmail.com> wrote:
>> > We saw the same issue here (two Class-Path entries).
>> >
>> > But if we set <addClasspath> to false and put all the known classpath
>> there,
>> > we can generate one Class-Path entry - not a pretty solution through.
>> >
>> > Anybody over there has other workaround for this issue(I believe it is
>> a
>> > bug)?
>>
>> This appears to be fixed in the trunk of maven-jar-plugin.
>> I'm not sure if the snapshot version has the fix in it.
>> It wasn't until I installed a local build of the trunk that this
>> problem went away.
>>
> 
> The fix is included maven-archiver-2.2-SNAPSHOT.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/classpath-in-jar-manifest-tp4295266p18327205.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: classpath in jar manifest

Posted by Barrie Treloar <ba...@gmail.com>.
On 8/15/06, Barrie Treloar <ba...@gmail.com> wrote:
> On 5/11/06, George Zhao <gx...@hotmail.com> wrote:
> > We saw the same issue here (two Class-Path entries).
> >
> > But if we set <addClasspath> to false and put all the known classpath there,
> > we can generate one Class-Path entry - not a pretty solution through.
> >
> > Anybody over there has other workaround for this issue(I believe it is a
> > bug)?
>
> This appears to be fixed in the trunk of maven-jar-plugin.
> I'm not sure if the snapshot version has the fix in it.
> It wasn't until I installed a local build of the trunk that this
> problem went away.
>

The fix is included maven-archiver-2.2-SNAPSHOT.

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


Re: classpath in jar manifest

Posted by Barrie Treloar <ba...@gmail.com>.
On 5/11/06, George Zhao <gx...@hotmail.com> wrote:
> We saw the same issue here (two Class-Path entries).
>
> But if we set <addClasspath> to false and put all the known classpath there,
> we can generate one Class-Path entry - not a pretty solution through.
>
> Anybody over there has other workaround for this issue(I believe it is a
> bug)?

This appears to be fixed in the trunk of maven-jar-plugin.
I'm not sure if the snapshot version has the fix in it.
It wasn't until I installed a local build of the trunk that this
problem went away.

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


Re: classpath in jar manifest

Posted by George Zhao <gx...@hotmail.com>.
We saw the same issue here (two Class-Path entries).

But if we set <addClasspath> to false and put all the known classpath there, 
we can generate one Class-Path entry - not a pretty solution through.

Anybody over there has other workaround for this issue(I believe it is a 
bug)?

Thanks,

George



>From: "Wayne Fay" <wa...@gmail.com>
>Reply-To: "Maven Users List" <us...@maven.apache.org>
>To: "Maven Users List" <us...@maven.apache.org>
>Subject: Re: classpath in jar manifest
>Date: Tue, 9 May 2006 09:37:02 -0500
>
>Sounds like a possible bug in the handling of Class-Path manifest
>entry. I'd take a look at the source code for maven-jar-plugin and see
>if you can't track it down.
>
>Or file a JIRA bug and wait for someone to fix it for you.
>
>Wayne
>
>On 5/9/06, Fredrik Vraalsen <fr...@vraalsen.no> wrote:
> > Hi,
> >
> > I'm moving a project from maven 1.1 to 2.0, but I've hit a problem with
> > specifying the classpath in the manifest file in my main application jar
> > and was wondering if someone here could help.
> >
> > Basically, I wish to add some resource directories to the classpath, in
> > addition to the jar dependencies.  The reason why I cannot put the
> > resources in a jar is that they are being read by the JDIC web browser
> > component (https://jdic.dev.java.net/) - in effect Mozilla or IE, which
> > do not understand jar files. ;-)
> >
> > In maven 1.1, I was able to do this with the following in
> > project.properties:
> >
> >      maven.jar.manifest.classpath.add=true
> >      maven.jar.classpath=help/ resources/
> >
> > This would create a single Class-Path: entry in the manifest file.
> >
> > I've been reading
> > http://maven.apache.org/guides/mini/guide-manifest.html and have tried
> >
> > <plugin>
> >    <groupId>org.apache.maven.plugins</groupId>
> >    <artifactId>maven-jar-plugin</artifactId>
> >    <configuration>
> >      <archive>
> >        <manifest>
> >          <mainClass>splash.Splasher</mainClass>
> >          <addClasspath>true</addClasspath>
> >        </manifest>
> >        <manifestEntries>
> >          <Class-Path>help/ resources/</Class-Path>
> >        </manifestEntries>
> >      </archive>
> >    </configuration>
> > </plugin>
> >
> > However, this ends up creating _two_ Class-Path: entries in the manifest
> > file, which is not allowed.
> >
> > Is there a way to get this to work in maven 2.0?  I'm using maven 2.0.4.
> >
> >
> > Best regards,
> >
> > Fredrik Vraalsen
> >
> > ---------------------------------------------------------------------
> > 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
>

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


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


Re: classpath in jar manifest

Posted by Wayne Fay <wa...@gmail.com>.
Sounds like a possible bug in the handling of Class-Path manifest
entry. I'd take a look at the source code for maven-jar-plugin and see
if you can't track it down.

Or file a JIRA bug and wait for someone to fix it for you.

Wayne

On 5/9/06, Fredrik Vraalsen <fr...@vraalsen.no> wrote:
> Hi,
>
> I'm moving a project from maven 1.1 to 2.0, but I've hit a problem with
> specifying the classpath in the manifest file in my main application jar
> and was wondering if someone here could help.
>
> Basically, I wish to add some resource directories to the classpath, in
> addition to the jar dependencies.  The reason why I cannot put the
> resources in a jar is that they are being read by the JDIC web browser
> component (https://jdic.dev.java.net/) - in effect Mozilla or IE, which
> do not understand jar files. ;-)
>
> In maven 1.1, I was able to do this with the following in
> project.properties:
>
>      maven.jar.manifest.classpath.add=true
>      maven.jar.classpath=help/ resources/
>
> This would create a single Class-Path: entry in the manifest file.
>
> I've been reading
> http://maven.apache.org/guides/mini/guide-manifest.html and have tried
>
> <plugin>
>    <groupId>org.apache.maven.plugins</groupId>
>    <artifactId>maven-jar-plugin</artifactId>
>    <configuration>
>      <archive>
>        <manifest>
>          <mainClass>splash.Splasher</mainClass>
>          <addClasspath>true</addClasspath>
>        </manifest>
>        <manifestEntries>
>          <Class-Path>help/ resources/</Class-Path>
>        </manifestEntries>
>      </archive>
>    </configuration>
> </plugin>
>
> However, this ends up creating _two_ Class-Path: entries in the manifest
> file, which is not allowed.
>
> Is there a way to get this to work in maven 2.0?  I'm using maven 2.0.4.
>
>
> Best regards,
>
> Fredrik Vraalsen
>
> ---------------------------------------------------------------------
> 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