所以我需要从jar/war文件中删除一个文件.我希望有类似"jar -d myjar.jar file_I_donot_need.txt"的内容
但是现在我从Linux命令行(不使用WinRAR/Winzip或Linux等价物)看到这样做的唯一方法就是
请告诉我有一个较短的方法?
我的问题正是这个maven-shade插件用户面临的问题:
但我正在使用tomcat7-maven-plugin构建一个自运行的webapp.我最近切换了数据库驱动程序以使用Microsoft自己的驱动程序来实现JDBC4.现在我有问题,包括它作为我的exec-war目标中的extraDependency.这是相关部分pom.xml.
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>tomcat-run</id>
<goals>
<goal>exec-war-only</goal>
</goals>
<phase>package</phase>
<configuration>
<path>/oases</path>
<contextFile>applicationContext.xml</contextFile>
<extraDependencies>
<extraDependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</extraDependency>
</extraDependencies>
<excludes>
<exclude>META-INF/MSFTSIG.RSA</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
该项目构建正常,但maven不遵守该exclude指令,以便sqljdbc4 RSA文件包含在META-INF目录中.这意味着当我尝试运行我的exec-war jar文件时,我收到此错误.
Exception in thread "main" java.lang.SecurityException: Invalid
signature file digest for Manifest main attributes
Run Code Online (Sandbox Code Playgroud)
我已经阅读了代码,据我所知,插件已正确配置为排除sqljdbc4 META-INF文件.这是版本2.2的插件代码,这是我正在使用的.看起来这应该做我想要的.然而,exec-war jar仍包括META-INF/MSFTSIG.RSA
protected void extractJarToArchive( JarFile file, ArchiveOutputStream os, String[] excludes )
throws IOException
{
Enumeration<? extends JarEntry> entries = file.entries();
while ( entries.hasMoreElements() )
{ …Run Code Online (Sandbox Code Playgroud)