maven从多个模块构建可执行jar

时间:2015-01-27 08:57:48

标签: java maven jar configuration pom.xml

我有以下项目结构,并尝试将整个项目编译为 jar

---- 父POM ----主层----服务层---- DTO层。我使用 Maven Shade插件创建一个带有 mvn package 命令的唯一可执行jar文件,但我得到的是这样的编译错误

[INFO] core-data .......................................... FAILURE [  0.616 s]

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project core-data: Compilation failure: Compilation failure:

\BetRadar\core-data\src\main\java\com\zzilla\entities\sportEntities\Handball.java:[3,46] error: **package com.sportradar.sdk.feed.common.entities** does not exist
[ERROR] \BetRadar\core-data\src\main\java\com\zzilla\entities\sportEntities\Handball.java:[12,12] error: cannot find symbol

我将以下构建配置放在父pom中。在我的主模块层中,我依赖于服务层项目,该项目本身依赖于核心数据(存储库)层。错误日志中提到的包 com.sportradar.sdk.feed.common.entities 存在于项目结构中包含的sdk jar文件中:

<dependency>
    <groupId>com.sportradar.sdk</groupId>
    <artifactId>sdk-parent</artifactId>
    <version>1.1.0.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/src/sdk jar/sdk.jar</systemPath>
</dependency>

似乎maven对这些依赖项有一些问题。我怎样才能达到预期的效果呢?在POM中有关于依赖声明的缺失部分吗?                  MyProjectName         

        <!-- download source code in Eclipse, best practice -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>false</downloadJavadocs>
            </configuration>
        </plugin>


        <!-- Set a compiler level -->
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
        <source>${source.jdk.version}</source>
        <target>${source.jdk.version}</target>
        </configuration>
        </plugin>

        <!-- Maven Shade Plugin -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.3</version>
            <executions>
                <!-- Run shade goal on package phase -->
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>
                            <!-- add Main-Class to manifest file -->
                            <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>zzilla.Main</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

0 个答案:

没有答案