Maven分模块项目将依赖一起打包

来源:互联网 发布:三菱plc编程实例3000 编辑:程序博客网 时间:2024/05/29 19:02

这里记录一下几种方式 以后备用:

1.maven-assembly-plugin插件(mvn assembly:assembly)

2.maven-shade-plugin插件

3.scala-maven-plugin插件(scala的打包插件)

<plugins>            <build>                <sourceDirectory>src/main/scala</sourceDirectory>                <testSourceDirectory>src/test/scala</testSourceDirectory>                <plugins>                    //scala-maven-plugin的打包插件配置                    <plugin>                        <groupId>net.alchim31.maven</groupId>                        <artifactId>scala-maven-plugin</artifactId>                        <version>3.2.2</version>                        <executions>                            <execution>                                <goals>                                    <goal>compile</goal>                                    <goal>testCompile</goal>                                </goals>                                <configuration>                                    <args>                                        <arg>-make:transitive</arg>                                        <arg>-dependencyfile</arg>                                        <arg>${project.build.directory}/.scala_dependencies</arg>                                    </args>                                </configuration>                            </execution>                        </executions>                    </plugin>                    //maven-shade-plugin的打包插件配置                    <plugin>                        <groupId>org.apache.maven.plugins</groupId>                        <artifactId>maven-shade-plugin</artifactId>                        <version>2.4.3</version>                        <executions>                            <execution>                                <phase>package</phase>                                <goals>                                    <goal>shade</goal>                                </goals>                                <configuration>                                    <filters>                                        <filter>                                            <artifact>*:*</artifact>                                            <excludes>                                                <exclude>META-INF/*.SF</exclude>                                                <exclude>META-INF/*.DSA</exclude>                                                <exclude>META-INF/*.RSA</exclude>                                            </excludes>                                        </filter>                                    </filters>                                    <transformers>                                        <transformer                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">                                            <resource>reference.conf</resource>                                        </transformer>                                        <transformer                                            implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">                                            <mainClass>cn.touna.main.BootStrop</mainClass>                                        </transformer>                                    </transformers>                                </configuration>                            </execution>                        </executions>                    </plugin>                    //maven-assembly-plugin的打包方式                    <plugin>                        <groupId>org.apache.maven.plugins</groupId>                        <artifactId>maven-assembly-plugin</artifactId>                        <version>2.5.5</version>                        <configuration>                            <archive>                                <manifest>                                    <mainClass>cn.touna.main.BootStrop</mainClass>                                </manifest>                            </archive>                            <descriptorRefs>                                <descriptorRef>jar-with-dependencies</descriptorRef>                            </descriptorRefs>                        </configuration>                        <executions>                            <execution>                                <id>make-assembly</id>                                <phase>package</phase>                                <goals>                                    <goal>single</goal>                                </goals>                            </execution>                        </executions>                    </plugin>                </plugins>
0 1