mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
* Removes old build system * Removes old gmock * Adds new gmock * Moves source files to new locations * Adds new build system
269 lines
7.3 KiB
Groovy
269 lines
7.3 KiB
Groovy
apply plugin: 'maven-publish'
|
|
apply plugin: 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin'
|
|
|
|
if (!hasProperty('releaseType')) {
|
|
WPILibVersion {
|
|
releaseType = 'dev'
|
|
}
|
|
}
|
|
|
|
def pubVersion
|
|
if (project.hasProperty("publishVersion")) {
|
|
pubVersion = project.publishVersion
|
|
} else {
|
|
pubVersion = WPILibVersion.version
|
|
}
|
|
|
|
def outputsFolder = file("$buildDir/outputs")
|
|
|
|
def versionFile = file("$outputsFolder/version.txt")
|
|
|
|
task outputVersions() {
|
|
description = 'Prints the versions of cscore to a file for use by the downstream packaging project'
|
|
group = 'Build'
|
|
outputs.files(versionFile)
|
|
|
|
doFirst {
|
|
outputsFolder.mkdir()
|
|
}
|
|
|
|
doLast {
|
|
versionFile.write pubVersion
|
|
}
|
|
}
|
|
|
|
build.dependsOn outputVersions
|
|
|
|
def baseArtifactId = 'cscore'
|
|
def artifactGroupId = 'edu.wpi.first.cscore'
|
|
|
|
def licenseFile = file("$rootDir/license.txt")
|
|
|
|
task cppSourcesZip(type: Zip) {
|
|
destinationDir = outputsFolder
|
|
classifier = "sources"
|
|
|
|
from(licenseFile) {
|
|
into '/'
|
|
}
|
|
|
|
from('src/main/native/cpp') {
|
|
into '/'
|
|
}
|
|
|
|
model {
|
|
tasks {
|
|
it.each {
|
|
if (it in getJNIHeadersClass()) {
|
|
from (it.outputs.files) {
|
|
into '/'
|
|
}
|
|
dependsOn it
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task cppHeadersZip(type: Zip) {
|
|
destinationDir = outputsFolder
|
|
classifier = "headers"
|
|
|
|
from(licenseFile) {
|
|
into '/'
|
|
}
|
|
|
|
from('src/main/native/include') {
|
|
into '/'
|
|
}
|
|
}
|
|
|
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
classifier = 'sources'
|
|
from sourceSets.main.allSource
|
|
}
|
|
|
|
task javadocJar(type: Jar, dependsOn: javadoc) {
|
|
classifier = 'javadoc'
|
|
from javadoc.destinationDir
|
|
}
|
|
|
|
if (project.hasProperty('jenkinsBuild')) {
|
|
jar {
|
|
classifier = 'javaArtifact'
|
|
}
|
|
}
|
|
|
|
artifacts {
|
|
archives sourcesJar
|
|
archives javadocJar
|
|
archives cppHeadersZip
|
|
archives cppSourcesZip
|
|
}
|
|
|
|
def createComponentZipTasks = { components, name, base, type, project, func ->
|
|
def configMap = [:]
|
|
components.each {
|
|
if (it in NativeLibrarySpec && it.name == name) {
|
|
it.binaries.each {
|
|
def target = getClassifier(it)
|
|
if (configMap.containsKey(target)) {
|
|
configMap.get(target).add(it)
|
|
} else {
|
|
configMap.put(target, [])
|
|
configMap.get(target).add(it)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
def taskList = []
|
|
configMap.each { key, value ->
|
|
def baseN = base + name
|
|
def task = project.tasks.create(baseN + "-${key}", type) {
|
|
description = 'Creates component archive for platform ' + key
|
|
destinationDir = outputsFolder
|
|
classifier = key
|
|
baseName = baseN + '-classifier'
|
|
duplicatesStrategy = 'exclude'
|
|
|
|
from(licenseFile) {
|
|
into '/'
|
|
}
|
|
|
|
func(it, value)
|
|
}
|
|
taskList.add(task)
|
|
|
|
project.build.dependsOn task
|
|
|
|
project.artifacts {
|
|
task
|
|
}
|
|
}
|
|
return taskList
|
|
}
|
|
|
|
model {
|
|
publishing {
|
|
def cscoreTaskList = createComponentZipTasks($.components, 'cscore', 'zipcppcscore', Zip, project, { task, value ->
|
|
value.each { binary->
|
|
if (binary.buildable) {
|
|
if (binary instanceof SharedLibraryBinarySpec) {
|
|
task.dependsOn binary.buildTask
|
|
task.from(new File(binary.sharedLibraryFile.absolutePath + ".debug")) {
|
|
into getPlatformPath(binary) + '/shared'
|
|
}
|
|
task.from (binary.sharedLibraryFile) {
|
|
into getPlatformPath(binary) + '/shared'
|
|
}
|
|
task.from (binary.sharedLibraryLinkFile) {
|
|
into getPlatformPath(binary) + '/shared'
|
|
}
|
|
} else if (binary instanceof StaticLibraryBinarySpec) {
|
|
task.dependsOn binary.buildTask
|
|
task.from (binary.staticLibraryFile) {
|
|
into getPlatformPath(binary) + '/static'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
def cscoreJNITaskList = createComponentZipTasks($.components, 'cscoreJNI', 'jnijnicscore', Jar, project, { task, value ->
|
|
value.each { binary->
|
|
if (binary.buildable) {
|
|
if (binary instanceof SharedLibraryBinarySpec) {
|
|
task.dependsOn binary.buildTask
|
|
task.from (binary.sharedLibraryFile) {
|
|
into getPlatformPath(binary)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
def allJniTask
|
|
if (!project.hasProperty('jenkinsBuild')) {
|
|
allJniTask = project.tasks.create("cscoreJNIAllJar", Jar) {
|
|
description = 'Creates a jar with all JNI artifacts'
|
|
classifier = 'all'
|
|
baseName = 'jnijnicscorecscoreJNI'
|
|
destinationDir = outputsFolder
|
|
duplicatesStrategy = 'exclude'
|
|
|
|
cscoreJNITaskList.each {
|
|
it.outputs.files.each {
|
|
from project.zipTree(it)
|
|
}
|
|
dependsOn it
|
|
}
|
|
}
|
|
project.build.dependsOn allJniTask
|
|
}
|
|
|
|
def allCppTask
|
|
if (!project.hasProperty('jenkinsBuild')) {
|
|
allCppTask = project.tasks.create("cscoreAllZip", Zip) {
|
|
description = 'Creates a zip with all Cpp artifacts'
|
|
classifier = 'all'
|
|
baseName = 'zipcppcscorecscore'
|
|
destinationDir = outputsFolder
|
|
duplicatesStrategy = 'exclude'
|
|
|
|
cscoreTaskList.each {
|
|
it.outputs.files.each {
|
|
from project.zipTree(it)
|
|
}
|
|
dependsOn it
|
|
}
|
|
}
|
|
project.build.dependsOn allCppTask
|
|
}
|
|
|
|
publications {
|
|
cpp(MavenPublication) {
|
|
cscoreTaskList.each {
|
|
artifact it
|
|
}
|
|
artifact cppHeadersZip
|
|
artifact cppSourcesZip
|
|
|
|
if (!project.hasProperty('jenkinsBuild')) {
|
|
artifact allCppTask
|
|
}
|
|
|
|
artifactId = "${baseArtifactId}-cpp"
|
|
groupId artifactGroupId
|
|
version pubVersion
|
|
}
|
|
jni(MavenPublication) {
|
|
cscoreJNITaskList.each {
|
|
artifact it
|
|
}
|
|
|
|
if (!project.hasProperty('jenkinsBuild')) {
|
|
artifact allJniTask
|
|
}
|
|
|
|
artifactId = "${baseArtifactId}-jni"
|
|
groupId artifactGroupId
|
|
version pubVersion
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
java(MavenPublication) {
|
|
artifact jar
|
|
artifact sourcesJar
|
|
artifact javadocJar
|
|
|
|
artifactId = "${baseArtifactId}-java"
|
|
groupId artifactGroupId
|
|
version pubVersion
|
|
}
|
|
}
|
|
}
|