Skip to content

update maven deployment #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 57 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repositories {
Next, add the dependency to your project's `build.gradle(.kts)` file:

```groovy
implementation("io.appwrite:sdk-for-kotlin:9.1.0")
implementation("io.appwrite:sdk-for-kotlin:9.1.2")
```

### Maven
Expand All @@ -50,7 +50,7 @@ Add this to your project's `pom.xml` file:
<dependency>
<groupId>io.appwrite</groupId>
<artifactId>sdk-for-kotlin</artifactId>
<version>9.1.0</version>
<version>9.1.2</version>
</dependency>
</dependencies>
```
Expand Down Expand Up @@ -119,6 +119,7 @@ suspend fun main() {

The Appwrite Kotlin SDK provides type safety when working with database documents through generic methods. Methods like `listDocuments`, `getDocument`, and others accept a `nestedType` parameter that allows you to specify your custom model type for full type safety.

**Kotlin:**
```kotlin
data class Book(
val name: String,
Expand Down Expand Up @@ -146,6 +147,60 @@ try {
}
```

**Java:**
```java
public class Book {
private String name;
private String author;
private String releaseYear;
private String category;
private List<String> genre;
private boolean isCheckedOut;

// Constructor
public Book(String name, String author, boolean isCheckedOut) {
this.name = name;
this.author = author;
this.isCheckedOut = isCheckedOut;
}

// Getters and setters
public String getName() { return name; }
public void setName(String name) { this.name = name; }

public String getAuthor() { return author; }
public void setAuthor(String author) { this.author = author; }

public String getReleaseYear() { return releaseYear; }
public void setReleaseYear(String releaseYear) { this.releaseYear = releaseYear; }

public String getCategory() { return category; }
public void setCategory(String category) { this.category = category; }

public List<String> getGenre() { return genre; }
public void setGenre(List<String> genre) { this.genre = genre; }

public boolean isCheckedOut() { return isCheckedOut; }
public void setCheckedOut(boolean checkedOut) { isCheckedOut = checkedOut; }
}

Databases databases = new Databases(client);

try {
DocumentList<Book> documents = databases.listDocuments(
"your-database-id",
"your-collection-id",
Book.class // Pass in your custom model type
);

for (Book book : documents.getDocuments()) {
Log.d("Appwrite", "Book: " + book.getName() + " by " + book.getAuthor()); // Now you have full type safety
}
} catch (AppwriteException e) {
Log.e("Appwrite", e.getMessage() != null ? e.getMessage() : "Unknown error");
}
```

**Tip**: You can use the `appwrite types` command to automatically generate model definitions based on your Appwrite database schema. Learn more about [type generation](https://appwrite.io/docs/products/databases/type-generation).

### Working with Model Methods
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/java/functions/create-execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ functions.createExecution(
"<PATH>", // path (optional)
ExecutionMethod.GET, // method (optional)
mapOf( "a" to "b" ), // headers (optional)
"", // scheduledAt (optional)
"<SCHEDULED_AT>", // scheduledAt (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/kotlin/functions/create-execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ val response = functions.createExecution(
path = "<PATH>", // optional
method = "GET", // optional
headers = mapOf( "a" to "b" ), // optional
scheduledAt = "" // optional
scheduledAt = "<SCHEDULED_AT>" // optional
)
12 changes: 0 additions & 12 deletions scripts/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@ java {
}

publishing {
repositories {
maven {
name = "sonatype"
def releaseUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('-SNAPSHOT') ? snapshotUrl : releaseUrl
credentials {
username = rootProject.ext["ossrhUsername"]
password = rootProject.ext["ossrhPassword"]
}
}
}
publications {
mavenJava(MavenPublication) {
from components.java
Expand Down
6 changes: 3 additions & 3 deletions scripts/setup.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') ?: ext["signing.keyId"]
ext["signing.password"] = System.getenv('SIGNING_PASSWORD') ?: ext["signing.password"]
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE') ?: ext["signing.secretKeyRingFile"]

// Set up Sonatype repository
// Set up Sonatype repository using OSSRH Staging API
nexusPublishing {
repositories {
sonatype {
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
}
}
}
4 changes: 2 additions & 2 deletions src/main/kotlin/io/appwrite/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ class Client @JvmOverloads constructor(
init {
headers = mutableMapOf(
"content-type" to "application/json",
"user-agent" to "AppwriteKotlinSDK/9.1.0 ${System.getProperty("http.agent")}",
"user-agent" to "AppwriteKotlinSDK/9.1.2 ${System.getProperty("http.agent")}",
"x-sdk-name" to "Kotlin",
"x-sdk-platform" to "server",
"x-sdk-language" to "kotlin",
"x-sdk-version" to "9.1.0",
"x-sdk-version" to "9.1.2",
"x-appwrite-response-format" to "1.7.0",
)

Expand Down