• Uncategorized

About linux : How-to-set-executable-permission-in-IntelliJ-idea-automatic-build-process

Question Detail


I’ve spent quite a lot of time re-setting-up the build process for a project that has been dormant for several months. This is a project written for Java 8. The output is a single JAR archive. The build output is defined in File / Project Structure / Project Settings / Artifacts, see screenshot. To build, I use Build / Build artifacts.

This GUI appears to be translated into the following config files:


<component name="ArtifactManager">
  <artifact type="jar" name="iFOS:jar">
    <root id="archive" name="iFOS.jar">
      <element id="directory" name="META-INF">
        <element id="file-copy" path="$PROJECT_DIR$/META-INF/MANIFEST.MF" />
      <element id="module-output" name="iFOS.main" />
      <element id="module-source" name="iFOS.main" />
      <element id="file-copy" path="$PROJECT_DIR$/src/main/resources/splash.png" />


apply plugin: 'idea'
apply plugin: 'java'

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'

jar {
    manifest {
            'Main-Class': 'za.co.iFos.IFos',
            "Class-Path": '. lib/jssc-2.5.0-src.jar lib/jssc.jar lib/commons-jexl-2.1.1.jar lib/commons-logging-1.2.jar lib/SteelSeries.jar lib/trident-6.3.jar lib/openmap.jar lib/commons-lang3-3.4.jar lib/CANBabel-2.0-jar-with-dependencies.jar'
        exclude 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.SF'
    //from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }

group 'za.co.iFos'

sourceCompatibility = 1.8

repositories {
    flatDir {
        dirs 'lib'

dependencies {
    compile fileTree(dir: 'lib', include: '*.jar')
    testCompile group: 'junit', name: 'junit', version: '4.12'

    compile group: 'jfree', name: 'jfreechart', version: '1.0.12'


Everything works except for one nuisance: The output JAR file only has read/write permissions but not the executable permission. So I have to manually go into the file properties / permissions tab and tick “Allow this file to run as a program”. I would like to have this set automatically during the build process with IntelliJ IDEA & Gradle.

How can I set the executable bit automatically at the end of the build process?

What I’ve researched

I’ve looked at this popular question with a similar title but it is not about the executable permission at all.

The answers to this question about setting the executable bit in Gradle appears to have the way forward. However I haven’t figured out what to use for the file path. I’m also not sure, if it’s okay to mess with build.gradle or whether this fill will be overwritten by the GUI anyways the next time I change something.

Question Answer

No answer for now.

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.