Files
allwpilib/wpilibj/build.gradle

173 lines
5.8 KiB
Groovy
Raw Permalink Normal View History

2018-04-29 13:29:07 -07:00
evaluationDependsOn(':hal')
evaluationDependsOn(':ntcore')
evaluationDependsOn(':cscore')
evaluationDependsOn(':cameraserver')
ext {
baseId = 'wpilibj'
2025-11-07 20:00:38 -05:00
groupId = 'org.wpilib.wpilibj'
devMain = 'org.wpilib.wpilibj.DevMain'
}
2018-04-29 13:29:07 -07:00
apply from: "${rootDir}/shared/java/javacommon.gradle"
Gradle Build This adds gradle support for building wpilibj and wpilibc. At this point, both of these libraries should be fully ready to go. Gradle should give us a number of improvements, including less dependencies for getting building up and running, and MUCH faster build times. I'm noticing significantly faster build times already compared to Maven, with neither system building the plugins. The changes here should be pretty straight forward. The basic command for gradle is './gradlew'. This is the gradle wrapper, and it will find and download the correct gradle executable for your system. There is no need to install anything yourself. To see every task available, run './gradlew tasks'. The important tasks for us are listed under the WPILib header when the tasks command is run. To generate unit test binaries, the fRCUserProgramExecutable command will create the C++ tester, and the wpilibjIntegrationTestJar command will create the Java tester. The Jenkins deploy scripts have been modified to know the difference between maven generated and gradle generated jars with an environment variable. Creating the eclipse plugins still requires Maven, but gradle will handle calling it correctly and generating the proper dependencies for it. Create the plugins by calling ./gradlew eclipsePlugins. Jenkins can now be modified to support the new build system. Unit tests are run with ./gradlew test. Generating the integration tests uses the above two commands, and then process proceeds exactly as it did before. For publishing documentation, a new task has been created, ./gradlew publishDocs, which handles putting the documentation where Jenkins expects for publishing. Change-Id: I9a260d391984f98ef9170993efe933e4026161dc
2015-05-05 09:54:14 -04:00
2018-04-29 13:29:07 -07:00
def wpilibVersionFileInput = file("src/generate/WPILibVersion.java.in")
def wpilibVersionFileOutput = file("$buildDir/generated/java/org/wpilib/system/WPILibVersion.java")
2018-04-29 13:29:07 -07:00
task generateJavaVersion() {
description = 'Generates the wpilib version class'
group = 'WPILib'
2018-04-29 13:29:07 -07:00
outputs.file wpilibVersionFileOutput
inputs.file wpilibVersionFileInput
if (wpilibVersioning.releaseMode) {
2018-04-29 13:29:07 -07:00
outputs.upToDateWhen { false }
}
// We follow a simple set of checks to determine whether we should generate a new version file:
2019-03-10 18:40:16 -07:00
// 1. If the release type is not development, we generate a new version file
// 2. If there is no generated version number, we generate a new version file
// 3. If there is a generated build number, and the release type is development, then we will
// only generate if the publish task is run.
doLast {
def version = wpilibVersioning.version.get()
println "Writing version ${version} to $wpilibVersionFileOutput"
2018-04-29 13:29:07 -07:00
if (wpilibVersionFileOutput.exists()) {
wpilibVersionFileOutput.delete()
}
def read = wpilibVersionFileInput.text.replace('${wpilib_version}', version)
2018-04-29 13:29:07 -07:00
wpilibVersionFileOutput.write(read)
}
}
2018-04-29 13:29:07 -07:00
gradle.taskGraph.addTaskExecutionGraphListener { graph ->
def willPublish = graph.hasTask(publish)
if (willPublish) {
generateJavaVersion.outputs.upToDateWhen { false }
}
}
sourceSets.main.java.srcDir "${buildDir}/generated/java/"
sourceSets.main.java.srcDir "${projectDir}/src/generated/main/java"
sourceSets.test.java.srcDir "${projectDir}/src/generated/test/java"
2018-04-29 13:29:07 -07:00
compileJava {
dependsOn generateJavaVersion
2016-12-08 00:24:44 -05:00
}
repositories {
2022-05-08 13:59:58 -07:00
maven {
url = 'https://frcmaven.wpi.edu/artifactory/ex-mvn'
}
}
Gradle Build This adds gradle support for building wpilibj and wpilibc. At this point, both of these libraries should be fully ready to go. Gradle should give us a number of improvements, including less dependencies for getting building up and running, and MUCH faster build times. I'm noticing significantly faster build times already compared to Maven, with neither system building the plugins. The changes here should be pretty straight forward. The basic command for gradle is './gradlew'. This is the gradle wrapper, and it will find and download the correct gradle executable for your system. There is no need to install anything yourself. To see every task available, run './gradlew tasks'. The important tasks for us are listed under the WPILib header when the tasks command is run. To generate unit test binaries, the fRCUserProgramExecutable command will create the C++ tester, and the wpilibjIntegrationTestJar command will create the Java tester. The Jenkins deploy scripts have been modified to know the difference between maven generated and gradle generated jars with an environment variable. Creating the eclipse plugins still requires Maven, but gradle will handle calling it correctly and generating the proper dependencies for it. Create the plugins by calling ./gradlew eclipsePlugins. Jenkins can now be modified to support the new build system. Unit tests are run with ./gradlew test. Generating the integration tests uses the above two commands, and then process proceeds exactly as it did before. For publishing documentation, a new task has been created, ./gradlew publishDocs, which handles putting the documentation where Jenkins expects for publishing. Change-Id: I9a260d391984f98ef9170993efe933e4026161dc
2015-05-05 09:54:14 -04:00
dependencies {
2019-11-12 17:14:04 -08:00
implementation project(':hal')
implementation project(':wpiutil')
implementation project(':wpinet')
implementation project(':wpimath')
2019-11-12 17:14:04 -08:00
implementation project(':ntcore')
implementation project(':cscore')
api project(':datalog')
2019-11-12 17:14:04 -08:00
implementation project(':cameraserver')
testImplementation(libs.bundles.mockito)
2019-11-12 17:14:04 -08:00
devImplementation sourceSets.main.output
Gradle Build This adds gradle support for building wpilibj and wpilibc. At this point, both of these libraries should be fully ready to go. Gradle should give us a number of improvements, including less dependencies for getting building up and running, and MUCH faster build times. I'm noticing significantly faster build times already compared to Maven, with neither system building the plugins. The changes here should be pretty straight forward. The basic command for gradle is './gradlew'. This is the gradle wrapper, and it will find and download the correct gradle executable for your system. There is no need to install anything yourself. To see every task available, run './gradlew tasks'. The important tasks for us are listed under the WPILib header when the tasks command is run. To generate unit test binaries, the fRCUserProgramExecutable command will create the C++ tester, and the wpilibjIntegrationTestJar command will create the Java tester. The Jenkins deploy scripts have been modified to know the difference between maven generated and gradle generated jars with an environment variable. Creating the eclipse plugins still requires Maven, but gradle will handle calling it correctly and generating the proper dependencies for it. Create the plugins by calling ./gradlew eclipsePlugins. Jenkins can now be modified to support the new build system. Unit tests are run with ./gradlew test. Generating the integration tests uses the above two commands, and then process proceeds exactly as it did before. For publishing documentation, a new task has been created, ./gradlew publishDocs, which handles putting the documentation where Jenkins expects for publishing. Change-Id: I9a260d391984f98ef9170993efe933e4026161dc
2015-05-05 09:54:14 -04:00
}
2018-04-29 13:29:07 -07:00
apply plugin: 'cpp'
apply plugin: 'org.wpilib.NativeUtils'
2018-04-29 13:29:07 -07:00
apply plugin: ExtraTasks
apply from: "${rootDir}/shared/config.gradle"
project(':').libraryBuild.dependsOn build
ext {
sharedCvConfigs = [wpilibjDev: []]
staticCvConfigs = [:]
useJava = true
useCpp = true
}
apply from: "${rootDir}/shared/opencv.gradle"
model {
components {
2018-04-29 13:29:07 -07:00
wpilibjDev(NativeExecutableSpec) {
targetBuildTypes 'debug'
sources {
cpp {
source {
2018-04-29 13:29:07 -07:00
srcDirs 'src/dev/native/cpp'
include '**/*.cpp'
}
2018-04-29 13:29:07 -07:00
exportedHeaders {
srcDirs 'src/dev/native/include'
}
}
}
2018-04-29 13:29:07 -07:00
binaries.all {
2022-10-08 10:01:31 -07:00
project(':ntcore').addNtcoreDependency(it, 'shared')
project(':ntcore').addNtcoreJniDependency(it)
2019-11-13 21:35:52 -08:00
lib project: ':cscore', library: 'cscore', linkage: 'shared'
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
2019-11-13 21:35:52 -08:00
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
2019-11-13 21:35:52 -08:00
lib project: ':cscore', library: 'cscoreJNIShared', linkage: 'shared'
lib project: ':wpinet', library: 'wpinetJNIShared', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutilJNIShared', linkage: 'shared'
lib project: ':wpimath', library: 'wpimathJNIShared', linkage: 'shared'
2019-11-13 21:35:52 -08:00
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
project(':hal').addHalDependency(it, 'shared')
project(':hal').addHalJniDependency(it)
2018-04-29 13:29:07 -07:00
}
}
}
tasks {
2018-04-29 13:29:07 -07:00
def c = $.components
project.tasks.create('runCpp', Exec) {
group = 'WPILib'
description = "Run the wpilibjDev executable"
def found = false
def systemArch = getCurrentArch()
c.each {
//println it.name
if (it in NativeExecutableSpec && it.name == "wpilibjDev") {
it.binaries.each {
2018-04-29 13:29:07 -07:00
if (!found) {
def arch = it.targetPlatform.name
2018-04-29 13:29:07 -07:00
if (arch == systemArch) {
dependsOn it.tasks.install
commandLine it.tasks.install.runScriptFile.get().asFile.toString()
def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib'
test.dependsOn it.tasks.install
test.systemProperty 'java.library.path', filePath
run.dependsOn it.tasks.install
run.systemProperty 'java.library.path', filePath
found = true
}
}
}
}
}
}
}
}
def oldWpilibVersionFile = file('src/main/java/org/wpilib/system/WPILibVersion.java')
2018-04-29 13:29:07 -07:00
clean {
delete oldWpilibVersionFile
}
test {
testLogging {
outputs.upToDateWhen {false}
showStandardStreams = true
}
}
apply from: "${rootDir}/shared/javaDesktopTestTask.gradle"