Skip to content

Commit

Permalink
remove LocalMavenRepository.java and replace it with MavenRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
Revxrsal committed Dec 15, 2024
1 parent 2585627 commit b9ed9b4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 46 deletions.
2 changes: 2 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ repositories {
dependencies {
compileOnly("org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT")
compileOnly("org.jetbrains:annotations:24.1.0")
compileOnly("org.projectlombok:lombok:1.18.36")
annotationProcessor("org.projectlombok:lombok:1.18.36")
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package revxrsal.zapper;

import lombok.SneakyThrows;
import org.jetbrains.annotations.NotNull;
import revxrsal.zapper.relocation.Relocation;
import revxrsal.zapper.repository.Repository;
Expand Down Expand Up @@ -83,21 +84,17 @@ public final class RuntimeLibPluginConfiguration {
return repos;
}

private static @NotNull Properties parseProperties() {
private static @SneakyThrows @NotNull Properties parseProperties() {
Properties properties = new Properties();
try (InputStream stream = ClassLoaderReader.getResource("zapper/zapper.properties")) {
properties.load(stream);
} catch (IOException e) {
throw sneakyThrow(e);
}
return properties;
}

private static List<String> readAllLines(InputStream inputStream) {
private static @SneakyThrows @NotNull List<String> readAllLines(InputStream inputStream) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
return reader.lines().collect(Collectors.toList());
} catch (IOException e) {
throw sneakyThrow(e);
}
}

Expand All @@ -124,9 +121,4 @@ public List<Relocation> getRelocations() {
public String toString() {
return "RuntimeLibPluginConfiguration(libsFolder=" + this.getLibsFolder() + ", relocationPrefix=" + this.getRelocationPrefix() + ", dependencies=" + this.getDependencies() + ", repositories=" + this.getRepositories() + ", relocations=" + this.getRelocations() + ")";
}

@SuppressWarnings("unchecked")
private static <T extends Throwable> RuntimeException sneakyThrow(Throwable t) throws T {
throw (T) t;
}
}

This file was deleted.

12 changes: 8 additions & 4 deletions api/src/main/java/revxrsal/zapper/repository/Repository.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package revxrsal.zapper.repository;

import lombok.SneakyThrows;
import org.jetbrains.annotations.NotNull;
import revxrsal.zapper.Dependency;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

/**
Expand Down Expand Up @@ -46,10 +48,11 @@ public interface Repository {
*
* @return the local Maven repository
*/
@SneakyThrows
static @NotNull Repository mavenLocal() {
String userHome = System.getProperty("user.home");
File m2 = new File(userHome, ".m2");
return new LocalMavenRepository(m2);
File repository = new File(userHome, ".m2" + File.separator + "repository");
return maven(repository);
}

/**
Expand All @@ -58,8 +61,9 @@ public interface Repository {
* @param directory the local Maven directory
* @return the local Maven repository
*/
static @NotNull Repository mavenLocal(@NotNull File directory) {
return new LocalMavenRepository(directory);
@SneakyThrows
static @NotNull Repository maven(@NotNull File directory) {
return maven(directory.toURI().toURL().toString());
}

/**
Expand Down

0 comments on commit b9ed9b4

Please sign in to comment.