This repository has been archived by the owner on Oct 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
173 lines (147 loc) · 12 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
* Copyright 2022 signald contributors
* SPDX-License-Identifier: GPL-3.0-only
* See included LICENSE file
*
*/
import org.gradle.nativeplatform.platform.internal.ArchitectureInternal
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.gradle.nativeplatform.platform.internal.OperatingSystemInternal
plugins {
id 'com.github.gmazzo.buildconfig' version '3.0.3'
id 'org.beryx.runtime' version '1.12.7'
id 'application'
}
compileJava.options.encoding = 'UTF-8'
// crappy rust target detection
static String getTarget() {
String target = System.getenv("SIGNALD_TARGET") // Allow overriding the architecture
if(target != null) {
System.out.println("skipping target detection, using " + target)
return target
}
String first = null
String second = null
String third = null
ArchitectureInternal arch = DefaultNativePlatform.getCurrentArchitecture()
switch(arch.getName()) {
case ["x86_64", "x64", "x86-64"]: // based on https://github.com/wasmerio/wasmer-java/blob/d1fc32347b206f28ddaf48896267a9740770323e/build.gradle#L79-L82
first = "x86_64"
break
case "aarch64":
first = "aarch64"
break
case "arm-v7":
throw new Exception("Unsupported architecture, only 64-bit arm is supported. " +
"For more info: https://gitlab.com/signald/signald/-/issues/349\n" +
"To override, set environment variable SIGNALD_TARGET")
break
}
OperatingSystemInternal os = DefaultNativePlatform.getCurrentOperatingSystem()
if(os.isLinux()) {
second = "unknown-linux"
third = "gnu"
}
if(os.isMacOsX()) {
second = "apple"
third = "darwin"
}
if(first == null || second == null || third == null) {
throw new Exception("Unable to detect architecture." +
"\n * os: " + os.getName() +
"\n * arch: " + arch.getName() +
"\n * linux: " + os.isLinux() ? "yes" : "no" +
"\n * osx:" + os.isMacOsX() ? "yes": "no" +
"\n\n Set environment variable SIGNALD_TARGET to force a target" +
"\n See https://gitlab.com/signald/signald/-/merge_requests/44")
}
target = first + "-" + second + "-" + third
System.out.println("detected build target: " + target + " (arch=" + arch.getName() + " os=" + os.getName() +")")
return target
}
static String getVersion() {
String version = System.getenv("VERSION")
if(version != null) {
System.out.println("signald version set to " + version)
return version
}
System.out.println("signald version not set")
return "unversioned"
}
repositories {
maven {url "https://gitlab.com/api/v4/groups/6853927/-/packages/maven"} // https://gitlab.com/groups/signald/-/packages
mavenCentral()
}
dependencies {
implementation 'org.signald:signal-service-java-' + getTarget() + ':2.15.3_unofficial_65'
implementation 'org.bouncycastle:bcprov-jdk15on:1.70'
implementation 'com.kohlschutter.junixsocket:junixsocket-common:2.6.1'
implementation 'com.kohlschutter.junixsocket:junixsocket-native-common:2.6.1'
implementation 'org.apache.logging.log4j:log4j-api:2.19.0'
implementation 'org.apache.logging.log4j:log4j-core:2.19.0'
implementation 'org.slf4j:slf4j-nop:2.0.5'
implementation 'info.picocli:picocli:4.7.0'
implementation 'org.xerial:sqlite-jdbc:3.40.0.0'
implementation 'org.postgresql:postgresql:42.5.1'
implementation 'org.flywaydb:flyway-core:9.10.2'
implementation 'com.google.protobuf:protobuf-javalite:3.21.11'
implementation 'io.prometheus:simpleclient:0.16.0'
implementation 'io.prometheus:simpleclient_hotspot:0.16.0'
implementation 'io.prometheus:simpleclient_httpserver:0.16.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
implementation 'io.sentry:sentry:6.11.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
}
buildConfig {
packageName("io.finn.signald")
buildConfigField('String', 'NAME', "\"signald\"")
buildConfigField('String', 'VERSION', "\"" + getVersion() + "\"")
buildConfigField('String', "ERROR_REPORTING_URL", "\"https://gitlab.com/signald/signald/-/issues/new\"")
buildConfigField('String', 'BRANCH', "\"" + (System.getenv("CI_BUILD_REF_NAME") ?: "") + "\"")
buildConfigField('String', 'COMMIT', "\"" + (System.getenv("CI_COMMIT_SHA") ?: "") + "\"")
buildConfigField('String', 'USER_AGENT', System.getenv("USER_AGENT") ? "\"" + System.getenv("USER_AGENT") + "\"" : "NAME + \"/\" + VERSION")
buildConfigField('String', 'SIGNAL_AGENT', System.getenv("SIGNAL_AGENT") ? "\"" + System.getenv("SIGNAL_AGENT") + "\"" : "NAME")
// Parameters for the default server to provision new accounts with, if not specified in the protocol.
// the server UUID is internal to signald, must be changed if any other server values are changed.
buildConfigField('String', "DEFAULT_SERVER_UUID", "\"" + (System.getenv("DEFAULT_SERVER_UUID") ?: "6e2eb5a8-5706-45d0-8377-127a816411a4") + "\"")
buildConfigField('String', 'SIGNAL_URL', "\"" + (System.getenv("SIGNAL_URL") ?: "https://chat.signal.org") + "\"")
buildConfigField('String', 'SIGNAL_CDN_URL', "\"" + (System.getenv("SIGNAL_CDN_URL") ?: "https://cdn.signal.org") + "\"")
buildConfigField('String', 'SIGNAL_CDN2_URL', "\"" + (System.getenv("SIGNAL_CDN_URL") ?: "https://cdn2.signal.org") + "\"")
buildConfigField('String', 'SIGNAL_KEY_BACKUP_URL', "\"" + (System.getenv("SIGNAL_KEY_BACKUP_URL") ?: "https://api.backup.signal.org") + "\"")
buildConfigField('String', 'SIGNAL_STORAGE_URL', "\"" + (System.getenv("SIGNAL_STORAGE_URL") ?: "https://storage.signal.org") + "\"")
buildConfigField('String', 'SIGNAL_CONTACT_DISCOVERY_URL', "\"" + (System.getenv("SIGNAL_CONTACT_DISCOVERY_URL") ?: "https://cms.souqcdn.com") + "\"")
buildConfigField('String', "UNIDENTIFIED_SENDER_TRUST_ROOT", "\"" + (System.getenv("SIGNAL_UNIDENTIFIED_SENDER_ROOT") ?: "BXu6QIKVz5MA8gstzfOgRQGqyLqOwNKHL6INkv3IHWMF") + "\"")
buildConfigField('String', "SIGNAL_ZK_GROUP_SERVER_PUBLIC_PARAMS", "\"" + (System.getenv("SIGNAL_ZK_GROUP_SERVER_PUBLIC_PARAMS") ?: "AMhf5ywVwITZMsff/eCyudZx9JDmkkkbV6PInzG4p8x3VqVJSFiMvnvlEKWuRob/1eaIetR31IYeAbm0NdOuHH8Qi+Rexi1wLlpzIo1gstHWBfZzy1+qHRV5A4TqPp15YzBPm0WSggW6PbSn+F4lf57VCnHF7p8SvzAA2ZZJPYJURt8X7bbg+H3i+PEjH9DXItNEqs2sNcug37xZQDLm7X36nOoGPs54XsEGzPdEV+itQNGUFEjY6X9Uv+Acuks7NpyGvCoKxGwgKgE5XyJ+nNKlyHHOLb6N1NuHyBrZrgtY/JYJHRooo5CEqYKBqdFnmbTVGEkCvJKxLnjwKWf+fEPoWeQFj5ObDjcKMZf2Jm2Ae69x+ikU5gBXsRmoF94GXTLfN0/vLt98KDPnxwAQL9j5V1jGOY8jQl6MLxEs56cwXN0dqCnImzVH3TZT1cJ8SW1BRX6qIVxEzjsSGx3yxF3suAilPMqGRp4ffyopjMD1JXiKR2RwLKzizUe5e8XyGOy9fplzhw3jVzTRyUZTRSZKkMLWcQ/gv0E4aONNqs4P") + "\"")
// the base64 encoded trust store
buildConfigField('String', "CA", "\"" + (System.getenv("SIGNAL_CA") ?: "AAAAAQAAABThGWAvYIoB26b2A/AhL6OoW74wfAAAB7cBABF0ZXh0c2VjdXJlLWdjbS1jYQAAAT2jsW+pAAAAAAAFWC41MDkAAAPzMIID7zCCAtegAwIBAgIJAIm6LatK5PNiMA0GCSqGSIb3DQEBBQUAMIGNMQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbz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kJe/oF4usY5J7LPkxK3LWzMJnb5EIJDmRvyH8pyRwWg6Qm6qiGFaI4nL8QU4La1x2en4DGXRaLMPRwjELNgQPodR38zoCMuA8gHZfZYYoZ7D7Q1wNUiVHcxuFrEeBaYJbLErwLVALvy/4I2uFTpAiDQ7Wz7yaNw7tAl") + "\"")
// proxy should be specified in host:port form
buildConfigField('String', "SIGNAL_PROXY", "\"" + (System.getenv("SIGNAL_PROXY") ?: "") + "\"")
buildConfigField('String', "KEY_BACKUP_SERVICE_NAME", "\"" + (System.getenv("KEY_BACKUP_SERVICE_NAME") ?: "fe7c1bfae98f9b073d220366ea31163ee82f6d04bead774f71ca8e5c40847bfe") + "\"")
buildConfigField('String', "KEY_BACKUP_SERVICE_ID", "\"" + (System.getenv("KEY_BACKUP_SERVICE_ID") ?: "/nwb+umPmwc9IgNm6jEWPugvbQS+rXdPccqOXECEe/4=") + "\"")
buildConfigField('String', "KEY_BACKUP_MRENCLAVE", "\"" + (System.getenv("KEY_BACKUP_MRENCLAVE") ?: "o7qrGe9s5vNKueuyW6ciclrkSohy3A/witbYOpSJ3oc=") + "\"")
buildConfigField('String', "CDS_MRENCLAVE", "\"" + (System.getenv("CDS_MRENCLAVE") ?: "yY4ApOP/l3pWr+/nNion5JYeTxniEf6/uxm4l+a4CxU=") + "\"")
buildConfigField('String', "CDS_CA", "\"" + (System.getenv("CDS_CA") ?: "AAAAAgAAABQeE5h3wTEjUgA1bUjXQbnoU41KKQAAB4EBAANpYXMAAAFkret5dgAAAAAABVguNTA5AAAFTzCCBUswggOzoAMCAQICCQDRB3ZdMqOwlDANBgkqhkiG9w0BAQsFADB+MQswCQYDVQQGEwJVUzELMAkGA1UECAwCQ0ExFDASBgNVBAcMC1NhbnRhIENsYXJhMRowGAYDVQQKDBFJbnRlbCBDb3Jwb3JhdGlvbjEwMC4GA1UEAwwnSW50ZWwgU0dYIEF0dGVzdGF0aW9uIFJlcG9ydCBTaWduaW5nIENBMCAXDTE2MTExNDE1MzczMVo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2ECE5FdqCybKeieCQKiWmx1sWCRxoqyBKrnEYiUksfh4yCRFFWo/BNEIxLnemOZTZl5XI6kV2gjzqitHhkc+oYvq4qTLT2bBTWgcC0FVfdOUg4wMw8zSA563J18geIHAxQr8AxSioC0Yzgf1gKoLHA1KBquWVYsy1M06okD5lCwEGgfXOjrYurJxBSYgkOuyS8lvxPN/368wpjuUbulo1OLZrJsvEWlHeADytMGUxrXz11O8PiAXRuRM9JBNas8RkGi+ICDSdczMpXg527kvFInIyYo76gNedkqtOPREg8/ta0RnNjVRKodSmhl5rV76sV3Ewfi48uQcNpHtL/Ihp4BQT6gk1Qd6KeSgRt0Y2xekUUs8M7lny+0BKzQvFhMucg1QEc0wOfsZgXN/PL/Q5ttRxn3AvDgw/oE/bEqbLKtGrHJrx+PTDoI7dcqMrC7XQrSVv/RWaaDsqWh8dEfpiUy8D11TK7w2lc1oeWohMfonZEhjJ1wCFFeX1mSzMRx87G8Gq7CSimX5q0w==") + "\"" )
buildConfigField('int', "SENDER_KEY_MAX_AGE_DAYS", System.getenv("SENDER_KEY_MAX_AGE_DAYS") ?: "14")
}
application {
mainClass = 'io.finn.signald.Main'
}
test {
useJUnitPlatform()
afterTest { desc, result ->
logger.quiet "Test ${desc.name} [${desc.className}]: ${result.resultType}"
}
}
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:cast" << "-Xlint:deprecation" << "-Xlint:divzero" << "-Xlint:empty"
options.compilerArgs << "-Xlint:fallthrough" << "-Xlint:finally" << "-Xlint:overrides" << "-Xlint:path"
options.compilerArgs << "-Xlint:unchecked"
}
}
}
runtime {
options = ['--strip-java-debug-attributes', '--compress', '2', '--no-header-files', '--no-man-pages']
modules = ['java.base', 'java.management', 'java.naming', 'java.sql', 'java.xml', 'jdk.crypto.ec', 'jdk.httpserver', 'java.desktop', 'jdk.unsupported']
}