]> nmode's Git Repositories - signal-cli/blob - build.gradle.kts
Convert gradle scripts to kotlin
[signal-cli] / build.gradle.kts
1 plugins {
2 java
3 application
4 eclipse
5 }
6
7 version = "0.7.4"
8
9 java {
10 sourceCompatibility = JavaVersion.VERSION_11
11 targetCompatibility = JavaVersion.VERSION_11
12 }
13
14 application {
15 mainClass.set("org.asamk.signal.Main")
16 }
17
18 repositories {
19 mavenLocal()
20 mavenCentral()
21 }
22
23 dependencies {
24 implementation("com.google.protobuf:protobuf-javalite:3.10.0")
25 implementation("com.github.turasa:signal-service-java:2.15.3_unofficial_18")
26 implementation("org.bouncycastle:bcprov-jdk15on:1.68")
27 implementation("net.sourceforge.argparse4j:argparse4j:0.8.1")
28 implementation("com.github.hypfvieh:dbus-java:3.2.4")
29 implementation("org.slf4j:slf4j-simple:1.7.30")
30 }
31
32 configurations {
33 implementation {
34 resolutionStrategy.failOnVersionConflict()
35 }
36 }
37
38 tasks.withType<JavaCompile> {
39 options.encoding = "UTF-8"
40 }
41
42 tasks.withType<Jar> {
43 manifest {
44 attributes(
45 "Implementation-Title" to project.name,
46 "Implementation-Version" to project.version,
47 "Main-Class" to application.mainClass.get()
48 )
49 }
50 }
51
52 tasks.withType<JavaExec> {
53 val appArgs: String? by project
54 if (appArgs != null) {
55 // allow passing command-line arguments to the main application e.g.:
56 // $ gradle run -PappArgs="['-u', '+...', 'daemon', '--json']"
57 args = groovy.util.Eval.me(appArgs) as MutableList<String>
58 }
59 }
60
61 // Find any 3rd party libraries which have released new versions
62 // to the central Maven repo since we last upgraded.
63 val checkLibVersions by tasks.registering {
64 doLast {
65 val checked = kotlin.collections.HashSet<Dependency>()
66 allprojects {
67 configurations.forEach { configuration ->
68 configuration.allDependencies.forEach { dependency ->
69 val version = dependency.version
70 if (!checked.contains(dependency)) {
71 val group = dependency.group
72 val path = group?.replace(".", "/") ?: ""
73 val name = dependency.name
74 val metaDataUrl = "https://repo1.maven.org/maven2/$path/$name/maven-metadata.xml"
75 try {
76 val url = org.codehaus.groovy.runtime.ResourceGroovyMethods.toURL(metaDataUrl)
77 val metaDataText = org.codehaus.groovy.runtime.ResourceGroovyMethods.getText(url)
78 val metadata = groovy.util.XmlSlurper().parseText(metaDataText)
79 val newest = (metadata.getProperty("versioning") as groovy.util.slurpersupport.GPathResult).getProperty("latest")
80 if (version != newest.toString()) {
81 println("UPGRADE {\"group\": \"$group\", \"name\": \"$name\", \"current\": \"$version\", \"latest\": \"$newest\"}")
82 }
83 } catch (e: Throwable) {
84 logger.debug("Unable to download or parse $metaDataUrl: $e.message")
85 }
86 checked.add(dependency)
87 }
88 }
89 }
90 }
91 }
92 }
93
94 val assembleNativeImage by tasks.registering {
95 dependsOn("assemble")
96
97 var graalVMHome = ""
98 doFirst {
99 graalVMHome = System.getenv("GRAALVM_HOME")
100 ?: throw GradleException("Required GRAALVM_HOME environment variable not set.")
101 }
102
103 doLast {
104 val nativeBinaryOutputPath = "$buildDir/native-image"
105 val nativeBinaryName = "signal-cli"
106
107 mkdir(nativeBinaryOutputPath)
108
109 exec {
110 workingDir = File(".")
111 commandLine("$graalVMHome/bin/native-image",
112 "-H:Path=$nativeBinaryOutputPath",
113 "-H:Name=$nativeBinaryName",
114 "-H:JNIConfigurationFiles=graalvm-config-dir/jni-config.json",
115 "-H:DynamicProxyConfigurationFiles=graalvm-config-dir/proxy-config.json",
116 "-H:ResourceConfigurationFiles=graalvm-config-dir/resource-config.json",
117 "-H:ReflectionConfigurationFiles=graalvm-config-dir/reflect-config.json",
118 "--no-fallback",
119 "--allow-incomplete-classpath",
120 "--report-unsupported-elements-at-runtime",
121 "--enable-url-protocols=http,https",
122 "--enable-https",
123 "--enable-all-security-services",
124 "-cp",
125 sourceSets.main.get().runtimeClasspath.asPath,
126 application.mainClass.get())
127 }
128 }
129 }