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