Files
allwpilib/tools/outlineviewer/publish.gradle

125 lines
6.0 KiB
Groovy
Raw Normal View History

2021-03-16 22:05:41 -07:00
apply plugin: 'maven-publish'
def baseArtifactId = 'OutlineViewer'
2025-11-07 20:00:38 -05:00
def artifactGroupId = 'org.wpilib.tools'
def zipBaseName = makeZipBaseName(artifactGroupId, baseArtifactId)
2021-03-16 22:05:41 -07:00
def outputsFolder = file("$project.buildDir/outputs")
model {
tasks {
// Create the run task.
$.components.outlineviewer.binaries.each { bin ->
if (bin.buildable && bin.name.toLowerCase().contains("debug") && nativeUtils.isNativeDesktopPlatform(bin.targetPlatform)) {
Task run = project.tasks.create("run", Exec) {
commandLine bin.tasks.install.runScriptFile.get().asFile.toString()
}
run.dependsOn bin.tasks.install
}
}
}
2021-03-16 22:05:41 -07:00
publishing {
def outlineViewerTaskList = []
$.components.each { component ->
component.binaries.each { binary ->
if (binary in NativeExecutableBinarySpec && binary.component.name.contains("outlineviewer")) {
if (binary.buildable && (binary.name.contains('Release') || binary.name.contains('release'))) {
2021-03-16 22:05:41 -07:00
// We are now in the binary that we want.
// This is the default application path for the ZIP task.
def applicationPath = binary.executable.file
def icon = file("$project.projectDir/src/main/native/mac/ov.icns")
// Create the ZIP.
def task = project.tasks.create("copyOutlineViewerExecutable" + binary.targetPlatform.operatingSystem.name + binary.targetPlatform.architecture.name, Zip) {
description = "Copies the OutlineViewer executable to the outputs directory."
2021-03-16 22:05:41 -07:00
destinationDirectory = outputsFolder
archiveBaseName = zipBaseName
2021-03-16 22:05:41 -07:00
duplicatesStrategy = 'exclude'
2023-05-12 21:27:31 -07:00
archiveClassifier = nativeUtils.getPublishClassifier(binary)
2021-03-16 22:05:41 -07:00
from(licenseFile) {
into '/'
}
if (binary.targetPlatform.operatingSystem.isWindows()) {
def exePath = binary.executable.file.absolutePath
exePath = exePath.substring(0, exePath.length() - 4)
def pdbPath = new File(exePath + '.pdb')
from(pdbPath)
}
2021-03-16 22:05:41 -07:00
into(nativeUtils.getPlatformPath(binary))
}
if (binary.targetPlatform.operatingSystem.isMacOsX()) {
// Create the macOS bundle.
def bundleTask = project.tasks.create("bundleOutlineViewerOsxApp" + binary.targetPlatform.architecture.name, Copy) {
description = "Creates a macOS application bundle for OutlineViewer"
from(file("$project.projectDir/Info.plist"))
into(file("$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name/OutlineViewer.app/Contents"))
into("MacOS") {
with copySpec {
from binary.executable.file
}
}
into("Resources") {
with copySpec {
from icon
}
}
inputs.property "HasDeveloperId", project.hasProperty("developerID")
doLast {
if (project.hasProperty("developerID")) {
// Get path to binary.
providers.exec {
setWorkingDir(rootDir)
def args = [
"sh",
"-c",
"codesign --force --strict --deep " +
"--timestamp --options=runtime " +
"--verbose -s ${project.findProperty("developerID")} " +
"$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name/OutlineViewer.app/"
]
commandLine(args)
}.result.get()
}
}
}
// Reset the application path if we are creating a bundle.
applicationPath = file("$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name")
task.from(applicationPath)
project.build.dependsOn bundleTask
2021-03-16 22:05:41 -07:00
bundleTask.dependsOn binary.tasks.link
task.dependsOn(bundleTask)
} else {
task.from(applicationPath)
2021-03-16 22:05:41 -07:00
}
task.dependsOn binary.tasks.link
outlineViewerTaskList.add(task)
project.build.dependsOn task
project.artifacts { task }
addTaskToCopyAllOutputs(task)
}
}
}
}
publications {
outlineViewer(MavenPublication) {
outlineViewerTaskList.each { artifact it }
artifactId = baseArtifactId
groupId = artifactGroupId
version = wpilibVersioning.version.get()
2021-03-16 22:05:41 -07:00
}
}
}
}