From f9f4dd72b5cd6d545fb75c36d7c3113df7a74c55 Mon Sep 17 00:00:00 2001 From: Ali Date: Mon, 16 Dec 2024 21:00:01 +0300 Subject: [PATCH] use maven central by default, bump version --- README.md | 6 +++--- .../java/revxrsal/zapper/DependencyManager.java | 8 ++++---- .../revxrsal/zapper/repository/MavenRepository.java | 13 +++++++++++++ build.gradle.kts | 2 +- .../java/revxrsal/zapper/gradle/ZapperPlugin.kt | 2 +- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e309d4d..056b590 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ build.gradle: ```groovy plugins { id 'com.github.johnrengelman.shadow' version '8.1.1' - id 'io.github.revxrsal.zapper' version '0.0.1' + id 'io.github.revxrsal.zapper' version '1.0.0' } ``` @@ -42,7 +42,7 @@ build.gradle.kts: ```groovy plugins { id("com.github.johnrengelman.shadow") version "8.1.1" - id("io.github.revxrsal.zapper") version "0.0.1" + id("io.github.revxrsal.zapper") version "1.0.0" } ``` @@ -118,7 +118,7 @@ To add the Zapper API: io.github.revxrsal zapper.api - 0.0.1 + 1.0.0 compile ``` diff --git a/api/src/main/java/revxrsal/zapper/DependencyManager.java b/api/src/main/java/revxrsal/zapper/DependencyManager.java index 5aa7ca4..7185e23 100644 --- a/api/src/main/java/revxrsal/zapper/DependencyManager.java +++ b/api/src/main/java/revxrsal/zapper/DependencyManager.java @@ -33,7 +33,9 @@ import java.io.File; import java.net.UnknownHostException; import java.util.ArrayList; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; import java.util.regex.Pattern; public final class DependencyManager implements DependencyScope { @@ -45,19 +47,17 @@ public final class DependencyManager implements DependencyScope { private final URLClassLoaderWrapper loaderWrapper; private final List dependencies = new ArrayList<>(); - private final List repositories = new ArrayList<>(); + private final Set repositories = new LinkedHashSet<>(); private final List relocations = new ArrayList<>(); public DependencyManager(@NotNull File directory, @NotNull URLClassLoaderWrapper loaderWrapper) { this.directory = directory; this.loaderWrapper = loaderWrapper; + this.repositories.add(Repository.mavenCentral()); } public void load() { try { - if (repositories.isEmpty()) { - throw new IllegalArgumentException("No repositories were specified."); - } for (Dependency dep : dependencies) { File file = new File(directory, String.format("%s.%s-%s.jar", dep.getGroupId(), dep.getArtifactId(), dep.getVersion())); File relocated = new File(directory, String.format("%s.%s-%s-relocated.jar", dep.getGroupId(), diff --git a/api/src/main/java/revxrsal/zapper/repository/MavenRepository.java b/api/src/main/java/revxrsal/zapper/repository/MavenRepository.java index ef11831..aac7df4 100644 --- a/api/src/main/java/revxrsal/zapper/repository/MavenRepository.java +++ b/api/src/main/java/revxrsal/zapper/repository/MavenRepository.java @@ -27,6 +27,7 @@ import revxrsal.zapper.Dependency; import java.net.URL; +import java.util.Objects; /** * Represents a Maven repository with a URL @@ -78,4 +79,16 @@ public String toString() { public @NotNull URL resolve(@NotNull Dependency dependency) throws Exception { return new URL(repoURL + dependency.getMavenPath()); } + + @Override + public boolean equals(Object o) { + if (o == null || getClass() != o.getClass()) return false; + MavenRepository that = (MavenRepository) o; + return Objects.equals(repoURL, that.repoURL); + } + + @Override + public int hashCode() { + return Objects.hashCode(repoURL); + } } diff --git a/build.gradle.kts b/build.gradle.kts index 1e0bf47..895728a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,7 @@ plugins { } group = "io.github.revxrsal" -version = "0.0.2" +version = "1.0.0" subprojects { diff --git a/gradle-plugin/src/main/java/revxrsal/zapper/gradle/ZapperPlugin.kt b/gradle-plugin/src/main/java/revxrsal/zapper/gradle/ZapperPlugin.kt index bf5dabf..e358a51 100644 --- a/gradle-plugin/src/main/java/revxrsal/zapper/gradle/ZapperPlugin.kt +++ b/gradle-plugin/src/main/java/revxrsal/zapper/gradle/ZapperPlugin.kt @@ -12,7 +12,7 @@ import java.io.File /** * The plugin version */ -private const val PLUGIN_VERSION: String = "0.0.2" +private const val PLUGIN_VERSION: String = "1.0.0" /** * The Zapper Gradle plugin collects information about the zapped dependencies