如何构建多模块maven项目的可执行jar
我有一个父Maven项目SampleProject,它有两个模块Sample1和Sample2。 SampleProject有一个主要的方法,如何为SampleProject创建一个可执行的jar文件,以便它执行主要的方法
SampleProject的Pom.xml是:http://maven.apache.org/xsd/maven-4.0.0.xsd“> 4.0.0
<groupId>com.test.sample</groupId>
<artifactId>SampleProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>SampleProject</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.7</version>
</dependency>
<dependency>
<groupId>sample</groupId>
<artifactId>com.sample</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>C:UserspchandDesktopExtentReport-0.0.1-SNAPSHOT.jar</systemPath>
</dependency>
</dependencies>
<modules>
<module>Sample1</module>
<module>Sample2</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.test.sample.SampleProject.Runner</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
链接地址: http://www.djcxy.com/p/37591.html
上一篇: How to build an executable jar for a multi module maven project