Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A simple picocli/native-image ion-java CLI #988

Draft
wants to merge 132 commits into
base: ion-11-encoding
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
98f351b
Updates write support for binary Ion 1.1 decimals and timestamps (#644)
popematt Nov 20, 2023
f8a7d5f
Prepares to support reading binary Ion 1.1.
tgregg Nov 8, 2023
27851d7
Adds support for reading binary Ion 1.1 timestamps.
tgregg Nov 15, 2023
6b71492
Adds support for reading binary Ion 1.1 nulls, booleans, ints, and fl…
tgregg Nov 16, 2023
775ab2e
Improves the readability of IonTypeID and makes other minor changes t…
tgregg Nov 16, 2023
b7a8f88
Updates read support for binary Ion 1.1 timestamps.
tgregg Nov 17, 2023
36906ec
Adds support for reading binary normalized half-precision floats; add…
tgregg Nov 18, 2023
483ff6b
Adds support for reading binary Ion 1.1 decimals.
tgregg Nov 21, 2023
52794dd
Adds support for reading binary Ion 1.1 string values, symbol values …
tgregg Nov 21, 2023
064c92c
Updates KtLint and adds editorconfig
popematt Nov 22, 2023
4e2daae
Copy ion-element-kotlin into ion-java
popematt Nov 21, 2023
89a1602
Updates THIRD_PARTY_LICENSES.md for ion-element-kotlin
popematt Nov 22, 2023
2eca592
Adds data model for macro definitions
popematt Nov 22, 2023
0b7f4ff
Makes SpotBugs ignore Kotlin
popematt Nov 22, 2023
d5ca028
Adds IonWriter_1_1 interface (#656)
popematt Nov 27, 2023
e1efc19
Optimizes parsing of binary Ion 1.1 numeric types.
tgregg Nov 29, 2023
87a5c92
Initial implementation of Ion 1.1 raw binary writer (#660)
popematt Dec 1, 2023
9ca8330
Run CI for all pull requests (#663)
popematt Dec 7, 2023
add35d8
Adds annotations to IonRawBinaryWriter_1_1 (#661)
popematt Dec 7, 2023
255eb4c
Adds support for writing Ion 1.1 sexps and structs (#665)
popematt Dec 8, 2023
e1181e4
Adds support for all scalar types to IonRawBinaryWriter_1_1 (#667)
popematt Dec 11, 2023
2d7ca09
Fix SID_TO_FLEX_SYM_SWITCH_MARKER (#673)
popematt Dec 14, 2023
65d15ad
Adds support for reading binary Ion 1.1 annotations.
tgregg Dec 7, 2023
b4b19c7
Adds support for reading Ion 1.1 length-prefixed structs.
tgregg Dec 13, 2023
470c0e4
Addresses feedback on PRs 666 and 671.
tgregg Dec 13, 2023
9103bfc
Corrects the struct FlexSym transition byte to FlexUInt 0 instead of …
tgregg Dec 14, 2023
f29522b
Adds support for macros to IonRawBinaryWriter_1_1 (#668)
popematt Dec 15, 2023
8455b23
Adds IonRawTextWriter_1_1 (#682)
popematt Jan 2, 2024
28088b9
Adds macro compiler (#697)
popematt Jan 25, 2024
8c4a6f1
Removes embedded copy of ion-element-kotlin
popematt Feb 22, 2024
d3d5771
Adds support for reading binary Ion 1.1 delimited containers.
tgregg Feb 16, 2024
4db0d4d
Fix macro parameter cardinality and minor todos (#798)
popematt Apr 19, 2024
2007358
Use Opcodes 50-5F for macros and shift 50-CF opcodes over to 60-DF (#…
popematt Apr 23, 2024
eb09db7
Makes Ion 1.1 floats little-endian.
tgregg Apr 25, 2024
4b5bb88
Adds the IonEncodingVersion pseudo-enum and IonBinaryWriterBuilder_1_…
tgregg May 1, 2024
767b473
Applies 'spotless' to the ion-11-encoding branch.
tgregg May 2, 2024
c8c301c
Fix several bugs in Ion 1.1 implementation (#829)
popematt May 3, 2024
686f585
Add managed writer for Ion 1.1 with basic round-trip testing (#830)
popematt May 6, 2024
5845d53
Minor fixes to get all of the quality checks to pass again. (#837)
popematt May 7, 2024
bf59d8d
Make IonManagedWriter_1_1 close its OutputStream (#840)
popematt May 8, 2024
a00f357
Adds BufferedAppendableFastAppendable (#845)
popematt May 10, 2024
7c9acd0
Fixes Ion 1.1 symbols for opcodes E1-E3 (#844)
popematt May 10, 2024
d515f79
Fix Spotless rachetFrom to use the closest ancestor commit that is pa…
popematt May 11, 2024
5b82bce
Adds the IonTextWriterBuilder_1_1 interface.
tgregg May 10, 2024
955d5b6
Improves performance by representing the LST using a Map instead of S…
tgregg May 14, 2024
98bcbb8
Makes FlexInt.writeFlexIntOrUIntInto inlineable for common sizes. (#856)
tgregg May 15, 2024
b302b93
Fix leaking field name text in IonCursorBinary (#859)
popematt May 15, 2024
916627d
Adds support for Ion 1.1 inline symbols to the system-level binary re…
tgregg May 15, 2024
72c58b0
Implements writeValues for IonManagedWriter_1_1 (#867)
popematt May 25, 2024
4e07828
Skips IonReaderBinaryLargeStreamTest unless running on CI server (#870)
popematt May 31, 2024
4439d48
Fixes various bugs in the 1.1 binary reader.
tgregg May 30, 2024
debc87d
Adds testing of various reader dimensions to the Ion 1.1 roundtrip test.
tgregg May 30, 2024
0402044
Removes IonCursorBinary.isSpecialVarSymPartiallyRead in favor of the …
tgregg May 30, 2024
4d45567
Ensures annotations are not overwritten when filling a delimited cont…
tgregg May 31, 2024
3f76518
Adds the ability to transform Ion 1.0 symbol IDs to Ion 1.1 equivalen…
tgregg Jun 7, 2024
9537158
Avoids an O(n) lookup for symbols newly added to the Ion 1.1 writer, …
tgregg Jun 8, 2024
eac74d2
Adds runner for Ion conformance tests (#887)
popematt Jun 28, 2024
b875035
Adds binary read support for macro invocation headers.
tgregg Jun 12, 2024
797c1ab
Adds support for lexing binary tagless types.
tgregg Jun 18, 2024
d529d14
Adds support for reading binary tagless types.
tgregg Jun 26, 2024
68799c0
Fixes incremental reading of FlexSyms.
tgregg Jun 19, 2024
f6c00d8
Swaps the order of the macro ID and length FlexUInts for opcode OxF5,…
tgregg Jun 26, 2024
aaf383a
Corrects handling of the return value of IonCursorBinary.slowReadMacr…
tgregg Jun 26, 2024
1035de0
Adds PresenceBitmap
popematt Jun 27, 2024
6ea00b3
Adds suggested changes
popematt Jun 28, 2024
ed8dc10
Fix incomplete sentences in comments
popematt Jun 28, 2024
02a7fd7
Rename cardinality enum to match spec (#907)
popematt Jul 2, 2024
936b7fd
Adds support for lexing the argument encoding bitmap (presence bits).…
tgregg Jul 2, 2024
6f8534a
Updates 'each' clauses to allow alternating name-strings and fragment…
popematt Jul 12, 2024
a94d9c2
Adds support for parsing binary argument groups. (#910)
tgregg Jul 16, 2024
6278b76
Adds writing length-prefixed E-Expressions, expression groups, and ta…
popematt Jul 19, 2024
23da062
Add stubs for macro evaluator (#923)
popematt Aug 15, 2024
25fc3c4
Adds macro evaluator implementation (#924)
popematt Aug 20, 2024
8852003
Renames DelimitedContainerStrategy to LengthPrefixStrategy (#932)
popematt Sep 3, 2024
e225e4f
Adds the ability to compile Ion encoding directives from binary Ion 1…
tgregg Aug 28, 2024
13e8402
Adds support for evaluating user-defined macros from binary streams. …
tgregg Sep 7, 2024
49769f5
Adds support for writing macros in IonManagedWriter_1_1 (#934)
popematt Sep 7, 2024
cc4cf2c
Adds custom formatting for encoding directives when writing text (#936)
popematt Sep 10, 2024
047e37a
Remove MacroRef from user-facing APIs (#937)
popematt Sep 17, 2024
d380bf0
Adds Ion 1.1 system symbols (#939)
popematt Sep 19, 2024
822f572
Ensures the Ion 1.1 managed writer does not close its OutputStream tw…
tgregg Sep 20, 2024
4b373e5
Write support for Ion 1.1 system symbols (#941)
popematt Sep 20, 2024
714dbcf
Enables MacroCompiler to operate over an IonReader.
tgregg Sep 24, 2024
c5562bf
Adds read support for Ion 1.1 system symbols (#944)
popematt Sep 27, 2024
492323f
Fix use of layout.buildDirectory (#949)
jobarr-amzn Oct 1, 2024
171aebd
Adds support for reading Ion 1.1 text syntax for e-expressions and ex…
tgregg Sep 27, 2024
76276cf
Account for missing system symbol table (#953)
jobarr-amzn Oct 3, 2024
fc8f49e
Updates TDL syntax for macro invocations, expression groups, and vari…
popematt Oct 3, 2024
41a666e
Adds support for parsing Ion 1.1 encoding directives in the text reader.
tgregg Oct 1, 2024
b8d9476
Ensures macros can be evaluated from both byte array and InputStream …
tgregg Oct 3, 2024
f9f72f0
Adds expansions for make_symbol, make_decimal, none, and annotate (#955)
popematt Oct 4, 2024
ebb3b65
Adds implementations of if_* special forms (#957)
popematt Oct 5, 2024
4ac2697
Fix bugs in conformance test runner (#959)
popematt Oct 7, 2024
36d63da
Move classes in Macro.kt to their own files
popematt Oct 5, 2024
ab1e041
Add support for reading system e-expressions (#961)
popematt Oct 8, 2024
93d4f3b
Make IonMangedWriter_1_1.intern public (#964)
jobarr-amzn Oct 9, 2024
257ecfe
Add support for writing System E-Expression invocations (#965)
popematt Oct 9, 2024
dbdd8a9
Adds support for evaluating Ion 1.1 macros from text Ion.
tgregg Oct 9, 2024
7b9ae9c
Uses shared e-expression arg reading logic for binary and text.
tgregg Oct 10, 2024
86c2bce
Marks Kotlin classes internal where possible.
tgregg Oct 11, 2024
f7c5a43
Fixes a bug that caused the binary reader to stop consuming from the …
tgregg Oct 11, 2024
c6acdbf
Fail more gracefully for a too-many-arguments case (#971)
jobarr-amzn Oct 14, 2024
b69f520
Adds support for reading text Ion 1.1 system macros and implicit rest…
tgregg Oct 11, 2024
6ebf471
Fixes #963 by properly setting the cursor's checkpoint after reading …
tgregg Oct 11, 2024
9dc06cc
Adds implementations of repeat, make_field, and make_blob (#972)
popematt Oct 14, 2024
66cab4e
Implements encoding directive macros and comment macro (#973)
popematt Oct 15, 2024
d402b46
Includes various small fixes for tagless parameters, expression group…
tgregg Oct 16, 2024
c608965
Allows readers to interpret macro invocations as encoding directives.
tgregg Oct 15, 2024
3f92b94
Fixes reading of macro table appends. (#979)
tgregg Oct 21, 2024
383066b
Various changes in support of system macros (#981)
jobarr-amzn Oct 29, 2024
69951dd
Fixes a bug that caused the binary reader to prematurely assume EOF h…
tgregg Oct 29, 2024
576e018
Ensures that macro arguments are present in the binary reader's buffe…
tgregg Oct 30, 2024
d434d2a
Use add/set_macros/symbols in ManagedWriter (#987)
jobarr-amzn Oct 31, 2024
7cd94d4
Rename compact_* parameter encodings to flex_* (#992)
jobarr-amzn Nov 13, 2024
10b489d
Applies various fixes to writing and reading of Ion 1.1 system symbol…
tgregg Nov 15, 2024
411c339
Improve conformance test runner (#997)
popematt Nov 15, 2024
e9237a2
System macros in tdl (#996)
jobarr-amzn Nov 19, 2024
7177234
Implement remaining 'denotes' expectations for conformance test runne…
popematt Nov 19, 2024
9138aca
Adds support for macro-aware transcoding from binary to text.
tgregg Nov 23, 2024
7482237
Fixes gaps in macro-aware transcoding identified while integrating wi…
tgregg Nov 27, 2024
44da868
Improves the factoring of the macro-aware transcoding tests and appli…
tgregg Nov 27, 2024
24e82fa
Adds a Macroize tool to enable conversion of Ion 1.0 data to Ion 1.1 …
tgregg Nov 11, 2024
0a17f82
Macro implementations and conformance test fixes (#1003)
popematt Dec 4, 2024
37a33d2
Use default module instead of $ion_encoding (#1007)
popematt Dec 5, 2024
6722ac7
Allows values to be macro-aware transcoded value-by-value, adds suppo…
tgregg Dec 3, 2024
5c35d1a
Adds support for macro-aware transcoding from text.
tgregg Dec 9, 2024
8f98013
Makes the Ion 1.1 text writer write symbol tokens inline by default, …
tgregg Dec 10, 2024
fbdc0b1
Simplify ion-java-cli OutputFormat (#1014)
jobarr-amzn Dec 12, 2024
4f594cf
Restack 1.1 macros and symbols to meet spec changes (#1013)
jobarr-amzn Dec 12, 2024
1ef79d9
A simple picocli/native-image ion-java CLI
jobarr-amzn Nov 1, 2024
1071d93
fixup: todo broken pipe
jobarr-amzn Nov 26, 2024
7c73766
Use own copy of OutputFormat, support 1.1 output
jobarr-amzn Dec 12, 2024
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
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace=true

[{*.kt,*.kts}]
ij_kotlin_imports_layout = *
ij_kotlin_packages_to_use_import_on_demand=com.amazon.ion.**,java.util.*

[src/test/**.kt]
ktlint_ignore_back_ticked_identifier=true
3 changes: 0 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ permissions: read-all

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]


jobs:
build-and-test:
Expand Down
16 changes: 16 additions & 0 deletions THIRD_PARTY_LICENSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,19 @@
**3** **Group:** `org.jetbrains.kotlin` **Name:** `kotlin-stdlib-common` **Version:** `1.9.0`
> - **POM Project URL**: [https://kotlinlang.org/](https://kotlinlang.org/)
> - **POM License**: Apache License, Version 2.0 - [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)

**4** **Group:** `org.jetbrains.kotlin` **Name:** `kotlin-stdlib-jdk7` **Version:** `1.9.0`
> - **POM Project URL**: [https://kotlinlang.org/](https://kotlinlang.org/)
> - **POM License**: Apache License, Version 2.0 - [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)

**5** **Group:** `org.jetbrains.kotlin` **Name:** `kotlin-stdlib-jdk8` **Version:** `1.9.0`
> - **POM Project URL**: [https://kotlinlang.org/](https://kotlinlang.org/)
> - **POM License**: Apache License, Version 2.0 - [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)

**6** **Group:** `org.jetbrains.kotlinx` **Name:** `kotlinx-collections-immutable-jvm` **Version:** `0.3.6`
> - **POM Project URL**: [https://github.com/Kotlin/kotlinx.collections.immutable](https://github.com/Kotlin/kotlinx.collections.immutable)
> - **POM License**: Apache License, Version 2.0 - [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)

## Unknown

**7** **Group:** `org.jetbrains.kotlinx` **Name:** `kotlinx-collections-immutable` **Version:** `0.3.6`
87 changes: 62 additions & 25 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import com.diffplug.gradle.spotless.SpotlessTask
import com.github.jk1.license.filter.LicenseBundleNormalizer
import com.github.jk1.license.render.InventoryMarkdownReportRenderer
import com.github.jk1.license.render.TextReportRenderer
import java.time.Instant
import java.util.Properties
import org.gradle.kotlin.dsl.support.unzipTo
import org.gradle.kotlin.dsl.support.zipTo
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
import proguard.gradle.ProGuardTask
import java.time.Instant
import java.util.Properties

buildscript {
repositories {
Expand Down Expand Up @@ -72,13 +73,19 @@ java {

dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.6")

testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
testCompileOnly("junit:junit:4.13")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine")
testImplementation("org.hamcrest:hamcrest:2.2")
testImplementation("pl.pragmatists:JUnitParams:1.1.1")
testImplementation("com.google.code.tempus-fugit:tempus-fugit:1.1")

// Used for the conformance test runner, because IonValue is not suitable for it.
testImplementation("com.amazon.ion:ion-element:1.2.0")
// Force the tests to use the locally built version rather than a version transitively provided by `ion-element`.
testImplementation(project)
}

group = "com.amazon.ion"
Expand All @@ -90,9 +97,9 @@ description = "A Java implementation of the Amazon Ion data notation."
val isCI: Boolean = System.getenv("CI") == "true"
val githubRepositoryUrl = "https://github.com/amazon-ion/ion-java/"
val isReleaseVersion: Boolean = !version.toString().endsWith("SNAPSHOT")
// The name we're checking for corresponds to the name that is set in the `publish-release-artifacts.yml` file.
val isReleaseWorkflow: Boolean = System.getenv("GITHUB_WORKFLOW") == "Publish Release Artifacts"
val generatedResourcesDir = "${layout.buildDirectory}/generated/main/resources"
// Workflows triggered by a new release always have a tag ref.
val isReleaseWorkflow: Boolean = (System.getenv("GITHUB_REF") ?: "").startsWith("refs/tags/")
val generatedResourcesDir = layout.buildDirectory.dir("generated/main/resources")

sourceSets {
main {
Expand All @@ -105,7 +112,7 @@ licenseReport {
// though ion-java does not depend on ion-java-cli. By default, the license report generator includes
// the current project (ion-java) and all its subprojects.
projects = arrayOf(project)
outputDir = "${layout.buildDirectory}/reports/licenses"
outputDir = layout.buildDirectory.dir("reports/licenses").get().asFile.path
renderers = arrayOf(InventoryMarkdownReportRenderer(), TextReportRenderer())
// Dependencies use inconsistent titles for Apache-2.0, so we need to specify mappings
filters = arrayOf(
Expand All @@ -118,49 +125,67 @@ licenseReport {
)
}

// Spotless eagerly checks for the `rachetFrom` git ref even if there are no spotless tasks in the task
// graph, so we're going to use a git tag to create our own lazy evaluation and setting of `rachetFrom`.
// See https://github.com/diffplug/spotless/issues/1902
val SPOTLESS_TAG = "spotless-check-${Instant.now().epochSecond}-DELETE-ME"

/**
* This is the `git remote` name that corresponds to amazon-ion/ion-java.
* It is used for applying the "spotless" checks only to things that are changed
* compared to the master branch of the source repo.
* This is the commit where the current branch most recently forked from master. We use this as
* our "rachetFrom" base so that changes in master don't cause unexpected formatting failures in
* feature branches.
*/
val sourceRepoRemoteName: String by lazy {
val sourceRepoRachetFromCommit: String by lazy {
val git = System.getenv("GIT_CLI") ?: "git"

fun String.isSourceRepo(): Boolean {
val url = "$git remote get-url ${this@isSourceRepo}".runCommand()
val url = "$git remote get-url ${this@isSourceRepo}".trim().runCommand()
return "amazon-ion/ion-java" in url || "amzn/ion-java" in url
}

var name = "$git remote".runCommand().lines().firstOrNull { it.isSourceRepo() }
var remoteName = "$git remote".runCommand().trim().lines().firstOrNull { it.isSourceRepo() }

if (isCI) {
// When running on a CI environment e.g. GitHub Actions, we might need to automatically add the remote
if (name == null) {
name = "ci_source_repository"
"$git remote add $name $githubRepositoryUrl".runCommand()
if (remoteName == null) {
remoteName = "ci_source_repository"
"$git remote add $remoteName $githubRepositoryUrl".runCommand(log = logger::quiet)
logger.quiet("Added remote repository ")
}
// ...and make sure that we have indeed fetched that remote
"$git fetch $name".runCommand()
"$git fetch --unshallow --no-tags --no-recurse-submodules $remoteName master".runCommand()
}

name ?: throw Exception(
remoteName ?: throw Exception(
"""
|No git remote found for amazon-ion/ion-java. Try again after running:
|
| git remote add -f <name> $githubRepositoryUrl
""".trimMargin()
""".trimMargin()
)

// TODO: We might need to use the PR base ref when this is running as part of a CI check for a PR.
logger.quiet("Finding spotless ratchetFrom base...")
"$git merge-base $remoteName/master HEAD".runCommand(log = logger::quiet).trim()
}

fun String.runCommand(workingDir: File = rootProject.projectDir): String {
fun String.runCommand(workingDir: File = rootProject.projectDir, log: (String) -> Unit = logger::info): String {
log("$ $this")
val parts = this.split("\\s".toRegex())
val proc = ProcessBuilder(*parts.toTypedArray())
.directory(workingDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()
proc.waitFor(30, TimeUnit.SECONDS)
return proc.inputStream.bufferedReader().readText()
val stdOut = proc.inputStream.bufferedReader().readText()
val stdErr = proc.errorStream.bufferedReader().readText()
if (stdOut.isNotBlank()) log(stdOut)
if (stdErr.isNotBlank()) logger.warn(stdErr)
if (proc.exitValue() != 0) {
throw Exception("Failed to run command: $this")
}
return stdOut
}

spotless {
Expand All @@ -171,14 +196,19 @@ spotless {
// release branch.
if (isReleaseWorkflow) return@spotless

ratchetFrom("$sourceRepoRemoteName/master")
"git tag -f $SPOTLESS_TAG".runCommand()
ratchetFrom(SPOTLESS_TAG)
// Make sure this always gets cleaned up. We can't do it inline here, so we'll do it once the task graph is created.
gradle.taskGraph.addTaskExecutionGraphListener { "git tag -d $SPOTLESS_TAG".runCommand() }

val shortFormLicenseHeader = """
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
""".trimIndent()

java {
// Note that the order of these is important. Each of these is an individual formatter
// that is applied sequentially.
licenseHeader(shortFormLicenseHeader)
removeUnusedImports()
}
Expand Down Expand Up @@ -368,7 +398,7 @@ tasks {
}

ktlint {
version.set("0.40.0")
version.set("0.45.2")
outputToConsole.set(true)
}

Expand All @@ -384,7 +414,9 @@ tasks {
}
)

val spotbugsBaselineFile = "$rootDir/config/spotbugs/baseline.xml"
val spotbugsConfigDir = "$rootDir/config/spotbugs"
excludeFilter.set(file("$spotbugsConfigDir/exclude.xml"))
val spotbugsBaselineFile = "$spotbugsConfigDir/baseline.xml"

val baselining = project.hasProperty("baseline") // e.g. `./gradlew :spotbugsMain -Pbaseline`

Expand Down Expand Up @@ -416,7 +448,7 @@ tasks {
commandLine(
"xsltproc",
"--output", spotbugsBaselineFile,
"$rootDir/config/spotbugs/baseline.xslt",
"$spotbugsConfigDir/baseline.xslt",
"${outputLocation.get()}"
)
}
Expand All @@ -441,7 +473,7 @@ tasks {
* for why this is done with a properties file rather than the Jar manifest.
*/
val generateJarInfo by creating<Task> {
val propertiesFile = File("$generatedResourcesDir/${project.name}.properties")
val propertiesFile = generatedResourcesDir.get().file("${project.name}.properties").asFile
doLast {
propertiesFile.parentFile.mkdirs()
val properties = Properties()
Expand Down Expand Up @@ -528,6 +560,11 @@ tasks {
dependsOn(jar)
includeConfigs.set(listOf("runtimeClasspath"))
}

withType<SpotlessTask> {
doFirst { "git tag -f $SPOTLESS_TAG $sourceRepoRachetFromCommit".runCommand() }
doLast { "git tag -d $SPOTLESS_TAG".runCommand() }
}
}

publishing {
Expand Down
28 changes: 28 additions & 0 deletions config/spotbugs/exclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@


<!-- This file specifies a spotbugs filter for excluding reports that
should not be considered errors.

The format of this file is documented at:

https://spotbugs.readthedocs.io/en/latest/filter.html

When possible, please specify the full names of the bug codes,
using the pattern attribute, to make it clearer what reports are
being suppressed. You can find a listing of codes at:

https://spotbugs.readthedocs.io/en/latest/bugDescriptions.html
-->

<FindBugsFilter>
<Match>
<Match>
<!--
Ignore Kotlin files, because SpotBugs doesn't provide specific Kotlin support,
so it raises warnings for things that might look dodgy in the byte code, but
were compiled from perfectly safe Kotlin code.
-->
<Source name="~.*\.kt"/>
</Match>
</Match>
</FindBugsFilter>
27 changes: 27 additions & 0 deletions ion-java-cli/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
java
application
// Apply GraalVM Native Image plugin
id("org.graalvm.buildtools.native") version "0.10.3"
}

description = "A CLI that implements the standard interface defined by ion-test-driver."
Expand All @@ -15,8 +17,33 @@ repositories {
dependencies {
implementation("args4j:args4j:2.33")
implementation(rootProject)

implementation("info.picocli:picocli:4.7.6")
annotationProcessor("info.picocli:picocli-codegen:4.7.6")
}

tasks.withType<JavaCompile> {
options.compilerArgs.add("-Aproject=${project.group}/${project.name}")
}

application {
mainClass.set("com.amazon.tools.cli.IonJavaCli")
}

// Defines an ion-java-cli:nativeCompile task which produces ion-java-cli/build/native/nativeCompile/jion
// You need to have GRAALVM_HOME pointed at a GraalVM installation
// You can get one of those via e.g. `sdk install java 17.0.9-graalce`
// See: https://sdkman.io/
graalvmNative {
testSupport.set(false)
binaries {
named("main") {
imageName.set("jion")
mainClass.set("com.amazon.tools.cli.SimpleIonCli")
buildArgs.add("-O4")
}
}
binaries.all {
buildArgs.add("--verbose")
}
}
Loading
Loading