Skip to content

Drop dev.dirs:directories dependency #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,6 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>dev.dirs</groupId>
<artifactId>directories</artifactId>
<version>26</version>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
Expand Down
7 changes: 0 additions & 7 deletions pom_all.xml
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,6 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>dev.dirs</groupId>
<artifactId>directories</artifactId>
<version>26</version>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
Expand Down
23 changes: 18 additions & 5 deletions src/main/java/one/profiler/AsyncProfilerLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package one.profiler;

import dev.dirs.ProjectDirectories;

import java.io.*;
import java.lang.instrument.Instrumentation;
import java.lang.management.ManagementFactory;
Expand Down Expand Up @@ -124,16 +122,31 @@ public static void deleteExtractionDirectory() throws IOException {
/** Returns the directory used for storing the extracted libraries, binaries and JARs */
public static Path getExtractionDirectory() throws IOException {
if (extractionDir == null) {
extractionDir =
Paths.get(
ProjectDirectories.from("me", "bechberger", "ap-loader-" + getVersion()).dataDir);
extractionDir = getApplicationsDir().resolve(Paths.get("me.bechberger.ap-loader", getVersion()));
if (Files.notExists(extractionDir)) {
Files.createDirectories(extractionDir);
}
}
return extractionDir;
}

/**
* Returns directory where applications places their files. Specific to operating system
*/
private static Path getApplicationsDir() {
String os = System.getProperty("os.name").toLowerCase();
if (os.startsWith("linux")) {
String xdgDataHome = System.getenv("XDG_DATA_HOME");
if (xdgDataHome != null && !xdgDataHome.isEmpty()) {
return Paths.get(xdgDataHome);
}
return Paths.get(System.getProperty("user.home"), ".local", "share");
} else if (os.startsWith("macosx") || os.startsWith("mac os x")) {
return Paths.get(System.getProperty("user.home"), "Library", "Application Support");
}
throw new UnsupportedOperationException("Unsupported os " + os);
}

/**
* @throws IllegalStateException if OS or Arch not supported
*/
Expand Down