Skip to content

Commit a09e2fd

Browse files
committed
Set up Scala import ordering
1 parent cf56cb0 commit a09e2fd

File tree

8 files changed

+31
-4
lines changed

8 files changed

+31
-4
lines changed

build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ buildscript {
55
dependencies {
66
classpath 'com.cinnober.gradle:semver-git:2.5.0'
77
classpath 'com.diffplug.spotless:spotless-plugin-gradle:5.11.0'
8+
classpath 'io.github.cosmicsilence:gradle-scalafix:0.1.8'
89
}
910
}
1011
plugins {
@@ -127,6 +128,17 @@ String getGitCommit() {
127128

128129
subprojects { project ->
129130

131+
if (project.plugins.hasPlugin('scala')) {
132+
project.scalafix {
133+
configFile = rootProject.file('scalafix.conf')
134+
}
135+
dependencies.scalafix('com.github.liancheng:organize-imports_2.13:0.5.0')
136+
project.tasks.scalafix.dependsOn(project.tasks.spotlessApply)
137+
project.tasks.checkScalafix.dependsOn(project.tasks.spotlessCheck)
138+
project.tasks.spotlessApply.finalizedBy(project.tasks.scalafix)
139+
project.tasks.spotlessCheck.finalizedBy(project.tasks.checkScalafix)
140+
}
141+
130142
if (project.hasProperty('sourceCompatibility')) {
131143
sourceCompatibility = 1.8
132144
targetCompatibility = 1.8
@@ -135,6 +147,9 @@ subprojects { project ->
135147
tasks.withType(JavaCompile) {
136148
options.encoding = 'UTF-8'
137149
}
150+
tasks.withType(ScalaCompile) {
151+
scalaCompileOptions.additionalParameters = ['-Wunused']
152+
}
138153

139154
tasks.withType(AbstractArchiveTask) {
140155
from(rootProject.file('COPYING'))

scalafix.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
rules = [
2+
OrganizeImports
3+
]
4+
5+
OrganizeImports {
6+
expandRelative = true
7+
removeUnused = true
8+
}

webauthn-server-attestation/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'java-library'
33
id 'scala'
4+
id 'io.github.cosmicsilence.scalafix'
45
}
56

67
description = 'Yubico WebAuthn attestation subsystem'

webauthn-server-core/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id 'java-library'
33
id 'scala'
44
id 'info.solidsoft.pitest'
5+
id 'io.github.cosmicsilence.scalafix'
56
}
67

78
description = 'Yubico WebAuthn server core API (fewer dependencies)'
@@ -46,7 +47,6 @@ dependencies {
4647
)
4748
}
4849

49-
5050
jar {
5151
manifest {
5252
attributes([

webauthn-server-core/src/test/scala/com/yubico/webauthn/RelyingPartyRegistrationSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import java.security.cert.X509Certificate
3434
import java.security.interfaces.RSAPublicKey
3535
import javax.security.auth.x500.X500Principal
3636
import scala.jdk.CollectionConverters._
37-
import scala.util.Failure
3837
import scala.util.Success
3938
import scala.util.Try
4039

@@ -54,19 +53,20 @@ import com.yubico.webauthn.data.AuthenticatorData
5453
import com.yubico.webauthn.data.AuthenticatorSelectionCriteria
5554
import com.yubico.webauthn.data.ByteArray
5655
import com.yubico.webauthn.data.COSEAlgorithmIdentifier
56+
import scala.util.Failure
5757
import com.yubico.webauthn.data.CollectedClientData
5858
import com.yubico.webauthn.data.Generators._
5959
import com.yubico.webauthn.data.PublicKeyCredentialParameters
60-
import com.yubico.webauthn.data.RegistrationExtensionInputs
60+
import org.mockito.Mockito
6161
import com.yubico.webauthn.data.RelyingPartyIdentity
6262
import com.yubico.webauthn.data.UserIdentity
6363
import com.yubico.webauthn.data.UserVerificationRequirement
64+
import com.yubico.webauthn.data.RegistrationExtensionInputs
6465
import com.yubico.webauthn.test.Helpers
6566
import com.yubico.webauthn.test.Util.toStepWithUtilities
6667
import org.bouncycastle.asn1.DEROctetString
6768
import org.bouncycastle.asn1.x500.X500Name
6869
import org.junit.runner.RunWith
69-
import org.mockito.Mockito
7070
import org.scalacheck.Gen
7171
import org.scalatest.FunSpec
7272
import org.scalatest.Matchers

webauthn-server-demo/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
id 'war'
44
id 'application'
55
id 'scala'
6+
id 'io.github.cosmicsilence.scalafix'
67
}
78

89
description = 'WebAuthn demo'

yubico-util-scala/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id 'scala'
3+
id 'io.github.cosmicsilence.scalafix'
34
}
45

56
description = 'Yubico internal Scala utilities'

yubico-util/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'java-library'
33
id 'scala'
4+
id 'io.github.cosmicsilence.scalafix'
45
}
56

67
description = 'Yubico internal utilities'

0 commit comments

Comments
 (0)