How to change jar resolution packed by maven? I am using the maven build plugin

I use the maven build plugin to pack a jar with all the dependencies. But the jar file is not executable. How can I change the resolution of a container?

-rw-r--r-- 1 e17490 ADPROD\Domain 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> 
+6
source share
2 answers

Use the maven:exec plugin to execute chmod

eg

 <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> 
+10
source

The Jar file can be run on Linux if there is Java support. Some distributions already come with this configuration. All you have to do is create threat files as if they were executable, for example, a compiled program or script:

 chmod 700 myJar.jar ./myJar.jar 

So the question makes sense.

You should be aware that this solution may not be portable across platforms.

According to this answer you need to use the following on Maven:

 <fileSets> <fileSet> <directory>${basedir}/src/main/web</directory> <includes> <include>some_dir</include> </includes> <outputDirectory>web</outputDirectory> <fileMode>0777</fileMode> <directoryMode>0777</directoryMode> </fileSet> </fileSets> 

If this does not work, you can also call chmod Ant task from Maven using the AntRun Plugin :

<chmod file="${dist}/start.sh" perm="ugo+rx"/>

+3
source

Source: https://habr.com/ru/post/957948/


All Articles