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
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,27 @@ on:
- main
workflow_dispatch:

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '21' ]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- name: Print Java version
run: java -version
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
uses: gradle/actions/setup-gradle@v5
- name: Run tests
run: ./gradlew --no-daemon --stacktrace clean build
42 changes: 22 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ plugins {
id 'idea'

// keep dependencies up-to-date!
id 'com.github.ben-manes.versions' version '0.53.0'
alias(libs.plugins.versions)

// to ensure clean code
id "net.ltgt.errorprone" version "5.0.0"
alias(libs.plugins.errorprone)

// for deployment to Maven Central
id "com.vanniktech.maven.publish" version "0.36.0"
alias(libs.plugins.maven.publish)
}

group = 'com.arakelian'
Expand Down Expand Up @@ -58,29 +58,31 @@ mavenPublishing {
}

dependencies {
annotationProcessor 'org.immutables:value:2.10.1'
annotationProcessor libs.immutables.value

// annotations
api 'org.immutables:value-annotations:2.10.1'
api libs.immutables.annotations

// for date utils
api 'com.arakelian:more-commons:5.1.0'
api libs.more.commons

// configure errorprone version
errorprone 'com.google.errorprone:error_prone_core:2.36.0'
errorprone libs.errorprone.core

// we use Guava directly
api 'com.google.guava:guava:33.4.0-jre'

// logging
testImplementation 'org.apache.logging.log4j:log4j-api:2.24.3'
testImplementation 'org.apache.logging.log4j:log4j-core:2.24.3'
testImplementation 'org.apache.logging.log4j:log4j-slf4j2-impl:2.24.3'
testImplementation 'org.slf4j:jcl-over-slf4j:2.0.16'
testImplementation 'org.slf4j:jul-to-slf4j:2.0.16'
api 'org.slf4j:slf4j-api:2.0.16'

// for unit testing
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
api libs.guava

// logging (Log4j versions managed by BOM)
testImplementation platform(libs.log4j.bom)
testImplementation libs.log4j.api
testImplementation libs.log4j.core
testImplementation libs.log4j.slf4j2.impl
testImplementation libs.jcl.over.slf4j
testImplementation libs.jul.to.slf4j
api libs.slf4j.api

// for unit testing (JUnit versions managed by BOM)
testImplementation platform(libs.junit.bom)
testImplementation libs.junit.jupiter
testRuntimeOnly libs.junit.platform.launcher
}
100 changes: 53 additions & 47 deletions core.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@

