Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
feat(build): Downgrade to Java 8
Browse files Browse the repository at this point in the history
Downgrade for java 8
  • Loading branch information
GeorgeV220 authored Jan 29, 2024
2 parents 7c59b29 + 7541953 commit 68ee816
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .idea/discord.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ if (project.hasProperty("local_script")) {
apply from: file(local_script + "/build.local.gradle")
}

sourceCompatibility = 17
targetCompatibility = 17

ext {
mcVersion = project.property("mcVersion")
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

group project.property("group")

Expand All @@ -50,8 +46,6 @@ repositories {

dependencies {

compileOnly "io.papermc.paper:paper-api:${mcVersion}-R0.1-SNAPSHOT"

compileOnly 'org.apache.commons:commons-lang3:3.12.0'
compileOnly 'com.google.guava:guava:31.1-jre'
compileOnly 'org.jetbrains:annotations:24.0.1'
Expand Down
20 changes: 0 additions & 20 deletions ensure-java-17

This file was deleted.

2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ group = com.georgev22.api
packageName = com.georgev22.api.libraryloader
pluginName = LibraryLoader
author = GeorgeV220
mcVersion = 1.19.2
apiVersion = 1.13
version = 1.6.1
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ public boolean contains(LibraryLoader.@NotNull Dependency dependency) throws URI
private boolean contains(LibraryLoader.@NotNull Dependency dependency, @NotNull Collection<URL> urls) throws URISyntaxException {
for (URL url : urls) {
String fileName = url.toURI().getPath().substring(url.toURI().getPath().lastIndexOf("\\") + 1);
if (fileName.equalsIgnoreCase(dependency.artifactId() + "-" + dependency.version() + ".jar")) {
if (fileName.equalsIgnoreCase(dependency.artifactId + "-" + dependency.version + ".jar")) {
return true;
} else if (fileName.replace("-" + dependency.version(), "").equalsIgnoreCase(dependency.artifactId() + ".jar")) {
} else if (fileName.replace("-" + dependency.version, "").equalsIgnoreCase(dependency.artifactId + ".jar")) {
return true;
} else if (fileName.contains(dependency.artifactId())) {
} else if (fileName.contains(dependency.artifactId)) {
return true;
}
}
Expand Down Expand Up @@ -202,7 +202,7 @@ public String toString() {
return "ClassLoaderAccess{" +
"unopenedURLs=" + unopenedURLs +
", pathURLs=" + pathURLs +
", classLoader=" + classLoader.getClass().getPackage().getName() + "." + classLoader.getName() +
", classLoader=" + classLoader.getClass().getPackage().getName() + "." + classLoader.getClass().getName() +
'}';
}
}
42 changes: 24 additions & 18 deletions src/main/java/com/georgev22/api/libraryloader/LibraryLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,20 @@ public void load(String groupId, String artifactId, String version, String repoU
*/
public void load(@NotNull Dependency d, boolean pathCheck) throws InvalidDependencyException, UnknownDependencyException {
if (dependencyList.contains(d)) {
logger.warning(String.format("Dependency %s:%s:%s is already loaded!", d.groupId(), d.artifactId(), d.version()));
logger.warning(String.format("Dependency %s:%s:%s is already loaded!", d.groupId, d.artifactId, d.version));
return;
}

logger.info(String.format("Loading dependency %s:%s:%s from %s", d.groupId(), d.artifactId(), d.version(), d.repoUrl()));
logger.info(String.format("Loading dependency %s:%s:%s from %s", d.groupId, d.artifactId, d.version, d.repoUrl));

String name = d.artifactId() + "-" + d.version();
String name = d.artifactId + "-" + d.version;

File saveLocationDir = new File(getLibFolder(), d.groupId().replace(".", File.separator) + File.separator + d.artifactId().replace(".", File.separator) + File.separator + d.version());
File saveLocationDir = new File(getLibFolder(), d.groupId.replace(".", File.separator) + File.separator + d.artifactId.replace(".", File.separator) + File.separator + d.version);

if (!saveLocationDir.exists()) {
logger.info(String.format("Creating directory for dependency %s:%s:%s from %s", d.groupId(), d.artifactId(), d.version(), d.repoUrl()));
logger.info(String.format("Creating directory for dependency %s:%s:%s from %s", d.groupId, d.artifactId, d.version, d.repoUrl));
if (saveLocationDir.mkdirs()) {
logger.info(String.format("The directory for dependency %s:%s:%s was successfully created!!", d.groupId(), d.artifactId(), d.version()));
logger.info(String.format("The directory for dependency %s:%s:%s was successfully created!!", d.groupId, d.artifactId, d.version));
}
}

Expand Down Expand Up @@ -281,19 +281,19 @@ public void unloadAll() throws InvalidDependencyException {
*/
public void unload(Dependency d) throws InvalidDependencyException {
if (!dependencyList.contains(d)) {
logger.warning(String.format("Dependency %s:%s:%s is not loaded!", d.groupId(), d.artifactId(), d.version()));
logger.warning(String.format("Dependency %s:%s:%s is not loaded!", d.groupId, d.artifactId, d.version));
return;
}

logger.info(String.format("Unloading dependency %s:%s:%s", d.groupId(), d.artifactId(), d.version()));
logger.info(String.format("Unloading dependency %s:%s:%s", d.groupId, d.artifactId, d.version));


String name = d.artifactId() + "-" + d.version();
String name = d.artifactId + "-" + d.version;

File saveLocationDir = new File(getLibFolder(), d.groupId().replace(".", File.separator) + File.separator + d.artifactId().replace(".", File.separator) + File.separator + d.version());
File saveLocationDir = new File(getLibFolder(), d.groupId.replace(".", File.separator) + File.separator + d.artifactId.replace(".", File.separator) + File.separator + d.version);

if (!saveLocationDir.exists()) {
throw new InvalidDependencyException(String.format("The directory for dependency %s:%s:%s does not exists!!", d.groupId(), d.artifactId(), d.version()));
throw new InvalidDependencyException(String.format("The directory for dependency %s:%s:%s does not exists!!", d.groupId, d.artifactId, d.version));
}

File saveLocation = new File(saveLocationDir, name + ".jar");
Expand All @@ -307,7 +307,7 @@ public void unload(Dependency d) throws InvalidDependencyException {
throw new InvalidDependencyException("Unable to unload dependency " + d, e);
}

logger.info(String.format("Unloaded dependency %s:%s:%s successfully", d.groupId(), d.artifactId(), d.version()));
logger.info(String.format("Unloaded dependency %s:%s:%s successfully", d.groupId, d.artifactId, d.version));
dependencyList.remove(d);
}

Expand Down Expand Up @@ -338,7 +338,12 @@ public void unload(Dependency d) throws InvalidDependencyException {
* Represents a dependency with the specified group ID, artifact ID, version, and repository URL.
*/
@NotNull
public record Dependency(String groupId, String artifactId, String version, String repoUrl) {
public static class Dependency {

public final String groupId;
public final String artifactId;
public final String version;
public final String repoUrl;

/**
* Constructs a new Dependency with the given group ID, artifact ID, version, and repository URL.
Expand Down Expand Up @@ -382,7 +387,8 @@ public Dependency(String groupId, String artifactId, String version, String repo
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Dependency that)) return false;
if (!(o instanceof Dependency)) return false;
Dependency that = (Dependency) o;
return groupId.equals(that.groupId) && artifactId.equals(that.artifactId) && version.equals(that.version) && repoUrl.equals(that.repoUrl);
}

Expand All @@ -394,10 +400,10 @@ public boolean equals(Object o) {
@Override
public @NotNull String toString() {
return "LibraryLoader.Dependency(" +
"groupId=" + this.groupId() + ", " +
"artifactId=" + this.artifactId() + ", " +
"version=" + this.version() + ", " +
"repoUrl=" + this.repoUrl() + ")";
"groupId=" + this.groupId + ", " +
"artifactId=" + this.artifactId + ", " +
"version=" + this.version + ", " +
"repoUrl=" + this.repoUrl + ")";
}

/**
Expand Down

0 comments on commit 68ee816

Please sign in to comment.