Skip to content

Commit f3bef39

Browse files
committed
Set up project, initial impl for K8sDnsNameResolver
README, integration tests and release publishing will be set up in subsequent PRs.
1 parent 0497429 commit f3bef39

File tree

13 files changed

+718
-0
lines changed

13 files changed

+718
-0
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v5
13+
with:
14+
# fetch tags - tags are needed for versionPolicyCheck binary and source compat checks
15+
fetch-tags: true
16+
- uses: coursier/cache-action@v6
17+
- uses: actions/setup-java@v5
18+
with:
19+
java-version: 17
20+
distribution: temurin
21+
cache: sbt
22+
- uses: sbt/setup-sbt@v1
23+
- name: sbt build
24+
run: sbt clean build

.sbtopts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# for using sbt-java-formatter on newer JDKs:
2+
-J--add-opens=java.base/java.lang=ALL-UNNAMED
3+
-J--add-opens=java.base/java.util=ALL-UNNAMED
4+
-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
5+
-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
6+
-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
7+
-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
8+
-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED

.scalafmt.conf

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Main goals:
2+
# - nicer commit diffs (trailing commas, no alignment for pattern matching, force new lines)
3+
# - better interop with default IntelliJ IDEA setup (matching import and modifiers sorting logic)
4+
# - better developer experience on laptop screens (like 16' MBPs) with IntelliJ IDEA (line wraps)
5+
6+
version = 3.9.9
7+
8+
runner.dialect = scala213source3
9+
fileOverride {
10+
"glob:**/scala-3/**/*.scala" {runner.dialect = scala3}
11+
}
12+
13+
# only format files tracked by git
14+
project.git = true
15+
16+
maxColumn = 110
17+
trailingCommas = always
18+
19+
preset = default
20+
# do not align to make nicer commit diffs
21+
align.preset = none
22+
23+
indent {
24+
# altering defnSite and extendSite to have this:
25+
# final class MyErr extends RuntimeException(
26+
# "super error message",
27+
# )
28+
# instead of this:
29+
# final class MyErr extends RuntimeException(
30+
# "super error message",
31+
# )
32+
defnSite = 2
33+
extendSite = 0
34+
}
35+
36+
spaces {
37+
# makes string interpolation with curlies more visually distinct
38+
inInterpolatedStringCurlyBraces = true
39+
}
40+
41+
newlines {
42+
# keep author new lines where possible
43+
source = keep
44+
# force new line after "(implicit" for multi-line arg lists
45+
implicitParamListModifierForce = [after]
46+
avoidForSimpleOverflow = [
47+
tooLong, # if the line would be too long even after newline inserted, do nothing
48+
slc, # do nothing if overflow caused by single line comment
49+
]
50+
}
51+
52+
verticalMultiline {
53+
atDefnSite = true
54+
arityThreshold = 4 # more than 3 args in a list will be turned vertical
55+
newlineAfterOpenParen = true # for nicer commit diffs
56+
}
57+
58+
# for nicer commit diffs - forces new line before last parenthesis:
59+
# class MyCls(
60+
# arg1: String,
61+
# arg2: String,
62+
# ) extends MyTrait {
63+
#
64+
# without it:
65+
# class MyCls(
66+
# arg1: String,
67+
# arg2: String) extends MyTrait {
68+
danglingParentheses.exclude = []
69+
70+
docstrings {
71+
# easier to view diffs in IDEA on 16' MBP screen if docs max line are shorter than code
72+
wrapMaxColumn = 90
73+
# next settings make it similar to the default IDEA javadoc formatting
74+
style = Asterisk
75+
oneline = unfold
76+
blankFirstLine = unfold
77+
}
78+
79+
rewrite.rules = [
80+
Imports,
81+
RedundantParens,
82+
SortModifiers,
83+
prefercurlyfors,
84+
]
85+
86+
# put visibility modifier first
87+
rewrite.sortModifiers.preset = styleGuide
88+
89+
# Import sorting as similar as possible to scalafix's "OrganizeImports.preset = INTELLIJ_2020_3".
90+
# Scalafix is not used as its commands mess up "all .." build aliases and it takes long time to run,
91+
# while its code semantic based features are not needed here.
92+
# I.e. detection of unused imports is done with Scala compiler options.
93+
rewrite.imports {
94+
sort = ascii
95+
groups = [
96+
[".*"],
97+
["java\\..*", "javax\\..*", "scala\\..*"],
98+
]
99+
}

