|
| 1 | +# Java Dotprompt |
| 2 | + |
| 3 | +This directory contains the Java implementation of the Dotprompt library. |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +Add the following dependency to your project: |
| 8 | + |
| 9 | +**Maven:** |
| 10 | +```xml |
| 11 | +<dependency> |
| 12 | + <groupId>com.google.dotprompt</groupId> |
| 13 | + <artifactId>dotprompt</artifactId> |
| 14 | + <version>0.1.0</version> |
| 15 | +</dependency> |
| 16 | +``` |
| 17 | + |
| 18 | +**Gradle:** |
| 19 | +```groovy |
| 20 | +implementation 'com.google.dotprompt:dotprompt:0.1.0' |
| 21 | +``` |
| 22 | + |
| 23 | +**Bazel:** |
| 24 | +```starlark |
| 25 | +maven_install( |
| 26 | + artifacts = [ |
| 27 | + "com.google.dotprompt:dotprompt:0.1.0", |
| 28 | + ], |
| 29 | + # ... |
| 30 | +) |
| 31 | +``` |
| 32 | + |
| 33 | +## Building |
| 34 | + |
| 35 | +```bash |
| 36 | +bazel build //java/com/google/dotprompt:dotprompt |
| 37 | +``` |
| 38 | + |
| 39 | +## Testing |
| 40 | + |
| 41 | +```bash |
| 42 | +bazel test //java/com/google/dotprompt/... |
| 43 | +``` |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +# Deploying to Maven Central |
| 48 | + |
| 49 | +This section describes the process for releasing the `dotprompt` Java library to Maven Central. |
| 50 | + |
| 51 | +## Prerequisites |
| 52 | + |
| 53 | +1. **GPG Keys**: You need a GPG key pair to sign artifacts. |
| 54 | + * Export the private key: `gpg --armor --export-secret-keys <KEY_ID>` |
| 55 | + * Note the passphrase. |
| 56 | + |
| 57 | +2. **Sonatype OSSRH Account**: You need an account on [s01.oss.sonatype.org](https://s01.oss.sonatype.org/) with access to the `com.google.dotprompt` group ID. |
| 58 | + |
| 59 | +## GitHub Secrets Configuration |
| 60 | + |
| 61 | +Configure these secrets in the repository settings (Settings → Secrets and variables → Actions): |
| 62 | + |
| 63 | +| Secret Name | Description | |
| 64 | +|-------------|-------------| |
| 65 | +| `OSSRH_USERNAME` | Your Sonatype username | |
| 66 | +| `OSSRH_TOKEN` | Your Sonatype password or user token | |
| 67 | +| `MAVEN_GPG_PRIVATE_KEY` | ASCII-armored GPG private key | |
| 68 | +| `MAVEN_GPG_PASSPHRASE` | Passphrase for your GPG key | |
| 69 | + |
| 70 | +## Release Process |
| 71 | + |
| 72 | +### 1. Update the Version |
| 73 | + |
| 74 | +Before creating a release, update the version in `java/com/google/dotprompt/BUILD.bazel`: |
| 75 | + |
| 76 | +```starlark |
| 77 | +java_export( |
| 78 | + name = "dotprompt_pkg", |
| 79 | + maven_coordinates = "com.google.dotprompt:dotprompt:X.Y.Z", # Update this |
| 80 | + # ... |
| 81 | +) |
| 82 | +``` |
| 83 | + |
| 84 | +### 2. Create a GitHub Release |
| 85 | + |
| 86 | +1. Go to the **Releases** section on GitHub. |
| 87 | +2. Click **Draft a new release**. |
| 88 | +3. Create a new tag matching the version (e.g., `java-v0.1.0`). |
| 89 | +4. Add release notes. |
| 90 | +5. **Publish** the release. |
| 91 | + |
| 92 | +### 3. Automated Publishing |
| 93 | + |
| 94 | +The `Publish Java Package` workflow (`.github/workflows/publish_java.yml`) triggers automatically when a release is created: |
| 95 | + |
| 96 | +1. Sets up JDK 21 and Bazel. |
| 97 | +2. Imports the GPG key. |
| 98 | +3. Runs `scripts/publish-java.sh` to publish to Maven Central. |
| 99 | + |
| 100 | +### 4. Verification |
| 101 | + |
| 102 | +* Check the GitHub Actions workflow logs for success. |
| 103 | +* Log in to [Sonatype OSSRH](https://s01.oss.sonatype.org/) to verify the staging repository. |
| 104 | +* After sync (typically 10-30 minutes), verify on [Maven Central](https://search.maven.org/search?q=g:com.google.dotprompt). |
| 105 | + |
| 106 | +## Local Testing (Dry Run) |
| 107 | + |
| 108 | +To verify artifacts build correctly without publishing: |
| 109 | + |
| 110 | +```bash |
| 111 | +bazel build //java/com/google/dotprompt:dotprompt_pkg |
| 112 | +``` |
| 113 | + |
| 114 | +To inspect the generated POM: |
| 115 | + |
| 116 | +```bash |
| 117 | +bazel build //java/com/google/dotprompt:dotprompt_pkg-pom |
| 118 | +cat bazel-bin/java/com/google/dotprompt/dotprompt_pkg-pom.xml |
| 119 | +``` |
0 commit comments