Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Basic usage

EUP edited this page Nov 4, 2023 · 2 revisions

Certainly, here's the basic usage of the dependency-haven library in a markdown snippet:

Basic Usage

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:

  1. 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;
  2. 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.

    1. Gradle Groovy implementation
    2. Gradle Kotlin implementation
    3. Conical declaration in from of (GroupID:ArtifactID:Version")
  3. 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.

  4. 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.

Clone this wiki locally