Skip to content

Commit 98e54cc

Browse files
authored
Merge pull request #219 from eed3si9n/wip/org
Move to com.github.sbt organization + cross build to sbt 2.x
2 parents 96a197c + 0c49ebf commit 98e54cc

File tree

18 files changed

+116
-80
lines changed

18 files changed

+116
-80
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,43 @@ name: CI
22
on:
33
pull_request:
44
push:
5-
schedule:
6-
# 2am EST every Saturday
7-
- cron: '0 7 * * 6'
5+
# schedule:
6+
# # 2am EST every Saturday
7+
# - cron: '0 7 * * 6'
88
jobs:
9-
build_scala2_12:
10-
runs-on: ubuntu-latest
9+
test:
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
include:
14+
- os: ubuntu-latest
15+
java: 8
16+
distribution: zulu
17+
jobtype: 1
18+
- os: ubuntu-latest
19+
java: 8
20+
distribution: zulu
21+
jobtype: 2
22+
runs-on: ${{ matrix.os }}
1123
env:
24+
# define Java options for both official sbt and sbt-extras
1225
JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
26+
JVM_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
1327
steps:
1428
- name: Checkout
15-
uses: actions/checkout@v2
16-
- name: Setup Scala
17-
uses: olafurpg/setup-scala@v13
29+
uses: actions/checkout@v4
30+
- name: Setup JDK
31+
uses: actions/setup-java@v4
1832
with:
19-
java-version: "[email protected]"
20-
- name: Coursier cache
21-
uses: coursier/cache-action@v6
22-
- name: Build and test
23-
run: |
24-
sbt -v clean scripted
25-
rm -rf "$HOME/.ivy2/local" || true
26-
find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true
27-
find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true
28-
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
29-
find $HOME/.sbt -name "ivydata-*.properties" -delete || true
33+
distribution: "${{ matrix.distribution }}"
34+
java-version: "${{ matrix.java }}"
35+
cache: sbt
36+
- uses: sbt/setup-sbt@v1
37+
- name: Build and test (sbt 1.x)
38+
if: ${{ matrix.jobtype == 1 }}
3039
shell: bash
40+
run: sbt -v '++ 2.12.x' clean test scripted
41+
- name: Build and test (sbt 2.x)
42+
if: ${{ matrix.jobtype == 2 }}
43+
shell: bash
44+
run: sbt -v '++ 3.x' clean test scripted

.github/workflows/release.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,30 @@ jobs:
77
build:
88
runs-on: ubuntu-latest
99
env:
10+
# define Java options for both official sbt and sbt-extras
1011
JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
12+
JVM_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
1113
steps:
1214
- name: Checkout
13-
uses: actions/checkout@v2
15+
uses: actions/checkout@v4
1416
- name: Setup Scala
1517
uses: olafurpg/setup-scala@v13
1618
with:
1719
java-version: "[email protected]"
20+
- name: Setup JDK
21+
uses: actions/setup-java@v4
22+
with:
23+
distribution: temurin
24+
java-version: 8
25+
cache: sbt
26+
- uses: sbt/setup-sbt@v1
1827
- name: Release
1928
env:
2029
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
2130
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
2231
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
2332
PGP_SECRET: ${{ secrets.PGP_SECRET }}
2433
CI_CLEAN: clean
25-
CI_RELEASE: publishSigned
34+
CI_RELEASE: +publishSigned
2635
run: |
2736
sbt ci-release

