blob: 58222bed96468243382012b23bf6e4660f8bc270 [file] [log] [blame]
Austin Schuh812d0d12021-11-04 20:16:48 -07001apply plugin: 'maven-publish'
2
3def baseArtifactId = 'OutlineViewer'
4def artifactGroupId = 'edu.wpi.first.tools'
5def zipBaseName = '_GROUP_edu_wpi_first_tools_ID_OutlineViewer_CLS'
6
7def outputsFolder = file("$project.buildDir/outputs")
8
9model {
10 tasks {
11 // Create the run task.
12 $.components.outlineviewer.binaries.each { bin ->
James Kuszmaulcf324122023-01-14 14:07:17 -080013 if (bin.buildable && bin.name.toLowerCase().contains("debug") && nativeUtils.isNativeDesktopPlatform(bin.targetPlatform)) {
Austin Schuh812d0d12021-11-04 20:16:48 -070014 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")) {
James Kuszmaulcf324122023-01-14 14:07:17 -080026 if (binary.buildable && (binary.name.contains('Release') || binary.name.contains('release'))) {
Austin Schuh812d0d12021-11-04 20:16:48 -070027 // 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.
James Kuszmaulcf324122023-01-14 14:07:17 -080033 def bundleTask = project.tasks.create("bundleOutlineViewerOsxApp" + binary.targetPlatform.architecture.name, Copy) {
Austin Schuh812d0d12021-11-04 20:16:48 -070034 description("Creates a macOS application bundle for OutlineViewer")
35 from(file("$project.projectDir/Info.plist"))
James Kuszmaulcf324122023-01-14 14:07:17 -080036 into(file("$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name/OutlineViewer.app/Contents"))
James Kuszmaulb13e13f2023-11-22 20:44:04 -080037 into("MacOS") {
38 with copySpec {
39 from binary.executable.file
40 }
41 }
42 into("Resources") {
43 with copySpec {
44 from icon
45 }
46 }
Austin Schuh812d0d12021-11-04 20:16:48 -070047
James Kuszmaulcf324122023-01-14 14:07:17 -080048 inputs.property "HasDeveloperId", project.hasProperty("developerID")
49
Austin Schuh812d0d12021-11-04 20:16:48 -070050 doLast {
51 if (project.hasProperty("developerID")) {
52 // Get path to binary.
53 exec {
54 workingDir rootDir
55 def args = [
56 "sh",
57 "-c",
58 "codesign --force --strict --deep " +
59 "--timestamp --options=runtime " +
60 "--verbose -s ${project.findProperty("developerID")} " +
James Kuszmaulcf324122023-01-14 14:07:17 -080061 "$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name/OutlineViewer.app/"
Austin Schuh812d0d12021-11-04 20:16:48 -070062 ]
63 commandLine args
64 }
65 }
66 }
67 }
68
69 // Reset the application path if we are creating a bundle.
70 if (binary.targetPlatform.operatingSystem.isMacOsX()) {
James Kuszmaulcf324122023-01-14 14:07:17 -080071 applicationPath = file("$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name")
Austin Schuh812d0d12021-11-04 20:16:48 -070072 project.build.dependsOn bundleTask
73 }
74
75 // Create the ZIP.
James Kuszmaulcf324122023-01-14 14:07:17 -080076 def task = project.tasks.create("copyOutlineViewerExecutable" + binary.targetPlatform.architecture.name, Zip) {
Austin Schuh812d0d12021-11-04 20:16:48 -070077 description("Copies the OutlineViewer executable to the outputs directory.")
78 destinationDirectory = outputsFolder
79
80 archiveBaseName = '_M_' + zipBaseName
81 duplicatesStrategy = 'exclude'
James Kuszmaulb13e13f2023-11-22 20:44:04 -080082 archiveClassifier = nativeUtils.getPublishClassifier(binary)
Austin Schuh812d0d12021-11-04 20:16:48 -070083
84 from(licenseFile) {
85 into '/'
86 }
87
88 from(applicationPath)
Austin Schuh75263e32022-02-22 18:05:32 -080089
90 if (binary.targetPlatform.operatingSystem.isWindows()) {
91 def exePath = binary.executable.file.absolutePath
92 exePath = exePath.substring(0, exePath.length() - 4)
93 def pdbPath = new File(exePath + '.pdb')
94 from(pdbPath)
95 }
96
Austin Schuh812d0d12021-11-04 20:16:48 -070097 into(nativeUtils.getPlatformPath(binary))
98 }
99
100 if (binary.targetPlatform.operatingSystem.isMacOsX()) {
101 bundleTask.dependsOn binary.tasks.link
102 task.dependsOn(bundleTask)
103 }
104
105 task.dependsOn binary.tasks.link
106 outlineViewerTaskList.add(task)
107 project.build.dependsOn task
108 project.artifacts { task }
109 addTaskToCopyAllOutputs(task)
110 }
111 }
112 }
113 }
114
115 publications {
116 outlineViewer(MavenPublication) {
117 outlineViewerTaskList.each { artifact it }
118
119 artifactId = baseArtifactId
120 groupId = artifactGroupId
121 version wpilibVersioning.version.get()
122 }
123 }
124 }
125}