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