blob: 9c53ae5b606467bf3734f396f8c79587a154dda6 [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"))
Austin Schuh812d0d12021-11-04 20:16:48 -070037 into("MacOS") { with copySpec { from binary.executable.file } }
38 into("Resources") { with copySpec { from icon } }
39
James Kuszmaulcf324122023-01-14 14:07:17 -080040 inputs.property "HasDeveloperId", project.hasProperty("developerID")
41
Austin Schuh812d0d12021-11-04 20:16:48 -070042 doLast {
43 if (project.hasProperty("developerID")) {
44 // Get path to binary.
45 exec {
46 workingDir rootDir
47 def args = [
48 "sh",
49 "-c",
50 "codesign --force --strict --deep " +
51 "--timestamp --options=runtime " +
52 "--verbose -s ${project.findProperty("developerID")} " +
James Kuszmaulcf324122023-01-14 14:07:17 -080053 "$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name/OutlineViewer.app/"
Austin Schuh812d0d12021-11-04 20:16:48 -070054 ]
55 commandLine args
56 }
57 }
58 }
59 }
60
61 // Reset the application path if we are creating a bundle.
62 if (binary.targetPlatform.operatingSystem.isMacOsX()) {
James Kuszmaulcf324122023-01-14 14:07:17 -080063 applicationPath = file("$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name")
Austin Schuh812d0d12021-11-04 20:16:48 -070064 project.build.dependsOn bundleTask
65 }
66
67 // Create the ZIP.
James Kuszmaulcf324122023-01-14 14:07:17 -080068 def task = project.tasks.create("copyOutlineViewerExecutable" + binary.targetPlatform.architecture.name, Zip) {
Austin Schuh812d0d12021-11-04 20:16:48 -070069 description("Copies the OutlineViewer executable to the outputs directory.")
70 destinationDirectory = outputsFolder
71
72 archiveBaseName = '_M_' + zipBaseName
73 duplicatesStrategy = 'exclude'
74 classifier = nativeUtils.getPublishClassifier(binary)
75
76 from(licenseFile) {
77 into '/'
78 }
79
80 from(applicationPath)
Austin Schuh75263e32022-02-22 18:05:32 -080081
82 if (binary.targetPlatform.operatingSystem.isWindows()) {
83 def exePath = binary.executable.file.absolutePath
84 exePath = exePath.substring(0, exePath.length() - 4)
85 def pdbPath = new File(exePath + '.pdb')
86 from(pdbPath)
87 }
88
Austin Schuh812d0d12021-11-04 20:16:48 -070089 into(nativeUtils.getPlatformPath(binary))
90 }
91
92 if (binary.targetPlatform.operatingSystem.isMacOsX()) {
93 bundleTask.dependsOn binary.tasks.link
94 task.dependsOn(bundleTask)
95 }
96
97 task.dependsOn binary.tasks.link
98 outlineViewerTaskList.add(task)
99 project.build.dependsOn task
100 project.artifacts { task }
101 addTaskToCopyAllOutputs(task)
102 }
103 }
104 }
105 }
106
107 publications {
108 outlineViewer(MavenPublication) {
109 outlineViewerTaskList.each { artifact it }
110
111 artifactId = baseArtifactId
112 groupId = artifactGroupId
113 version wpilibVersioning.version.get()
114 }
115 }
116 }
117}