Cloudant-client is written in Java and uses maven as its build tool.
- gradle
- Java 1.6
Follow the instructions for your platform.
The project uses the gradle wrapper to download specified version of gradle. The gradle wrapper is run by using the following command:
$ ./gradlew
Note: on windows the command to run is gradlew.bat rather than gradlew
Adopting the Google Java Style with the following changes:
4.2
Our block indent is +4 characters
4.4
Our line length is 100 characters.
4.5.2
Indent continuation of +4 characters fine, but I think
IDEA defaults to 8, which is okay too.
An IDEA code style matching these guidelines is included in the project,
in the .idea
folder.
If you already have the project, to enable the code style follow these steps:
- Go to Preferences -> Editor -> Code Style.
- In the Scheme dropdown, select Project.
IDEA will then use the style when reformatting, refactoring and so on.
The project should build out of the box with:
$ ./gradlew compileJava
###Running the tests
The tests can be configured before running, by default they use the local CouchDB. To run tests with a remote CouchDB or Cloudant, you need set the details of this CouchDB server, including access credentials:
systemProp.test.couch.username=yourUsername
systemProp.test.couch.password=yourPassword
systemProp.test.couch.host=couchdbHost # default localhost
systemProp.test.couch.port=couchdbPort # default 5984
systemProp.test.couch.http=[http|https] # default http
Alternatively, provide a URL containing all the above information:
systemProp.test.couch.uri=https://example.couch.db
You can leave out the port (it will use the protocol's default) and username and password (if the server does not require one)
Note: using the uri config option will override all the individual options such as "test.couch.username"
Add these properties to a gradle.properties
file, this can be either:
- in the
GRADLE_USER_HOME
folder - in the same folder as
build.gradle
Take care not to commit your credentials. Using the GRADLE_USER_HOME
folder
will make it harder to do this accidentally!
The default tests (that require a running DB) can be run with:
$ ./gradlew check
The tests are categorized based on the resources they need. In addition to the
default check
and test
tasks there are gradle tasks to run tests from these
selected categories:
- Tests that do not need a database
$ ./gradlew noDBTest
- For tests which run against Cloudant Local or the Cloudant Service
$ ./gradlew cloudantTest
- For tests which run only against the Cloudant Service
$ ./gradlew cloudantServiceTest
Note: you will need a Cloudant account to run tests against the Cloudant service.
Additionally the ReplicatorTest cases require the _replicator
DB to exist.