Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 1 | apply plugin: 'maven-publish' |
| 2 | |
| 3 | def baseArtifactId = 'OutlineViewer' |
| 4 | def artifactGroupId = 'edu.wpi.first.tools' |
| 5 | def zipBaseName = '_GROUP_edu_wpi_first_tools_ID_OutlineViewer_CLS' |
| 6 | |
| 7 | def outputsFolder = file("$project.buildDir/outputs") |
| 8 | |
| 9 | model { |
| 10 | tasks { |
| 11 | // Create the run task. |
| 12 | $.components.outlineviewer.binaries.each { bin -> |
| 13 | if (bin.buildable && bin.name.toLowerCase().contains("debug")) { |
| 14 | Task run = project.tasks.create("run", Exec) { |
| 15 | commandLine bin.tasks.install.runScriptFile.get().asFile.toString() |
| 16 | } |
| 17 | run.dependsOn bin.tasks.install |
| 18 | } |
| 19 | } |
| 20 | } |
| 21 | publishing { |
| 22 | def outlineViewerTaskList = [] |
| 23 | $.components.each { component -> |
| 24 | component.binaries.each { binary -> |
| 25 | if (binary in NativeExecutableBinarySpec && binary.component.name.contains("outlineviewer")) { |
| 26 | if (binary.buildable && binary.name.contains("Release")) { |
| 27 | // We are now in the binary that we want. |
| 28 | // This is the default application path for the ZIP task. |
| 29 | def applicationPath = binary.executable.file |
| 30 | def icon = file("$project.projectDir/src/main/native/mac/ov.icns") |
| 31 | |
| 32 | // Create the macOS bundle. |
| 33 | def bundleTask = project.tasks.create("bundleOutlineViewerOsxApp", Copy) { |
| 34 | description("Creates a macOS application bundle for OutlineViewer") |
| 35 | from(file("$project.projectDir/Info.plist")) |
| 36 | into(file("$project.buildDir/outputs/bundles/OutlineViewer.app/Contents")) |
| 37 | into("MacOS") { with copySpec { from binary.executable.file } } |
| 38 | into("Resources") { with copySpec { from icon } } |
| 39 | |
| 40 | doLast { |
| 41 | if (project.hasProperty("developerID")) { |
| 42 | // Get path to binary. |
| 43 | exec { |
| 44 | workingDir rootDir |
| 45 | def args = [ |
| 46 | "sh", |
| 47 | "-c", |
| 48 | "codesign --force --strict --deep " + |
| 49 | "--timestamp --options=runtime " + |
| 50 | "--verbose -s ${project.findProperty("developerID")} " + |
| 51 | "$project.buildDir/outputs/bundles/OutlineViewer.app/" |
| 52 | ] |
| 53 | commandLine args |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | // Reset the application path if we are creating a bundle. |
| 60 | if (binary.targetPlatform.operatingSystem.isMacOsX()) { |
| 61 | applicationPath = file("$project.buildDir/outputs/bundles") |
| 62 | project.build.dependsOn bundleTask |
| 63 | } |
| 64 | |
| 65 | // Create the ZIP. |
| 66 | def task = project.tasks.create("copyOutlineViewerExecutable", Zip) { |
| 67 | description("Copies the OutlineViewer executable to the outputs directory.") |
| 68 | destinationDirectory = outputsFolder |
| 69 | |
| 70 | archiveBaseName = '_M_' + zipBaseName |
| 71 | duplicatesStrategy = 'exclude' |
| 72 | classifier = nativeUtils.getPublishClassifier(binary) |
| 73 | |
| 74 | from(licenseFile) { |
| 75 | into '/' |
| 76 | } |
| 77 | |
| 78 | from(applicationPath) |
Austin Schuh | 75263e3 | 2022-02-22 18:05:32 -0800 | [diff] [blame] | 79 | |
| 80 | if (binary.targetPlatform.operatingSystem.isWindows()) { |
| 81 | def exePath = binary.executable.file.absolutePath |
| 82 | exePath = exePath.substring(0, exePath.length() - 4) |
| 83 | def pdbPath = new File(exePath + '.pdb') |
| 84 | from(pdbPath) |
| 85 | } |
| 86 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 87 | into(nativeUtils.getPlatformPath(binary)) |
| 88 | } |
| 89 | |
| 90 | if (binary.targetPlatform.operatingSystem.isMacOsX()) { |
| 91 | bundleTask.dependsOn binary.tasks.link |
| 92 | task.dependsOn(bundleTask) |
| 93 | } |
| 94 | |
| 95 | task.dependsOn binary.tasks.link |
| 96 | outlineViewerTaskList.add(task) |
| 97 | project.build.dependsOn task |
| 98 | project.artifacts { task } |
| 99 | addTaskToCopyAllOutputs(task) |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | publications { |
| 106 | outlineViewer(MavenPublication) { |
| 107 | outlineViewerTaskList.each { artifact it } |
| 108 | |
| 109 | artifactId = baseArtifactId |
| 110 | groupId = artifactGroupId |
| 111 | version wpilibVersioning.version.get() |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | } |