blob: c2d5f98b5cca66d4f907c1872c5a0b5f432f80f3 [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 {
5 mavenCentral()
6 }
7 dependencies {
Austin Schuh75263e32022-02-22 18:05:32 -08008 classpath 'com.hubspot.jinjava:jinjava:2.6.0'
Austin Schuh812d0d12021-11-04 20:16:48 -07009 }
10}
11
Brian Silverman8fce7482020-01-05 13:18:21 -080012plugins {
13 id 'base'
Austin Schuh812d0d12021-11-04 20:16:48 -070014 id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '4.1.0'
Brian Silverman8fce7482020-01-05 13:18:21 -080015 id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2'
16 id 'edu.wpi.first.NativeUtils' apply false
Austin Schuh812d0d12021-11-04 20:16:48 -070017 id 'edu.wpi.first.GradleJni' version '1.0.0'
Austin Schuh75263e32022-02-22 18:05:32 -080018 id 'edu.wpi.first.GradleVsCode'
Brian Silverman8fce7482020-01-05 13:18:21 -080019 id 'idea'
20 id 'visual-studio'
Austin Schuh75263e32022-02-22 18:05:32 -080021 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 Silverman8fce7482020-01-05 13:18:21 -080025}
26
Austin Schuh812d0d12021-11-04 20:16:48 -070027wpilibVersioning.buildServerMode = project.hasProperty('buildServer')
28wpilibVersioning.releaseMode = project.hasProperty('releaseMode')
Brian Silverman8fce7482020-01-05 13:18:21 -080029
30allprojects {
31 repositories {
32 mavenCentral()
33 }
34 if (project.hasProperty('releaseMode')) {
35 wpilibRepositories.addAllReleaseRepositories(it)
36 } else {
37 wpilibRepositories.addAllDevelopmentRepositories(it)
38 }
39}
40
41buildScan {
42 termsOfServiceUrl = 'https://gradle.com/terms-of-service'
43 termsOfServiceAgree = 'yes'
44
45 publishAlways()
46}
47
Austin Schuh1e69f942020-11-14 15:06:14 -080048ext.licenseFile = files("$rootDir/LICENSE.md", "$rootDir/ThirdPartyNotices.txt")
Brian Silverman8fce7482020-01-05 13:18:21 -080049
50if (project.hasProperty("publishVersion")) {
51 wpilibVersioning.version.set(project.publishVersion)
52}
53
54wpilibVersioning.version.finalizeValue()
55
56def outputsFolder = file("$buildDir/allOutputs")
57
58def versionFile = file("$outputsFolder/version.txt")
59
60task 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
75task libraryBuild() {}
76
77build.dependsOn outputVersions
78
79task copyAllOutputs(type: Copy) {
80 destinationDir outputsFolder
81}
82
83build.dependsOn copyAllOutputs
84copyAllOutputs.dependsOn outputVersions
85
86ext.addTaskToCopyAllOutputs = { task ->
87 copyAllOutputs.dependsOn task
88 copyAllOutputs.inputs.file task.archivePath
89 copyAllOutputs.from task.archivePath
90}
91
92subprojects {
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 Schuh1e69f942020-11-14 15:06:14 -0800112
Austin Schuh812d0d12021-11-04 20:16:48 -0700113 // 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 Schuh1e69f942020-11-14 15:06:14 -0800120 // 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 Schuh812d0d12021-11-04 20:16:48 -0700131 def args = [
132 "sh",
133 "-c",
134 "codesign --force --strict --timestamp --options=runtime " +
135 "--verbose -s ${project.findProperty("developerID")} ${path}"
136 ]
Austin Schuh1e69f942020-11-14 15:06:14 -0800137 commandLine args
138 }
139 }
140 }
141 }
142 }
Brian Silverman8fce7482020-01-05 13:18:21 -0800143}
144
145ext.getCurrentArch = {
146 return NativePlatforms.desktop
147}
148
149wrapper {
Austin Schuh75263e32022-02-22 18:05:32 -0800150 gradleVersion = '7.3.3'
Brian Silverman8fce7482020-01-05 13:18:21 -0800151}