blob: aab12433e86f8a6c127832dbee2a17c57d574c2f [file] [log] [blame]
John Park7eb90422018-01-27 12:04:57 -08001apply plugin: 'maven-publish'
2apply plugin: 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin'
3
4if (!hasProperty('releaseType')) {
5 WPILibVersion {
6 releaseType = 'dev'
7 }
8}
9
10def pubVersion
11if (project.hasProperty("publishVersion")) {
12 pubVersion = project.publishVersion
13} else {
14 pubVersion = WPILibVersion.version
15}
16
17def baseArtifactId = 'wpilibj'
18def artifactGroupId = 'edu.wpi.first.wpilibj'
19
20def outputsFolder = file("$project.buildDir/outputs")
21
22task 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
49task sourcesJar(type: Jar, dependsOn: classes) {
50 classifier = 'sources'
51 from sourceSets.main.allSource
52}
53
54task 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
62task javadocJar(type: Jar, dependsOn: javadoc) {
63 classifier = 'javadoc'
64 from javadoc.destinationDir
65}
66
67if (project.hasProperty('jenkinsBuild')) {
68 jar {
69 classifier = 'javaArtifact'
70 }
71}
72
73artifacts {
74 archives sourcesJar
75 archives javadocJar
76 archives cppSourcesZip
77}
78
79model {
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
157publishing {
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}