From beed7466c14d3a09d9a79e7960ec7ccf023a18a6 Mon Sep 17 00:00:00 2001 From: j5155 <54331556+j5155@users.noreply.github.com> Date: Sun, 1 Dec 2024 22:32:41 +0000 Subject: [PATCH 1/4] Update releases.yml --- .github/workflows/releases.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 1f0475f..1ca20f0 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -42,5 +42,5 @@ jobs: - name: Publish to Dairy Snapshots run: ./gradlew publishAllPublicationsToDairyReleasesRepository env: - ORG_GRADLE_PROJECT_dairyReleasesUsername: ${{ secrets.RELEASES_USERNAME }} - ORG_GRADLE_PROJECT_dairyReleasesPassword: ${{ secrets.RELEASES_PASSWORD }} + ORG_GRADLE_PROJECT_dairyReleasesUsername: ${{ secrets.SNAPSHOTS_USERNAME }} + ORG_GRADLE_PROJECT_dairyReleasesPassword: ${{ secrets.SNAPSHOTS_PASSWORD }} From 8e8bcc8eaae9fe57b6f05400975ac3abe4df57f3 Mon Sep 17 00:00:00 2001 From: Rowan McAlpin <87948250+rowan-mcalpin@users.noreply.github.com> Date: Sun, 1 Dec 2024 15:24:12 -0800 Subject: [PATCH 2/4] Added ActionBuilder --- .../expressway/ftc/actions/ActionBuilder.kt | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 ftc/src/main/kotlin/page/j5155/expressway/ftc/actions/ActionBuilder.kt diff --git a/ftc/src/main/kotlin/page/j5155/expressway/ftc/actions/ActionBuilder.kt b/ftc/src/main/kotlin/page/j5155/expressway/ftc/actions/ActionBuilder.kt new file mode 100644 index 0000000..8b8db4f --- /dev/null +++ b/ftc/src/main/kotlin/page/j5155/expressway/ftc/actions/ActionBuilder.kt @@ -0,0 +1,92 @@ +package page.j5155.expressway.ftc.actions + +import android.app.Notification.Action +import com.acmerobotics.dashboard.telemetry.TelemetryPacket +import page.j5155.expressway.core.actions.Condition +import page.j5155.expressway.core.actions.InitLoopCondAction +import java.util.function.Consumer +import java.util.function.Supplier + +/** + * This class builds an InitLoopCondAction + * @param condition the condition for the action to complete + */ +class ActionBuilder(val condition: Condition) { + + private var initLambda: () -> Unit = { } + private var loopLambda: (TelemetryPacket) -> Unit = { } + private var cleanupLambda: () -> Unit = { } + + /** + * Set the initialization function + * @param initialization the initialization function + */ + fun setInit(initialization: () -> Unit): ActionBuilder { + initLambda = initialization + return this + } + + /** + * Set the initialization function + * @param initialization the initialization function + */ + fun setInit(initialization: Supplier): ActionBuilder { + initLambda = { initialization.get() } + return this + } + + /** + * Set the loop function + * @param loop the loop function + */ + fun setLoop(loop: (TelemetryPacket) -> Unit): ActionBuilder { + loopLambda = loop + return this + } + + /** + * Set the loop function + * @param loop the loop function + */ + fun setLoop(loop: Consumer): ActionBuilder { + loopLambda = { loop.accept(it) } + return this + } + + /** + * Set the cleanup function + * @param cleanup the cleanup function + */ + fun setCleanup(cleanup: () -> Unit): ActionBuilder { + cleanupLambda = cleanup + return this + } + + /** + * Set the cleanup function + * @param cleanup the cleanup function + */ + fun setCleanup(cleanup: Supplier): ActionBuilder { + cleanupLambda = { cleanup.get() } + return this + } + + /** + * Builds the InitLoopCondAction + */ + fun build(): InitLoopCondAction { + return object: InitLoopCondAction(condition) { + override fun loop(p: TelemetryPacket) { + loopLambda(p) + } + + override fun init() { + initLambda() + } + + override fun cleanup() { + cleanupLambda() + } + } + } +} \ No newline at end of file From 35fd5ab1eccbc647d74c67526825f7e914089146 Mon Sep 17 00:00:00 2001 From: Zach Harel Date: Sun, 1 Dec 2024 18:34:53 -0500 Subject: [PATCH 3/4] ActionBuilder: remove unneeded import + use functional interfaces like the other Action types --- .../expressway/ftc/actions/ActionBuilder.kt | 56 ++++--------------- 1 file changed, 11 insertions(+), 45 deletions(-) diff --git a/ftc/src/main/kotlin/page/j5155/expressway/ftc/actions/ActionBuilder.kt b/ftc/src/main/kotlin/page/j5155/expressway/ftc/actions/ActionBuilder.kt index 8b8db4f..a2b5742 100644 --- a/ftc/src/main/kotlin/page/j5155/expressway/ftc/actions/ActionBuilder.kt +++ b/ftc/src/main/kotlin/page/j5155/expressway/ftc/actions/ActionBuilder.kt @@ -1,6 +1,5 @@ package page.j5155.expressway.ftc.actions -import android.app.Notification.Action import com.acmerobotics.dashboard.telemetry.TelemetryPacket import page.j5155.expressway.core.actions.Condition import page.j5155.expressway.core.actions.InitLoopCondAction @@ -13,34 +12,16 @@ import java.util.function.Supplier */ class ActionBuilder(val condition: Condition) { - private var initLambda: () -> Unit = { } - private var loopLambda: (TelemetryPacket) -> Unit = { } - private var cleanupLambda: () -> Unit = { } + private var initInternal: Supplier = Supplier { } + private var loopInternal: Consumer = Consumer { } + private var cleanupInternal: Supplier = Supplier { } /** * Set the initialization function - * @param initialization the initialization function + * @param init the initialization function */ - fun setInit(initialization: () -> Unit): ActionBuilder { - initLambda = initialization - return this - } - - /** - * Set the initialization function - * @param initialization the initialization function - */ - fun setInit(initialization: Supplier): ActionBuilder { - initLambda = { initialization.get() } - return this - } - - /** - * Set the loop function - * @param loop the loop function - */ - fun setLoop(loop: (TelemetryPacket) -> Unit): ActionBuilder { - loopLambda = loop + fun setInit(init: Supplier): ActionBuilder { + initInternal = init return this } @@ -49,16 +30,7 @@ class ActionBuilder(val condition: Condition) { * @param loop the loop function */ fun setLoop(loop: Consumer): ActionBuilder { - loopLambda = { loop.accept(it) } - return this - } - - /** - * Set the cleanup function - * @param cleanup the cleanup function - */ - fun setCleanup(cleanup: () -> Unit): ActionBuilder { - cleanupLambda = cleanup + loopInternal = loop return this } @@ -67,7 +39,7 @@ class ActionBuilder(val condition: Condition) { * @param cleanup the cleanup function */ fun setCleanup(cleanup: Supplier): ActionBuilder { - cleanupLambda = { cleanup.get() } + cleanupInternal = cleanup return this } @@ -76,17 +48,11 @@ class ActionBuilder(val condition: Condition) { */ fun build(): InitLoopCondAction { return object: InitLoopCondAction(condition) { - override fun loop(p: TelemetryPacket) { - loopLambda(p) - } + override fun init() = initInternal.get() - override fun init() { - initLambda() - } + override fun loop(p: TelemetryPacket) = loopInternal.accept(p) - override fun cleanup() { - cleanupLambda() - } + override fun cleanup() = cleanupInternal.get() } } } \ No newline at end of file From 222982f36f510541c7d732c9993ffe26b29b7da7 Mon Sep 17 00:00:00 2001 From: j5155 <54331556+j5155@users.noreply.github.com> Date: Mon, 2 Dec 2024 02:03:45 +0000 Subject: [PATCH 4/4] Delete .github/workflows/snapshots.yml by request of oscar --- .github/workflows/snapshots.yml | 48 --------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 .github/workflows/snapshots.yml diff --git a/.github/workflows/snapshots.yml b/.github/workflows/snapshots.yml deleted file mode 100644 index aa04b7b..0000000 --- a/.github/workflows/snapshots.yml +++ /dev/null @@ -1,48 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created -# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle - -name: Publish Snapshots - -on: - push: - branches: - - 'master' - -jobs: - build: - - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: '21' - distribution: 'temurin' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 - - - name: Build with Gradle - run: ./gradlew build - - # The USERNAME and TOKEN need to correspond to the credentials environment variables used in - # the publishing section of your build.gradle - - name: Publish to Dairy Snapshots - run: ./gradlew publishAllPublicationsToDairySnapshotsRepository - env: - ORG_GRADLE_PROJECT_dairySnapshotsUsername: ${{ secrets.SNAPSHOTS_USERNAME }} - ORG_GRADLE_PROJECT_dairySnapshotsPassword: ${{ secrets.SNAPSHOTS_PASSWORD }}