=build Fix commandAlias for fixall and sortImports (#28984)

* =build Fix commandAlias for fixall and sortImports

* =build Update sortImports to 0.5.0

* Sort imports to handle `javax`.

* fx
This commit is contained in:
kerr 2020-05-11 17:47:33 +08:00 committed by GitHub
parent de7d18667f
commit bada816714
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 97 additions and 77 deletions

View file

@ -31,6 +31,7 @@ ignored-files = [
//ignored packages //ignored packages
ignored-packages = [ ignored-packages = [
"docs",
"doc", "doc",
"jdoc" "jdoc"
] ]
@ -38,7 +39,7 @@ ignored-packages = [
//sort imports, see https://github.com/NeQuissimus/sort-imports //sort imports, see https://github.com/NeQuissimus/sort-imports
SortImports.asciiSort = false SortImports.asciiSort = false
SortImports.blocks = [ SortImports.blocks = [
"java.", "re:javax?\\.",
"scala.", "scala.",
"*", "*",
"com.sun." "com.sun."

View file

@ -4,9 +4,10 @@
package akka.compat package akka.compat
import akka.annotation.InternalApi
import scala.concurrent.{ ExecutionContext, Future => SFuture }
import scala.collection.immutable import scala.collection.immutable
import scala.concurrent.{ ExecutionContext, Future => SFuture }
import akka.annotation.InternalApi
/** /**
* INTERNAL API * INTERNAL API

View file

@ -4,10 +4,10 @@
package akka.dispatch.internal package akka.dispatch.internal
import akka.annotation.InternalApi
import scala.concurrent.ExecutionContext import scala.concurrent.ExecutionContext
import akka.annotation.InternalApi
/** /**
* Factory to create same thread ec. Not intended to be called from any other site than to create [[akka.dispatch.ExecutionContexts#parasitic]] * Factory to create same thread ec. Not intended to be called from any other site than to create [[akka.dispatch.ExecutionContexts#parasitic]]
* *

View file

@ -4,8 +4,6 @@
package akka.util package akka.util
import akka.util.Collections.EmptyImmutableSeq
import java.nio.{ ByteBuffer, ByteOrder } import java.nio.{ ByteBuffer, ByteOrder }
import scala.annotation.tailrec import scala.annotation.tailrec
@ -14,6 +12,8 @@ import scala.collection.LinearSeq
import scala.collection.mutable.ListBuffer import scala.collection.mutable.ListBuffer
import scala.reflect.ClassTag import scala.reflect.ClassTag
import akka.util.Collections.EmptyImmutableSeq
object ByteIterator { object ByteIterator {
object ByteArrayIterator { object ByteArrayIterator {

View file

@ -5,16 +5,17 @@
package akka.util package akka.util
import java.io.{ ObjectInputStream, ObjectOutputStream } import java.io.{ ObjectInputStream, ObjectOutputStream }
import java.nio.{ ByteBuffer, ByteOrder }
import java.lang.{ Iterable => JIterable } import java.lang.{ Iterable => JIterable }
import java.nio.{ ByteBuffer, ByteOrder }
import java.nio.charset.{ Charset, StandardCharsets } import java.nio.charset.{ Charset, StandardCharsets }
import java.util.Base64 import java.util.Base64
import scala.annotation.{ tailrec, varargs } import scala.annotation.{ tailrec, varargs }
import scala.collection.mutable.{ Builder, WrappedArray }
import scala.collection.{ immutable, mutable } import scala.collection.{ immutable, mutable }
import scala.collection.immutable.{ IndexedSeq, IndexedSeqOps, StrictOptimizedSeqOps, VectorBuilder } import scala.collection.immutable.{ IndexedSeq, IndexedSeqOps, StrictOptimizedSeqOps, VectorBuilder }
import scala.collection.mutable.{ Builder, WrappedArray }
import scala.reflect.ClassTag import scala.reflect.ClassTag
import com.github.ghik.silencer.silent import com.github.ghik.silencer.silent
object ByteString { object ByteString {

View file

@ -22,9 +22,6 @@ import akka.event.Logging
import akka.util.{ ImmutableIntMap, ReentrantGuard } import akka.util.{ ImmutableIntMap, ReentrantGuard }
import akka.util.Helpers.Requiring import akka.util.Helpers.Requiring
import scala.annotation.{ switch, tailrec }
import scala.collection.{ immutable, mutable }
@InternalApi @InternalApi
@ApiMayChange @ApiMayChange
private[affinity] object AffinityPool { private[affinity] object AffinityPool {

View file

@ -165,7 +165,6 @@ object DnsSettings {
def getNameserversUsingJNDI: Try[List[InetSocketAddress]] = { def getNameserversUsingJNDI: Try[List[InetSocketAddress]] = {
import java.util import java.util
import javax.naming.Context import javax.naming.Context
import javax.naming.directory.InitialDirContext import javax.naming.directory.InitialDirContext
// Using jndi-dns to obtain the default name servers. // Using jndi-dns to obtain the default name servers.

View file

@ -36,9 +36,9 @@ import akka.dispatch.MessageDispatcher
import akka.event.Logging import akka.event.Logging
import akka.pattern.ask import akka.pattern.ask
import akka.util.JavaDurationConverters._ import akka.util.JavaDurationConverters._
import akka.util.ccompat.JavaConverters._
import akka.util.PrettyDuration._ import akka.util.PrettyDuration._
import akka.util.Timeout import akka.util.Timeout
import akka.util.ccompat.JavaConverters._
/** /**
* INTERNAL API * INTERNAL API

View file

@ -5,7 +5,6 @@
package akka.cluster package akka.cluster
import java.lang.management.ManagementFactory import java.lang.management.ManagementFactory
import javax.management.InstanceAlreadyExistsException import javax.management.InstanceAlreadyExistsException
import javax.management.InstanceNotFoundException import javax.management.InstanceNotFoundException
import javax.management.ObjectName import javax.management.ObjectName

View file

@ -5,12 +5,12 @@
package akka.cluster package akka.cluster
import java.lang.management.ManagementFactory import java.lang.management.ManagementFactory
import javax.management.ObjectName
import scala.concurrent.Await import scala.concurrent.Await
import scala.concurrent.duration._ import scala.concurrent.duration._
import com.typesafe.config.ConfigFactory import com.typesafe.config.ConfigFactory
import javax.management.ObjectName
import akka.actor.ActorSystem import akka.actor.ActorSystem
import akka.actor.Address import akka.actor.Address

View file

@ -4,8 +4,8 @@
package akka.persistence.testkit.javadsl package akka.persistence.testkit.javadsl
import java.util.function.{ Function => JFunction }
import java.util.{ List => JList } import java.util.{ List => JList }
import java.util.function.{ Function => JFunction }
import scala.reflect.ClassTag import scala.reflect.ClassTag

View file

@ -31,13 +31,13 @@ import akka.persistence.typed.DeleteSnapshotsFailed
import akka.persistence.typed.DeletionTarget import akka.persistence.typed.DeletionTarget
import akka.persistence.typed.EventAdapter import akka.persistence.typed.EventAdapter
import akka.persistence.typed.NoOpEventAdapter import akka.persistence.typed.NoOpEventAdapter
import akka.persistence.typed.scaladsl.{ Recovery => TypedRecovery }
import akka.persistence.typed.PersistenceId import akka.persistence.typed.PersistenceId
import akka.persistence.typed.SnapshotAdapter import akka.persistence.typed.SnapshotAdapter
import akka.persistence.typed.SnapshotCompleted import akka.persistence.typed.SnapshotCompleted
import akka.persistence.typed.SnapshotFailed import akka.persistence.typed.SnapshotFailed
import akka.persistence.typed.SnapshotSelectionCriteria import akka.persistence.typed.SnapshotSelectionCriteria
import akka.persistence.typed.scaladsl._ import akka.persistence.typed.scaladsl._
import akka.persistence.typed.scaladsl.{ Recovery => TypedRecovery }
import akka.persistence.typed.scaladsl.RetentionCriteria import akka.persistence.typed.scaladsl.RetentionCriteria
import akka.util.ConstantFun import akka.util.ConstantFun
import akka.util.unused import akka.util.unused

View file

@ -32,7 +32,6 @@ import akka.actor.typed.scaladsl.Behaviors
import akka.persistence.{ SnapshotMetadata => ClassicSnapshotMetadata } import akka.persistence.{ SnapshotMetadata => ClassicSnapshotMetadata }
import akka.persistence.{ SnapshotSelectionCriteria => ClassicSnapshotSelectionCriteria } import akka.persistence.{ SnapshotSelectionCriteria => ClassicSnapshotSelectionCriteria }
import akka.persistence.SelectedSnapshot import akka.persistence.SelectedSnapshot
import akka.persistence.typed.SnapshotSelectionCriteria
import akka.persistence.journal.inmem.InmemJournal import akka.persistence.journal.inmem.InmemJournal
import akka.persistence.query.EventEnvelope import akka.persistence.query.EventEnvelope
import akka.persistence.query.PersistenceQuery import akka.persistence.query.PersistenceQuery
@ -44,6 +43,7 @@ import akka.persistence.typed.RecoveryCompleted
import akka.persistence.typed.SnapshotCompleted import akka.persistence.typed.SnapshotCompleted
import akka.persistence.typed.SnapshotFailed import akka.persistence.typed.SnapshotFailed
import akka.persistence.typed.SnapshotMetadata import akka.persistence.typed.SnapshotMetadata
import akka.persistence.typed.SnapshotSelectionCriteria
import akka.serialization.jackson.CborSerializable import akka.serialization.jackson.CborSerializable
import akka.stream.scaladsl.Sink import akka.stream.scaladsl.Sink

View file

@ -12,10 +12,6 @@ import java.nio.file.Paths
import java.security.GeneralSecurityException import java.security.GeneralSecurityException
import java.security.KeyStore import java.security.KeyStore
import java.security.SecureRandom import java.security.SecureRandom
import scala.util.Try
import com.typesafe.config.Config
import javax.net.ssl.KeyManager import javax.net.ssl.KeyManager
import javax.net.ssl.KeyManagerFactory import javax.net.ssl.KeyManagerFactory
import javax.net.ssl.SSLContext import javax.net.ssl.SSLContext
@ -24,6 +20,10 @@ import javax.net.ssl.SSLSession
import javax.net.ssl.TrustManager import javax.net.ssl.TrustManager
import javax.net.ssl.TrustManagerFactory import javax.net.ssl.TrustManagerFactory
import scala.util.Try
import com.typesafe.config.Config
import akka.actor.ActorSystem import akka.actor.ActorSystem
import akka.actor.ExtendedActorSystem import akka.actor.ExtendedActorSystem
import akka.actor.setup.Setup import akka.actor.setup.Setup

View file

@ -11,9 +11,6 @@ import java.nio.file.Paths
import java.security.GeneralSecurityException import java.security.GeneralSecurityException
import java.security.KeyStore import java.security.KeyStore
import java.security.SecureRandom import java.security.SecureRandom
import scala.util.Try
import javax.net.ssl.KeyManager import javax.net.ssl.KeyManager
import javax.net.ssl.KeyManagerFactory import javax.net.ssl.KeyManagerFactory
import javax.net.ssl.SSLContext import javax.net.ssl.SSLContext
@ -21,6 +18,8 @@ import javax.net.ssl.SSLEngine
import javax.net.ssl.TrustManager import javax.net.ssl.TrustManager
import javax.net.ssl.TrustManagerFactory import javax.net.ssl.TrustManagerFactory
import scala.util.Try
import akka.actor.ActorSystem import akka.actor.ActorSystem
import akka.event.Logging import akka.event.Logging
import akka.event.MarkerLoggingAdapter import akka.event.MarkerLoggingAdapter

View file

@ -7,7 +7,9 @@ package akka.remote.artery
import java.util.UUID import java.util.UUID
import scala.concurrent.duration._ import scala.concurrent.duration._
import com.typesafe.config.{ Config, ConfigFactory } import com.typesafe.config.{ Config, ConfigFactory }
import akka.actor.Actor import akka.actor.Actor
import akka.actor.ActorIdentity import akka.actor.ActorIdentity
import akka.actor.ActorPath import akka.actor.ActorPath

View file

@ -8,12 +8,12 @@ package tcp
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.security.NoSuchAlgorithmException import java.security.NoSuchAlgorithmException
import java.util.zip.GZIPOutputStream import java.util.zip.GZIPOutputStream
import javax.net.ssl.SSLEngine
import scala.concurrent.duration._ import scala.concurrent.duration._
import com.typesafe.config.Config import com.typesafe.config.Config
import com.typesafe.config.ConfigFactory import com.typesafe.config.ConfigFactory
import javax.net.ssl.SSLEngine
import akka.actor.ActorIdentity import akka.actor.ActorIdentity
import akka.actor.ActorPath import akka.actor.ActorPath

View file

@ -8,6 +8,7 @@ import java.security.KeyStore
import java.security.SecureRandom import java.security.SecureRandom
import java.security.cert.CertificateException import java.security.cert.CertificateException
import java.util.concurrent.TimeoutException import java.util.concurrent.TimeoutException
import javax.net.ssl._
import scala.collection.immutable import scala.collection.immutable
import scala.concurrent.Await import scala.concurrent.Await
@ -17,7 +18,6 @@ import scala.util.Random
import com.github.ghik.silencer.silent import com.github.ghik.silencer.silent
import com.typesafe.sslconfig.akka.AkkaSSLConfig import com.typesafe.sslconfig.akka.AkkaSSLConfig
import javax.net.ssl._
import akka.NotUsed import akka.NotUsed
import akka.pattern.{ after => later } import akka.pattern.{ after => later }

View file

@ -921,7 +921,6 @@ class TcpSpec extends StreamSpec("""
// #setting-up-ssl-engine // #setting-up-ssl-engine
import java.security.KeyStore import java.security.KeyStore
import javax.net.ssl.KeyManagerFactory import javax.net.ssl.KeyManagerFactory
import javax.net.ssl.SSLContext import javax.net.ssl.SSLContext
import javax.net.ssl.SSLEngine import javax.net.ssl.SSLEngine
@ -1010,9 +1009,9 @@ class TcpSpec extends StreamSpec("""
def initSslMess() = { def initSslMess() = {
// #setting-up-ssl-context // #setting-up-ssl-context
import java.security.KeyStore import java.security.KeyStore
import javax.net.ssl._
import com.typesafe.sslconfig.akka.AkkaSSLConfig import com.typesafe.sslconfig.akka.AkkaSSLConfig
import javax.net.ssl._
import akka.stream.TLSClientAuth import akka.stream.TLSClientAuth
import akka.stream.TLSProtocol import akka.stream.TLSProtocol

View file

@ -8,6 +8,7 @@ import java.security.KeyStore
import java.security.SecureRandom import java.security.SecureRandom
import java.security.cert.CertificateException import java.security.cert.CertificateException
import java.util.concurrent.TimeoutException import java.util.concurrent.TimeoutException
import javax.net.ssl._
import scala.collection.immutable import scala.collection.immutable
import scala.concurrent.Await import scala.concurrent.Await
@ -15,8 +16,6 @@ import scala.concurrent.Future
import scala.concurrent.duration._ import scala.concurrent.duration._
import scala.util.Random import scala.util.Random
import javax.net.ssl._
import akka.NotUsed import akka.NotUsed
import akka.pattern.{ after => later } import akka.pattern.{ after => later }
import akka.stream._ import akka.stream._

View file

@ -4,12 +4,12 @@
package akka.stream.scaladsl package akka.stream.scaladsl
import akka.stream.testkit.scaladsl.StreamTestKit._
import akka.stream.testkit.{ StreamSpec, TestSubscriber }
import akka.testkit.DefaultTimeout
import scala.concurrent.duration._ import scala.concurrent.duration._
import akka.stream.testkit.{ StreamSpec, TestSubscriber }
import akka.stream.testkit.scaladsl.StreamTestKit._
import akka.testkit.DefaultTimeout
class NeverSourceSpec extends StreamSpec with DefaultTimeout { class NeverSourceSpec extends StreamSpec with DefaultTimeout {
"The Never Source" must { "The Never Source" must {

View file

@ -4,11 +4,11 @@
package akka.stream package akka.stream
import javax.net.ssl._
import scala.annotation.varargs import scala.annotation.varargs
import scala.collection.immutable import scala.collection.immutable
import javax.net.ssl._
import akka.util.ByteString import akka.util.ByteString
/** /**

View file

@ -5,16 +5,15 @@
package akka.stream.impl.io package akka.stream.impl.io
import java.nio.ByteBuffer import java.nio.ByteBuffer
import scala.annotation.tailrec
import scala.util.{ Failure, Success, Try }
import scala.util.control.NonFatal
import javax.net.ssl._ import javax.net.ssl._
import javax.net.ssl.SSLEngineResult.HandshakeStatus import javax.net.ssl.SSLEngineResult.HandshakeStatus
import javax.net.ssl.SSLEngineResult.HandshakeStatus._ import javax.net.ssl.SSLEngineResult.HandshakeStatus._
import javax.net.ssl.SSLEngineResult.Status._ import javax.net.ssl.SSLEngineResult.Status._
import scala.annotation.tailrec
import scala.util.{ Failure, Success, Try }
import scala.util.control.NonFatal
import akka.actor._ import akka.actor._
import akka.annotation.InternalApi import akka.annotation.InternalApi
import akka.stream._ import akka.stream._

View file

@ -4,10 +4,10 @@
package akka.stream.impl.io package akka.stream.impl.io
import scala.util.Try
import javax.net.ssl.{ SSLEngine, SSLSession } import javax.net.ssl.{ SSLEngine, SSLSession }
import scala.util.Try
import akka.NotUsed import akka.NotUsed
import akka.actor.ActorSystem import akka.actor.ActorSystem
import akka.annotation.InternalApi import akka.annotation.InternalApi

View file

@ -6,12 +6,12 @@ package akka.stream.javadsl
import java.util.Optional import java.util.Optional
import java.util.function.{ Consumer, Supplier } import java.util.function.{ Consumer, Supplier }
import javax.net.ssl.{ SSLContext, SSLEngine, SSLSession }
import scala.compat.java8.OptionConverters import scala.compat.java8.OptionConverters
import scala.util.Try import scala.util.Try
import com.typesafe.sslconfig.akka.AkkaSSLConfig import com.typesafe.sslconfig.akka.AkkaSSLConfig
import javax.net.ssl.{ SSLContext, SSLEngine, SSLSession }
import akka.{ japi, NotUsed } import akka.{ japi, NotUsed }
import akka.stream._ import akka.stream._

View file

@ -10,6 +10,9 @@ import java.util.Optional
import java.util.concurrent.CompletionStage import java.util.concurrent.CompletionStage
import java.util.function.{ Function => JFunction } import java.util.function.{ Function => JFunction }
import java.util.function.Supplier import java.util.function.Supplier
import javax.net.ssl.SSLContext
import javax.net.ssl.SSLEngine
import javax.net.ssl.SSLSession
import scala.compat.java8.FutureConverters._ import scala.compat.java8.FutureConverters._
import scala.compat.java8.OptionConverters._ import scala.compat.java8.OptionConverters._
@ -18,9 +21,6 @@ import scala.util.Failure
import scala.util.Success import scala.util.Success
import com.github.ghik.silencer.silent import com.github.ghik.silencer.silent
import javax.net.ssl.SSLContext
import javax.net.ssl.SSLEngine
import javax.net.ssl.SSLSession
import akka.{ Done, NotUsed } import akka.{ Done, NotUsed }
import akka.actor.ActorSystem import akka.actor.ActorSystem

View file

@ -5,12 +5,12 @@
package akka.stream.scaladsl package akka.stream.scaladsl
import java.util.Collections import java.util.Collections
import javax.net.ssl.{ SNIHostName, SSLContext, SSLEngine, SSLSession }
import javax.net.ssl.SSLParameters
import scala.util.{ Failure, Success, Try } import scala.util.{ Failure, Success, Try }
import com.typesafe.sslconfig.akka.AkkaSSLConfig import com.typesafe.sslconfig.akka.AkkaSSLConfig
import javax.net.ssl.{ SNIHostName, SSLContext, SSLEngine, SSLSession }
import javax.net.ssl.SSLParameters
import akka.NotUsed import akka.NotUsed
import akka.actor.ActorSystem import akka.actor.ActorSystem
@ -229,7 +229,6 @@ object TLSPlacebo {
import java.security.Principal import java.security.Principal
import java.security.cert.Certificate import java.security.cert.Certificate
import javax.net.ssl.{ SSLPeerUnverifiedException, SSLSession } import javax.net.ssl.{ SSLPeerUnverifiedException, SSLSession }
/** Allows access to an SSLSession with Scala types */ /** Allows access to an SSLSession with Scala types */

View file

@ -6,6 +6,9 @@ package akka.stream.scaladsl
import java.net.InetSocketAddress import java.net.InetSocketAddress
import java.util.concurrent.TimeoutException import java.util.concurrent.TimeoutException
import javax.net.ssl.SSLContext
import javax.net.ssl.SSLEngine
import javax.net.ssl.SSLSession
import scala.collection.immutable import scala.collection.immutable
import scala.concurrent.Future import scala.concurrent.Future
@ -17,9 +20,6 @@ import scala.util.Try
import scala.util.control.NoStackTrace import scala.util.control.NoStackTrace
import com.github.ghik.silencer.silent import com.github.ghik.silencer.silent
import javax.net.ssl.SSLContext
import javax.net.ssl.SSLEngine
import javax.net.ssl.SSLSession
import akka.Done import akka.Done
import akka.NotUsed import akka.NotUsed

View file

@ -7,11 +7,11 @@ package com.typesafe.sslconfig.akka
import java.security.KeyStore import java.security.KeyStore
import java.security.cert.CertPathValidatorException import java.security.cert.CertPathValidatorException
import java.util.Collections import java.util.Collections
import javax.net.ssl._
import com.typesafe.sslconfig.akka.util.AkkaLoggerFactory import com.typesafe.sslconfig.akka.util.AkkaLoggerFactory
import com.typesafe.sslconfig.ssl._ import com.typesafe.sslconfig.ssl._
import com.typesafe.sslconfig.util.LoggerFactory import com.typesafe.sslconfig.util.LoggerFactory
import javax.net.ssl._
import akka.actor._ import akka.actor._
import akka.annotation.InternalApi import akka.annotation.InternalApi

View file

@ -4,9 +4,10 @@
package com.typesafe.sslconfig.akka package com.typesafe.sslconfig.akka
import com.typesafe.sslconfig.ssl.SSLConfigSettings
import javax.net.ssl.{ SSLContext, SSLEngine } import javax.net.ssl.{ SSLContext, SSLEngine }
import com.typesafe.sslconfig.ssl.SSLConfigSettings
/** /**
* Gives the chance to configure the SSLContext before it is going to be used. * Gives the chance to configure the SSLContext before it is going to be used.
* The passed in context will be already set in client mode and provided with hostInfo during initialization. * The passed in context will be already set in client mode and provided with hostInfo during initialization.

View file

@ -15,8 +15,7 @@ addCommandAlias(
addCommandAlias( addCommandAlias(
name = "sortImports", name = "sortImports",
value = ";scalafixEnable;compile:scalafix SortImports;test:scalafix SortImports;multi-jvm:scalafix SortImports;" + value = ";scalafixEnable;compile:scalafix SortImports;test:scalafix SortImports;scalafmtAll")
"CompileJdk9:scalafix SortImports;TestJdk9:scalafix SortImports;scalafmtAll;test:compile;multi-jvm:compile;reload")
import akka.AkkaBuild._ import akka.AkkaBuild._
import akka.{AkkaBuild, Dependencies, OSGi, Protobuf, SigarLoader, VersionGenerator} import akka.{AkkaBuild, Dependencies, OSGi, Protobuf, SigarLoader, VersionGenerator}

View file

@ -7,14 +7,23 @@ package akka
import java.io.File import java.io.File
import com.typesafe.config.ConfigFactory import com.typesafe.config.ConfigFactory
import sbt.AutoPlugin
import sbt.Def
import sbt.file
import sbt.internal.sbtscalafix.Compat import sbt.internal.sbtscalafix.Compat
class ProjectFileIgnoreSupport(ignoreConfigFile: File, descriptor: String) { class ProjectFileIgnoreSupport(ignoreConfigFile: File, descriptor: String) {
private val stdoutLogger = Compat.ConsoleLogger(System.out) private val stdoutLogger = Compat.ConsoleLogger(System.out)
private val javaSourceDirectories = Set(
"java",
Jdk9.JAVA_SOURCE_DIRECTORY,
Jdk9.JAVA_TEST_SOURCE_DIRECTORY
)
private val scalaSourceDirectories = Set(
"scala",
Jdk9.SCALA_SOURCE_DIRECTORY,
Jdk9.SCALA_TEST_SOURCE_DIRECTORY
)
private lazy val ignoreConfig = { private lazy val ignoreConfig = {
require(ignoreConfigFile.exists(), s"Expected ignore configuration for $descriptor at ${ignoreConfigFile.getAbsolutePath} but was missing") require(ignoreConfigFile.exists(), s"Expected ignore configuration for $descriptor at ${ignoreConfigFile.getAbsolutePath} but was missing")
ConfigFactory.parseFile(ignoreConfigFile) ConfigFactory.parseFile(ignoreConfigFile)
@ -55,7 +64,7 @@ class ProjectFileIgnoreSupport(ignoreConfigFile: File, descriptor: String) {
case Some(packageName) => case Some(packageName) =>
val ignored = packageName.startsWith(pkg) val ignored = packageName.startsWith(pkg)
if (ignored) { if (ignored) {
stdoutLogger.debug(s"$descriptor ignored file with pkg:$pkg file:[${file.toPath}] ") stdoutLogger.debug(s"$descriptor ignored file with pkg:$pkg for package:$packageName file:[${file.toPath}] ")
} }
ignored ignored
case None => false case None => false
@ -65,22 +74,23 @@ class ProjectFileIgnoreSupport(ignoreConfigFile: File, descriptor: String) {
} }
private def getPackageName(fileName: String): Option[String] = { private def getPackageName(fileName: String): Option[String] = {
def getPackageName0(fileType: String): String = { def getPackageName0(sourceDirectories:Set[String]): String = {
import java.io.{File => JFile} import java.io.{File => JFile}
fileName.split(JFile.separatorChar) val packageName = fileName.split(JFile.separatorChar)
.dropWhile(part => part != fileType) .dropWhile(part => !sourceDirectories(part))
.drop(1) .drop(1)
.dropRight(1) .dropRight(1)
.mkString(".") .mkString(".")
packageName
} }
fileName.split('.').lastOption match { fileName.split('.').lastOption match {
case Some(fileType) => case Some(fileType) =>
fileType match { fileType match {
case "java" => case "java" =>
Option(getPackageName0("java")) Option(getPackageName0(javaSourceDirectories))
case "scala" => case "scala" =>
Option(getPackageName0("scala")) Option(getPackageName0(scalaSourceDirectories))
case _ => None case _ => None
} }
case None => None case None => None

View file

@ -15,6 +15,6 @@ object ScalaFixExtraRulesPlugin extends AutoPlugin with ScalafixSupport{
import sbt._ import sbt._
import scalafix.sbt.ScalafixPlugin.autoImport.scalafixDependencies import scalafix.sbt.ScalafixPlugin.autoImport.scalafixDependencies
override def projectSettings: Seq[Def.Setting[_]] = super.projectSettings ++ { override def projectSettings: Seq[Def.Setting[_]] = super.projectSettings ++ {
scalafixDependencies in ThisBuild += "com.nequissimus" %% "sort-imports" % "0.4.0" scalafixDependencies in ThisBuild += "com.nequissimus" %% "sort-imports" % "0.5.0"
} }
} }

View file

@ -9,12 +9,23 @@ import scalafix.sbt.ScalafixPlugin
object ScalaFixForJdk9Plugin extends AutoPlugin with ScalafixSupport { object ScalaFixForJdk9Plugin extends AutoPlugin with ScalafixSupport {
override def trigger: PluginTrigger = allRequirements override def trigger: PluginTrigger = allRequirements
import Jdk9._ import Jdk9._
override def requires: Plugins = Jdk9 && ScalafixPlugin override def requires: Plugins = Jdk9
import ScalafixPlugin.autoImport.scalafixConfigSettings import ScalafixPlugin.autoImport.scalafixConfigSettings
import sbt._ import sbt._
override def projectSettings: Seq[Def.Setting[_]] = super.projectSettings ++ {
inConfig(TestJdk9)(scalafixConfigSettings(TestJdk9)) ++ lazy val scalafixIgnoredSetting: Seq[Setting[_]] = Seq(
inConfig(CompileJdk9)(scalafixConfigSettings(CompileJdk9)) ignore(TestJdk9)
} )
override def projectSettings: Seq[Def.Setting[_]] =
Seq(CompileJdk9, TestJdk9).flatMap(c => inConfig(c)(scalafixConfigSettings(c))) ++
scalafixIgnoredSetting ++ Seq(
updateProjectCommands(
alias = "fixall",
value = ";scalafixEnable;compile:scalafix;test:scalafix;multi-jvm:scalafix;scalafmtAll;test:compile;multi-jvm:compile;reload"),
updateProjectCommands(
alias = "sortImports",
value = ";scalafixEnable;compile:scalafix SortImports;test:scalafix SortImports;CompileJdk9:scalafix SortImports;TestJdk9:scalafix SortImports;scalafmtAll")
)
} }

View file

@ -23,6 +23,10 @@ object ScalafixForMultiNodePlugin extends AutoPlugin with ScalafixSupport {
Seq(MultiJvm).flatMap(c => inConfig(c)(scalafixConfigSettings(c))) ++ Seq(MultiJvm).flatMap(c => inConfig(c)(scalafixConfigSettings(c))) ++
scalafixIgnoredSetting ++ Seq( scalafixIgnoredSetting ++ Seq(
updateProjectCommands( updateProjectCommands(
alias = "fix", alias = "fixall",
value = ";scalafixEnable;compile:scalafix;test:scalafix;multi-jvm:scalafix;test:compile;reload")) value = ";scalafixEnable;compile:scalafix;test:scalafix;multi-jvm:scalafix;scalafmtAll"),
updateProjectCommands(
alias = "sortImports",
value = ";scalafixEnable;compile:scalafix SortImports;test:scalafix SortImports;multi-jvm:scalafix SortImports;scalafmtAll")
)
} }