无法获得解压缩依赖项在jar:jar之前运行, [英] Unable to get unpack-dependencies to run before jar:jar,

查看:113
本文介绍了无法获得解压缩依赖项在jar:jar之前运行,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从命令行运行mvn clean install时,我无法在maven-jar-plugin/jar之前运行maven-dependency-plugin/unpack-dependencies.

I cannot get maven-dependency-plugin/unpack-dependencies to run before maven-jar-plugin/jar when running mvn clean install from the command line.

每一次,我都看到它在解包工作开始之前运行jar:jar,我在谷歌搜索中看到一些关于在Maven生命周期中添加预打包阶段的说法,这似乎是行不通的.

Every time, I see it running jar:jar before the unpack stuff runs, I saw in my googling some talk of adding a pre-package phase to the maven lifecycle, doesn't seem to be working thought.

基本上,我想创建一个包含所有必需类(全部2600个)的jar文件.该jar会显示清单,使其能够以以下方式运行:

Basically I want to create a single jar file containing all necessary classes (all 2600 of them). This jar gets a Manifest which enables it to be run in the manner of:

java -jar blah.jar 

如果我能使用它的话...

If I ever get it to work...

这是xml片段...

And here's the xml snippet...

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
         <version>2.2</version>
            <executions>
                <execution>
                    <id>unpack-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>unpack-dependencies</goal>
                    </goals>
                </execution>
            </executions>
          </plugin>
    <plugin>
      <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>archivedb.Read</mainClass>
                    </manifest>
                </archive>
            </configuration>
          </plugin>

推荐答案

在您的原始问题中,将该阶段替换为以下阶段.

In your original question, replace the phase with the following phase.

<phase>prepare-package</phase>

这将导致罐子首先被提取.对于您的问题,阴影解决方案更好,但是我仍然将其发布在此处,以作为其他类似问题的参考,其中阴影无法解决问题.

this will cause the jars to be extracted first. For your problem, the shade solution is better, but I will still post this here as a reference for other with similar problems where shade does not help.

设置输出路径以确保jar的内容以jar:jar目标包(目标/类)的目录结尾.

The output path is set to make sure that jar's contents end up in dir that the jar:jar goal packages (target/classes).

完整的插件执行XML代码段:

Full plugin execution xml snippet:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.4</version>
            <executions>
                <execution>
                    <id>unpack-dependencies</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>unpack-dependencies</goal>
                    </goals>
                    <configuration>
                        <includes>**/*.class</includes>
                        <excludes>**/*.properties</excludes>
                        <outputDirectory>${project.build.outputDirectory}</outputDirectory>

                    </configuration>
                </execution>
            </executions>
        </plugin>

这篇关于无法获得解压缩依赖项在jar:jar之前运行,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