Maven阴影插件 – Jar和依赖项

huangapple go评论80阅读模式
英文:

Maven shade plugin - Jar and dependencies

问题

我正在使用 shade 插件来对 org.apache.poi jar 文件进行阴影处理,因为在 Tomcat 服务器上有一个旧版本。我遇到了一个问题,因为这个 jar 文件引用了其他的 jar 文件(commons-compress、xmlbeans、commons-collections)。我应该如何不仅对这个 jar 文件进行阴影处理,还要对它引用的 jar 文件进行阴影处理?

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-shade-plugin</artifactId>
	<version>3.2.4</version>
	<executions>
		<execution>
			<phase>package</phase>
			<goals>
				<goal>shade</goal>
			</goals>
			<configuration>
				<shadedClassifierName>shaded</shadedClassifierName>
				<shadedArtifactAttached>true</shadedArtifactAttached>
				<relocations>
					<relocation>
						<pattern>org.apache.poi</pattern>
						<shadedPattern>hidden.org.apache</shadedPattern>
					</relocation>
					<!-- Other relocations for referenced jars can be added here -->
				</relocations>
				<filters>
					<filter>
						<artifact>*:*</artifact>
						<excludes>
							<exclude>META-INF/maven/**/*</exclude>
							<exclude>META-INF/*.SF</exclude>
							<exclude>META-INF/*.DSA</exclude>
							<exclude>META-INF/*.RSA</exclude>
						</excludes>
					</filter>
				</filters>
			</configuration>
		</execution>
	</executions>
</plugin>

我尝试过对所有的 jar 文件进行重新定位,但这是不可能的。

英文:

I'm using shade plugin to shade org.apache.poi jar because there is an old version on Tomcat server. I have a problem because this jar makes reference to others jars (commons-compress, xmlbeans, commons-collections). How can I shade not only this jar but also its references jars?

&lt;plugin&gt;
	&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
	&lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
	&lt;version&gt;3.2.4&lt;/version&gt;
	&lt;executions&gt;
		&lt;execution&gt;
			&lt;phase&gt;package&lt;/phase&gt;
			&lt;goals&gt;
				&lt;goal&gt;shade&lt;/goal&gt;
			&lt;/goals&gt;
			&lt;configuration&gt;
				&lt;shadedClassifierName&gt;shaded&lt;/shadedClassifierName&gt;
				&lt;shadedArtifactAttached&gt;true&lt;/shadedArtifactAttached&gt;
				&lt;relocations&gt;
					&lt;relocation&gt;
						&lt;pattern&gt;org.apache.poi&lt;/pattern&gt;
						&lt;shadedPattern&gt;hidden.org.apache&lt;/shadedPattern&gt;
					&lt;/relocation&gt;
				&lt;/relocations&gt;
				&lt;filters&gt;
					&lt;filter&gt;
						&lt;artifact&gt;*:*&lt;/artifact&gt;
						&lt;excludes&gt;
							&lt;exclude&gt;META-INF/maven/**/*&lt;/exclude&gt;
							&lt;exclude&gt;META-INF/*.SF&lt;/exclude&gt;
							&lt;exclude&gt;META-INF/*.DSA&lt;/exclude&gt;
							&lt;exclude&gt;META-INF/*.RSA&lt;/exclude&gt;
						&lt;/excludes&gt;
					&lt;/filter&gt;
				&lt;/filters&gt;
			&lt;/configuration&gt;
		&lt;/execution&gt;
	&lt;/executions&gt;
&lt;/plugin&gt;

I tried to relocate all the jars but it's impossible.

答案1

得分: 0

我将所有逻辑放在一个外部微服务中,并从Pentaho内部调用。我不知道这是否是最佳解决方案,但我找不到其他解决方案。

英文:

I put all the logic on an external microservice and called from inside Pentaho. I don't know if it is the best solution but I couldn't find another one.

huangapple
  • 本文由 发表于 2020年9月1日 22:16:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/63689510.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定