-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpublish.gradle
More file actions
154 lines (126 loc) · 3.59 KB
/
publish.gradle
File metadata and controls
154 lines (126 loc) · 3.59 KB
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
// Define directories and files used for outputs.
def outputs_dir = file("$buildDir/outputs")
def libssh_license_file = file("libssh-mirror/COPYING")
def openssl_license_file = file("openssl/LICENSE.txt")
// Define names for publishing.
def base_artifact_id = "libssh"
def artifact_group_id = "org.wpilib.thirdparty"
// Define names for archives.
def zip_base_name = "_GROUP_org_wpilib_thirdparty_ID_libssh_CLS"
// Generate version number.
def version_file = file("$outputs_dir/version.txt")
task outputVersions() {
outputs.files(version_file)
doFirst {
buildDir.mkdir()
outputs_dir.mkdir()
}
doLast {
version_file.write project.pub_version
}
}
build.dependsOn outputVersions
copyAllOutputs.dependsOn outputVersions
copyAllOutputs.inputs.file version_file
copyAllOutputs.from version_file
// Create archive of headers.
task cppHeadersZip(type: Zip) {
dependsOn "libSSHDebug"
destinationDirectory = outputs_dir
archiveBaseName = zip_base_name
archiveClassifier = "headers"
// Copy license files.
from(libssh_license_file) {
into "/"
rename { _ -> "LIBSSH-LICENSE" }
}
from(openssl_license_file) {
into "/"
rename { _ -> "OPENSSL_LICENSE" }
}
// Copy headers.
from("${project.libssh_dir}/include") {
into "/"
include "**/*.h", "**/*.hpp"
}
from("${project.libssh_build}/debug/include") {
into "/"
include "**/*.h", "**/*.hpp"
}
includeEmptyDirs = false
// Add task to copy all outputs.
project.addTaskToCopyAllOutputs(it)
}
// Create archive of sources.
task cppSourcesZip(type: Zip) {
dependsOn "libSSHDebug"
destinationDirectory = outputs_dir
archiveBaseName = zip_base_name
archiveClassifier = "sources"
// Copy license files.
from(libssh_license_file) {
into "/"
rename { _ -> "LIBSSH-LICENSE" }
}
from(openssl_license_file) {
into "/"
rename { _ -> "OPENSSL_LICENSE" }
}
// Copy headers.
from("${project.libssh_dir}/src") {
into "/"
include "**/*.c"
}
includeEmptyDirs = false
// Add task to copy all outputs.
project.addTaskToCopyAllOutputs(it)
}
// Create archive of libraries.
def types = ["Debug", "Release"]
types.each { type ->
project.tasks.create("cpp${type}LibrariesZip", Zip) {
dependsOn "libSSH$type"
destinationDirectory = outputs_dir
archiveBaseName = zip_base_name
archiveClassifier = project.platform_classifier + "static" + type.toLowerCase().replace("release", "")
// Copy license files.
from(libssh_license_file) {
into "/"
rename { _ -> "LIBSSH-LICENSE" }
}
from(openssl_license_file) {
into "/"
rename { _ -> "OPENSSL_LICENSE" }
}
// Copy libraries.
def lib_dir = file("${project.libssh_build}/${type.toLowerCase()}/lib")
if (project.platform.contains("windows")) {
// On Windows, the staging dir is one layer deeper.
lib_dir = file("$lib_dir/$type")
from("$lib_dir/ssh${project.pub_version}.lib") { into "${project.platform_path}/static" }
from("$lib_dir") {
into "${project.platform_path}/static"
include "*.pdb"
}
} else {
from("$lib_dir/libssh${project.pub_version}.a") { into "${project.platform_path}/static" }
}
// Add task to copy all outputs.
project.addTaskToCopyAllOutputs(it)
}
}
model {
publishing {
publications {
libssh(MavenPublication) {
artifact cppHeadersZip
artifact cppSourcesZip
artifact cppDebugLibrariesZip
artifact cppReleaseLibrariesZip
artifactId = base_artifact_id
groupId = artifact_group_id
version = project.pub_version
}
}
}
}