A Java library that makes it easy to call the Pelias Search and Autocomplete APIs
You'll need JDK 7 or higher.
See the pelias-client-library-demo project for an example of how to use this library.
To add this library to your project using Maven, add the following to your pom.xml
file:
<dependencies>
<!-- Pelias Client Library -->
<dependency>
<groupId>edu.usf.cutr</groupId>
<artifactId>pelias-client-library</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
If you're using Gradle and Android Studio, here's what your build.gradle
should look like:
...
repositories {
maven { url 'https://jitpack.io' }
}
android {
...
// http://stackoverflow.com/questions/20673625/gradle-0-7-0-duplicate-files-during-packaging-of-apk
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
exclude 'META-INF/services/com.fasterxml.jackson.core.ObjectCodec'
}
...
dependencies {
...
// Pelias Client library
implementation 'com.github.OneBusAway:pelias-client-library:v1.1.0'
}
The below example shows how to call the Pelias Search API.
String apiKey = "YourKeyHere";
String text = "London";
PeliasResponse response = new SearchRequest.Builder(apiKey, text).build().call();
System.out.println(response.toString());
PeliasResponse response = new AutocompleteRequest.Builder(apiKey, text).build().call();
System.out.println(response.toString());
This project was created in IntelliJ. You can also compile it from the command line using Maven.
To get started with this project, use a Git client to clone this repository to your local computer. Then, in IntelliJ import the project as a Maven project.
Managed via Maven:
- Jackson JSON and XML Processor project - For parsing JSON.
- GeoJson POJOs for Jackson - Plain-Old-Java-Objects (POJOs) used for Jackson data binding of GeoJSON elements to Java objects.
- IntelliJ - Clean and build the project
- Maven -
mvn install
Snapshots
We've set up a Maven repository to hold the snapshot artifacts from this project in a Github project - cutr-mvn-repo.
At CUTR, we should run the following at the command-line to create a new artifact:
mvn -DaltDeploymentRepository=cutr-snapshots::default::file:"/Git Projects/cutr-mvn-repo/snapshots" clean deploy
Then commit using Git and push new artifacts to Github.
If you want to include snapshot releases in your project, you'll need to add the following to the pom.xml
of the project you want to use it in:
<!-- CUTR SNAPSHOTs/RELEASES -->
<repositories>
<repository>
<id>cutr-snapshots</id>
<url>https://raw.githubusercontent.com/CUTR-at-USF/cutr-mvn-repo/master/snapshots</url>
</repository>
</repositories>
Releases
We're hosting releases on JCenter via Bintray.
These are the steps for publishing the pelias-client-library
on jcenter
repository.
1 - Create an account on Bintray.
We need to specify the URL from which to distribute your project.
<distributionManagement>
<repository>
<id>jCenter</id>
<url>https://api.bintray.com/maven/cutr-at-usf/cutr-mvn-repo/pelias-client-library/;publish=1</url>
</repository>
</distributionManagement>
We need to provide Bintray username and API Key to the Maven settings.xml
file. This may be under your Maven installation directory (e.g., C:\Program Files\Apache Software Foundation\apache-maven-3.2.5\conf
).
<server>
<id>jCenter</id>
<username>yourjcenteraccount</username>
<password>***youraccount-secret-api-key***</password>
</server>
You'll need to import the CUTR secret key if it's a new machine (first time only):
gpg --import C:\xxxxx\CUTR\Maven\private.key
To sign the application (required for distribution to Maven Central), you need to add the following block as well (after importing the CUTR key):
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.passphrase>the_pass_phrase</gpg.passphrase>
</properties>
</profile>
Finally, we can run mvn deploy
to complete publishing.