John Park | 7eb9042 | 2018-01-27 12:04:57 -0800 | [diff] [blame] | 1 | apply plugin: 'maven-publish' |
| 2 | apply plugin: 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' |
| 3 | |
| 4 | if (!hasProperty('releaseType')) { |
| 5 | WPILibVersion { |
| 6 | releaseType = 'dev' |
| 7 | } |
| 8 | } |
| 9 | |
| 10 | def pubVersion = '' |
| 11 | if (project.hasProperty("publishVersion")) { |
| 12 | pubVersion = project.publishVersion |
| 13 | } else { |
| 14 | pubVersion = WPILibVersion.version |
| 15 | } |
| 16 | |
| 17 | def baseArtifactId = 'hal' |
| 18 | def artifactGroupId = 'edu.wpi.first.hal' |
| 19 | |
| 20 | def outputsFolder = file("$project.buildDir/outputs") |
| 21 | |
| 22 | task cppSourcesZip(type: Zip) { |
| 23 | destinationDir = outputsFolder |
| 24 | baseName = 'hal' |
| 25 | classifier = "sources" |
| 26 | |
| 27 | from(licenseFile) { |
| 28 | into '/' |
| 29 | } |
| 30 | |
| 31 | from('src/main/native/athena') { |
| 32 | into '/athena' |
| 33 | } |
| 34 | |
| 35 | from('src/main/native/sim') { |
| 36 | into '/sim' |
| 37 | } |
| 38 | |
| 39 | from('src/main/native/shared') { |
| 40 | into '/shared' |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | task cppHeadersZip(type: Zip) { |
| 45 | destinationDir = outputsFolder |
| 46 | baseName = 'hal' |
| 47 | classifier = "headers" |
| 48 | |
| 49 | from(licenseFile) { |
| 50 | into '/' |
| 51 | } |
| 52 | |
| 53 | from('src/main/native/include') { |
| 54 | into '/' |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | build.dependsOn cppHeadersZip |
| 59 | build.dependsOn cppSourcesZip |
| 60 | |
| 61 | |
| 62 | model { |
| 63 | publishing { |
| 64 | def halAthenaTaskList = [] |
| 65 | if (!project.hasProperty('skipAthena')) { |
| 66 | halAthenaTaskList = createComponentZipTasks($.components, 'halAthena', 'zipcpp', Zip, project, includeStandardZipFormat) |
| 67 | } |
| 68 | def halSimTaskList = [] |
| 69 | if (!project.hasProperty('onlyAthena')) { |
| 70 | halSimTaskList = createComponentZipTasks($.components, 'halSim', 'zipcpp', Zip, project, includeStandardZipFormat) |
| 71 | } |
| 72 | |
| 73 | def allTask |
| 74 | if (!project.hasProperty('jenkinsBuild')) { |
| 75 | def combinedList = [] |
| 76 | halAthenaTaskList.each { |
| 77 | combinedList.add(it) |
| 78 | } |
| 79 | halSimTaskList.each { |
| 80 | combinedList.add(it) |
| 81 | } |
| 82 | allTask = createAllCombined(combinedList, 'hal', 'zipcpp', Zip, project) |
| 83 | } |
| 84 | |
| 85 | def halSimStaticDepsTaskList = [] |
| 86 | if (project.hasProperty('buildHalStaticDeps')) { |
| 87 | halSimStaticDepsTaskList = createComponentZipTasks($.components, 'halSimStaticDeps', 'zipcpp', Zip, project, includeStandardZipFormat) |
| 88 | if (!project.hasProperty('jenkinsBuild')) { |
| 89 | def staticAllTask = createAllCombined(halSimStaticDepsTaskList, 'halSimStaticDeps', 'zipcpp', Zip, project) |
| 90 | halSimStaticDepsTaskList.add(staticAllTask) |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | publications { |
| 95 | cpp(MavenPublication) { |
| 96 | halAthenaTaskList.each { |
| 97 | artifact it |
| 98 | } |
| 99 | halSimTaskList.each { |
| 100 | artifact it |
| 101 | } |
| 102 | if (!project.hasProperty('jenkinsBuild')) { |
| 103 | artifact allTask |
| 104 | } |
| 105 | artifact cppHeadersZip |
| 106 | artifact cppSourcesZip |
| 107 | |
| 108 | artifactId = baseArtifactId |
| 109 | groupId artifactGroupId |
| 110 | version pubVersion |
| 111 | } |
| 112 | if (project.hasProperty('buildHalStaticDeps')) { |
| 113 | cppStaticDeps(MavenPublication) { |
| 114 | halSimStaticDepsTaskList.each { |
| 115 | artifact it |
| 116 | } |
| 117 | |
| 118 | artifactId = baseArtifactId + 'StaticDeps' |
| 119 | groupId artifactGroupId |
| 120 | version pubVersion |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | } |