Error trying to adding arbitrary classpath in Manifest.mf

对着背影说爱祢 提交于 2019-12-11 09:21:27

问题


I have this code to add my classpath:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.4</version>
        <configuration>
        <archive>
            <manifest>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                <addClasspath>true</addClasspath>
                <mainClass>ApuestaYa</mainClass>                    
            </manifest>
            <manifestEntries>
                <Class-path>../lib/jcalendar.jar ../lib/eclipselink.jar ../lib/libforms-1.3.0.jar ../lib/Imagenes.jar ../lib/DriverPersistencia.jar ../lib/javax.persistence_2.0.3.v201010191057.jar</Class-path>
            </manifestEntries>
        </archive>
        </configuration>
    </plugin>

But I got this in my manifest.mf:

Manifest-Version: 1.0
Implementation-Title: Apuestaya
Implementation-Version: 0.9.0-SNAPSHOT
Implementation-Vendor-Id: um.tds.VictorMRuiz
Built-By: Celor
Build-Jdk: 1.7.0_09
Class-Path: ../lib/jcalendar.jar ../lib/eclipselink.jar ../lib/libform
s-1.3.0.jar ../lib/Imagenes.jar ../lib/DriverPersistencia.jar ../lib/
javax.persistence_2.0.3.v201010191057.jar
Created-By: Apache Maven 3.0.4
Main-Class: ApuestaYa
Archiver-Version: Plexus Archiver

As you can see, Maven put random blank spaces in the jar's routes. For example: ../lib/libform s-1.3.0.Jar ... So, when I lunch mi jar I get an error because it can't find the jars. Any ideas?


回答1:


A workaround

Use version 2.3.2 of maven-jar-plugin and change configuration of Class-path.

<Class-path><![CDATA[../lib/jcalendar.jar
 ../lib/eclipselink.jar
 ../lib/libforms-1.3.0.jar
 ../lib/Imagenes.jar
 ../lib/DriverPersistencia.jar
 ../lib/javax.persistence_2.0.3.v201010191057.jar]]></Class-path>

It will make your classpath multi line, just remember about spaces at start of each line. According to Jar specification, manifest line can have at most 72 bytes.



来源:https://stackoverflow.com/questions/16626883/error-trying-to-adding-arbitrary-classpath-in-manifest-mf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!