build.sbt

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import Dependencies.*
2+
import sbt.*
3+
4+
ThisBuild / organization := "com.evolution.jgrpc.tools"
5+
ThisBuild / startYear := Some(2025)
6+
ThisBuild / homepage := Some(url("https://github.com/evolution-gaming/grpc-java-tools"))
7+
ThisBuild / licenses := Seq(("MIT", url("https://opensource.org/licenses/MIT")))
8+
ThisBuild / organizationName := "Evolution"
9+
ThisBuild / organizationHomepage := Some(url("https://evolution.com"))
10+
11+
// Maven Central requires <developers> in published pom.xml files
12+
ThisBuild / developers := List(
13+
Developer(
14+
id = "migesok",
15+
name = "Mikhail Sokolov",
16+
email = "[email protected]",
17+
url = url("https://github.com/migesok"),
18+
),
19+
)
20+
21+
ThisBuild / scmInfo := Some(ScmInfo(
22+
browseUrl = url("https://github.com/evolution-gaming/grpc-java-tools"),
23+
connection = "[email protected]:evolution-gaming/grpc-java-tools.git",
24+
))
25+
26+
// not sure if bincompat check works for Java code, put it here just in case
27+
ThisBuild / versionPolicyIntention := Compatibility.BinaryCompatible
28+
29+
// this is a Java project, setting a fixed Scala version just in case
30+
ThisBuild / scalaVersion := "2.13.16"
31+
32+
// setting pure-Java module build settings
33+
ThisBuild / crossPaths := false // drop off Scala suffix from artifact names.
34+
ThisBuild / autoScalaLibrary := false // exclude scala-library from dependencies
35+
ThisBuild / javacOptions := Seq("-source", "17", "-target", "17", "-Werror", "-Xlint:all")
36+
ThisBuild / doc / javacOptions := Seq("-source", "17", "-Xdoclint:all", "-Werror")
37+
38+
// common test dependencies:
39+
ThisBuild / libraryDependencies ++= Seq(
40+
// to be able to run JUnit 5+ tests:
41+
"com.github.sbt.junit" % "jupiter-interface" % JupiterKeys.jupiterVersion.value,
42+
Slf4j.simple,
43+
).map(_ % Test)
44+
45+
// common compile dependencies:
46+
ThisBuild / libraryDependencies ++= Seq(
47+
jspecify, // JSpecify null-check annotations
48+
)
49+
50+
lazy val root = project.in(file("."))
51+
.settings(
52+
name := "grpc-java-tools-root",
53+
description := "Evolution grpc-java tools - root",
54+
publish / skip := true,
55+
)
56+
.aggregate(
57+
k8sDnsNameResolver,
58+
)
59+
60+
lazy val k8sDnsNameResolver = project.in(file("k8s-dns-name-resolver"))
61+
.settings(
62+
name := "k8s-dns-name-resolver",
63+
description := "Evolution grpc-java tools - DNS-based name resolver for Kubernetes services",
64+
libraryDependencies ++= Seq(
65+
Grpc.api,
66+
Slf4j.api,
67+
dnsJava,
68+
),
69+
)
70+
71+
addCommandAlias("fmt", "all scalafmtAll scalafmtSbt javafmtAll")
72+
addCommandAlias(
73+
"build",
74+
"all scalafmtCheckAll scalafmtSbtCheck javafmtCheckAll versionPolicyCheck Compile/doc test",
75+
)

0 commit comments

Comments
 (0)