|
1 | 1 | # Push API Client
|
2 | 2 |
|
3 |
| -A Coveo Push API Client in Java |
| 3 | +A [Coveo Push API](https://docs.coveo.com/en/12/api-reference/push-api) client library for Java. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +The Coveo `push-api-client.java` package is stored on GitHub packages. |
| 8 | +You will need a personal access token (classic) with at least `read:packages` scope to install this dependency. |
| 9 | + |
| 10 | +For details, see [Authenticating to GitHub Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry#authenticating-to-github-packages) |
4 | 11 |
|
5 | 12 | ## Installation
|
6 | 13 |
|
7 |
| -### Step 1: Prerequisites |
8 |
| -The Coveo `push-api-client.java` package is stored on Github packages. You will need a personal access token (classic) with at least `read:packages` scope to install this dependency. |
| 14 | +### Step 1: Update `settings.xml` |
9 | 15 |
|
10 |
| -More info, visit [Authenticating to GitHub Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry#authenticating-to-github-packages) |
| 16 | +You can install this GitHub Package with [Apache Maven](https://maven.apache.org/) by editing the `~/.m2/settings.xml` file: |
11 | 17 |
|
12 |
| -### Step 2: Update `settings.xml` |
13 |
| -You can install this GitHub Package with Apache Maven by editing your `~/.m2/settings.xml`: |
| 18 | +1. Add a repository definition to the GitHub Package. |
14 | 19 |
|
15 |
| -#### The repository to the package |
16 |
| -Add a definition to the Github Package |
| 20 | + ```xml |
| 21 | + <repository> |
| 22 | + <id>github</id> |
| 23 | + <url>https://maven.pkg.github.com/coveo/push-api-client.java</url> |
| 24 | + <snapshots> |
| 25 | + <enabled>true</enabled> |
| 26 | + </snapshots> |
| 27 | + </repository> |
| 28 | + ``` |
17 | 29 |
|
18 |
| -```xml |
19 |
| -<repository> |
20 |
| - <id>github</id> |
21 |
| - <url>https://maven.pkg.github.com/coveo/push-api-client.java</url> |
22 |
| - <snapshots> |
23 |
| - <enabled>true</enabled> |
24 |
| - </snapshots> |
25 |
| -</repository> |
26 |
| -``` |
| 30 | +1. Add your GitHub personal access token to install packages from GitHub Packages. |
| 31 | + |
| 32 | + ```xml |
| 33 | + <servers> |
| 34 | + <server> |
| 35 | + <id>github</id> |
| 36 | + <username>USERNAME</username> |
| 37 | + <password>TOKEN</password> |
| 38 | + </server> |
| 39 | + </servers> |
| 40 | + ``` |
27 | 41 |
|
28 |
| -#### Your GitHub personal access token |
29 |
| -Your personal access token required to install packages from Github Packages |
| 42 | +### Step 2: Add a Coveo dependency to project |
| 43 | + |
| 44 | +Add a Coveo dependency to your Maven project by editing the `pom.xml` file. |
30 | 45 |
|
31 | 46 | ```xml
|
32 |
| -<servers> |
33 |
| - <server> |
34 |
| - <id>github</id> |
35 |
| - <username>USERNAME</username> |
36 |
| - <password>TOKEN</password> |
37 |
| - </server> |
38 |
| -</servers> |
| 47 | +<dependency> |
| 48 | + <groupId>com.coveo</groupId> |
| 49 | + <artifactId>push-api-client.java</artifactId> |
| 50 | + <version>2.3.0</version> |
| 51 | +</dependency> |
39 | 52 | ```
|
40 | 53 |
|
41 |
| -### Step 3: Add Coveo dependency to project |
42 |
| -Using Maven: |
43 |
| - |
| 54 | +### Step 3: Install the project files |
44 | 55 |
|
45 |
| -Add Coveo dependency to your maven project. Instructions on how to do that available in this [URL](https://github.com/coveo/push-api-client.java/packages/1884180). |
| 56 | +To install the updated project files, build the Maven project. |
46 | 57 |
|
47 |
| -### Step 4: Install |
48 |
| -Run via command line |
49 | 58 | ```bash
|
50 | 59 | mvn install
|
51 | 60 | ```
|
52 | 61 |
|
53 | 62 | ## Usage
|
54 | 63 |
|
55 |
| -See more examples in the `./samples` folder. |
| 64 | +> See more examples in the `./samples` folder. |
56 | 65 |
|
57 | 66 | ```java
|
58 | 67 | import com.coveo.pushapiclient.DocumentBuilder;
|
@@ -82,45 +91,56 @@ public class PushOneDocument {
|
82 | 91 | ```
|
83 | 92 |
|
84 | 93 | ## Logging
|
85 |
| -When pushing multiple documents into your source using a service (e.g. `PushService`, `StreamService`), make sure to configure a **logger** to be able to see what happens. |
86 |
| -to do so .. in your `resources` folder. |
87 | 94 |
|
88 |
| -### Log4j2 XML Configuration Example |
89 |
| -To log execution output into the console, use the below `log4j2.xml` configuration: |
90 |
| -```xml |
91 |
| -<!-- log4j2.xml --> |
92 |
| -<?xml version="1.0" encoding="UTF-8"?> |
93 |
| -<Configuration> |
94 |
| - <Appenders> |
95 |
| - <Console name="ConsoleAppender" target="SYSTEM_OUT"> |
96 |
| - <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" /> |
97 |
| - </Console> |
98 |
| - </Appenders> |
99 |
| - <Loggers> |
100 |
| - <Root level="debug"> |
101 |
| - <AppenderRef ref="ConsoleAppender" /> |
102 |
| - </Root> |
103 |
| - </Loggers> |
104 |
| -</Configuration> |
105 |
| -``` |
| 95 | +If you want to push multiple documents to your Coveo organization and use a service for that (e.g. `PushService`, `StreamService`), you may find it useful to configure a **logger** to catch error and warning messages. |
| 96 | + |
| 97 | +1. Go to your project's root folder. |
106 | 98 |
|
107 |
| -See [Log4j2 configuration](https://logging.apache.org/log4j/2.x/manual/configuration.html) for more details. |
| 99 | +1. Update the Apache Log4j2 configuration by editing the `log4j2.xml` file. |
| 100 | + The following example will print the log execution to the console. |
108 | 101 |
|
109 |
| -## Local Setup to Contribute |
| 102 | + ```xml |
| 103 | + <?xml version="1.0" encoding="UTF-8"?> |
| 104 | + <Configuration> |
| 105 | + <Appenders> |
| 106 | + <Console name="ConsoleAppender" target="SYSTEM_OUT"> |
| 107 | + <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" /> |
| 108 | + </Console> |
| 109 | + </Appenders> |
| 110 | + <Loggers> |
| 111 | + <Root level="debug"> |
| 112 | + <AppenderRef ref="ConsoleAppender" /> |
| 113 | + </Root> |
| 114 | + </Loggers> |
| 115 | + </Configuration> |
| 116 | + ``` |
110 | 117 |
|
111 |
| -### Formatting |
| 118 | + For more details, see [Log4j2 configuration](https://logging.apache.org/log4j/2.x/manual/configuration.html). |
| 119 | + |
| 120 | +## Formatting the code before contributing |
112 | 121 |
|
113 | 122 | This project uses [Google Java Format](https://github.com/google/google-java-format), so make sure your code is properly formatted before opening a pull request.
|
| 123 | + |
| 124 | +To enforce code style and formatting rules, run the Maven Spotless plugin: |
| 125 | + |
114 | 126 | ```bash
|
115 | 127 | mvn spotless:apply
|
116 | 128 | ```
|
117 | 129 |
|
118 | 130 | ## Release
|
119 | 131 |
|
120 |
| -* Tag the commit following semver. |
121 |
| -* Bump version in pom.xml |
122 |
| -* mvn -P release clean deploy |
123 |
| -* cd into ./target |
124 |
| -* jar -cvf bundle.jar push-api-client.java-1.0.0-javadoc.jar push-api-client.java-1.0.0-javadoc.jar.asc push-api-client.java-1.0.0-sources.jar push-api-client.java-1.0.0-sources.jar.asc push-api-client.java-1.0.0.jar push-api-client.java-1.0.0.jar.asc push-api-client.java-1.0.0.pom push-api-client.java-1.0.0.pom.asc |
125 |
| -* Log into https://oss.sonatype.org/ |
126 |
| -* Upload newly created bundle.jar |
| 132 | +1. Tag the commit according to the [semantic versioning](https://semver.org/). |
| 133 | + |
| 134 | +1. Bump version in `pom.xml`. |
| 135 | + |
| 136 | +1. Run the following commands: |
| 137 | + |
| 138 | + 1. `mvn -P release clean deploy`. |
| 139 | + |
| 140 | + 1. `cd ./target`. |
| 141 | + |
| 142 | + 1. `jar -cvf bundle.jar push-api-client.java-1.0.0-javadoc.jar push-api-client.java-1.0.0-javadoc.jar.asc push-api-client.java-1.0.0-sources.jar push-api-client.java-1.0.0-sources.jar.asc push-api-client.java-1.0.0.jar push-api-client.java-1.0.0.jar.asc push-api-client.java-1.0.0.pom push-api-client.java-1.0.0.pom.asc` |
| 143 | + |
| 144 | +1. Log in to https://oss.sonatype.org/. |
| 145 | + |
| 146 | +1. Upload the newly created `bundle.jar` file. |
0 commit comments