增加以下两行配置
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>with-spark-${spark.internal.version}</shadedClassifierName>
就可以使得编译的jar包带上指定的后缀
maven
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>with-spark-${spark.internal.version}</shadedClassifierName>
<artifactSet>
<includes>
<include>org.spark-project.spark:unused</include>
<include>com.google.guava:guava</include>
<include>org.apache.parquet:*</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.eclipse.jetty</pattern>
<shadedPattern>org.spark_project.jetty</shadedPattern>
<includes>
<include>org.eclipse.jetty.**</include>
</includes>
</relocation>
<relocation>
<pattern>com.google.common</pattern>
<shadedPattern>org.spark_project.guava</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
使用编译安装命令
mvn clean -Pspark-2.3 -Ppersistent-memory -DskipTests install
会自动安装到本地 repo。
其他 project 可以这样写在 pom里
<dependency>
<groupId>com.{}.ssg.bdt</groupId>
<artifactId>oap</artifactId>
<version>0.5.0-SNAPSHOT</version>
<classifier>with-spark-2.2.0</classifier>
</dependency>