webstart maven插件与依赖项

时间:2013-04-30 14:32:14

标签: maven plugins dependencies java-web-start maven-webstart-plugin

我的老板告诉我使用Maven Web Start插件生成JNLP和签名的JAR。

问题是无论我如何尝试我都无法制作包含我的依赖项的JAR。

我总是面临ClassDefNotFound异常

的pom.xml

<repositories>
    <repository>
        <releases />
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>mygrid-repository</id>
        <name>myGrid Repository</name>
        <url>http://www.mygrid.org.uk/maven/repository</url>
    </repository>
    <repository>
        <id>com.springsource.repository.bundles.external</id>
        <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
        <url>http://repository.springsource.com/maven/bundles/external</url>
    </repository>
</repositories>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo.webstart</groupId>
            <artifactId>webstart-maven-plugin</artifactId>
            <version>1.0-alpha-2</version>

            <executions>
                <execution>
                    <id>package</id>
                    <phase>package</phase>
                    <goals>
                        <goal>jnlp</goal>
                    </goals>
                </execution>
            </executions>

            <configuration>
                <jnlp>
                    <outputFile>ctScan.jnlp</outputFile>
                    <mainClass>com.test.testScan.App</mainClass>
                </jnlp>

                <libPath>lib</libPath>
                <outputJarVersions>true</outputJarVersions>
                <includes>
                    <include>commons-logging:commons-logging</include>
                    <include>commons-cli:commons-cli</include>
                </includes>
                <sign>
                    <keystore>../../ctKeystore</keystore>
                    <keypass>CreativeKeypass</keypass>
                    <storepass>CreativeKeypass</storepass>
                    <alias>CreativeScan</alias>

                    <dnameCn>Mohcine Wannas</dnameCn>
                    <dnameOu>DARD</dnameOu>
                    <dnameO>Creative technologies</dnameO>
                    <dnameL>Rabat</dnameL>
                    <dnameSt>Rabat</dnameSt>
                    <dnameC>ma</dnameC>

                    <verify>true</verify>
                </sign>

                <pack200>false</pack200>
                <gzip>true</gzip>
                <outputJarVersions>false</outputJarVersions>
                <verbose>true</verbose>

            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>lib/</classpathPrefix>
                        <mainClass>com.test.testScan.App</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>uk.co.mmscomputing</groupId>
        <artifactId>device</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>net.htmlparser.jericho</groupId>
        <artifactId>jericho-html</artifactId>
        <version>3.3</version>
    </dependency>
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>itextpdf</artifactId>
        <version>0.0</version>
    </dependency>
    <dependency>
        <groupId>net.java.dev.jai-imageio</groupId>
        <artifactId>jai-imageio-core-standalone</artifactId>
        <version>1.2-pre-dr-b04-2011-07-04</version>
    </dependency>
    <dependency>
        <groupId>javax.media.jai</groupId>
        <artifactId>com.springsource.javax.media.jai.codec</artifactId>
        <version>1.1.3</version>
    </dependency>
</dependencies>

构建输出

  

请在此处添加您的构建输出(可能是创建的目录结构及其内容,特别是lib/文件夹的内容,如果它走得那么远)

1 个答案:

答案 0 :(得分:1)

webstart-maven-plugin不会创建带有依赖项的JAR ,它会在{{1}中创建一个带有的JAR 和JAR依赖项文件夹。

如果您想将所有内容打包在一个JAR中,则需要使用lib/