Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

153 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DUB Client

Java CI Maven Central Javadocs Coverage Status

SonarCloud

Stand-alone library to provide convenient access to the REST API of a dub repository. Deserializes the json from the API for convenient use within a JVM language such as Java or Kotlin.

https://code.dlang.org/api/packages/search?q=

https://code.dlang.org/api/packages/{package}/info

https://code.dlang.org/api/packages/{package}/{version}/info

https://code.dlang.org/api/packages/{package}/stats

https://code.dlang.org/api/packages/{package}/{version}/stats

https://code.dlang.org/api/packages/{package}/latest

Adding the dependency to your project

<dependency>
    <groupId>com.singingbush</groupId>
    <artifactId>dub-client</artifactId>
    <version>0.3.0</version>
</dependency>

Example usage

DubClient client = DubClient.builder()
            //.withScheme("https") optionally override to http is needed 
            //.withHostname("code.dlang.org") optionally override if you host your own dub repo
            //.withPort(443) optionally override if needed
            .build();

final PackageInfo info = client.packageInfo("vibe-d"); // for info about a dub package

final Stream<SearchResult> results = client.search("unit"); // search dub repo

// There are also functions for dealing with local dub files (dub.json or dub.sdl), such as:

final DubProject project = client.parseProjectFile(Paths.get("dub.json").toFile());

The API for the dub registry can be found here:

interface IPackages {
@safe:

    @method(HTTPMethod.GET)
    SearchResult[] search(string q = "");

    @path(":name/latest")
    string getLatestVersion(string _name);

    @path(":name/stats")
    DbPackageStats getStats(string _name);

    @path(":name/:version/stats")
    DownloadStats getStats(string _name, string _version);

    @path(":name/info")
    Json getInfo(string _name, bool minimize = false);

    @path(":name/:version/info")
    Json getInfo(string _name, string _version, bool minimize = false);

    Json[string] getInfos(string[] packages, bool include_dependencies = false, bool minimize = false);
}

This package requires Gson v2.13, and uses slf4j-api for logging. It's intended for use in the Intellij-DUB plugin but may also be helpful to other projects.

About

Conveniently call the REST API on code.dlang.org and other DUB repositories

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages