diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 416d099..4ee582f 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -1,6 +1,10 @@ -name: Build with cached gradle +name: Build with gradle run-name: Building for ${{ gitea.actor }} -on: [pull_request] +on: + pull_request: + push: + branches: + - 'main' jobs: Build-with-gradle: @@ -15,4 +19,5 @@ jobs: # cache-dependency-path: | # optional # sub-project/*.gradle* # sub-project/**/gradle-wrapper.properties - - run: ./gradlew build --no-daemon \ No newline at end of file + - run: ./gradlew test --no-daemon + - run: ./gradlew publishAllPublicationsToGiteaRepository -PgradleKey=${{ secrets.GRADLE_KEY }} --no-daemon \ No newline at end of file diff --git a/.gitea/workflows/linting.yml b/.gitea/workflows/linting.yml index 0b6fb23..75a4779 100644 --- a/.gitea/workflows/linting.yml +++ b/.gitea/workflows/linting.yml @@ -1,10 +1,15 @@ name: Java Google Checkstyle +run-name: Linting for ${{ gitea.actor }} permissions: contents: read pull-request: write -on: [pull_request] +on: + pull_request: + push: + branches: + - 'main' jobs: checkstyle: @@ -16,16 +21,6 @@ jobs: REVIEWDOG_GITEA_API_TOKEN: ${{ secrets.REVIEWDOG_TOKEN }} GITEA_ADDRESS: http://gitea:3000 steps: - - name: 'Pull code' - uses: actions/checkout@v6 - - - name: 'Find changed Java files' - id: changed-files - uses: tj-actions/changed-files@v44 - with: - files: | - **.java - - name: 'Setup Java JDK' uses: actions/setup-java@v4 with: @@ -36,7 +31,16 @@ jobs: uses: reviewdog/action-setup@v1 with: reviewdog_version: latest -# reviewdog_version: ${{ env.REVIEWDOG_VERSION }} + + - name: 'Pull code' + uses: actions/checkout@v6 + + - name: 'Find changed Java files' + id: changed-files + uses: tj-actions/changed-files@v44 + with: + files: | + **.java - name: 'Run Checkstyle with Reviewdog' if: steps.changed-files.outputs.any_changed == 'true' @@ -46,7 +50,7 @@ jobs: echo "Changed files:" echo "${{ steps.changed-files.outputs.all_changed_files }}" - java -jar checkstyle-${{ env.CHECKSTYLE_VERSION }}-all.jar -c google_checks.xml -f xml ${{ steps.changed-files.outputs.all_changed_files }} \ + java -jar checkstyle-${{ env.CHECKSTYLE_VERSION }}-all.jar -c ./style_guide.xml -f xml ${{ steps.changed-files.outputs.all_changed_files }} \ | reviewdog -f=checkstyle \ -name="Checkstyle" \ -reporter="gitea-pr-review" \ diff --git a/build.gradle.kts b/build.gradle.kts index 7588752..98771a9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,12 +1,65 @@ plugins { id("java") + `maven-publish` + // Also commonly used for creating source/javadoc JARs + id("org.jetbrains.dokka") version "1.9.20" } group = "com.softwaresmyth" version = "1.0-SNAPSHOT" +val mySecret = project.findProperty("gradleKey") + +publishing { + // Define a publication, in this case for Maven + publications { + // other settings of publication + repositories { + maven { + name = "Gitea" + url = uri("https://gitea.softwaresmyth.com/api/packages/numbers/maven") + + credentials(HttpHeaderCredentials::class) { + name = "Authorization" + value = "token $mySecret" + } + + authentication { + create("header") + } + } + } +// +// create("Smythery") { +// // Specify which component to publish (usually "java" for a standard library) +// from(components["java"]) +// +// // Optional: Customize POM metadata (required for Maven Central) +// pom { +// name = "Ornot" +// description = "A library of methods that do nothing" +// url = "https://gitea.softwaresmyth.com/numbers/Ornot" +// licenses { +// license { +// name = "The Apache License, Version 2.0" +// url = "http://www.apache.org/licenses/LICENSE-2.0.txt" +// } +// } +// developers { +// developer { +// id = "Numbers" +// name = "Josh Chester" +// } +// } +// } +// } + } +} + repositories { mavenCentral() + // other repositories + maven { url = uri("https://gitea.softwaresmyth.com/api/packages/numbers/maven") } } dependencies { diff --git a/readme.md b/readme.md index 1f2c48d..67b8e8b 100644 --- a/readme.md +++ b/readme.md @@ -2,5 +2,10 @@ A ridiculous library that...does nothing. Contained are three methods that together cover every possible method signature. +Any instance where a method reference is expected and a no-op is needed can be covered by one of these three methods. -Any instance where a method reference is expected and a no-op is needed can be covered by one of these three methods. \ No newline at end of file +This project came about when I realized an `Object...` parameter might satisfy the type system for methods +that expected any combination of parameters. Turns out it does, including methods that take no arguments +such as implementations of `Supplier`. + +It continues here as my go-to place for learning CI actions with a small java project. diff --git a/src/test/java/com/softwaresmyth/functions/NoopTest.java b/src/test/java/com/softwaresmyth/functions/NoopTest.java index cd58a99..9175e24 100644 --- a/src/test/java/com/softwaresmyth/functions/NoopTest.java +++ b/src/test/java/com/softwaresmyth/functions/NoopTest.java @@ -6,12 +6,19 @@ import java.util.function.BiConsumer; import java.util.function.Consumer; class NoopTest { + + /** + * Test as a function with one argument. + */ @Test void TestOneArg() { Consumer toTest = OrNot::noop; toTest.accept("Ignored"); } + /** + * Test as a function with two arguments. + */ @Test void TestTwoArg() { BiConsumer toTest = OrNot::noop; diff --git a/style_guide.xml b/style_guide.xml new file mode 100644 index 0000000..f27b8be --- /dev/null +++ b/style_guide.xml @@ -0,0 +1,483 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +