-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
170 lines (145 loc) · 5.09 KB
/
build.gradle.kts
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
import com.vanniktech.maven.publish.JavaLibrary
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.SonatypeHost
import java.io.ByteArrayOutputStream
plugins {
java
//`maven-publish`
//signing
id("com.vanniktech.maven.publish") version "0.28.0"
}
val groupVal = "io.github.selemba1000"
val nameVal = "JavaMediaTransportControls"
val versionVal = "0.0.3"
repositories {
mavenCentral()
}
java{
//withJavadocJar()
//withSourcesJar()
}
dependencies {
testImplementation(platform("org.junit:junit-bom:5.10.2"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
implementation("net.java.dev.jna:jna:5.14.0")
implementation("com.github.hypfvieh:dbus-java-core:5.0.0")
implementation("com.github.hypfvieh:dbus-java-transport-native-unixsocket:5.0.0")
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
mavenPublishing{
coordinates(groupVal,nameVal,versionVal)
configure(JavaLibrary(
javadocJar = JavadocJar.Javadoc(),
sourcesJar = true
))
pom {
name.set("JavaMediaTransportControls")
description.set("A simple Java library to interface with system media controls.")
url.set("https://github.com/Selemba1000/JavaMediaTransportControls")
licenses {
license {
name.set("MIT License")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("Selemba1000")
name.set("Sebastian Lempik")
email.set("[email protected]")
url.set("https://github.com/Selemba1000")
}
}
scm {
connection.set("scm:git:git://https://github.com/Selemba1000/JavaMediaTransportControls.git")
developerConnection.set("scm:git:ssh://[email protected]:Selemba1000/JavaMediaTransportControls.git")
url.set("https://github.com/Selemba1000/JavaMediaTransportControls")
}
}
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
}
tasks.javadoc {
if (JavaVersion.current().isJava9Compatible) {
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
}
}
tasks.register<NativeCompile>("build_x86_debug") {
inputs.property("platform" , "Win32")
inputs.property("configuration" , "Debug")
}
tasks.register<NativeCompile>("build_x86_release") {
inputs.property("platform" , "Win32")
inputs.property("configuration" , "Release")
}
tasks.register<NativeCompile>("build_x64_debug") {
inputs.property("platform" , "x64")
inputs.property("configuration" , "Debug")
}
tasks.register<NativeCompile>("build_x64_release") {
inputs.property("platform" , "x64")
inputs.property("configuration" , "Release")
}
tasks.register("build_debug"){
group = "build native"
dependsOn("build_x64_debug","build_x86_debug")
}
tasks.register("build_release"){
group = "build native"
dependsOn("build_x64_release","build_x86_release")
}
tasks.register<Delete>("clean_native"){
group = "build native"
delete(layout.projectDirectory.dir("src/main/sources").files(".build","bin"))
}
tasks.register<Copy>("copy_x86_debug"){
from("src/main/sources/bin/Debug/x86/SMTCAdapter.dll")
into("src/main/resources/win32-x86")
dependsOn("build_debug")
}
tasks.register<Copy>("copy_x86_release"){
from("src/main/sources/bin/Release/x86/SMTCAdapter.dll")
into("src/main/resources/win32-x86")
dependsOn("build_release")
}
tasks.register<Copy>("copy_x64_debug"){
from("src/main/sources/bin/Debug/x64/SMTCAdapter.dll")
into("src/main/resources/win32-x86-64")
dependsOn("build_debug")
}
tasks.register<Copy>("copy_x64_release"){
from("src/main/sources/bin/Release/x64/SMTCAdapter.dll")
into("src/main/resources/win32-x86-64")
dependsOn("build_release")
}
tasks.register("copy_debug"){
group = "build native"
dependsOn("copy_x86_debug","copy_x64_debug")
}
tasks.register("copy_release"){
group = "build native"
dependsOn("copy_x86_release","copy_x64_release")
}
abstract class NativeCompile : DefaultTask() {
@get:InputFiles
val source = arrayOf("src/main/sources/SMTCAdapter.vcxproj","src/main/sources/SMTCAdapter.cpp","src/main/sources/SMTCAdapter.h").map { File(it) }
@get:OutputDirectories
val output = arrayOf(File("src/main/sources/.build"),File("src/main/sources/bin"))
@TaskAction
fun compile() {
val platform = inputs.properties["platform"]
val configuration = inputs.properties["configuration"]
val source = inputs.files
val command = "MSBuild.exe -m /property:Platform=${platform} /property:Configuration=${configuration}"
val stream = ByteArrayOutputStream()
project.exec{
workingDir = source.single { it.extension == "vcxproj" }.parentFile
commandLine(command.split(" "))
standardOutput = stream
}
}
}