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 = 'wpilibj' |
| 18 | def artifactGroupId = 'edu.wpi.first.wpilibj' |
| 19 | |
| 20 | def outputsFolder = file("$project.buildDir/outputs") |
| 21 | |
| 22 | task cppSourcesZip(type: Zip) { |
| 23 | destinationDir = outputsFolder |
| 24 | baseName = 'wpilibJNI' |
| 25 | classifier = "sources" |
| 26 | |
| 27 | from(licenseFile) { |
| 28 | into '/' |
| 29 | } |
| 30 | |
| 31 | from('src/main/native/cpp') { |
| 32 | into '/' |
| 33 | } |
| 34 | |
| 35 | model { |
| 36 | tasks { |
| 37 | it.each { |
| 38 | if (it in getJNIHeadersClass()) { |
| 39 | from (it.outputs.files) { |
| 40 | into '/' |
| 41 | } |
| 42 | dependsOn it |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | task sourcesJar(type: Jar, dependsOn: classes) { |
| 50 | classifier = 'sources' |
| 51 | from sourceSets.main.allSource |
| 52 | } |
| 53 | |
| 54 | task javadoc(type: Javadoc, overwrite: true) { |
| 55 | javadoc.options.links("http://docs.oracle.com/javase/8/docs/api/") |
| 56 | options.addStringOption "tag", "pre:a:Pre-Condition" |
| 57 | options.addStringOption('Xdoclint:accessibility,syntax,html', '-quiet') |
| 58 | source = sourceSets.main.allJava |
| 59 | failOnError = true |
| 60 | } |
| 61 | |
| 62 | task javadocJar(type: Jar, dependsOn: javadoc) { |
| 63 | classifier = 'javadoc' |
| 64 | from javadoc.destinationDir |
| 65 | } |
| 66 | |
| 67 | if (project.hasProperty('jenkinsBuild')) { |
| 68 | jar { |
| 69 | classifier = 'javaArtifact' |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | artifacts { |
| 74 | archives sourcesJar |
| 75 | archives javadocJar |
| 76 | archives cppSourcesZip |
| 77 | } |
| 78 | |
| 79 | model { |
| 80 | publishing { |
| 81 | def wpilibJNIStaticTaskList = createComponentZipTasks($.components, 'wpilibJNIStatic', 'jni', Jar, project, { task, value -> |
| 82 | value.each { binary-> |
| 83 | if (binary.buildable) { |
| 84 | if (binary instanceof SharedLibraryBinarySpec) { |
| 85 | task.dependsOn binary.buildTask |
| 86 | task.from (binary.sharedLibraryFile) { |
| 87 | into getPlatformPath(binary) |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | }) |
| 93 | |
| 94 | def wpilibJNISharedTaskList = createComponentZipTasks($.components, 'wpilibJNIShared', 'jni', Jar, project, { task, value -> |
| 95 | value.each { binary-> |
| 96 | if (binary.buildable) { |
| 97 | if (binary instanceof SharedLibraryBinarySpec) { |
| 98 | task.dependsOn binary.buildTask |
| 99 | task.from (binary.sharedLibraryFile) { |
| 100 | into getPlatformPath(binary) + '/shared' |
| 101 | } |
| 102 | task.from(new File(binary.sharedLibraryFile.absolutePath + ".debug")) { |
| 103 | into getPlatformPath(binary) + '/shared' |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | }) |
| 109 | |
| 110 | def allSharedTask |
| 111 | if (!project.hasProperty('jenkinsBuild')) { |
| 112 | allSharedTask = createAllCombined(wpilibJNISharedTaskList, 'wpilibJNIShared', 'jni', Jar, project) |
| 113 | } |
| 114 | |
| 115 | def allStaticTask |
| 116 | if (!project.hasProperty('jenkinsBuild')) { |
| 117 | allStaticTask = createAllCombined(wpilibJNIStaticTaskList, 'wpilibJNIStatic', 'jni', Jar, project) |
| 118 | } |
| 119 | |
| 120 | publications { |
| 121 | jniShared(MavenPublication) { |
| 122 | wpilibJNISharedTaskList.each { |
| 123 | artifact it |
| 124 | } |
| 125 | |
| 126 | if (!project.hasProperty('jenkinsBuild')) { |
| 127 | artifact allSharedTask |
| 128 | } |
| 129 | |
| 130 | artifact cppSourcesZip |
| 131 | |
| 132 | artifactId = "${baseArtifactId}-jniShared" |
| 133 | groupId artifactGroupId |
| 134 | version pubVersion |
| 135 | } |
| 136 | |
| 137 | jni(MavenPublication) { |
| 138 | wpilibJNIStaticTaskList.each { |
| 139 | artifact it |
| 140 | } |
| 141 | |
| 142 | if (!project.hasProperty('jenkinsBuild')) { |
| 143 | artifact allStaticTask |
| 144 | } |
| 145 | |
| 146 | artifact cppSourcesZip |
| 147 | |
| 148 | artifactId = "${baseArtifactId}-jni" |
| 149 | groupId artifactGroupId |
| 150 | version pubVersion |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | |
| 157 | publishing { |
| 158 | publications { |
| 159 | |
| 160 | java(MavenPublication) { |
| 161 | artifact jar |
| 162 | artifact sourcesJar |
| 163 | artifact javadocJar |
| 164 | |
| 165 | artifactId = "${baseArtifactId}-java" |
| 166 | groupId artifactGroupId |
| 167 | version pubVersion |
| 168 | } |
| 169 | } |
| 170 | } |