Skip to content

Commit 2a37903

Browse files
Anton Piontkovskiyparttimenerd
Anton Piontkovskiy
authored andcommitted
Drop dev.dirs:directories dependency
1 parent 3f741ec commit 2a37903

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,6 @@
233233
</plugin>
234234
</plugins>
235235
</build>
236-
<dependencies>
237-
<dependency>
238-
<groupId>dev.dirs</groupId>
239-
<artifactId>directories</artifactId>
240-
<version>26</version>
241-
</dependency>
242-
</dependencies>
243236
<distributionManagement>
244237
<snapshotRepository>
245238
<id>ossrh</id>

pom_all.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,6 @@
222222
</plugin>
223223
</plugins>
224224
</build>
225-
<dependencies>
226-
<dependency>
227-
<groupId>dev.dirs</groupId>
228-
<artifactId>directories</artifactId>
229-
<version>26</version>
230-
</dependency>
231-
</dependencies>
232225
<distributionManagement>
233226
<snapshotRepository>
234227
<id>ossrh</id>

src/main/java/one/profiler/AsyncProfilerLoader.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
package one.profiler;
1919

20-
import dev.dirs.ProjectDirectories;
21-
2220
import java.io.*;
2321
import java.lang.instrument.Instrumentation;
2422
import java.lang.management.ManagementFactory;
@@ -124,16 +122,31 @@ public static void deleteExtractionDirectory() throws IOException {
124122
/** Returns the directory used for storing the extracted libraries, binaries and JARs */
125123
public static Path getExtractionDirectory() throws IOException {
126124
if (extractionDir == null) {
127-
extractionDir =
128-
Paths.get(
129-
ProjectDirectories.from("me", "bechberger", "ap-loader-" + getVersion()).dataDir);
125+
extractionDir = Paths.get(getApplicationsDir(), "me.bechberger.ap-loader", getVersion());
130126
if (Files.notExists(extractionDir)) {
131127
Files.createDirectories(extractionDir);
132128
}
133129
}
134130
return extractionDir;
135131
}
136132

133+
/**
134+
* Returns directory where applications places their files. Specific to operating system
135+
*/
136+
private static String getApplicationsDir() {
137+
String os = System.getProperty("os.name").toLowerCase();
138+
if (os.contains("linux")) {
139+
String xdgDataHome = System.getenv("XDG_DATA_HOME");
140+
if (xdgDataHome != null && !xdgDataHome.isEmpty()) {
141+
return xdgDataHome;
142+
}
143+
return Paths.get(System.getProperty("user.home"), ".local", "share").toString();
144+
} else if (os.contains("mac")) {
145+
return Paths.get(System.getProperty("user.home"), "Library", "Application Support").toString();
146+
}
147+
throw new UnsupportedOperationException("Unsupported os " + os);
148+
}
149+
137150
/**
138151
* @throws IllegalStateException if OS or Arch not supported
139152
*/

0 commit comments

Comments
 (0)