Skip to content

Commit 01c3e04

Browse files
Run protobuf compiler (#32)
1 parent b029430 commit 01c3e04

File tree

6 files changed

+83
-5
lines changed

6 files changed

+83
-5
lines changed

gradle/libs.versions.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[versions]
22
agp = "8.13.1"
33
kotlin = "2.2.21"
4+
protobufVersion = "4.33.1"
45

56
[libraries]
67
junit = { module = "junit:junit", version = "4.13.2" }
@@ -9,8 +10,11 @@ androidx-test-rules = { module = "androidx.test:rules", version = "1.7.0" }
910
androidx-test-ext = { module = "androidx.test.ext:junit", version = "1.3.0" }
1011
androidx-annotations = { module = "androidx.annotation:annotation", version = "1.9.1" }
1112
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version = "1.9.0" }
13+
protoc = { module = "com.google.protobuf:protoc", version.ref = "protobufVersion" }
14+
protobuf-java = { module = "com.google.protobuf:protobuf-java", version.ref = "protobufVersion" }
1215

1316
[plugins]
1417
android-library = { id = "com.android.library", version.ref = "agp" }
1518
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
1619
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
20+
protobuf-compiler = { id = "com.google.protobuf", version = "0.9.5" }

library/build.gradle.kts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import com.google.protobuf.gradle.id
12
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
23

34
plugins {
45
alias(libs.plugins.android.library)
56
alias(libs.plugins.kotlin.android)
67
alias(libs.plugins.kotlinx.serialization)
78
id("maven-publish")
9+
10+
alias(libs.plugins.protobuf.compiler)
811
}
912

1013
group = "org.sessionfoundation"
@@ -20,10 +23,10 @@ android {
2023
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2124

2225
externalNativeBuild {
23-
cmake {
24-
arguments += listOf("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON")
25-
targets("session_util")
26-
}
26+
cmake {
27+
arguments += listOf("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON")
28+
targets("session_util")
29+
}
2730
}
2831
}
2932

@@ -76,6 +79,22 @@ kotlin {
7679
}
7780
}
7881

82+
protobuf {
83+
protoc {
84+
artifact = libs.protoc.get().toString()
85+
}
86+
87+
plugins {
88+
generateProtoTasks {
89+
all().forEach { task ->
90+
task.builtins {
91+
create("java") {}
92+
}
93+
}
94+
}
95+
}
96+
}
97+
7998
publishing {
8099
publications {
81100
create<MavenPublication>("release") {
@@ -121,4 +140,8 @@ dependencies {
121140

122141
implementation(libs.androidx.annotations)
123142
implementation(libs.kotlinx.serialization.core)
143+
144+
api(libs.protobuf.java)
145+
146+
protobuf(files("../libsession-util/proto/SessionProtos.proto"))
124147
}

library/src/main/proto/Utils.proto

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
syntax = "proto2";
2+
3+
package signalservice;
4+
5+
option java_package = "org.session.libsignal.protos";
6+
option java_outer_classname = "UtilProtos";
7+
8+
message ByteArrayList {
9+
repeated bytes content = 1;
10+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Copyright (C) 2014-2016 Open Whisper Systems
3+
*
4+
* Licensed according to the LICENSE file in this repository.
5+
*/
6+
7+
syntax = "proto2";
8+
9+
package signalservice;
10+
11+
option java_package = "org.session.libsignal.protos";
12+
option java_outer_classname = "WebSocketProtos";
13+
14+
message WebSocketRequestMessage {
15+
optional string verb = 1;
16+
optional string path = 2;
17+
optional bytes body = 3;
18+
repeated string headers = 5;
19+
optional uint64 id = 4;
20+
}
21+
22+
message WebSocketResponseMessage {
23+
optional uint64 id = 1;
24+
optional uint32 status = 2;
25+
optional string message = 3;
26+
repeated string headers = 5;
27+
optional bytes body = 4;
28+
}
29+
30+
message WebSocketMessage {
31+
enum Type {
32+
UNKNOWN = 0;
33+
REQUEST = 1;
34+
RESPONSE = 2;
35+
}
36+
37+
optional Type type = 1;
38+
optional WebSocketRequestMessage request = 2;
39+
optional WebSocketResponseMessage response = 3;
40+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The proto files under this folder are deprecated and will be removed in future releases.

0 commit comments

Comments
 (0)