Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
id 'groovy-gradle-plugin'
}

dependencies {
// Spotless code formatter.
implementation('com.diffplug.spotless:com.diffplug.spotless.gradle.plugin:6.25.0')
}

repositories {
gradlePluginPortal()
}
50 changes: 50 additions & 0 deletions buildSrc/src/main/groovy/java-common-conventions.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
plugins {
// Apply the java-library plugin for API and implementation separation.
id 'java-library'
id 'com.diffplug.spotless'
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

tasks.withType(JavaCompile) {
// Configure string concat to always inline compile
options.compilerArgs.add '-XDstringConcat=inline'
}

tasks.named('jar') {
manifest {
attributes(
'Implementation-Title': project.name,
'Implementation-Version': project.version,
)
}
}

spotless {
// See https://github.com/diffplug/spotless/tree/main/plugin-gradle
format 'misc', {
// define the files to apply `misc` to
target '.gitattributes', '.gitignore'

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
groovyGradle {
greclipse().configFile('../greclipse-gradle.properties')
}
java {
importOrder() // Use the default importOrder configuration (can override)
removeUnusedImports()

// Use Google Java Format
// - aosp() causes it to use a four-space indent
googleJavaFormat('1.24.0').reflowLongStrings()

formatAnnotations() // fix formatting of type annotations
}
}
File renamed without changes.
59 changes: 2 additions & 57 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,9 @@
*/

plugins {
// Apply the java-library plugin for API and implementation separation.
id 'java-library'
id 'java-common-conventions'
id 'edu.wpi.first.GradleRIO' version '2025.1.1'
id 'maven-publish'
// Spotless code formatter.
id 'com.diffplug.spotless' version '6.25.0'
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

tasks.withType(JavaCompile) {
// Configure string concat to always inline compile
options.compilerArgs.add '-XDstringConcat=inline'
}

version = '2.0.0-alpha.1'
Expand Down Expand Up @@ -59,18 +46,11 @@ dependencies {
wpi.java.configureTestTasks(test)

tasks.named('test') {
// Use JUnit 4 for unit tests.
// Support running both JUnit Vintage and JUnit Jupiter tests
useJUnitPlatform()
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
}

tasks.named('jar') {
manifest {
attributes('Implementation-Title': project.name,
'Implementation-Version': project.version)
}
}

javadoc {
options.tags = [
// Converts `@apiNote` paragraph to "Note: " section in the generated javadoc
Expand All @@ -80,46 +60,11 @@ javadoc {
]
}

// Generates Javadocs for test libraries under /build/docs/testjavadoc
// https://discuss.gradle.org/t/how-configure-gradle-to-generate-javadoc-for-testing-classes-junit/12764/6
task testJavadoc(type: Javadoc) {
source = sourceSets.test.allJava
classpath = sourceSets.test.compileClasspath
destinationDir = file("${buildDir}/docs/testjavadoc")
println (title == null ? '<null>' : title)
}

task sourceJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}

spotless {
// See https://github.com/diffplug/spotless/tree/main/plugin-gradle
format 'misc', {
// define the files to apply `misc` to
target '.gitattributes', '.gitignore'

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
groovyGradle {
greclipse().configFile('greclipse-gradle.properties')
}
java {
importOrder() // Use the default importOrder configuration (can override)
removeUnusedImports()

// Use Google Java Format
// - aosp() causes it to use a four-space indent
googleJavaFormat('1.24.0').reflowLongStrings()

formatAnnotations() // fix formatting of type annotations
}
}

publishing {
publications {
lib2813(MavenPublication) {
Expand Down
38 changes: 4 additions & 34 deletions limelight/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id 'java-library'
id 'java-common-conventions'
id "edu.wpi.first.GradleRIO" version "2025.1.1"
id 'idea'
// Spotless code formatter.
id 'com.diffplug.spotless' version '6.25.0'
id 'com.diffplug.spotless'
}

idea {
Expand All @@ -13,24 +13,20 @@ idea {
}
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

repositories {
mavenCentral()
}

dependencies {
implementation wpi.java.deps.wpilib()
implementation wpi.java.vendor.java()
implementation 'com.google.code.gson:gson:2.12.1'

api "org.json:json:20240205"

testImplementation 'junit:junit:4.13.2'
testImplementation 'com.google.truth:truth:1.4.4'
implementation 'com.google.code.gson:gson:2.12.1'
testImplementation project(':testing')

nativeDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.desktop)
nativeDebug wpi.java.vendor.jniDebug(wpi.platforms.desktop)
Expand All @@ -47,29 +43,3 @@ tasks.named('test') {
// Use JUnit 4 for tests
useJUnit()
}

spotless {
// See https://github.com/diffplug/spotless/tree/main/plugin-gradle
format 'misc', {
// define the files to apply `misc` to
target '.gitattributes', '.gitignore'

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
groovyGradle {
greclipse().configFile('greclipse-gradle.properties')
}
java {
importOrder() // Use the default importOrder configuration (can override)
removeUnusedImports()

// Use Google Java Format
// - aosp() causes it to use a four-space indent
googleJavaFormat('1.24.0').reflowLongStrings()

formatAnnotations() // fix formatting of type annotations
}
}
1 change: 0 additions & 1 deletion limelight/greclipse-gradle.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.team2813.lib2813.limelight.truth.Pose2dSubject.assertThat;
import static com.team2813.lib2813.limelight.truth.Pose3dSubject.assertThat;
import static com.team2813.lib2813.limelight.truth.Translation3dSubject.assertThat;
import static com.team2813.lib2813.testing.truth.Pose2dSubject.assertThat;
import static com.team2813.lib2813.testing.truth.Pose3dSubject.assertThat;
import static com.team2813.lib2813.testing.truth.Translation3dSubject.assertThat;
import static org.junit.Assert.assertEquals;

import edu.wpi.first.math.geometry.Pose2d;
Expand Down
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@

rootProject.name = 'lib2813'
include('lib')
include('limelight')
include('limelight')
include('testing')
60 changes: 60 additions & 0 deletions testing/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
plugins {
id 'java-common-conventions'
id 'edu.wpi.first.GradleRIO' version '2025.1.1'
}

version = '1.0.0-alpha.1'

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

dependencies {
implementation wpi.java.deps.wpilib()
implementation wpi.java.vendor.java()
implementation 'com.google.truth:truth:1.4.4'

nativeDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.desktop)
nativeDebug wpi.java.vendor.jniDebug(wpi.platforms.desktop)
simulationDebug wpi.sim.enableDebug()

nativeRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.desktop)
nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop)
simulationRelease wpi.sim.enableRelease()
testImplementation(platform('org.junit:junit-bom:5.13.1'))
testImplementation('org.junit.jupiter:junit-jupiter')
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
}

// the magic line that makes tests work :)
wpi.java.configureTestTasks(test)

tasks.named('test') {
// Support running both JUnit Vintage and JUnit Jupiter tests
useJUnitPlatform()
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
}

javadoc {
options.tags = [
// Converts `@apiNote` paragraph to "Note: " section in the generated javadoc
'apiNote:a:Api Note:',
// Converts `@implSpec` paragraph to "Implementation Requirements: " section in the generated javadoc
'implSpec:a:Implementation Requirements:'
]
}

// Generates Javadocs for test libraries under /build/docs/testjavadoc
// https://discuss.gradle.org/t/how-configure-gradle-to-generate-javadoc-for-testing-classes-junit/12764/6
task testJavadoc(type: Javadoc) {
source = sourceSets.test.allJava
classpath = sourceSets.test.compileClasspath
destinationDir = file("${buildDir}/docs/testjavadoc")
println (title == null ? '<null>' : title)
}

task sourceJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.team2813.lib2813.limelight.truth;
package com.team2813.lib2813.testing.truth;

import static com.google.common.truth.Fact.simpleFact;
import static com.google.common.truth.Truth.assertAbout;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.team2813.lib2813.limelight.truth;
package com.team2813.lib2813.testing.truth;

import static com.google.common.truth.Fact.simpleFact;
import static com.google.common.truth.Truth.assertAbout;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.team2813.lib2813.limelight.truth;
package com.team2813.lib2813.testing.truth;

import static com.google.common.truth.Fact.simpleFact;
import static com.google.common.truth.Truth.assertAbout;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.team2813.lib2813.limelight.truth;
package com.team2813.lib2813.testing.truth;

import static com.google.common.truth.Fact.simpleFact;
import static com.google.common.truth.Truth.assertAbout;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.team2813.lib2813.limelight.truth;
package com.team2813.lib2813.testing.truth;

import org.jspecify.annotations.Nullable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.team2813.lib2813.limelight.truth;
package com.team2813.lib2813.testing.truth;

import static com.google.common.truth.Fact.simpleFact;
import static com.google.common.truth.Truth.assertAbout;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.team2813.lib2813.limelight.truth;
package com.team2813.lib2813.testing.truth;

import static com.google.common.truth.Fact.simpleFact;
import static com.google.common.truth.Truth.assertAbout;
Expand Down
Loading