How to change permission of jar packaged by maven? I am using maven assembly plugin(如何更改Maven打包的JAR的权限?我正在使用maven汇编插件)
问题描述
我正在使用maven汇编插件来打包一个带有所有依赖项的JAR。但是JAR文件是不可执行的。如何更改JAR的权限?
-rw-r--r-- 1 e17490 ADPRODDomain Users 12072889 Nov 12 14:16 com-foo-bar.jar
Pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>foo.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
推荐答案
使用maven:exec
插件执行chmod
例如
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${org.codehaus.mojo.version}</version>
<executions>
<execution>
<id>script-chmod</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>chmod</executable>
<arguments>
<argument>+x</argument>
<argument>your-assembled-jar.jar</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
这篇关于如何更改Maven打包的JAR的权限?我正在使用maven汇编插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!