如何让maven shade插件在多模块项目中使用本地模块?

时间:2017-02-12 12:20:32

标签: java maven jar uberjar

我正在尝试使用maven-shade插件在多模块项目中生成超级jar但没有成功。
版本:maven v3.9,maven-shade v3.0

该项目如下:

main
|- library
|- admin
|- ...

子模块“admin”继承(依赖)子模块“library”并包含maven-shade插件定义。在构建过程中,插件似乎找不到本地子模块“库”的POM。

这是poms

main pom.xml
<groupId>tapmeppe.server</groupId>
<artifactId>tapmeppe-server</artifactId>
<version>2017.1</version>
<packaging>pom</packaging>
<modules>
    <module>library</module>
    <module>admin</module>
    <module>core</module>
</modules>
...


library pom.xml
<parent>
    <groupId>tapmeppe.server</groupId>
    <artifactId>tapmeppe-server</artifactId>
    <version>2017.1</version>
</parent>

<artifactId>tapmeppe-server-library</artifactId>

<dependencies>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.38</version>
    </dependency>
    <dependency><!--jdbc driver-->
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>4.2.5.RELEASE</version>
    </dependency>
    <dependency><!--JSON parser-->
        <groupId>com.typesafe.play</groupId>
        <artifactId>play_2.11</artifactId>
        <version>2.5.2</version>
    </dependency>
</dependencies>


admin pom.xml
<parent>
    <groupId>tapmeppe.server</groupId>
    <artifactId>tapmeppe-server</artifactId>
    <version>2017.1</version>
</parent>

<artifactId>tapmeppe-server-admin</artifactId>

<dependencies>
    <dependency>
        <groupId>tapmeppe.server</groupId>
        <artifactId>tapmeppe-server-library</artifactId>
        <version>${project.version}</version>
    </dependency>
</dependencies>

<build>
    <finalName>admin-${project.version}</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.0</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <shadedArtifactAttached>true</shadedArtifactAttached>
                        <minimizeJar>true</minimizeJar>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>tapmeppe.admin.Starter</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

这是构建

的输出
[INFO] Scanning for projects...
...
  

[警告] POM for   tapmeppe.server:tapmeppe-server-library:jar:2017.1缺少,没有   可用的依赖性信息

...
  

[错误]无法在项目tapmeppe-server-admin上执行目标:可以   不解决项目的依赖关系   tapmeppe.server:tapmeppe-server-admin:jar:2017.1:找不到   tapmeppe.server:tapmeppe-server-library:jar:2017.1 in   https://repo.maven.apache.org/maven2被缓存在当地   存储库,在更新之前不会重新尝试解析   中心间隔已经过去或强制更新 - > [帮助1]

[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

由于某种原因,插件正在远程存储库中寻找依赖jar而不是使用子模块。 我错过了什么?谢谢你的帮助。

0 个答案:

没有答案