Skip to content

Commit

Permalink
chore: Format java code (#103)
Browse files Browse the repository at this point in the history
* add formatting logic

* check formatting in ci

* apply formatting

* separate step for formatting

* remove grEclipse: has troubles with arm64-linux
  • Loading branch information
kevaundray authored Oct 25, 2024
1 parent 55b1cca commit e27b8b4
Show file tree
Hide file tree
Showing 9 changed files with 594 additions and 493 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/release-java-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ concurrency:
cancel-in-progress: true

jobs:
format:
name: Check Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: Check formatting
run: ./gradlew spotlessCheck
working-directory: bindings/java/java_code

build:
name: Build - ${{ matrix.target }}
runs-on: ${{ matrix.os }}
Expand Down
148 changes: 83 additions & 65 deletions bindings/java/java_code/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,35 @@ plugins {
group = 'io.github.crate-crypto'
version = '0.0.3'

spotless {
java {
// Apply Google's Java formatting style
googleJavaFormat()

// Remove unused imports
importOrder()
removeUnusedImports()

// Enforce Unix line endings
endWithNewline()
indentWithSpaces(4)
trimTrailingWhitespace()
}

// Use a simpler formatter for Gradle files
groovy {
target '*.gradle'
// Basic formatting rules instead of Eclipse formatter
// which seems to have issues on arm64-linux
indentWithSpaces(4)
trimTrailingWhitespace()
endWithNewline()
}
}

java {
withJavadocJar()
withSourcesJar()
withJavadocJar()
withSourcesJar()
}

repositories {
Expand All @@ -30,17 +55,14 @@ if (hasProperty('buildScan')) {
dependencies {
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'

implementation 'net.java.dev.jna:jna:5.12.1'
testImplementation 'io.tmio:tuweni-bytes:2.4.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.12.5'
testImplementation 'org.assertj:assertj-core:3.22.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2'

def jacksonVersion = "2.14.2"

testFixturesImplementation("org.apache.tuweni:tuweni-units:2.3.1")
testFixturesImplementation("com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}")
testFixturesImplementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${jacksonVersion}")
Expand All @@ -51,79 +73,75 @@ test {
dependsOn cleanTest
testLogging.showStandardStreams = true
}

publishing {
publications {
maven(MavenPublication) {
from components.java

pom {
name = 'Verkle Cryptography Library'
description = 'A library for working with Cryptography used in verkle trie'
url = 'https://github.com/crate-crypto/rust-verkle'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'kevthedev'
name = 'Kevaundray Wedderburn'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:git://github.com/crate-crypto/rust-verkle.git'
developerConnection = 'scm:git:ssh://github.com:crate-crypto/rust-verkle.git'
url = 'https://github.com/crate-crypto/rust-verkle'
publishing {
publications {
maven(MavenPublication) {
from components.java
pom {
name = 'Verkle Cryptography Library'
description = 'A library for working with Cryptography used in verkle trie'
url = 'https://github.com/crate-crypto/rust-verkle'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'kevthedev'
name = 'Kevaundray Wedderburn'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:git://github.com/crate-crypto/rust-verkle.git'
developerConnection = 'scm:git:ssh://github.com:crate-crypto/rust-verkle.git'
url = 'https://github.com/crate-crypto/rust-verkle'
}
}
}
}
}
}

repositories {
maven {
url = layout.buildDirectory.dir('staging-deploy')
repositories {
maven {
url = layout.buildDirectory.dir('staging-deploy')
}
}
}
}

jreleaser {
// Jreleaser will look for .git and its at the top level repository
gitRootSearch = true
release {
// Skip releases as this is handled by release-please
github {
skipRelease = true
gitRootSearch = true
release {
github {
skipRelease = true
}
}
signing {
active = 'ALWAYS'
armored = true
}
}
signing {
active = 'ALWAYS'
armored = true
}
deploy {
maven {
mavenCentral {
sonatype {
active = 'ALWAYS'
url = 'https://central.sonatype.com/api/v1/publisher'
stagingRepository('build/staging-deploy')
deploy {
maven {
mavenCentral {
sonatype {
active = 'ALWAYS'
url = 'https://central.sonatype.com/api/v1/publisher'
stagingRepository('build/staging-deploy')
}
}
}
}
}
}
}

// JReleaser does not create this directory, so we manually create it
// JReleaser does not create this directory, so we manually create it
// ourselves.
tasks.register('createJReleaserOutputDir') {
doLast {
mkdir 'build/jreleaser'
}
doLast {
mkdir 'build/jreleaser'
}
}

tasks.named('jreleaserFullRelease') {
dependsOn 'createJReleaserOutputDir'
}
dependsOn 'createJReleaserOutputDir'
}
1 change: 0 additions & 1 deletion bindings/java/java_code/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
rootProject.name = 'java-verkle-cryptography'

Loading

0 comments on commit e27b8b4

Please sign in to comment.