maven 中,使用shadedClassifierName配置項,解決jar自帶版本號的問題
阿新 • • 發佈:2018-12-04
增加以下兩行配置
<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.intel.ssg.bdt</groupId> <artifactId>oap</artifactId> <version>0.5.0-SNAPSHOT</version> <classifier>with-spark-2.2.0</classifier> </dependency>