blob: a5c0577dfdc68114e09f92783addb8208102ec77 [file] [log] [blame]
Brian Silverman8fce7482020-01-05 13:18:21 -08001import edu.wpi.first.toolchain.*
2
3plugins {
4 id 'base'
Austin Schuh1e69f942020-11-14 15:06:14 -08005 id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '4.0.2'
Brian Silverman8fce7482020-01-05 13:18:21 -08006 id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2'
7 id 'edu.wpi.first.NativeUtils' apply false
8 id 'edu.wpi.first.GradleJni' version '0.10.1'
9 id 'edu.wpi.first.GradleVsCode' version '0.11.0'
10 id 'idea'
11 id 'visual-studio'
12 id 'net.ltgt.errorprone' version '1.1.1' apply false
13 id 'com.github.johnrengelman.shadow' version '5.2.0' apply false
14}
15
16if (project.hasProperty('buildServer')) {
17 wpilibVersioning.buildServerMode = true
Austin Schuh1e69f942020-11-14 15:06:14 -080018 wpilibVersioning.useAllTags = true
Brian Silverman8fce7482020-01-05 13:18:21 -080019}
20
21if (project.hasProperty('releaseMode')) {
22 wpilibVersioning.releaseMode = true
Austin Schuh1e69f942020-11-14 15:06:14 -080023 wpilibVersioning.useAllTags = true
Brian Silverman8fce7482020-01-05 13:18:21 -080024}
25
26allprojects {
27 repositories {
28 mavenCentral()
29 }
30 if (project.hasProperty('releaseMode')) {
31 wpilibRepositories.addAllReleaseRepositories(it)
32 } else {
33 wpilibRepositories.addAllDevelopmentRepositories(it)
34 }
35}
36
37buildScan {
38 termsOfServiceUrl = 'https://gradle.com/terms-of-service'
39 termsOfServiceAgree = 'yes'
40
41 publishAlways()
42}
43
Austin Schuh1e69f942020-11-14 15:06:14 -080044ext.licenseFile = files("$rootDir/LICENSE.md", "$rootDir/ThirdPartyNotices.txt")
Brian Silverman8fce7482020-01-05 13:18:21 -080045
46if (project.hasProperty("publishVersion")) {
47 wpilibVersioning.version.set(project.publishVersion)
48}
49
50wpilibVersioning.version.finalizeValue()
51
52def outputsFolder = file("$buildDir/allOutputs")
53
54def versionFile = file("$outputsFolder/version.txt")
55
56task outputVersions() {
57 description = 'Prints the versions of wpilib to a file for use by the downstream packaging project'
58 group = 'Build'
59 outputs.files(versionFile)
60
61 doFirst {
62 buildDir.mkdir()
63 outputsFolder.mkdir()
64 }
65
66 doLast {
67 versionFile.write wpilibVersioning.version.get()
68 }
69}
70
71task libraryBuild() {}
72
73build.dependsOn outputVersions
74
75task copyAllOutputs(type: Copy) {
76 destinationDir outputsFolder
77}
78
79build.dependsOn copyAllOutputs
80copyAllOutputs.dependsOn outputVersions
81
82ext.addTaskToCopyAllOutputs = { task ->
83 copyAllOutputs.dependsOn task
84 copyAllOutputs.inputs.file task.archivePath
85 copyAllOutputs.from task.archivePath
86}
87
88subprojects {
89 apply plugin: 'eclipse'
90 apply plugin: 'idea'
91
92 def subproj = it
93
94 plugins.withType(NativeComponentPlugin) {
95 subproj.apply plugin: MultiBuilds
96 }
97
98 apply from: "${rootDir}/shared/java/javastyle.gradle"
99
100 // Disables doclint in java 8.
101 if (JavaVersion.current().isJava8Compatible()) {
102 tasks.withType(Javadoc) {
103 if (project.name != "docs") {
104 options.addStringOption('Xdoclint:none', '-quiet')
105 }
106 }
107 }
Austin Schuh1e69f942020-11-14 15:06:14 -0800108
109 // Sign outputs with Developer ID
110 if (project.hasProperty("developerID")) {
111 tasks.withType(AbstractLinkTask) { task ->
112 // Don't sign any executables because codesign complains
113 // about relative rpath.
114 if (!(task instanceof LinkExecutable)) {
115 doLast {
116 // Get path to binary.
117 String path = task.getLinkedFile().getAsFile().get().getAbsolutePath()
118 exec {
119 workingDir rootDir
120 def args = ["sh", "-c", "codesign --force --strict --timestamp --options=runtime " +
121 "--verbose -s ${project.findProperty("developerID")} ${path}"]
122 commandLine args
123 }
124 }
125 }
126 }
127 }
Brian Silverman8fce7482020-01-05 13:18:21 -0800128}
129
130ext.getCurrentArch = {
131 return NativePlatforms.desktop
132}
133
134wrapper {
Austin Schuh1e69f942020-11-14 15:06:14 -0800135 gradleVersion = '6.0.1'
Brian Silverman8fce7482020-01-05 13:18:21 -0800136}