mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
The tools plugin won't include them in the binary, but it will be easy to look them up if needed.
150 lines
5.0 KiB
Groovy
150 lines
5.0 KiB
Groovy
import java.security.MessageDigest
|
|
apply plugin: 'maven-publish'
|
|
|
|
def outputsFolder = file("$buildDir/outputs")
|
|
|
|
def baseArtifactId = nativeName
|
|
def artifactGroupId = "edu.wpi.first.${nativeName}"
|
|
def zipBaseName = "_GROUP_edu_wpi_first_${nativeName}_ID_${nativeName}-cpp_CLS"
|
|
def jniBaseName = "_GROUP_edu_wpi_first_${nativeName}_ID_${nativeName}-jni_CLS"
|
|
def jniCvStaticBaseName = "_GROUP_edu_wpi_first_${nativeName}_ID_${nativeName}-jnicvstatic_CLS"
|
|
|
|
def licenseFile = file("$rootDir/license.md")
|
|
|
|
task cppSourcesZip(type: Zip) {
|
|
destinationDirectory = outputsFolder
|
|
archiveBaseName = zipBaseName
|
|
classifier = "sources"
|
|
duplicatesStrategy = 'exclude'
|
|
|
|
from(licenseFile) {
|
|
into '/'
|
|
}
|
|
|
|
from('src/main/native/cpp') {
|
|
into '/'
|
|
}
|
|
|
|
model {
|
|
components {
|
|
it.all {
|
|
if (it in getJniSpecClass()) {
|
|
it.jniHeaderLocations.each {
|
|
dependsOn it.key
|
|
from(it.value) {
|
|
into '/jni'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task cppHeadersZip(type: Zip) {
|
|
destinationDirectory = outputsFolder
|
|
archiveBaseName = zipBaseName
|
|
classifier = "headers"
|
|
|
|
from(licenseFile) {
|
|
into '/'
|
|
}
|
|
|
|
from('src/main/native/include') {
|
|
into '/'
|
|
}
|
|
}
|
|
|
|
artifacts {
|
|
archives cppHeadersZip
|
|
archives cppSourcesZip
|
|
}
|
|
|
|
addTaskToCopyAllOutputs(cppSourcesZip)
|
|
addTaskToCopyAllOutputs(cppHeadersZip)
|
|
|
|
model {
|
|
publishing {
|
|
def taskList = createComponentZipTasks($.components, [nativeName, "${nativeName}JNIShared"], zipBaseName, Zip, project, includeStandardZipFormat)
|
|
|
|
def jniTaskList = createComponentZipTasks($.components, ["${nativeName}JNI"], jniBaseName, Jar, project, { task, value ->
|
|
value.each { binary ->
|
|
if (binary.buildable) {
|
|
if (binary instanceof SharedLibraryBinarySpec) {
|
|
task.dependsOn binary.tasks.link
|
|
def hashFile = new File(binary.sharedLibraryFile.parentFile.absolutePath, "${binary.component.baseName}.hash")
|
|
task.outputs.file(hashFile)
|
|
task.inputs.file(binary.sharedLibraryFile)
|
|
task.from(hashFile) {
|
|
into nativeUtils.getPlatformPath(binary)
|
|
}
|
|
task.doFirst {
|
|
hashFile.text = MessageDigest.getInstance("MD5").digest(binary.sharedLibraryFile.bytes).encodeHex().toString()
|
|
}
|
|
task.from(binary.sharedLibraryFile) {
|
|
into nativeUtils.getPlatformPath(binary)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
publications {
|
|
cpp(MavenPublication) {
|
|
taskList.each {
|
|
artifact it
|
|
}
|
|
artifact cppHeadersZip
|
|
artifact cppSourcesZip
|
|
|
|
artifactId = "${baseArtifactId}-cpp"
|
|
groupId artifactGroupId
|
|
version wpilibVersioning.version.get()
|
|
}
|
|
jni(MavenPublication) {
|
|
jniTaskList.each {
|
|
artifact it
|
|
}
|
|
|
|
artifactId = "${baseArtifactId}-jni"
|
|
groupId artifactGroupId
|
|
version wpilibVersioning.version.get()
|
|
}
|
|
}
|
|
|
|
if (project.hasProperty('cvStaticBuild') && project.getProperty('cvStaticBuild') == true) {
|
|
def jniCvTaskList = createComponentZipTasks($.components, ["${nativeName}JNICvStatic"], jniCvStaticBaseName, Zip, project, { task, value ->
|
|
value.each { binary ->
|
|
if (binary.buildable) {
|
|
if (binary instanceof SharedLibraryBinarySpec) {
|
|
task.dependsOn binary.tasks.link
|
|
task.inputs.file(binary.sharedLibraryFile)
|
|
task.from(binary.sharedLibraryFile) {
|
|
into nativeUtils.getPlatformPath(binary) + '/shared'
|
|
}
|
|
def sharedPath = binary.sharedLibraryFile.absolutePath
|
|
sharedPath = sharedPath.substring(0, sharedPath.length() - 4)
|
|
|
|
task.from(new File(sharedPath + '.pdb')) {
|
|
into nativeUtils.getPlatformPath(binary) + '/shared'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
publications {
|
|
jniCvStatic(MavenPublication) {
|
|
jniCvTaskList.each {
|
|
artifact it
|
|
}
|
|
|
|
artifactId = "${baseArtifactId}-jnicvstatic"
|
|
groupId artifactGroupId
|
|
version wpilibVersioning.version.get()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|