blob: b1c3ca2e6df6d58d568881a10fadd4d612fb2b33 [file] [log] [blame]
Brian Silverman8fce7482020-01-05 13:18:21 -08001import edu.wpi.first.toolchain.*
2
Austin Schuh812d0d12021-11-04 20:16:48 -07003buildscript {
4 repositories {
James Kuszmaulcf324122023-01-14 14:07:17 -08005 maven {
6 url = 'https://frcmaven.wpi.edu/artifactory/ex-mvn'
7 }
Austin Schuh812d0d12021-11-04 20:16:48 -07008 }
9 dependencies {
James Kuszmaulb13e13f2023-11-22 20:44:04 -080010 classpath 'com.hubspot.jinjava:jinjava:2.7.1'
Austin Schuh812d0d12021-11-04 20:16:48 -070011 }
12}
13
Brian Silverman8fce7482020-01-05 13:18:21 -080014plugins {
15 id 'base'
James Kuszmaulcf324122023-01-14 14:07:17 -080016 id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '2023.0.1'
Brian Silverman8fce7482020-01-05 13:18:21 -080017 id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2'
18 id 'edu.wpi.first.NativeUtils' apply false
James Kuszmaulcf324122023-01-14 14:07:17 -080019 id 'edu.wpi.first.GradleJni' version '1.1.0'
Austin Schuh75263e32022-02-22 18:05:32 -080020 id 'edu.wpi.first.GradleVsCode'
Brian Silverman8fce7482020-01-05 13:18:21 -080021 id 'idea'
22 id 'visual-studio'
James Kuszmaulb13e13f2023-11-22 20:44:04 -080023 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
26 id 'com.github.spotbugs' version '5.1.3' apply false
27 id 'com.google.protobuf' version '0.9.3' apply false
Brian Silverman8fce7482020-01-05 13:18:21 -080028}
29
Austin Schuh812d0d12021-11-04 20:16:48 -070030wpilibVersioning.buildServerMode = project.hasProperty('buildServer')
31wpilibVersioning.releaseMode = project.hasProperty('releaseMode')
Brian Silverman8fce7482020-01-05 13:18:21 -080032
33allprojects {
34 repositories {
James Kuszmaulcf324122023-01-14 14:07:17 -080035 maven {
36 url = 'https://frcmaven.wpi.edu/artifactory/ex-mvn'
37 }
Brian Silverman8fce7482020-01-05 13:18:21 -080038 }
39 if (project.hasProperty('releaseMode')) {
40 wpilibRepositories.addAllReleaseRepositories(it)
41 } else {
42 wpilibRepositories.addAllDevelopmentRepositories(it)
43 }
44}
45
46buildScan {
47 termsOfServiceUrl = 'https://gradle.com/terms-of-service'
48 termsOfServiceAgree = 'yes'
49
50 publishAlways()
51}
52
Austin Schuh1e69f942020-11-14 15:06:14 -080053ext.licenseFile = files("$rootDir/LICENSE.md", "$rootDir/ThirdPartyNotices.txt")
Brian Silverman8fce7482020-01-05 13:18:21 -080054
55if (project.hasProperty("publishVersion")) {
56 wpilibVersioning.version.set(project.publishVersion)
57}
58
59wpilibVersioning.version.finalizeValue()
60
61def outputsFolder = file("$buildDir/allOutputs")
62
63def versionFile = file("$outputsFolder/version.txt")
64
65task outputVersions() {
66 description = 'Prints the versions of wpilib to a file for use by the downstream packaging project'
67 group = 'Build'
68 outputs.files(versionFile)
69
70 doFirst {
71 buildDir.mkdir()
72 outputsFolder.mkdir()
73 }
74
75 doLast {
76 versionFile.write wpilibVersioning.version.get()
77 }
78}
79
80task libraryBuild() {}
81
82build.dependsOn outputVersions
83
84task copyAllOutputs(type: Copy) {
85 destinationDir outputsFolder
86}
87
88build.dependsOn copyAllOutputs
89copyAllOutputs.dependsOn outputVersions
90
James Kuszmaulcf324122023-01-14 14:07:17 -080091def copyReleaseOnly = project.hasProperty('ciReleaseOnly')
92
Brian Silverman8fce7482020-01-05 13:18:21 -080093ext.addTaskToCopyAllOutputs = { task ->
James Kuszmaulcf324122023-01-14 14:07:17 -080094 if (copyReleaseOnly && task.name.contains('debug')) {
95 return
96 }
Brian Silverman8fce7482020-01-05 13:18:21 -080097 copyAllOutputs.dependsOn task
James Kuszmaulb13e13f2023-11-22 20:44:04 -080098 copyAllOutputs.inputs.file task.archiveFile
99 copyAllOutputs.from task.archiveFile
Brian Silverman8fce7482020-01-05 13:18:21 -0800100}
101
102subprojects {
103 apply plugin: 'eclipse'
104 apply plugin: 'idea'
105
106 def subproj = it
107
108 plugins.withType(NativeComponentPlugin) {
109 subproj.apply plugin: MultiBuilds
110 }
111
James Kuszmaulcf324122023-01-14 14:07:17 -0800112 plugins.withType(JavaPlugin) {
James Kuszmaulb13e13f2023-11-22 20:44:04 -0800113 java {
114 sourceCompatibility = 11
115 targetCompatibility = 11
116 }
James Kuszmaulcf324122023-01-14 14:07:17 -0800117 }
118
Brian Silverman8fce7482020-01-05 13:18:21 -0800119 apply from: "${rootDir}/shared/java/javastyle.gradle"
120
121 // Disables doclint in java 8.
122 if (JavaVersion.current().isJava8Compatible()) {
123 tasks.withType(Javadoc) {
124 if (project.name != "docs") {
125 options.addStringOption('Xdoclint:none', '-quiet')
126 }
127 }
128 }
Austin Schuh1e69f942020-11-14 15:06:14 -0800129
James Kuszmaulcf324122023-01-14 14:07:17 -0800130 tasks.withType(JavaCompile) {
131 options.compilerArgs.add '-XDstringConcat=inline'
James Kuszmaulb13e13f2023-11-22 20:44:04 -0800132 options.encoding = 'UTF-8'
James Kuszmaulcf324122023-01-14 14:07:17 -0800133 }
134
Austin Schuh812d0d12021-11-04 20:16:48 -0700135 // Enables UTF-8 support in Javadoc
136 tasks.withType(Javadoc) {
137 options.addStringOption("charset", "utf-8")
138 options.addStringOption("docencoding", "utf-8")
139 options.addStringOption("encoding", "utf-8")
140 }
141
Austin Schuh1e69f942020-11-14 15:06:14 -0800142 // Sign outputs with Developer ID
James Kuszmaulcf324122023-01-14 14:07:17 -0800143 tasks.withType(AbstractLinkTask) { task ->
144 task.inputs.property "HasDeveloperId", project.hasProperty("developerID")
145
146 if (project.hasProperty("developerID")) {
Austin Schuh1e69f942020-11-14 15:06:14 -0800147 // Don't sign any executables because codesign complains
148 // about relative rpath.
149 if (!(task instanceof LinkExecutable)) {
150 doLast {
151 // Get path to binary.
152 String path = task.getLinkedFile().getAsFile().get().getAbsolutePath()
153 exec {
154 workingDir rootDir
Austin Schuh812d0d12021-11-04 20:16:48 -0700155 def args = [
156 "sh",
157 "-c",
158 "codesign --force --strict --timestamp --options=runtime " +
159 "--verbose -s ${project.findProperty("developerID")} ${path}"
160 ]
Austin Schuh1e69f942020-11-14 15:06:14 -0800161 commandLine args
162 }
163 }
164 }
165 }
166 }
Brian Silverman8fce7482020-01-05 13:18:21 -0800167}
168
169ext.getCurrentArch = {
170 return NativePlatforms.desktop
171}
172
173wrapper {
James Kuszmaulb13e13f2023-11-22 20:44:04 -0800174 gradleVersion = '8.4'
Brian Silverman8fce7482020-01-05 13:18:21 -0800175}