Skip to content

Commit fc4e558

Browse files
committed
Chmod +x mvn after extracting it
1 parent ece3912 commit fc4e558

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

tmc-plugin/src/fi/helsinki/cs/tmc/actions/EnsureMavenBinaryIsExecutable.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
import org.openide.modules.InstalledFileLocator;
1111

1212
public class EnsureMavenBinaryIsExecutable {
13-
13+
1414
private final static Path RELATIVE_MAVEN_LOCATION = Paths.get("java").resolve("maven").resolve("bin").resolve("mvn");
15-
15+
1616
private Path mavenPath;
1717
private final boolean isUnix;
18-
18+
1919
public EnsureMavenBinaryIsExecutable() {
2020
this.isUnix = !System.getProperty("os.name").startsWith("Windows");
2121
}
22-
22+
2323
public void run() {
2424
if (!isUnix) {
2525
return;
@@ -37,6 +37,10 @@ public void run() {
3737
return;
3838
}
3939
tryToChmod(mavenPath);
40+
41+
Path mavenHome = getConfigDirectory();
42+
Path extractedMavenLocation = mavenHome.resolve("apache-maven-3.5.4");
43+
tryToChmod(extractedMavenLocation.resolve("bin").resolve("mvn"));
4044
}
4145

4246
private void tryToChmod(Path path) {
@@ -46,6 +50,21 @@ private void tryToChmod(Path path) {
4650
permissions.add(PosixFilePermission.OWNER_EXECUTE);
4751
Files.setPosixFilePermissions(path, permissions);
4852
}
49-
} catch (IOException ex) { }
53+
} catch (IOException ex) {
54+
}
55+
}
56+
57+
static Path getConfigDirectory() {
58+
Path configPath;
59+
60+
String configEnv = System.getenv("XDG_CONFIG_HOME");
61+
62+
if (configEnv != null && configEnv.length() > 0) {
63+
configPath = Paths.get(configEnv);
64+
} else {
65+
configPath = Paths.get(System.getProperty("user.home")).resolve(".config");
66+
}
67+
68+
return configPath.resolve("tmc");
5069
}
5170
}

0 commit comments

Comments
 (0)