Skip to content

Commit

Permalink
Chmod +x mvn after extracting it
Browse files Browse the repository at this point in the history
  • Loading branch information
Redande committed Jan 3, 2020
1 parent ece3912 commit fc4e558
Showing 1 changed file with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
import org.openide.modules.InstalledFileLocator;

public class EnsureMavenBinaryIsExecutable {

private final static Path RELATIVE_MAVEN_LOCATION = Paths.get("java").resolve("maven").resolve("bin").resolve("mvn");

private Path mavenPath;
private final boolean isUnix;

public EnsureMavenBinaryIsExecutable() {
this.isUnix = !System.getProperty("os.name").startsWith("Windows");
}

public void run() {
if (!isUnix) {
return;
Expand All @@ -37,6 +37,10 @@ public void run() {
return;
}
tryToChmod(mavenPath);

Path mavenHome = getConfigDirectory();
Path extractedMavenLocation = mavenHome.resolve("apache-maven-3.5.4");
tryToChmod(extractedMavenLocation.resolve("bin").resolve("mvn"));
}

private void tryToChmod(Path path) {
Expand All @@ -46,6 +50,21 @@ private void tryToChmod(Path path) {
permissions.add(PosixFilePermission.OWNER_EXECUTE);
Files.setPosixFilePermissions(path, permissions);
}
} catch (IOException ex) { }
} catch (IOException ex) {
}
}

static Path getConfigDirectory() {
Path configPath;

String configEnv = System.getenv("XDG_CONFIG_HOME");

if (configEnv != null && configEnv.length() > 0) {
configPath = Paths.get(configEnv);
} else {
configPath = Paths.get(System.getProperty("user.home")).resolve(".config");
}

return configPath.resolve("tmc");
}
}

0 comments on commit fc4e558

Please sign in to comment.