[英]Exclude resource package from maven dependency (webjars)
I have dependency in my pom: 我对pom有依赖性:
<dependency>
<groupId>org.webjars</groupId>
<artifactId>extjs</artifactId>
<version>6.0.0</version>
</dependency>
After building my project into war, I received a pack that has over 200MB. 将项目投入战争后,我收到了一个超过200MB的数据包。 Is there a possibility to exclude package 是否有可能排除包裹
/webjars/extjs/6.0.0/build/examples/
from this dependency? 从这种依赖? How can I do that? 我怎样才能做到这一点?
I've tried to use shade plugin, but it doesn't work, also in war plugin config: 我尝试使用阴影插件,但是在war插件配置中也不起作用:
<configuration>
<packagingExcludes>
/webjars/extjs/${extjs.version}/build/examples/
</packagingExcludes>
</configuration>
doesn't work. 不起作用。
You could use the maven-assembly-plugin
and use the exclude
within the dependencySet . 您可以使用maven-assembly-plugin
并在dependencySet中使用exclude
。 The following question how to exclude a resource file in a maven assembly gives some more background. 以下问题如何在Maven程序集中排除资源文件提供了更多背景知识。
Thanks to Dark Knight i found the solution that works for me: 多亏了Dark Knight,我找到了适合我的解决方案:
<dependency>
<groupId>org.webjars</groupId>
<artifactId>extjs</artifactId>
<version>${extjs.version}</version>
<scope>provided</scope>
</dependency>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
<webResources>
<resource>
<directory>${project.build.directory}\extjs\META-INF\resources</directory>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-jar</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.webjars</groupId>
<artifactId>extjs</artifactId>
<version>${extjs.version}</version>
<type>jar</type>
<destFileName>extjs-dependency</destFileName>
<includes>
META-INF/resources/webjars/extjs/${extjs.version}/build/*.*,
META-INF/resources/webjars/extjs/${extjs.version}/build/classic/**/*.*,
META-INF/resources/webjars/extjs/${extjs.version}/build/packages/**/*.*
</includes>
<outputDirectory>
${project.build.directory}/extjs
</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.