Skip to content

Commit

Permalink
🚀 Add the possibility to load multiple dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Cleymax committed Apr 12, 2020
1 parent 17f88c3 commit 753e1e8
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/main/java/fr/cleymax/clibrary/CLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,31 @@ public void load(@NotNull Object object)
*/
public void load(Class<?> classz)
{
Dependency[] libraries = classz.getDeclaredAnnotationsByType(Dependency.class);
Dependencies[] dependencies = classz.getDeclaredAnnotationsByType(Dependencies.class);
Dependency[] libraries = classz.getDeclaredAnnotationsByType(Dependency.class);

if (libraries == null)
if (libraries == null && dependencies == null)
return;

Repository repository = classz.getAnnotation(Repository.class);

if (repository != null)
Arrays.stream(libraries).forEach(library -> load(library, repository.url()));
else
Arrays.stream(libraries).forEach(library -> load(library, MAVEN_CENTRAL_URL));
if (dependencies != null)
{
Arrays.stream(dependencies).forEach(dep -> {
if (repository != null)
Arrays.stream(dep.value()).forEach(library -> load(library, repository.url()));
else
Arrays.stream(dep.value()).forEach(library -> load(library, MAVEN_CENTRAL_URL));
});
}

if (libraries != null)
{
if (repository != null)
Arrays.stream(libraries).forEach(library -> load(library, repository.url()));
else
Arrays.stream(libraries).forEach(library -> load(library, MAVEN_CENTRAL_URL));
}
}

/**
Expand Down

0 comments on commit 753e1e8

Please sign in to comment.