From 43b08927db6c18299c6083986f94916315b59690 Mon Sep 17 00:00:00 2001 From: sttk Date: Sat, 26 Apr 2025 18:05:44 +0900 Subject: [PATCH 1/2] chore: created development environment --- .gitattribute | 1 + .github/workflows/java-ci.yml | 28 ++++ .github/workflows/javadoc.yml | 28 ++++ .github/workflows/publish.yml | 45 ++++++ .gitignore | 14 ++ .gitmessage.txt | 19 +++ LICENSE | 21 +++ build.sh | 115 +++++++++++++++ pom.xml | 270 ++++++++++++++++++++++++++++++++++ src/main/java/Sample.java | 5 + src/test/java/SampleTest.java | 11 ++ 11 files changed, 557 insertions(+) create mode 100644 .gitattribute create mode 100644 .github/workflows/java-ci.yml create mode 100644 .github/workflows/javadoc.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .gitignore create mode 100644 .gitmessage.txt create mode 100644 LICENSE create mode 100755 build.sh create mode 100644 pom.xml create mode 100644 src/main/java/Sample.java create mode 100644 src/test/java/SampleTest.java diff --git a/.gitattribute b/.gitattribute new file mode 100644 index 0000000..6313b56 --- /dev/null +++ b/.gitattribute @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.github/workflows/java-ci.yml b/.github/workflows/java-ci.yml new file mode 100644 index 0000000..1ed6961 --- /dev/null +++ b/.github/workflows/java-ci.yml @@ -0,0 +1,28 @@ +name: Java CI + +on: + push: + branches: [ '*', '*/*' ] + +jobs: + build: + name: Build for GraalVM (OpenJDK ${{ matrix.javaver }}) on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + javaver: [21, 22, 23, 24] + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - name: GitHub Action for GraalVM + uses: graalvm/setup-graalvm@v1 + with: + java-version: ${{ matrix.javaver }} + distribution: 'graalvm' + github-token: ${{ secrets.GITHUB_TOKEN }} + native-image-job-reports: 'true' + - name: Build and test + run: mvn package + - name: Native test + run: mvn -Pnative test diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml new file mode 100644 index 0000000..d3494a4 --- /dev/null +++ b/.github/workflows/javadoc.yml @@ -0,0 +1,28 @@ +name: Javadoc + +on: + release: + types: [ created ] + + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: GitHub Action for GraalVM + uses: graalvm/setup-graalvm@v1 + with: + java-version: 23 + distribution: 'graalvm' + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: Compile + run: mvn compile + - name: Javadoc + run: mvn javadoc:javadoc + - name: Publish Documentation on GitHub Pages + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./target/site/apidocs + diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..6913c26 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,45 @@ +name: Publish package to the Maven Central Repository and GitHub Packages + +on: + release: + types: [ created ] + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 23 + - name: Build with Maven + run: mvn -ntp -B package + - name: Publish to GitHub Packages + run: mvn -ntp -B -DskipTests -Prelease-gh deploy + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Maven Central Repository + uses: actions/setup-java@v4 + with: + java-version: '23' + distribution: 'temurin' + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-private-key: ${{ secrets.OSSRH_GPG_PRIVATE_KEY }} + gpg-passphrase: MAVEN_GPG_PASSPHRASE + - name: Publish to the Maven Central Repository + run: | + mvn -ntp -B -DskipTests -Prelease-ossrh deploy + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_PASSPHRASE }} + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..45e5f9f --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +# Java +*.class +*.jar +*.war +*.ear +hs_err_pid* + +# Directories +target/ +test-results-native/ + +# OS generating files +.DS_Store +Thumbs.db diff --git a/.gitmessage.txt b/.gitmessage.txt new file mode 100644 index 0000000..3e9444c --- /dev/null +++ b/.gitmessage.txt @@ -0,0 +1,19 @@ + + +########50 characters############################ +## Prefix examples: +# +# new: a new feature +# fix: a bug fix +# update: a slight change +# merge: merge pull request +# style: only code style changes +# comment: only comment changes +# refactor: code changes that do not affect the behavior +# perf: a code change that improves performance +# deps: bump deps used on compiling or runtime +# test: update test files +# cicd: update CI/CD confguration files. +# doc: documentation only changes +# wip: work in progress +# chore: bump test deps, modify build files, etc diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9454692 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Takayuki Sato + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..da1d0bd --- /dev/null +++ b/build.sh @@ -0,0 +1,115 @@ +#!/usr/bin/env bash + +errcheck() { + exitcd=$1 + if [[ "$exitcd" != "0" ]]; then + exit $exitcd + fi +} + +clean() { + mvn clean + errcheck $? +} + +compile() { + mvn compile + errcheck $? +} + +format() { + mvn formatter:format + errcheck $? +} + +test() { + mvn test + errcheck $? +} + +jar() { + mvn package + errcheck $? +} + +javadoc() { + mvn javadoc:javadoc + errcheck $? +} + +deps() { + mvn versions:display-dependency-updates + errcheck $? +} + +sver() { + serialver -classpath target/classes $1 + errcheck $? +} + +trace_test() { + mvn -Ptrace test + errcheck $? +} + +native_test() { + mvn -Pnative test + errcheck $? +} + +deploy() { + mvn deploy + errcheck $? +} + + +if [[ "$#" == "0" ]]; then + clean + format + jar + javadoc + native_test +else + for a in "$@"; do + case "$a" in + clean) + clean + ;; + compile) + compile + ;; + format) + format + ;; + test) + test + ;; + jar) + jar + ;; + javadoc) + javadoc + ;; + deps) + deps + ;; + sver) + sver $2 + ;; + 'trace-test') + trace_test + ;; + 'native-test') + native_test + ;; + deploy) + deploy + ;; + *) + echo "Bad task: $a" + exit 1 + ;; + esac + done +fi + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a3566aa --- /dev/null +++ b/pom.xml @@ -0,0 +1,270 @@ + + + + 4.0.0 + + io.github.sttk + errs + 0.1.0 + jar + + errs + A library for handling errors with reasons for Java + https://github.com/sttk/errs-java + + + + The MIT License + https://opensource.org/license/mit/ + repo + + + + + + sttk + Takayuki Sato + https://github.com/sttk + + + + + https://github.com/sttk/errs-java + scm:git:git://github.com/sttk/errs-java.git + scm:git:git://github.com/sttk/errs-java.git + + + + 21 + UTF-8 + + --add-opens java.base/java.lang=ALL-UNNAMED + + + + + org.junit.jupiter + junit-jupiter-api + 5.13.0-M2 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.13.0-M2 + test + + + org.junit.platform + junit-platform-launcher + 1.13.0-M2 + test + + + org.assertj + assertj-core + 4.0.0-M1 + test + + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.11.2 + + true + 21 + protected + UTF-8 + UTF-8 + UTF-8 + + + + + + aggregate + + site + + + attach-javadoc + + jar + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.13 + + + default-prepare-agent + + prepare-agent + + + + default-report + test + + report + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.0 + + + -g + -Xlint + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.5.3 + + + net.revelc.code.formatter + formatter-maven-plugin + 2.26.0 + + + + + + + native + + + + org.graalvm.buildtools + native-maven-plugin + 0.10.6 + true + + + native test + + test + + test + + + + false + + + -J--add-opens=java.base/java.lang=ALL-UNNAMED + --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig + --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter + + + + + + + + trace + + -agentlib:native-image-agent=config-output-dir=target/native-trace + + + + release-gh + + + github + GitHub Packages + https://maven.pkg.github.com/sttk/stringcase-java + + + + + release-ossrh + + + ossrh + Central Repository OSSRH (Snapshot) + https://s01.oss.sonatype.org/content/repositories/snapshots + + + ossrh + Central Repository OSSRH + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + true + + + deploy + + deploy + + + + + ossrh + https://s01.oss.sonatype.org + true + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.1.0 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + + + + diff --git a/src/main/java/Sample.java b/src/main/java/Sample.java new file mode 100644 index 0000000..7cb5f74 --- /dev/null +++ b/src/main/java/Sample.java @@ -0,0 +1,5 @@ +public class Sample { + public String hello() { + return "Hello"; + } +} diff --git a/src/test/java/SampleTest.java b/src/test/java/SampleTest.java new file mode 100644 index 0000000..990d20a --- /dev/null +++ b/src/test/java/SampleTest.java @@ -0,0 +1,11 @@ +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.jupiter.api.Test; + +public class SampleTest { + + @Test + void hello() { + var sample = new Sample(); + assertThat(sample.hello()).isEqualTo("Hello"); + } +} From 4776f706b8b4148c279beb0d488a02c8d58bce73 Mon Sep 17 00:00:00 2001 From: sttk Date: Sat, 26 Apr 2025 18:14:06 +0900 Subject: [PATCH 2/2] fix: modified what pointed out --- .gitmessage.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmessage.txt b/.gitmessage.txt index 3e9444c..0c79dab 100644 --- a/.gitmessage.txt +++ b/.gitmessage.txt @@ -13,7 +13,7 @@ # perf: a code change that improves performance # deps: bump deps used on compiling or runtime # test: update test files -# cicd: update CI/CD confguration files. +# cicd: update CI/CD configuration files. # doc: documentation only changes # wip: work in progress # chore: bump test deps, modify build files, etc