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
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: ci

on:
push:
branches: [ main ]
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
# fetch tags - tags are needed for versionPolicyCheck binary and source compat checks
fetch-tags: true
- uses: coursier/cache-action@v6
- uses: actions/setup-java@v5
with:
java-version: 17
distribution: temurin
cache: sbt
- uses: sbt/setup-sbt@v1
- name: sbt build
run: sbt clean build
8 changes: 8 additions & 0 deletions .sbtopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# for using sbt-java-formatter on newer JDKs:
-J--add-opens=java.base/java.lang=ALL-UNNAMED
-J--add-opens=java.base/java.util=ALL-UNNAMED
-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
99 changes: 99 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Main goals:
# - nicer commit diffs (trailing commas, no alignment for pattern matching, force new lines)
# - better interop with default IntelliJ IDEA setup (matching import and modifiers sorting logic)
# - better developer experience on laptop screens (like 16' MBPs) with IntelliJ IDEA (line wraps)

version = 3.9.9

runner.dialect = scala213source3
fileOverride {
"glob:**/scala-3/**/*.scala" {runner.dialect = scala3}
}

# only format files tracked by git
project.git = true

maxColumn = 110
trailingCommas = always

preset = default
# do not align to make nicer commit diffs
align.preset = none

indent {
# altering defnSite and extendSite to have this:
# final class MyErr extends RuntimeException(
# "super error message",
# )
# instead of this:
# final class MyErr extends RuntimeException(
# "super error message",
# )
defnSite = 2
extendSite = 0
}

spaces {
# makes string interpolation with curlies more visually distinct
inInterpolatedStringCurlyBraces = true
}

newlines {
# keep author new lines where possible
source = keep
# force new line after "(implicit" for multi-line arg lists
implicitParamListModifierForce = [after]
avoidForSimpleOverflow = [
tooLong, # if the line would be too long even after newline inserted, do nothing
slc, # do nothing if overflow caused by single line comment
]
}

verticalMultiline {
atDefnSite = true
arityThreshold = 4 # more than 3 args in a list will be turned vertical
newlineAfterOpenParen = true # for nicer commit diffs
}

# for nicer commit diffs - forces new line before last parenthesis:
# class MyCls(
# arg1: String,
# arg2: String,
# ) extends MyTrait {
#
# without it:
# class MyCls(
# arg1: String,
# arg2: String) extends MyTrait {
danglingParentheses.exclude = []

docstrings {
# easier to view diffs in IDEA on 16' MBP screen if docs max line are shorter than code
wrapMaxColumn = 90
# next settings make it similar to the default IDEA javadoc formatting
style = Asterisk
oneline = unfold
blankFirstLine = unfold
}

rewrite.rules = [
Imports,
RedundantParens,
SortModifiers,
prefercurlyfors,
]

# put visibility modifier first
rewrite.sortModifiers.preset = styleGuide

# Import sorting as similar as possible to scalafix's "OrganizeImports.preset = INTELLIJ_2020_3".
# Scalafix is not used as its commands mess up "all .." build aliases and it takes long time to run,
# while its code semantic based features are not needed here.
# I.e. detection of unused imports is done with Scala compiler options.
rewrite.imports {
sort = ascii
groups = [
[".*"],
["java\\..*", "javax\\..*", "scala\\..*"],
]
}
75 changes: 75 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import Dependencies.*
import sbt.*

ThisBuild / organization := "com.evolution.jgrpc.tools"
ThisBuild / startYear := Some(2025)
ThisBuild / homepage := Some(url("https://github.com/evolution-gaming/grpc-java-tools"))
ThisBuild / licenses := Seq(("MIT", url("https://opensource.org/licenses/MIT")))
ThisBuild / organizationName := "Evolution"
ThisBuild / organizationHomepage := Some(url("https://evolution.com"))

// Maven Central requires <developers> in published pom.xml files
ThisBuild / developers := List(
Developer(
id = "migesok",
name = "Mikhail Sokolov",
email = "mikhail.g.sokolov@gmail.com",
url = url("https://github.com/migesok"),
),
)

ThisBuild / scmInfo := Some(ScmInfo(
browseUrl = url("https://github.com/evolution-gaming/grpc-java-tools"),
connection = "git@github.com:evolution-gaming/grpc-java-tools.git",
))

// not sure if bincompat check works for Java code, put it here just in case
ThisBuild / versionPolicyIntention := Compatibility.BinaryCompatible

// this is a Java project, setting a fixed Scala version just in case
ThisBuild / scalaVersion := "2.13.16"

// setting pure-Java module build settings
ThisBuild / crossPaths := false // drop off Scala suffix from artifact names.
ThisBuild / autoScalaLibrary := false // exclude scala-library from dependencies
ThisBuild / javacOptions := Seq("-source", "17", "-target", "17", "-Werror", "-Xlint:all")
ThisBuild / doc / javacOptions := Seq("-source", "17", "-Xdoclint:all", "-Werror")

// common test dependencies:
ThisBuild / libraryDependencies ++= Seq(
// to be able to run JUnit 5+ tests:
"com.github.sbt.junit" % "jupiter-interface" % JupiterKeys.jupiterVersion.value,
Slf4j.simple,
).map(_ % Test)

// common compile dependencies:
ThisBuild / libraryDependencies ++= Seq(
jspecify, // JSpecify null-check annotations
)

lazy val root = project.in(file("."))
.settings(
name := "grpc-java-tools-root",
description := "Evolution grpc-java tools - root",
publish / skip := true,
)
.aggregate(
k8sDnsNameResolver,
)

lazy val k8sDnsNameResolver = project.in(file("k8s-dns-name-resolver"))
.settings(
name := "k8s-dns-name-resolver",
description := "Evolution grpc-java tools - DNS-based name resolver for Kubernetes services",
libraryDependencies ++= Seq(
Grpc.api,
Slf4j.api,
dnsJava,
),
)

addCommandAlias("fmt", "all scalafmtAll scalafmtSbt javafmtAll")
addCommandAlias(
"build",
"all scalafmtCheckAll scalafmtSbtCheck javafmtCheckAll versionPolicyCheck Compile/doc test",
)
Loading