-
Notifications
You must be signed in to change notification settings - Fork 2
Basic usage
Certainly, here's the basic usage of the dependency-haven
library in a markdown snippet:
After you've successfully added the dependency-haven
library to your project, you can begin using it to manage dependencies. Here are the basic steps to get started:
-
Import the library:
Import the necessary classes or methods from the
dependency-haven
library in your code.import eup.dependency.haven.callback.DependencyResolutionCallback; import eup.dependency.haven.callback.DownloadCallback; import eup.dependency.haven.model.Coordinates; import eup.dependency.haven.model.Dependency; import eup.dependency.haven.repository.RemoteRepository; import eup.dependency.haven.resolver.DependencyResolver; import java.util.List;
-
Coordinates Parsing:
You can start by parsing a Coordinates (groupID:artifactID:version) to extract information about the project's dependencies. For example:
Coordinates coordinates; DependencyResolver resolver; try { coordinates = Coordinates.valueOf(binding.tilDepName.getEditText().getText().toString()); } catch (Exception e) { // Handle the error }
Note
dependency-haven
supports any of the following declaration formats.- Gradle Groovy implementation
- Gradle Kotlin implementation
- Conical declaration in from of (GroupID:ArtifactID:Version")
-
Dependency Resolution:
Once you've entered the dependency coordinates, to resolve the project's dependencies. Initialize the resolver Here's an example:
resolver = new DependencyResolver(coordinates);
Now we have to add remote repositories you want to search the dependency coordinates in.
resolver.addRepository("jitpack,"https://jitpack.io"); resolver.addRepository("maven-central,"https://repo1.maven.org/maven2");
After add search repositories you should listen for callbacks from the resolver.
-
Listen for callbacks: After you've added search repositories you should listen for callbacks from the resolver.
resolver.resolve(new DependencyResolutionCallback() { @Override public void onDependenciesResolved( String message, List<Dependency> resolvedDependencies, long totalTime) { // Handle this } @Override public void onDependencyNotResolved( String message, List<Dependency> unresolvedDependencies) { // Handle this } @Override public void info(String message) { // Handle this } @Override public void verbose(String message) { // Handle this } @Override public void error(String message) { // Handle this } @Override public void warning(String message) { // Handle this } });
For a basic approach that is pretty much it.