blob: ed2c520caa62a4617f9491c82cca464334941b62 [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 {
Austin Schuh75263e32022-02-22 18:05:32 -080010 classpath 'com.hubspot.jinjava:jinjava:2.6.0'
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'
Austin Schuh75263e32022-02-22 18:05:32 -080023 id 'net.ltgt.errorprone' version '2.0.2' apply false
24 id 'com.github.johnrengelman.shadow' version '7.1.2' apply false
James Kuszmaulcf324122023-01-14 14:07:17 -080025 id 'com.diffplug.spotless' version '6.12.0' apply false
26 id 'com.github.spotbugs' version '5.0.8' apply false
Brian Silverman8fce7482020-01-05 13:18:21 -080027}
28
Austin Schuh812d0d12021-11-04 20:16:48 -070029wpilibVersioning.buildServerMode = project.hasProperty('buildServer')
30wpilibVersioning.releaseMode = project.hasProperty('releaseMode')
Brian Silverman8fce7482020-01-05 13:18:21 -080031
32allprojects {
33 repositories {
James Kuszmaulcf324122023-01-14 14:07:17 -080034 maven {
35 url = 'https://frcmaven.wpi.edu/artifactory/ex-mvn'
36 }
Brian Silverman8fce7482020-01-05 13:18:21 -080037 }
38 if (project.hasProperty('releaseMode')) {
39 wpilibRepositories.addAllReleaseRepositories(it)
40 } else {
41 wpilibRepositories.addAllDevelopmentRepositories(it)
42 }
43}
44
45buildScan {
46 termsOfServiceUrl = 'https://gradle.com/terms-of-service'
47 termsOfServiceAgree = 'yes'
48
49 publishAlways()
50}
51
Austin Schuh1e69f942020-11-14 15:06:14 -080052ext.licenseFile = files("$rootDir/LICENSE.md", "$rootDir/ThirdPartyNotices.txt")
Brian Silverman8fce7482020-01-05 13:18:21 -080053
54if (project.hasProperty("publishVersion")) {
55 wpilibVersioning.version.set(project.publishVersion)
56}
57
58wpilibVersioning.version.finalizeValue()
59
60def outputsFolder = file("$buildDir/allOutputs")
61
62def versionFile = file("$outputsFolder/version.txt")
63
64task 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
79task libraryBuild() {}
80
81build.dependsOn outputVersions
82
83task copyAllOutputs(type: Copy) {
84 destinationDir outputsFolder
85}
86
87build.dependsOn copyAllOutputs
88copyAllOutputs.dependsOn outputVersions
89
James Kuszmaulcf324122023-01-14 14:07:17 -080090def copyReleaseOnly = project.hasProperty('ciReleaseOnly')
91
Brian Silverman8fce7482020-01-05 13:18:21 -080092ext.addTaskToCopyAllOutputs = { task ->
James Kuszmaulcf324122023-01-14 14:07:17 -080093 if (copyReleaseOnly && task.name.contains('debug')) {
94 return
95 }
Brian Silverman8fce7482020-01-05 13:18:21 -080096 copyAllOutputs.dependsOn task
97 copyAllOutputs.inputs.file task.archivePath
98 copyAllOutputs.from task.archivePath
99}
100
101subprojects {
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 Kuszmaulcf324122023-01-14 14:07:17 -0800111 plugins.withType(JavaPlugin) {
112 sourceCompatibility = 11
113 targetCompatibility = 11
114 }
115
Brian Silverman8fce7482020-01-05 13:18:21 -0800116 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 Schuh1e69f942020-11-14 15:06:14 -0800126
James Kuszmaulcf324122023-01-14 14:07:17 -0800127 tasks.withType(JavaCompile) {
128 options.compilerArgs.add '-XDstringConcat=inline'
129 }
130
Austin Schuh812d0d12021-11-04 20:16:48 -0700131 // 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 Schuh1e69f942020-11-14 15:06:14 -0800138 // Sign outputs with Developer ID
James Kuszmaulcf324122023-01-14 14:07:17 -0800139 tasks.withType(AbstractLinkTask) { task ->
140 task.inputs.property "HasDeveloperId", project.hasProperty("developerID")
141
142 if (project.hasProperty("developerID")) {
Austin Schuh1e69f942020-11-14 15:06:14 -0800143 // 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 Schuh812d0d12021-11-04 20:16:48 -0700151 def args = [
152 "sh",
153 "-c",
154 "codesign --force --strict --timestamp --options=runtime " +
155 "--verbose -s ${project.findProperty("developerID")} ${path}"
156 ]
Austin Schuh1e69f942020-11-14 15:06:14 -0800157 commandLine args
158 }
159 }
160 }
161 }
162 }
Brian Silverman8fce7482020-01-05 13:18:21 -0800163}
164
165ext.getCurrentArch = {
166 return NativePlatforms.desktop
167}
168
169wrapper {
James Kuszmaulcf324122023-01-14 14:07:17 -0800170 gradleVersion = '7.5.1'
Brian Silverman8fce7482020-01-05 13:18:21 -0800171}