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