Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

CUTR-at-USF/pelias-client-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pelias-client-library Build Status Download

A Java library that makes it easy to call the Pelias Search and Autocomplete APIs

Requirements

You'll need JDK 7 or higher.

Including this library in your application

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 {
    jcenter()
}

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
    compile 'edu.usf.cutr:pelias-client-library:1.1.0'
}

Usage

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());

Compiling the code yourself

Setting up your environment

This project was created in IntelliJ. You can also compile it from the command line using Maven.

Getting the code

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.

Dependencies

Managed via Maven:

Build the project

  • IntelliJ - Clean and build the project
  • Maven - mvn install

CUTR Release Process

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.
2 - Setup your pom.xml

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>
3 - Setup your setting.xml

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>
4 - Run maven deploy

Finally, we can run mvn deploy to complete publishing.