ext {
// useful macros, you can add your own
macros = [
'all' : [
'clean',
'classpath',
'build',
'publishToMavenLocal'
],
'classpath' : [
'cleanEclipseClasspath',
'eclipseClasspath',
'eclipseFactoryPath',
'cleanIdeaModule',
'ideaModule'
],
]

// package patterns to exclude from Eclipse
excludeFromEclipse = []
}
Expand All @@ -41,13 +24,21 @@ tasks.named('test') {


// -------------------------------------------
// JAVA COMPILER
// JAVA TOOLCHAIN
// -------------------------------------------

tasks.withType(JavaCompile).configureEach { task ->
sourceCompatibility = 21
targetCompatibility = 21
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}


// -------------------------------------------
// JAVA COMPILER
// -------------------------------------------

tasks.withType(JavaCompile).configureEach {
// always UTF-8
options.encoding = 'UTF-8'

Expand Down Expand Up @@ -162,46 +153,61 @@ eclipse {
}


// -------------------------------------------
// ECLIPSE FACTORY PATH (for annotation processing)
// -------------------------------------------

tasks.register('eclipseFactoryPath') {
description = 'Generates the .factorypath file for Eclipse annotation processing'

doLast {
def factorypath = new File(projectDir, '.factorypath')
factorypath.withWriter { writer ->
writer.writeLine '<?xml version="1.0" encoding="UTF-8"?>'
writer.writeLine '<factorypath>'
configurations.annotationProcessor.resolvedConfiguration.resolvedArtifacts.each { artifact ->
writer.writeLine " <factorypathentry kind=\"EXTJAR\" id=\"${artifact.file.absolutePath}\" enabled=\"true\" runInBatchMode=\"false\" />"
}
writer.writeLine '</factorypath>'
}
println "Generated ${factorypath}"
}
}


// -------------------------------------------
// README
// -------------------------------------------

tasks.register('readme') {
doLast {
ant.replaceregexp(match:'\\<version\\>([0-9\\.]+)\\<\\/version\\>', replace:"<version>${version}</version>", flags:'g', byline:true) {
fileset(dir: '.', includes: 'README.md')
}
ant.replaceregexp(match:'com\\.arakelian\\:' + project.name + ':([0-9\\.]+)', replace:"com.arakelian:${project.name}:${version}", flags:'g', byline:true) {
fileset(dir: '.', includes: 'README.md')
}
def readmeFile = file('README.md')
def content = readmeFile.text
content = content.replaceAll(/<version>[0-9.]+<\/version>/, "<version>${version}</version>")
content = content.replaceAll("com\\.arakelian:" + project.name + ":[0-9.]+", "com.arakelian:${project.name}:${version}")
readmeFile.text = content
}
}


// -------------------------------------------
// SHORTCUT TASKS
// LIFECYCLE TASKS
// -------------------------------------------

tasks.register('classpath') {
dependsOn 'cleanEclipseClasspath', 'eclipseClasspath',
'eclipseFactoryPath', 'cleanIdeaModule', 'ideaModule'
}

// This code allows us to define aliases, such as "all", so that when we do "gradle all",
// we can substitute in a series of other gradle tasks
// see: https://caffeineinduced.wordpress.com/2015/01/25/run-a-list-of-gradle-tasks-in-specific-order/
def newTasks = []
// ensure clean tasks run before generate tasks
tasks.named('eclipseClasspath') { mustRunAfter 'cleanEclipseClasspath' }
tasks.named('ideaModule') { mustRunAfter 'cleanIdeaModule' }

// gradle respects ordering of tasks specified on command line, so we replace shortcuts
// with equivalent commands as though they were specified by user
gradle.startParameter.taskNames.each { param ->
def macro = project.ext.macros[param]
if( macro ) {
macro.each { task ->
if(project.tasks.names.contains(task)) {
newTasks << task
}
}
} else {
newTasks << param
}
tasks.register('all') {
dependsOn 'clean', 'classpath', 'build', 'publishToMavenLocal'
}

// replace command line arguments
gradle.startParameter.taskNames = newTasks.flatten()
// ensure proper execution order
tasks.named('classpath') { mustRunAfter 'clean' }
tasks.named('build') { mustRunAfter 'classpath' }
tasks.named('publishToMavenLocal') { mustRunAfter 'build' }
34 changes: 34 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[versions]
errorprone = "2.36.0"
guava = "33.4.0-jre"
immutables = "2.10.1"
junit = "5.11.4"
log4j = "2.24.3"
more-commons = "5.1.0"
slf4j = "2.0.16"

errorprone-plugin = "5.0.0"
maven-publish-plugin = "0.36.0"
versions-plugin = "0.53.0"

[libraries]
errorprone-core = { module = "com.google.errorprone:error_prone_core", version.ref = "errorprone" }
guava = { module = "com.google.guava:guava", version.ref = "guava" }
immutables-value = { module = "org.immutables:value", version.ref = "immutables" }
immutables-annotations = { module = "org.immutables:value-annotations", version.ref = "immutables" }
junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" }
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter" }
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" }
log4j-bom = { module = "org.apache.logging.log4j:log4j-bom", version.ref = "log4j" }
log4j-api = { module = "org.apache.logging.log4j:log4j-api" }
log4j-core = { module = "org.apache.logging.log4j:log4j-core" }
log4j-slf4j2-impl = { module = "org.apache.logging.log4j:log4j-slf4j2-impl" }
more-commons = { module = "com.arakelian:more-commons", version.ref = "more-commons" }
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
jcl-over-slf4j = { module = "org.slf4j:jcl-over-slf4j", version.ref = "slf4j" }
jul-to-slf4j = { module = "org.slf4j:jul-to-slf4j", version.ref = "slf4j" }

[plugins]
versions = { id = "com.github.ben-manes.versions", version.ref = "versions-plugin" }
errorprone = { id = "net.ltgt.errorprone", version.ref = "errorprone-plugin" }
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish-plugin" }
3 changes: 3 additions & 0 deletions src/main/java/com/arakelian/json/JsonFilterOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
*/
@Value.Immutable(copy = false)
public abstract class JsonFilterOptions {
/** Constructs a new {@code JsonFilterOptions}. */
protected JsonFilterOptions() {
}
/**
* Returns the optional callback for custom processing during filtering.
*
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/arakelian/json/JsonReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public JsonParseException(final String msg) {
* Enumeration of JSON token types that can be encountered during parsing.
*/
public enum JsonToken {
// Event indicating a JSON string value, including member names of objects
/** Event indicating a JSON string value, including member names of objects. */
STRING,

// Event indicating a JSON number value which fits into a signed 64 bit integer
/** Event indicating a JSON number value which fits into a signed 64 bit integer. */
LONG,

/**
Expand All @@ -65,25 +65,25 @@ public enum JsonToken {
*/
BIGNUMBER,

// Event indicating a JSON boolean
/** Event indicating a JSON boolean. */
BOOLEAN,

// Event indicating a JSON null
/** Event indicating a JSON null. */
NULL,

// Event indicating the start of a JSON object
/** Event indicating the start of a JSON object. */
OBJECT_START,

// Event indicating the end of a JSON object
/** Event indicating the end of a JSON object. */
OBJECT_END,

// Event indicating the start of a JSON array
/** Event indicating the start of a JSON array. */
ARRAY_START,

// Event indicating the end of a JSON array
/** Event indicating the end of a JSON array. */
ARRAY_END,

// Event indicating the end of input has been reached
/** Event indicating the end of input has been reached. */
EOF;
}

Expand Down Expand Up @@ -853,7 +853,7 @@ private int readCharUntilWs() throws IOException {
if ((WS_MASK >> ch & 0x01) == 0) {
return ch;
} else if (ch <= ' ') { // this will only be true if one of the whitespace bits was set
continue;
// skip whitespace
} else if (!isWhitespace(ch)) { // we'll only reach here with certain bare strings,
// errors, or strange whitespace like 0xa0
return ch;
Expand Down
Loading