Files
allwpilib/wpilibj/build.gradle

321 lines
10 KiB
Groovy
Raw Normal View History

import edu.wpi.first.nativeutils.NativeUtils
import org.gradle.api.file.FileCollection
import org.gradle.internal.os.OperatingSystem
repositories {
mavenCentral()
}
apply plugin: 'cpp'
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
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
apply plugin: 'java'
apply plugin: 'net.ltgt.errorprone'
2016-12-08 00:24:44 -05:00
apply plugin: 'pmd'
configurations.errorprone {
resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.9'
}
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
apply from: '../config.gradle'
sourceSets {
dev
}
task nativeTestFilesJar(type: Jar) {
destinationDir = project.buildDir
classifier = "nativeTestFiles"
project.model {
binaries {
withType(SharedLibraryBinarySpec) { binary ->
if (binary.component.name == 'wpilibJNIStatic') {
from(binary.sharedLibraryFile) {
into NativeUtils.getPlatformPath(binary)
}
dependsOn binary.buildTask
}
}
}
}
}
task run(type: JavaExec) {
classpath = sourceSets.dev.runtimeClasspath
main = 'edu.wpi.first.wpilibj.DevMain'
}
test.dependsOn nativeTestFilesJar
run.dependsOn nativeTestFilesJar
def versionClass = """
package edu.wpi.first.wpilibj.util;
/*
* Autogenerated file! Do not manually edit this file. This version is regenerated
* any time the publish task is run, or when this file is deleted.
*/
public final class WPILibVersion {
public static final String Version = "${WPILibVersion.version}";
}
""".trim()
def wpilibVersionFile = file('src/main/java/edu/wpi/first/wpilibj/util/WPILibVersion.java')
def willPublish = false
gradle.taskGraph.addTaskExecutionGraphListener { graph ->
willPublish = graph.hasTask(publish)
}
task generateJavaVersion() {
description = 'Generates the wpilib version class.'
group = 'WPILib'
// We follow a simple set of checks to determine whether we should generate a new version file:
// 1. If the release type is not development, we generate a new verison 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 {
if (!WPILibVersion.releaseType.toString().equalsIgnoreCase('official') && !willPublish && wpilibVersionFile.exists()) {
return
}
println "Writing version ${WPILibVersion.version} to $wpilibVersionFile"
if (wpilibVersionFile.exists()) {
wpilibVersionFile.delete()
}
wpilibVersionFile.write(versionClass)
}
}
clean {
delete wpilibVersionFile
}
compileJava.dependsOn generateJavaVersion
2016-12-08 00:24:44 -05:00
pmd {
sourceSets = [sourceSets.main]
2016-12-08 00:24:44 -05:00
consoleOutput = true
reportsDir = file("$project.buildDir/reports/pmd")
ruleSetFiles = files(new File(rootDir, "styleguide/pmd-ruleset.xml"))
ruleSets = []
}
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 {
compile 'edu.wpi.first.wpiutil:wpiutil-java:3.+'
compile 'edu.wpi.first.ntcore:ntcore-java:4.+'
compile 'org.opencv:opencv-java:3.2.0'
compile 'edu.wpi.first.cscore:cscore-java:1.+'
testCompile 'org.hamcrest:hamcrest-all:1.3'
testCompile 'junit:junit:4.12'
testCompile 'com.google.guava:guava:19.0'
testRuntime files(project.nativeTestFilesJar.archivePath)
testRuntime 'edu.wpi.first.ntcore:ntcore-jni:4.+:all'
testRuntime 'org.opencv:opencv-jni:3.2.0:all'
testRuntime 'edu.wpi.first.cscore:cscore-jni:1.+:all'
devCompile 'edu.wpi.first.wpiutil:wpiutil-java:3.+'
devCompile 'edu.wpi.first.ntcore:ntcore-java:4.+'
devCompile 'org.opencv:opencv-java:3.2.0'
devCompile 'edu.wpi.first.cscore:cscore-java:1.+'
devCompile sourceSets.main.output
devRuntime files(project.nativeTestFilesJar.archivePath)
devRuntime 'edu.wpi.first.ntcore:ntcore-jni:4.+:all'
devRuntime 'org.opencv:opencv-jni:3.2.0:all'
devRuntime 'edu.wpi.first.cscore:cscore-jni:1.+:all'
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
}
def jniClasses = [
'edu.wpi.first.wpilibj.can.CANJNI',
'edu.wpi.first.wpilibj.hal.FRCNetComm',
'edu.wpi.first.wpilibj.hal.HAL',
'edu.wpi.first.wpilibj.hal.HALUtil',
'edu.wpi.first.wpilibj.hal.JNIWrapper',
'edu.wpi.first.wpilibj.hal.AccelerometerJNI',
'edu.wpi.first.wpilibj.hal.AnalogJNI',
'edu.wpi.first.wpilibj.hal.AnalogGyroJNI',
'edu.wpi.first.wpilibj.hal.ConstantsJNI',
'edu.wpi.first.wpilibj.hal.CounterJNI',
'edu.wpi.first.wpilibj.hal.DigitalGlitchFilterJNI',
'edu.wpi.first.wpilibj.hal.DIOJNI',
'edu.wpi.first.wpilibj.hal.EncoderJNI',
'edu.wpi.first.wpilibj.hal.I2CJNI',
'edu.wpi.first.wpilibj.hal.InterruptJNI',
'edu.wpi.first.wpilibj.hal.NotifierJNI',
'edu.wpi.first.wpilibj.hal.PortsJNI',
'edu.wpi.first.wpilibj.hal.PWMJNI',
'edu.wpi.first.wpilibj.hal.RelayJNI',
'edu.wpi.first.wpilibj.hal.SPIJNI',
'edu.wpi.first.wpilibj.hal.SolenoidJNI',
'edu.wpi.first.wpilibj.hal.CompressorJNI',
'edu.wpi.first.wpilibj.hal.PDPJNI',
'edu.wpi.first.wpilibj.hal.PowerJNI',
'edu.wpi.first.wpilibj.hal.SerialPortJNI',
'edu.wpi.first.wpilibj.hal.OSSerialPortJNI',
'edu.wpi.first.wpilibj.hal.ThreadsJNI',
]
model {
jniConfigs {
wpilibJNIShared(JNIConfig) {
jniDefinitionClasses = jniClasses
jniArmHeaderLocations = [ all: file("${projectDir}/src/arm-linux-jni") ]
sourceSets = [ project.sourceSets.main ]
}
wpilibJNIStatic(JNIConfig) {
jniDefinitionClasses = jniClasses
jniArmHeaderLocations = [ all: file("${projectDir}/src/arm-linux-jni") ]
sourceSets = [ project.sourceSets.main ]
}
}
exportsConfigs {
wpilibJNIShared(ExportsConfig) {
x86SymbolFilter = { symbols->
def retList = []
symbols.each { symbol->
if (symbol.startsWith('Java_') || symbol.startsWith('JNI_')) {
retList << symbol
}
}
return retList
}
x64SymbolFilter = { symbols->
def retList = []
symbols.each { symbol->
if (symbol.startsWith('Java_') || symbol.startsWith('JNI_')) {
retList << symbol
}
}
return retList
}
}
wpilibJNIStatic(ExportsConfig) {
x86SymbolFilter = { symbols->
def retList = []
symbols.each { symbol->
if (symbol.startsWith('Java_') || symbol.startsWith('JNI_')) {
retList << symbol
}
}
return retList
}
x64SymbolFilter = { symbols->
def retList = []
symbols.each { symbol->
if (symbol.startsWith('Java_') || symbol.startsWith('JNI_')) {
retList << symbol
}
}
return retList
}
}
}
dependencyConfigs {
wpiutil(DependencyConfig) {
groupId = 'edu.wpi.first.wpiutil'
artifactId = 'wpiutil-cpp'
headerClassifier = 'headers'
ext = 'zip'
version = '3.+'
sharedConfigs = [ wpilibJNIShared: [] ]
staticConfigs = [ wpilibJNIStatic: [] ]
}
}
components {
wpilibJNIStatic(NativeLibrarySpec) {
baseName = 'wpilibJNI'
binaries.withType(NativeBinarySpec) { binary ->
if (binary.targetPlatform.architecture.name == 'athena') {
binary.lib project: ':hal', library: 'halAthena', linkage: 'static'
} else {
binary.lib project: ':hal', library: 'halSim', linkage: 'static'
}
}
sources {
cpp {
source {
srcDirs = ['src/main/native/cpp']
includes = ['**/*.cpp']
}
}
}
}
wpilibJNIShared(NativeLibrarySpec) {
baseName = 'wpilibJNI'
binaries.withType(NativeBinarySpec) { binary ->
if (binary.targetPlatform.architecture.name == 'athena') {
binary.lib project: ':hal', library: 'halAthena', linkage: 'shared'
} else {
binary.lib project: ':hal', library: 'halSim', linkage: 'shared'
}
}
sources {
cpp {
source {
srcDirs = ['src/main/native/cpp']
includes = ['**/*.cpp']
}
}
}
}
}
binaries {
withType(NativeBinarySpec) {
project(':hal').addHalCompilerArguments(it)
project(':ni-libraries').addNiLibrariesToLinker(it)
}
withType(StaticLibraryBinarySpec) {
it.buildable = false
}
}
tasks {
getHeaders(Task) {
def list = []
$.components.each {
if (it in NativeLibrarySpec && it.name == 'wpilibJNIStatic') {
it.sources.each {
it.exportedHeaders.srcDirs.each {
list.add(it)
}
}
it.binaries.each {
it.libs.each {
it.includeRoots.each {
list.add(it)
}
}
}
}
}
// use file to normalize this dir
list.add(file("$buildDir/wpilibJNIStatic/jniinclude"))
list = list.unique(false)
doLast {
list.each {
print "WPIHEADER: "
println it
}
}
}
}
}
apply from: 'publish.gradle'
apply from: 'integrationTestingFiles.gradle'
test {
testLogging {
events "failed"
exceptionFormat "full"
}
}
if (project.hasProperty('onlyAthena')) {
test.enabled = false
}