CODE_OF_CONDUCT.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ and this [maven plugin](https://github.com/revelc/formatter-maven-plugin), thoug
1313
Add the plugin to `project/plugins.sbt`:
1414

1515
```scala
16-
addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % --latest version---)
16+
addSbtPlugin("com.github.sbt" % "sbt-java-formatter" % --latest version---)
1717
```
1818

1919
For available versions see [releases](https://github.com/sbt/sbt-java-formatter/releases).
@@ -45,7 +45,7 @@ If you decide you really need more flexibility, you could consider other plugins
4545

4646
# Contributing
4747

48-
Yes, we'll happily accept PRs to improve the plugin. We expect you to adhere to the [Lightbend Community Code of Conduct](https://www.lightbend.com/conduct) and to sign the [Lightbend Contributor License Agreement - CLA](https://www.lightbend.com/contribute/cla).
48+
Yes, we'll happily accept PRs to improve the plugin.
4949

5050
Take a look at the [contributors graph](https://github.com/sbt/sbt-java-formatter/graphs/contributors) if you want to contact
5151
any of the contributors directly.

build.sbt

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
lazy val scala212 = "2.12.15"
2+
lazy val scala3 = "3.6.4"
3+
ThisBuild / scalaVersion := scala212
4+
ThisBuild / crossScalaVersions := Seq(scala212, scala3)
5+
16
lazy val sbtJavaFormatter = project.in(file(".")).aggregate(plugin).settings(publish / skip := true)
27

38
lazy val plugin = project
49
.in(file("plugin"))
510
.enablePlugins(SbtPlugin)
11+
.enablePlugins(AutomateHeaderPlugin)
612
.settings(
7-
organization := "com.lightbend.sbt",
8-
organizationName := "Lightbend Inc.",
9-
organizationHomepage := Some(url("https://lightbend.com")),
1013
name := "sbt-java-formatter",
1114
homepage := scmInfo.value.map(_.browseUrl),
1215
scmInfo := Some(
@@ -18,13 +21,32 @@ lazy val plugin = project
1821
description := "Formats Java code in your project.",
1922
licenses += ("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html")),
2023
publishTo := Some(if (isSnapshot.value) Opts.resolver.sonatypeSnapshots else Opts.resolver.sonatypeStaging),
21-
crossSbtVersions := List("1.3.0"),
22-
scalacOptions ++= Seq("-encoding", "UTF-8", "-unchecked", "-deprecation", "-feature"),
24+
(pluginCrossBuild / sbtVersion) := {
25+
scalaBinaryVersion.value match {
26+
case "2.12" => "1.5.8"
27+
case _ => "2.0.0-M4"
28+
}
29+
},
30+
scalacOptions ++= {
31+
Vector("-encoding", "UTF-8", "-unchecked", "-deprecation", "-feature") ++ (scalaBinaryVersion.value match {
32+
case "2.12" => Vector("-Xsource:3")
33+
case _ => Vector("-Wconf:error")
34+
})
35+
},
2336
javacOptions ++= Seq("-encoding", "UTF-8"),
2437
scriptedLaunchOpts := {
2538
scriptedLaunchOpts.value ++
2639
Seq("-Xmx1024M", "-Dplugin.version=" + version.value)
2740
},
2841
scriptedBufferLog := false,
29-
scalafmtOnCompile := true)
30-
.enablePlugins(AutomateHeaderPlugin)
42+
scalafmtOnCompile := true
43+
)
44+
45+
ThisBuild / organization := "com.github.sbt"
46+
ThisBuild / organizationName := "sbt community"
47+
ThisBuild / dynverSonatypeSnapshots := true
48+
ThisBuild / version := {
49+
val orig = (ThisBuild / version).value
50+
if (orig.endsWith("-SNAPSHOT")) "0.9.0-SNAPSHOT"
51+
else orig
52+
}

plugin/src/main/scala/com/lightbend/sbt/JavaFormatterPlugin.scala renamed to plugin/src/main/scala/com/github/sbt/JavaFormatterPlugin.scala

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 Lightbend Inc.
2+
* Copyright 2015 sbt community
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,20 +14,20 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.lightbend.sbt
17+
package com.github.sbt
1818

19+
import _root_.sbt.Keys._
20+
import _root_.sbt.{ Def, _ }
1921
import com.google.googlejavaformat.java.JavaFormatterOptions
20-
import com.lightbend.sbt.javaformatter.JavaFormatter
21-
import sbt.Keys._
22-
import sbt.{ Def, _ }
22+
import com.github.sbt.javaformatter.JavaFormatter
2323

2424
@deprecated("Use javafmtOnCompile setting instead", "0.5.1")
2525
object AutomateJavaFormatterPlugin extends AutoPlugin {
2626
override def trigger = allRequirements
2727

2828
override def `requires` = plugins.JvmPlugin && JavaFormatterPlugin
2929

30-
override def globalSettings: Seq[Def.Setting[_]] = Seq(JavaFormatterPlugin.autoImport.javafmtOnCompile := false)
30+
override def globalSettings: Seq[Def.Setting[?]] = Seq(JavaFormatterPlugin.autoImport.javafmtOnCompile := false)
3131
}
3232

3333
object JavaFormatterPlugin extends AutoPlugin {
@@ -54,20 +54,24 @@ object JavaFormatterPlugin extends AutoPlugin {
5454

5555
override def `requires` = plugins.JvmPlugin
5656

57-
override def projectSettings: Seq[Def.Setting[_]] = {
57+
override def projectSettings: Seq[Def.Setting[?]] = {
5858
val anyConfigsInThisProject = ScopeFilter(configurations = inAnyConfiguration)
5959

6060
notToBeScopedSettings ++
6161
Seq(Compile, Test).flatMap(inConfig(_)(toBeScopedSettings)) ++
6262
Seq(
63-
javafmtAll := javafmt.?.all(anyConfigsInThisProject).value,
64-
javafmtCheckAll := javafmtCheck.?.all(anyConfigsInThisProject).value)
63+
javafmtAll := {
64+
val _ = javafmt.?.all(anyConfigsInThisProject).value
65+
},
66+
javafmtCheckAll := {
67+
val _ = javafmtCheck.?.all(anyConfigsInThisProject).value
68+
})
6569
}
6670

67-
override def globalSettings: Seq[Def.Setting[_]] =
71+
override def globalSettings: Seq[Def.Setting[?]] =
6872
Seq(javafmtOnCompile := false, javafmtStyle := JavaFormatterOptions.Style.GOOGLE)
6973

70-
def toBeScopedSettings: Seq[Setting[_]] =
74+
def toBeScopedSettings: Seq[Setting[?]] =
7175
List(
7276
(javafmt / sourceDirectories) := List(javaSource.value),
7377
javafmtOptions := JavaFormatterOptions.builder().style(javafmtStyle.value).build(),
@@ -92,17 +96,17 @@ object JavaFormatterPlugin extends AutoPlugin {
9296
},
9397
javafmtDoFormatOnCompile := Def.settingDyn {
9498
if (javafmtOnCompile.value) {
95-
javafmt in resolvedScoped.value.scope
99+
resolvedScoped.value.scope / javafmt
96100
} else {
97101
Def.task(())
98102
}
99103
}.value,
100104
compile / compileInputs := (compile / compileInputs).dependsOn(javafmtDoFormatOnCompile).value)
101105

102-
def notToBeScopedSettings: Seq[Setting[_]] =
106+
def notToBeScopedSettings: Seq[Setting[?]] =
103107
List(javafmt / includeFilter := "*.java")
104108

105-
private[this] val javafmtDoFormatOnCompile =
109+
private val javafmtDoFormatOnCompile =
106110
taskKey[Unit]("Format Java source files if javafmtOnCompile is on.")
107111

108112
}

plugin/src/main/scala/com/lightbend/sbt/javaformatter/JavaFormatter.scala renamed to plugin/src/main/scala/com/github/sbt/javaformatter/JavaFormatter.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 Lightbend Inc.
2+
* Copyright 2015 sbt community
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,13 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.lightbend.sbt.javaformatter
17+
package com.github.sbt.javaformatter
1818

19+
import _root_.sbt.Keys._
20+
import _root_.sbt._
21+
import _root_.sbt.util.CacheImplicits._
22+
import _root_.sbt.util.{ CacheStoreFactory, FileInfo, Logger }
1923
import com.google.googlejavaformat.java.{ Formatter, JavaFormatterOptions }
20-
import sbt.Keys._
21-
import sbt._
22-
import sbt.util.CacheImplicits._
23-
import sbt.util.{ CacheStoreFactory, FileInfo, Logger }
2424
import scala.collection.immutable.Seq
2525

2626
object JavaFormatter {
@@ -32,7 +32,7 @@ object JavaFormatter {
3232
streams: TaskStreams,
3333
cacheStoreFactory: CacheStoreFactory,
3434
options: JavaFormatterOptions): Unit = {
35-
val files = sourceDirectories.descendantsExcept(includeFilter, excludeFilter).get.toList
35+
val files = sourceDirectories.descendantsExcept(includeFilter, excludeFilter).get().toList
3636
cachedFormatSources(cacheStoreFactory, files, streams.log)(new Formatter(options))
3737
}
3838

@@ -44,7 +44,7 @@ object JavaFormatter {
4444
streams: TaskStreams,
4545
cacheStoreFactory: CacheStoreFactory,
4646
options: JavaFormatterOptions): Boolean = {
47-
val files = sourceDirectories.descendantsExcept(includeFilter, excludeFilter).get.toList
47+
val files = sourceDirectories.descendantsExcept(includeFilter, excludeFilter).get().toList
4848
val analysis = cachedCheckSources(cacheStoreFactory, baseDir, files, streams.log)(new Formatter(options))
4949
trueOrBoom(analysis)
5050
}
@@ -65,9 +65,9 @@ object JavaFormatter {
6565

6666
import sjsonnew.{ :*:, LList, LNil }
6767

68-
implicit val analysisIso = LList.iso(
69-
{ a: Analysis => ("failedCheck", a.failedCheck) :*: LNil },
70-
{ in: Set[File] :*: LNil =>
68+
implicit val analysisIso: sjsonnew.IsoLList.Aux[Analysis, Set[File] :*: LNil] = LList.iso(
69+
{ (a: Analysis) => ("failedCheck", a.failedCheck) :*: LNil },
70+
{ (in: Set[File] :*: LNil) =>
7171
Analysis(in.head)
7272
})
7373
}

plugin/src/sbt-test/sbt-java-formatter/aosp-style/project/build.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % System.getProperty("plugin.version"))
1+
addSbtPlugin("com.github.sbt" % "sbt-java-formatter" % System.getProperty("plugin.version"))

plugin/src/sbt-test/sbt-java-formatter/aosp-style/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# compile should trigger formatting
2-
> test:compile
2+
> Test/compile
33

44
#$ exec echo "====== FORMATTED ======"
55
#$ exec cat src/main/java/com/lightbend/BadFormatting.java

0 commit comments

Comments
 (0)