Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 1 | import edu.wpi.first.toolchain.* |
| 2 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 3 | buildscript { |
| 4 | repositories { |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 5 | maven { |
| 6 | url = 'https://frcmaven.wpi.edu/artifactory/ex-mvn' |
| 7 | } |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 8 | } |
| 9 | dependencies { |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 10 | classpath 'com.hubspot.jinjava:jinjava:2.7.1' |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 11 | } |
| 12 | } |
| 13 | |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 14 | plugins { |
| 15 | id 'base' |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 16 | id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '2023.0.1' |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 17 | id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2' |
| 18 | id 'edu.wpi.first.NativeUtils' apply false |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 19 | id 'edu.wpi.first.GradleJni' version '1.1.0' |
Austin Schuh | 75263e3 | 2022-02-22 18:05:32 -0800 | [diff] [blame] | 20 | id 'edu.wpi.first.GradleVsCode' |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 21 | id 'idea' |
| 22 | id 'visual-studio' |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 23 | id 'net.ltgt.errorprone' version '3.1.0' apply false |
| 24 | id 'com.github.johnrengelman.shadow' version '8.1.1' apply false |
| 25 | id 'com.diffplug.spotless' version '6.20.0' apply false |
Maxwell Henderson | 80bec32 | 2024-01-09 15:48:44 -0800 | [diff] [blame] | 26 | id 'com.github.spotbugs' version '6.0.2' apply false |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 27 | id 'com.google.protobuf' version '0.9.3' apply false |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 28 | } |
| 29 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 30 | wpilibVersioning.buildServerMode = project.hasProperty('buildServer') |
| 31 | wpilibVersioning.releaseMode = project.hasProperty('releaseMode') |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 32 | |
| 33 | allprojects { |
| 34 | repositories { |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 35 | maven { |
| 36 | url = 'https://frcmaven.wpi.edu/artifactory/ex-mvn' |
| 37 | } |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 38 | } |
| 39 | if (project.hasProperty('releaseMode')) { |
| 40 | wpilibRepositories.addAllReleaseRepositories(it) |
| 41 | } else { |
| 42 | wpilibRepositories.addAllDevelopmentRepositories(it) |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | buildScan { |
| 47 | termsOfServiceUrl = 'https://gradle.com/terms-of-service' |
| 48 | termsOfServiceAgree = 'yes' |
| 49 | |
| 50 | publishAlways() |
| 51 | } |
| 52 | |
Maxwell Henderson | 80bec32 | 2024-01-09 15:48:44 -0800 | [diff] [blame] | 53 | import com.github.spotbugs.snom.Effort |
| 54 | ext.spotbugsEffort = Effort.MAX |
| 55 | |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 56 | ext.licenseFile = files("$rootDir/LICENSE.md", "$rootDir/ThirdPartyNotices.txt") |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 57 | |
| 58 | if (project.hasProperty("publishVersion")) { |
| 59 | wpilibVersioning.version.set(project.publishVersion) |
| 60 | } |
| 61 | |
| 62 | wpilibVersioning.version.finalizeValue() |
| 63 | |
| 64 | def outputsFolder = file("$buildDir/allOutputs") |
| 65 | |
| 66 | def versionFile = file("$outputsFolder/version.txt") |
| 67 | |
| 68 | task outputVersions() { |
| 69 | description = 'Prints the versions of wpilib to a file for use by the downstream packaging project' |
| 70 | group = 'Build' |
| 71 | outputs.files(versionFile) |
| 72 | |
| 73 | doFirst { |
| 74 | buildDir.mkdir() |
| 75 | outputsFolder.mkdir() |
| 76 | } |
| 77 | |
| 78 | doLast { |
| 79 | versionFile.write wpilibVersioning.version.get() |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | task libraryBuild() {} |
| 84 | |
| 85 | build.dependsOn outputVersions |
| 86 | |
| 87 | task copyAllOutputs(type: Copy) { |
| 88 | destinationDir outputsFolder |
| 89 | } |
| 90 | |
| 91 | build.dependsOn copyAllOutputs |
| 92 | copyAllOutputs.dependsOn outputVersions |
| 93 | |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 94 | def copyReleaseOnly = project.hasProperty('ciReleaseOnly') |
| 95 | |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 96 | ext.addTaskToCopyAllOutputs = { task -> |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 97 | if (copyReleaseOnly && task.name.contains('debug')) { |
| 98 | return |
| 99 | } |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 100 | copyAllOutputs.dependsOn task |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 101 | copyAllOutputs.inputs.file task.archiveFile |
| 102 | copyAllOutputs.from task.archiveFile |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | subprojects { |
| 106 | apply plugin: 'eclipse' |
| 107 | apply plugin: 'idea' |
| 108 | |
| 109 | def subproj = it |
| 110 | |
| 111 | plugins.withType(NativeComponentPlugin) { |
| 112 | subproj.apply plugin: MultiBuilds |
| 113 | } |
| 114 | |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 115 | plugins.withType(JavaPlugin) { |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 116 | java { |
| 117 | sourceCompatibility = 11 |
| 118 | targetCompatibility = 11 |
| 119 | } |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 120 | } |
| 121 | |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 122 | apply from: "${rootDir}/shared/java/javastyle.gradle" |
| 123 | |
| 124 | // Disables doclint in java 8. |
| 125 | if (JavaVersion.current().isJava8Compatible()) { |
| 126 | tasks.withType(Javadoc) { |
| 127 | if (project.name != "docs") { |
| 128 | options.addStringOption('Xdoclint:none', '-quiet') |
| 129 | } |
| 130 | } |
| 131 | } |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 132 | |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 133 | tasks.withType(JavaCompile) { |
| 134 | options.compilerArgs.add '-XDstringConcat=inline' |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 135 | options.encoding = 'UTF-8' |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 136 | } |
| 137 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 138 | // Enables UTF-8 support in Javadoc |
| 139 | tasks.withType(Javadoc) { |
| 140 | options.addStringOption("charset", "utf-8") |
| 141 | options.addStringOption("docencoding", "utf-8") |
| 142 | options.addStringOption("encoding", "utf-8") |
| 143 | } |
| 144 | |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 145 | // Sign outputs with Developer ID |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 146 | tasks.withType(AbstractLinkTask) { task -> |
| 147 | task.inputs.property "HasDeveloperId", project.hasProperty("developerID") |
| 148 | |
| 149 | if (project.hasProperty("developerID")) { |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 150 | // Don't sign any executables because codesign complains |
| 151 | // about relative rpath. |
| 152 | if (!(task instanceof LinkExecutable)) { |
| 153 | doLast { |
| 154 | // Get path to binary. |
| 155 | String path = task.getLinkedFile().getAsFile().get().getAbsolutePath() |
| 156 | exec { |
| 157 | workingDir rootDir |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 158 | def args = [ |
| 159 | "sh", |
| 160 | "-c", |
| 161 | "codesign --force --strict --timestamp --options=runtime " + |
| 162 | "--verbose -s ${project.findProperty("developerID")} ${path}" |
| 163 | ] |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 164 | commandLine args |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | } |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | ext.getCurrentArch = { |
| 173 | return NativePlatforms.desktop |
| 174 | } |
| 175 | |
| 176 | wrapper { |
Maxwell Henderson | 80bec32 | 2024-01-09 15:48:44 -0800 | [diff] [blame] | 177 | gradleVersion = '8.5' |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 178 | } |