mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-05-01 10:30:35 +00:00
Fix generator for JsonUnwrapped files
This commit is contained in:
parent
b6b8276fd6
commit
5f9fb1da88
@ -72,6 +72,11 @@ val excludePatterns = mapOf(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val schemaAnnotationProcessor by configurations.creating {
|
||||||
|
isCanBeConsumed = false
|
||||||
|
isCanBeResolved = true
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
registerTransform(JarFileExcluder::class) {
|
registerTransform(JarFileExcluder::class) {
|
||||||
from.attribute(minified, false).attribute(artifactType, "jar")
|
from.attribute(minified, false).attribute(artifactType, "jar")
|
||||||
@ -82,8 +87,8 @@ dependencies {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
annotationProcessor(libs.micronaut.json.schema.processor)
|
schemaAnnotationProcessor(libs.micronaut.json.schema.processor)
|
||||||
annotationProcessor(libs.micronaut.inject.java)
|
schemaAnnotationProcessor(libs.micronaut.inject.java)
|
||||||
|
|
||||||
implementation(libs.bouncycastle)
|
implementation(libs.bouncycastle)
|
||||||
implementation(libs.jackson.databind)
|
implementation(libs.jackson.databind)
|
||||||
@ -112,14 +117,6 @@ tasks.withType<AbstractArchiveTask>().configureEach {
|
|||||||
|
|
||||||
tasks.withType<JavaCompile>().configureEach {
|
tasks.withType<JavaCompile>().configureEach {
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
options.compilerArgs.addAll(
|
|
||||||
listOf(
|
|
||||||
"-Amicronaut.processing.group=org.asamk",
|
|
||||||
"-Amicronaut.processing.module=signal-cli",
|
|
||||||
"-Amicronaut.processing.annotations=org.asamk.signal.json.*",
|
|
||||||
"-Amicronaut.jsonschema.baseUri=https://example.com/schemas",
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<Jar> {
|
tasks.withType<Jar> {
|
||||||
@ -152,8 +149,42 @@ tasks.register("fatJar", type = Jar::class) {
|
|||||||
with(tasks.jar.get())
|
with(tasks.jar.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val compileJsonSchemas by tasks.registering(JavaCompile::class) {
|
||||||
|
dependsOn(tasks.compileJava)
|
||||||
|
|
||||||
|
source = sourceSets.main.get().java
|
||||||
|
include("org/asamk/signal/json/**/*.java")
|
||||||
|
|
||||||
|
// Exclude files with @JsonUnwrapped and files that reference them
|
||||||
|
exclude("org/asamk/signal/json/JsonSyncDataMessage.java")
|
||||||
|
exclude("org/asamk/signal/json/JsonSyncStoryMessage.java")
|
||||||
|
exclude("org/asamk/signal/json/JsonSyncMessage.java")
|
||||||
|
|
||||||
|
classpath = sourceSets.main.get().compileClasspath + files(sourceSets.main.get().java.destinationDirectory)
|
||||||
|
destinationDirectory.set(layout.buildDirectory.dir("classes/java/schemas"))
|
||||||
|
|
||||||
|
options.annotationProcessorPath = schemaAnnotationProcessor
|
||||||
|
options.compilerArgs.addAll(
|
||||||
|
listOf(
|
||||||
|
"-Amicronaut.processing.group=org.asamk",
|
||||||
|
"-Amicronaut.processing.module=signal-cli",
|
||||||
|
"-Amicronaut.processing.annotations=org.asamk.signal.json.*",
|
||||||
|
"-Amicronaut.jsonschema.baseUri=https://example.com/schemas",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
// Copy manual schemas for classes with @JsonUnwrapped
|
||||||
|
copy {
|
||||||
|
from("src/main/resources/META-INF/schemas")
|
||||||
|
into(destinationDirectory.get().dir("META-INF/schemas"))
|
||||||
|
include("*.schema.json")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tasks.register("genJsonSchemas") {
|
tasks.register("genJsonSchemas") {
|
||||||
group = "application"
|
group = "application"
|
||||||
description = "Generate JSON schemas using annotation processing"
|
description = "Generate JSON schemas using annotation processing"
|
||||||
dependsOn(tasks.compileJava)
|
dependsOn(compileJsonSchemas)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,56 +0,0 @@
|
|||||||
package org.asamk.signal.json;
|
|
||||||
|
|
||||||
import io.micronaut.jsonschema.JsonSchema;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@JsonSchema(title = "SchemaCatalog")
|
|
||||||
public class JsonSchemaCatalog {
|
|
||||||
|
|
||||||
public JsonAdminDelete adminDelete;
|
|
||||||
public JsonAttachment attachment;
|
|
||||||
public JsonAttachmentData attachmentData;
|
|
||||||
public JsonCallMessage callMessage;
|
|
||||||
public JsonContact contact;
|
|
||||||
public JsonContactAddress contactAddress;
|
|
||||||
public JsonContactAvatar contactAvatar;
|
|
||||||
public JsonContactEmail contactEmail;
|
|
||||||
public JsonContactName contactName;
|
|
||||||
public JsonContactPhone contactPhone;
|
|
||||||
public JsonDataMessage dataMessage;
|
|
||||||
public JsonEditMessage editMessage;
|
|
||||||
public JsonError error;
|
|
||||||
public JsonGroupInfo groupInfo;
|
|
||||||
public JsonMention mention;
|
|
||||||
public JsonMessageEnvelope messageEnvelope;
|
|
||||||
public JsonPayment payment;
|
|
||||||
public JsonPinMessage pinMessage;
|
|
||||||
public JsonPollCreate pollCreate;
|
|
||||||
public JsonPollTerminate pollTerminate;
|
|
||||||
public JsonPollVote pollVote;
|
|
||||||
public JsonPreview preview;
|
|
||||||
public JsonQuote quote;
|
|
||||||
public JsonQuotedAttachment quotedAttachment;
|
|
||||||
public JsonReaction reaction;
|
|
||||||
public JsonReceiptMessage receiptMessage;
|
|
||||||
public JsonRecipientAddress recipientAddress;
|
|
||||||
public JsonRemoteDelete remoteDelete;
|
|
||||||
public JsonSendMessageResult sendMessageResult;
|
|
||||||
public JsonSharedContact sharedContact;
|
|
||||||
public JsonSticker sticker;
|
|
||||||
public JsonStoryContext storyContext;
|
|
||||||
public JsonStoryMessage storyMessage;
|
|
||||||
public JsonSyncDataMessage syncDataMessage;
|
|
||||||
public JsonSyncMessage syncMessage;
|
|
||||||
public JsonSyncReadMessage syncReadMessage;
|
|
||||||
public JsonSyncStoryMessage syncStoryMessage;
|
|
||||||
public JsonTextStyle textStyle;
|
|
||||||
public JsonTypingMessage typingMessage;
|
|
||||||
public JsonUnpinMessage unpinMessage;
|
|
||||||
|
|
||||||
public List<JsonAttachment> attachments;
|
|
||||||
public List<JsonMention> mentions;
|
|
||||||
public List<JsonPreview> previews;
|
|
||||||
public List<JsonSharedContact> contacts;
|
|
||||||
public List<JsonTextStyle> textStyles;
|
|
||||||
}
|
|
||||||
@ -0,0 +1,111 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"$id": "https://example.com/schemas/sync-data-message.schema.json",
|
||||||
|
"title": "SyncDataMessage",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"adminDelete": {
|
||||||
|
"$ref": "https://example.com/schemas/admin-delete.schema.json"
|
||||||
|
},
|
||||||
|
"attachments": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "https://example.com/schemas/attachment.schema.json"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contacts": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "https://example.com/schemas/shared-contact.schema.json"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"destination": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"destinationNumber": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"destinationUuid": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"editMessage": {
|
||||||
|
"$ref": "https://example.com/schemas/edit-message.schema.json"
|
||||||
|
},
|
||||||
|
"expiresInSeconds": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"groupInfo": {
|
||||||
|
"$ref": "https://example.com/schemas/group-info.schema.json"
|
||||||
|
},
|
||||||
|
"isExpirationUpdate": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"mentions": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "https://example.com/schemas/mention.schema.json"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"message": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"payment": {
|
||||||
|
"$ref": "https://example.com/schemas/payment.schema.json"
|
||||||
|
},
|
||||||
|
"pinMessage": {
|
||||||
|
"$ref": "https://example.com/schemas/pin-message.schema.json"
|
||||||
|
},
|
||||||
|
"pollCreate": {
|
||||||
|
"$ref": "https://example.com/schemas/poll-create.schema.json"
|
||||||
|
},
|
||||||
|
"pollTerminate": {
|
||||||
|
"$ref": "https://example.com/schemas/poll-terminate.schema.json"
|
||||||
|
},
|
||||||
|
"pollVote": {
|
||||||
|
"$ref": "https://example.com/schemas/poll-vote.schema.json"
|
||||||
|
},
|
||||||
|
"previews": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "https://example.com/schemas/preview.schema.json"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"quote": {
|
||||||
|
"$ref": "https://example.com/schemas/quote.schema.json"
|
||||||
|
},
|
||||||
|
"reaction": {
|
||||||
|
"$ref": "https://example.com/schemas/reaction.schema.json"
|
||||||
|
},
|
||||||
|
"remoteDelete": {
|
||||||
|
"$ref": "https://example.com/schemas/remote-delete.schema.json"
|
||||||
|
},
|
||||||
|
"sticker": {
|
||||||
|
"$ref": "https://example.com/schemas/sticker.schema.json"
|
||||||
|
},
|
||||||
|
"storyContext": {
|
||||||
|
"$ref": "https://example.com/schemas/story-context.schema.json"
|
||||||
|
},
|
||||||
|
"textStyles": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "https://example.com/schemas/text-style.schema.json"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"timestamp": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"unpinMessage": {
|
||||||
|
"$ref": "https://example.com/schemas/unpin-message.schema.json"
|
||||||
|
},
|
||||||
|
"viewOnce": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"destinationNumber",
|
||||||
|
"destinationUuid",
|
||||||
|
"message",
|
||||||
|
"expiresInSeconds",
|
||||||
|
"timestamp"
|
||||||
|
]
|
||||||
|
}
|
||||||
40
src/main/resources/META-INF/schemas/sync-message.schema.json
Normal file
40
src/main/resources/META-INF/schemas/sync-message.schema.json
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"$id": "https://example.com/schemas/sync-message.schema.json",
|
||||||
|
"title": "SyncMessage",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"blockedGroupIds": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"blockedNumbers": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"readMessages": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "https://example.com/schemas/sync-read-message.schema.json"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sentMessage": {
|
||||||
|
"$ref": "https://example.com/schemas/sync-data-message.schema.json"
|
||||||
|
},
|
||||||
|
"sentStoryMessage": {
|
||||||
|
"$ref": "https://example.com/schemas/sync-story-message.schema.json"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"CONTACTS_SYNC",
|
||||||
|
"GROUPS_SYNC",
|
||||||
|
"REQUEST_SYNC"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"$id": "https://example.com/schemas/sync-story-message.schema.json",
|
||||||
|
"title": "SyncStoryMessage",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"allowsReplies": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"destinationNumber": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"destinationUuid": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"fileAttachment": {
|
||||||
|
"$ref": "https://example.com/schemas/attachment.schema.json"
|
||||||
|
},
|
||||||
|
"groupId": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"textAttachment": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"backgroundColor": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"backgroundGradient": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"preview": {
|
||||||
|
"$ref": "https://example.com/schemas/preview.schema.json"
|
||||||
|
},
|
||||||
|
"style": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"text": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"textBackgroundColor": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"textForegroundColor": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"text"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"destinationNumber",
|
||||||
|
"destinationUuid",
|
||||||
|
"allowsReplies"
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user