homebrew-core/Formula/jsonschema2pojo.rb

46 lines
1.3 KiB
Ruby

class Jsonschema2pojo < Formula
desc "Generates Java types from JSON Schema (or example JSON)"
homepage "https://www.jsonschema2pojo.org/"
url "https://github.com/joelittlejohn/jsonschema2pojo/releases/download/jsonschema2pojo-1.1.2/jsonschema2pojo-1.1.2.tar.gz"
sha256 "13648191c731ad590d730aa3a366ee78fef20f484af50d00e81e7a0de4c1182e"
license "Apache-2.0"
livecheck do
url :stable
strategy :github_latest
regex(%r{href=.*?/tag/jsonschema2pojo[._-]v?(\d+(?:\.\d+)+)["' >]}i)
end
bottle do
sha256 cellar: :any_skip_relocation, all: "1752a7fe84c4bee3d4bd48d6587b8927141fab348c159e117e8844b42fda985e"
end
depends_on "openjdk"
def install
libexec.install "jsonschema2pojo-#{version}-javadoc.jar", "lib"
bin.write_jar_script libexec/"lib/jsonschema2pojo-cli-#{version}.jar", "jsonschema2pojo"
end
test do
(testpath/"src/jsonschema.json").write <<~EOS
{
"type":"object",
"properties": {
"foo": {
"type": "string"
},
"bar": {
"type": "integer"
},
"baz": {
"type": "boolean"
}
}
}
EOS
system bin/"jsonschema2pojo", "-s", "src", "-t", testpath
assert_predicate testpath/"Jsonschema.java", :exist?, "Failed to generate Jsonschema.java"
end
end