https://github.com/singingbush/dubclient
Conveniently call the REST API on code.dlang.org and other DUB repositories
https://github.com/singingbush/dubclient
dub java
Last synced: 6 months ago
JSON representation
Conveniently call the REST API on code.dlang.org and other DUB repositories
- Host: GitHub
- URL: https://github.com/singingbush/dubclient
- Owner: SingingBush
- License: lgpl-2.1
- Created: 2018-06-17T10:45:44.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2025-02-26T08:31:23.000Z (over 1 year ago)
- Last Synced: 2025-02-26T09:30:36.728Z (over 1 year ago)
- Topics: dub, java
- Language: Java
- Size: 130 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
DUB Client
==========
[](https://github.com/SingingBush/dubclient/actions/workflows/maven.yml)
[](https://maven-badges.herokuapp.com/maven-central/com.singingbush/dub-client)
[](https://www.javadoc.io/doc/com.singingbush/dub-client)
[](https://coveralls.io/github/SingingBush/dubclient?branch=main)
[](https://sonarcloud.io/summary/new_code?id=dubclient)
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
```xml
com.singingbush
dub-client
0.3.0
```
## Example usage
```Java
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 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](https://github.com/dlang/dub-registry/blob/master/source/dubregistry/api.d):
```D
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](https://github.com/intellij-dlanguage/intellij-dub) plugin but may also be helpful to other projects.