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

build on sbt 1.8.1 to allow for CI on Java 17 #756

Closed
wants to merge 4 commits into from
Closed
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
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ name: CI
on:
pull_request:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
if: github.repository == 'lightbend/config'
strategy:
fail-fast: false
matrix:
include:
- java: 8
- java: 11
- java: 17
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: ${{ matrix.java }}
Expand Down
75 changes: 38 additions & 37 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ lazy val root = (project in file("."))
doc := (configLib / Compile / doc).value
packageDoc / aggregate := false
packageDoc := (configLib / Compile / packageDoc).value
checkstyle / aggregate := false
checkstyle := (configLib / Compile / checkstyle).value
useGpg := true
// checkstyle / aggregate := false
// checkstyle := (configLib / Compile / checkstyle).value
PgpKeys.publishSigned / aggregate := false
PgpKeys.publishSigned := (PgpKeys.publishSigned in configLib).value
PgpKeys.publishSigned := (configLib / PgpKeys.publishSigned).value
PgpKeys.publishLocalSigned / aggregate := false
PgpKeys.publishLocalSigned := (PgpKeys.publishLocalSigned in configLib).value
PgpKeys.publishLocalSigned := (configLib / PgpKeys.publishLocalSigned).value
})

lazy val configLib = Project("config", file("config"))
Expand Down Expand Up @@ -106,40 +105,42 @@ lazy val configLib = Project("config", file("config"))
.setPreference(IndentSpaces, 4)
.setPreference(FirstArgumentOnNewline, Preserve)

checkstyleConfigLocation := CheckstyleConfigLocation.File((baseDirectory.value / "checkstyle-config.xml").toString)

Compile / checkstyle := {
val log = streams.value.log
(Compile / checkstyle).value
val resultFile = (Compile / checkstyleOutputFile).value
val results = scala.xml.XML.loadFile(resultFile)
val errorFiles = results \\ "checkstyle" \\ "file"

def errorFromXml(node: scala.xml.NodeSeq): (String, String, String) = {
val line: String = (node \ "@line" text)
val msg: String = (node \ "@message" text)
val source: String = (node \ "@source" text)
(line, msg, source)
}
def errorsFromXml(fileNode: scala.xml.NodeSeq): Seq[(String, String, String, String)] = {
val name: String = (fileNode \ "@name" text)
val errors = (fileNode \\ "error") map { e => errorFromXml(e) }
errors map { case (line, error, source) => (name, line, error, source) }
}

val errors = errorFiles flatMap { f => errorsFromXml(f) }

if (errors.nonEmpty) {
for (e <- errors) {
log.error(s"${e._1}:${e._2}: ${e._3} (from ${e._4})")
}
throw new RuntimeException(s"Checkstyle failed with ${errors.size} errors")
}
log.info("No errors from checkstyle")
}
// checkstyleConfigLocation := CheckstyleConfigLocation.File((baseDirectory.value / "checkstyle-config.xml").toString)

// Compile / checkstyle := {
// val log = streams.value.log
// (Compile / checkstyle).value
// val resultFile = (Compile / checkstyleOutputFile).value
// val results = scala.xml.XML.loadFile(resultFile)
// val errorFiles = results \\ "checkstyle" \\ "file"
//
// def errorFromXml(node: scala.xml.NodeSeq): (String, String, String) = {
// val line: String = (node \ "@line" text)
// val msg: String = (node \ "@message" text)
// val source: String = (node \ "@source" text)
// (line, msg, source)
// }
// def errorsFromXml(fileNode: scala.xml.NodeSeq): Seq[(String, String, String, String)] = {
// val name: String = (fileNode \ "@name" text)
// val errors = (fileNode \\ "error") map { e => errorFromXml(e) }
// errors map { case (line, error, source) => (name, line, error, source) }
// }
//
// val errors = errorFiles flatMap { f => errorsFromXml(f) }
//
// if (errors.nonEmpty) {
// for (e <- errors) {
// log.error(s"${e._1}:${e._2}: ${e._3} (from ${e._4})")
// }
// throw new RuntimeException(s"Checkstyle failed with ${errors.size} errors")
// }
// log.info("No errors from checkstyle")
// }

// add checkstyle as a dependency of doc
Compile / doc := ((Compile / doc).dependsOn(Compile / checkstyle)).value
Compile / doc := (Compile / doc)
// .dependsOn(Compile / checkstyle)
.value

findbugsReportType := Some(FindbugsReport.Html)
findbugsReportPath := Some(crossTarget.value / "findbugs.html")
Expand Down
5 changes: 3 additions & 2 deletions config/src/main/java/com/typesafe/config/ConfigFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,10 @@ public static Config systemProperties() {
* <p>
* Environment variables are mangled in the following way after stripping the prefix "CONFIG_FORCE_":
* <table border="1">
* <caption>Mangling of environment variables</caption>
* <tr>
* <th bgcolor="silver">Env Var</th>
* <th bgcolor="silver">Config</th>
* <th>Env Var</th>
* <th>Config</th>
* </tr>
* <tr>
* <td>_&nbsp;&nbsp;&nbsp;[1 underscore]</td>
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.8
sbt.version=1.8.1
10 changes: 5 additions & 5 deletions project/linksource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ object LinkSourcePlugin extends AutoPlugin {
override def requires = JvmPlugin
override lazy val projectSettings: Seq[Def.Setting[_ >: Option[String] with Task[Seq[String]] with Task[File] <: Product]] = Seq(
javadocSourceBaseUrl := None,
javacOptions in (Compile, doc) := {
val old = (javacOptions in doc).value
Compile / doc / javacOptions := {
val old = (doc / javacOptions).value
if (old.contains("-linksource"))
old
else
"-linksource" +: old
},
(doc in Compile) := {
val result = (doc in Compile).value
(Compile / doc) := {
val result = (Compile / doc).value

val dir = (target in doc in Compile).value
val dir = (Compile / doc / target).value

(javadocSourceBaseUrl.value, streams.value) match {
case (Some(url), streamz) =>
Expand Down
14 changes: 8 additions & 6 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
addSbtPlugin("com.github.sbt" % "sbt-findbugs" % "2.0.0")
addSbtPlugin("com.github.sbt" % "sbt-jacoco" % "3.1.0")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0-M2")
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.3")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.2")
//addSbtPlugin("com.github.sbt" % "sbt-jacoco" % "3.4.0")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.1.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.6")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")

addSbtPlugin("com.etsy" % "sbt-checkstyle-plugin" % "3.1.1")
//addSbtPlugin("com.etsy" % "sbt-checkstyle-plugin" % "3.1.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.2")
addSbtPlugin("com.eed3si9n" % "sbt-nocomma" % "0.1.0")

libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always