From 81f547521b3d441a97e8bf7088f4b2c282bc601f Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Thu, 8 Sep 2022 16:47:07 +0200 Subject: [PATCH 1/3] Fix scalacOptions handling in build doh --- project/settings.sc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/settings.sc b/project/settings.sc index 8288d1b33d..05c2d00542 100644 --- a/project/settings.sc +++ b/project/settings.sc @@ -866,7 +866,7 @@ trait ScalaCliScalafixModule extends ScalafixModule with ScalaCliCompile { else { val len = l.length val idx = l.indexWhere(_.startsWith("-sourceroot")) - if (idx < len - 1) l.take(idx) ++ l.drop(idx + 2) + if (idx >= 0 && idx < len - 1) l.take(idx) ++ l.drop(idx + 2) else l } } From c841d31cdb24d177f56b2a4d314bbdb480912fdb Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Thu, 8 Sep 2022 16:20:03 +0200 Subject: [PATCH 2/3] Update Scalafix, apply rules --- .scalafix3.conf | 15 ++++++++++++++- .../build/src/main/scala/scala/build/Build.scala | 2 +- .../build/src/main/scala/scala/build/Inputs.scala | 3 +-- .../main/scala/scala/build/bsp/BspClient.scala | 3 +-- .../src/main/scala/scala/build/bsp/BspImpl.scala | 5 +++-- .../src/main/scala/scala/build/bsp/package.scala | 3 ++- .../internal/markdown/MarkdownCodeWrapper.scala | 3 +-- .../build/preprocessing/DirectivesProcessor.scala | 5 ++--- .../preprocessing/MarkdownPreprocessor.scala | 1 + .../build/preprocessing/ScalaPreprocessor.scala | 1 + .../src/main/scala/scala/cli/commands/Bsp.scala | 3 +-- .../src/main/scala/scala/cli/commands/Clean.scala | 3 +-- .../main/scala/scala/cli/commands/Compile.scala | 2 +- .../main/scala/scala/cli/commands/Default.scala | 2 +- .../src/main/scala/scala/cli/commands/Doc.scala | 4 ++-- .../scala/scala/cli/commands/Metabrowse.scala | 4 ++-- .../main/scala/scala/cli/commands/Package.scala | 3 ++- .../src/main/scala/scala/cli/commands/Repl.scala | 5 ++--- .../src/main/scala/scala/cli/commands/Run.scala | 3 ++- .../src/main/scala/scala/cli/commands/Test.scala | 2 +- .../scala/scala/cli/commands/bloop/Bloop.scala | 4 ++-- .../cli/commands/pgp/PgpExternalCommand.scala | 12 ++++++++---- .../scala/cli/commands/publish/Publish.scala | 12 ++++++------ .../publish/checks/PgpSecretKeyCheck.scala | 2 +- .../cli/commands/util/BuildCommandHelpers.scala | 2 +- .../scala/cli/commands/util/FmtOptionsUtil.scala | 4 ++-- .../scala/scala/cli/commands/util/FmtUtil.scala | 9 ++++----- .../scala/scala/cli/commands/util/RunHadoop.scala | 4 ++-- .../scala/scala/cli/commands/util/RunSpark.scala | 4 ++-- .../cli/commands/util/SharedOptionsUtil.scala | 3 ++- .../main/scala/scala/cli/config/ConfigDb.scala | 3 ++- .../main/scala/scala/cli/internal/CliLogger.scala | 6 +++--- .../scala/scala/cli/internal/ScalaJsLinker.scala | 2 +- .../cli/util/ConfigPasswordOptionHelpers.scala | 2 +- .../src/test/scala/cli/tests/ScalafmtTest.scala | 2 +- .../UsingPublishContextualDirectiveHandler.scala | 3 +-- .../src/main/scala/scala/build/Artifacts.scala | 3 ++- .../main/scala/scala/build/CoursierUtils.scala | 7 +++---- .../build/actionable/ActionableDiagnostic.scala | 2 +- .../build/actionable/ActionablePreprocessor.scala | 3 +-- .../scala/scala/build/options/BuildOptions.scala | 1 + .../scala/scala/build/options/HasHashData.scala | 2 +- .../scala/scala/build/options/JavaOptions.scala | 9 +++------ .../build/options/PublishContextualOptions.scala | 2 +- project/deps.sc | 2 +- 45 files changed, 95 insertions(+), 82 deletions(-) diff --git a/.scalafix3.conf b/.scalafix3.conf index b58dd6a894..e5a920e622 100644 --- a/.scalafix3.conf +++ b/.scalafix3.conf @@ -1,11 +1,24 @@ # Same as .scalafix.conf, but for RemoveUnused commented out rules = [ DisableSyntax, - # RemoveUnused + # RemoveUnused, + OrganizeImports, + NoValInForComprehension, + # ProcedureSyntax ] DisableSyntax.noFinalize = true +DisableSyntax.noIsInstanceOf = true +DisableSyntax.noReturns = true // `rules` on compilation triggered.rules = [ DisableSyntax ] + +OrganizeImports { + coalesceToWildcardImportThreshold = 6 + expandRelative = true + groups = ["*", "re:javax?\\.", "scala."] + groupedImports = AggressiveMerge + removeUnused = false # added for Scala 3 +} diff --git a/modules/build/src/main/scala/scala/build/Build.scala b/modules/build/src/main/scala/scala/build/Build.scala index 9c3888bf54..13da6784fe 100644 --- a/modules/build/src/main/scala/scala/build/Build.scala +++ b/modules/build/src/main/scala/scala/build/Build.scala @@ -13,6 +13,7 @@ import scala.annotation.tailrec import scala.build.EitherCps.{either, value} import scala.build.Inputs.VirtualScript.VirtualScriptNameRegex import scala.build.Ops.* +import scala.build.actionable.ActionablePreprocessor import scala.build.compiler.{ScalaCompiler, ScalaCompilerMaker} import scala.build.errors.* import scala.build.internal.{Constants, CustomCodeWrapper, MainClass, Util} @@ -23,7 +24,6 @@ import scala.collection.mutable.ListBuffer import scala.concurrent.duration.DurationInt import scala.util.Properties import scala.util.control.NonFatal -import scala.build.actionable.ActionablePreprocessor trait Build { def inputs: Inputs diff --git a/modules/build/src/main/scala/scala/build/Inputs.scala b/modules/build/src/main/scala/scala/build/Inputs.scala index 5ba43e5f59..4fbd9c3027 100644 --- a/modules/build/src/main/scala/scala/build/Inputs.scala +++ b/modules/build/src/main/scala/scala/build/Inputs.scala @@ -6,7 +6,7 @@ import java.nio.charset.StandardCharsets import java.security.MessageDigest import scala.annotation.tailrec -import scala.build.Inputs.WorkspaceOrigin +import scala.build.Inputs.{Element, WorkspaceOrigin} import scala.build.errors.{BuildException, InputsException} import scala.build.internal.Constants import scala.build.internal.zip.WrappedZipInputStream @@ -14,7 +14,6 @@ import scala.build.options.Scope import scala.build.preprocessing.ScopePath import scala.util.Properties import scala.util.matching.Regex -import scala.build.Inputs.Element final case class Inputs( elements: Seq[Inputs.Element], diff --git a/modules/build/src/main/scala/scala/build/bsp/BspClient.scala b/modules/build/src/main/scala/scala/build/bsp/BspClient.scala index 22a9ed9268..859c505db6 100644 --- a/modules/build/src/main/scala/scala/build/bsp/BspClient.scala +++ b/modules/build/src/main/scala/scala/build/bsp/BspClient.scala @@ -1,5 +1,6 @@ package scala.build.bsp +import ch.epfl.scala.bsp4j.Location import ch.epfl.scala.{bsp4j => b} import java.lang.{Boolean => JBoolean} @@ -7,8 +8,6 @@ import java.net.URI import java.nio.file.Paths import java.util.concurrent.{ConcurrentHashMap, ExecutorService} -import ch.epfl.scala.bsp4j.Location - import scala.build.Position.File import scala.build.errors.{BuildException, CompositeBuildException, Diagnostic, Severity} import scala.build.postprocessing.LineConversion diff --git a/modules/build/src/main/scala/scala/build/bsp/BspImpl.scala b/modules/build/src/main/scala/scala/build/bsp/BspImpl.scala index 9b2a381ef6..70810f208e 100644 --- a/modules/build/src/main/scala/scala/build/bsp/BspImpl.scala +++ b/modules/build/src/main/scala/scala/build/bsp/BspImpl.scala @@ -8,8 +8,10 @@ import org.eclipse.lsp4j.jsonrpc.messages.ResponseError import java.io.{InputStream, OutputStream} import java.util.concurrent.{CompletableFuture, Executor} -import scala.build.* + import scala.build.EitherCps.{either, value} +import scala.build.* +import scala.build.actionable.ActionablePreprocessor import scala.build.bloop.BloopServer import scala.build.compiler.BloopCompiler import scala.build.errors.{BuildException, Diagnostic, ParsingInputsException} @@ -20,7 +22,6 @@ import scala.concurrent.duration.DurationInt import scala.concurrent.{ExecutionContext, Future, Promise} import scala.jdk.CollectionConverters.* import scala.util.{Failure, Success} -import scala.build.actionable.ActionablePreprocessor /** The implementation for [[Bsp]]. * diff --git a/modules/build/src/main/scala/scala/build/bsp/package.scala b/modules/build/src/main/scala/scala/build/bsp/package.scala index 05ccc91cee..4590c1865c 100644 --- a/modules/build/src/main/scala/scala/build/bsp/package.scala +++ b/modules/build/src/main/scala/scala/build/bsp/package.scala @@ -1,9 +1,10 @@ package scala.build -import ch.epfl.scala.bsp4j as b import ch.epfl.scala.bsp4j.SourcesItem +import ch.epfl.scala.bsp4j as b import java.util.concurrent.CompletableFuture + import scala.jdk.CollectionConverters.* package object bsp { diff --git a/modules/build/src/main/scala/scala/build/internal/markdown/MarkdownCodeWrapper.scala b/modules/build/src/main/scala/scala/build/internal/markdown/MarkdownCodeWrapper.scala index 7c0c76da9b..f26809dfe3 100644 --- a/modules/build/src/main/scala/scala/build/internal/markdown/MarkdownCodeWrapper.scala +++ b/modules/build/src/main/scala/scala/build/internal/markdown/MarkdownCodeWrapper.scala @@ -1,9 +1,8 @@ package scala.build.internal.markdown import scala.annotation.tailrec -import scala.build.internal.AmmUtil import scala.build.internal.markdown.MarkdownCodeBlock -import scala.build.internal.Name +import scala.build.internal.{AmmUtil, Name} /** A util for extraction and wrapping of code blocks in Markdown files. */ diff --git a/modules/build/src/main/scala/scala/build/preprocessing/DirectivesProcessor.scala b/modules/build/src/main/scala/scala/build/preprocessing/DirectivesProcessor.scala index dd8b6caeae..ad259a3df8 100644 --- a/modules/build/src/main/scala/scala/build/preprocessing/DirectivesProcessor.scala +++ b/modules/build/src/main/scala/scala/build/preprocessing/DirectivesProcessor.scala @@ -1,16 +1,15 @@ package scala.build.preprocessing import scala.build.Logger import scala.build.Ops._ -import scala.build.errors.{BuildException, CompositeBuildException} +import scala.build.errors.{BuildException, CompositeBuildException, DirectiveErrors} import scala.build.options.ConfigMonoid import scala.build.preprocessing.directives.{ DirectiveHandler, + DirectiveUtil, ProcessedDirective, ScopedDirective, StrictDirective } -import scala.build.errors.DirectiveErrors -import scala.build.preprocessing.directives.DirectiveUtil object DirectivesProcessor { diff --git a/modules/build/src/main/scala/scala/build/preprocessing/MarkdownPreprocessor.scala b/modules/build/src/main/scala/scala/build/preprocessing/MarkdownPreprocessor.scala index 6812b78b24..7ed3abc032 100644 --- a/modules/build/src/main/scala/scala/build/preprocessing/MarkdownPreprocessor.scala +++ b/modules/build/src/main/scala/scala/build/preprocessing/MarkdownPreprocessor.scala @@ -1,6 +1,7 @@ package scala.build.preprocessing import java.nio.charset.StandardCharsets + import scala.build.EitherCps.{either, value} import scala.build.errors.BuildException import scala.build.internal.markdown.MarkdownCodeWrapper diff --git a/modules/build/src/main/scala/scala/build/preprocessing/ScalaPreprocessor.scala b/modules/build/src/main/scala/scala/build/preprocessing/ScalaPreprocessor.scala index fff071ffce..c51e8783a1 100644 --- a/modules/build/src/main/scala/scala/build/preprocessing/ScalaPreprocessor.scala +++ b/modules/build/src/main/scala/scala/build/preprocessing/ScalaPreprocessor.scala @@ -5,6 +5,7 @@ import dependency.AnyDependency import dependency.parser.DependencyParser import java.nio.charset.StandardCharsets + import scala.build.EitherCps.{either, value} import scala.build.Ops.* import scala.build.errors.* diff --git a/modules/cli/src/main/scala/scala/cli/commands/Bsp.scala b/modules/cli/src/main/scala/scala/cli/commands/Bsp.scala index 891fb05c4c..a7d94dd130 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/Bsp.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/Bsp.scala @@ -12,10 +12,9 @@ import scala.build.{Build, CrossSources, Inputs, PersistentDiagnosticLogger, Sou import scala.cli.CurrentParams import scala.cli.commands.util.CommonOps._ import scala.cli.commands.util.SharedOptionsUtil._ +import scala.cli.config.{ConfigDb, Keys} import scala.concurrent.Await import scala.concurrent.duration.Duration -import scala.cli.config.{ConfigDb, Keys} -import scala.cli.commands.util.CommonOps.SharedDirectoriesOptionsOps object Bsp extends ScalaCommand[BspOptions] { override def hidden = true diff --git a/modules/cli/src/main/scala/scala/cli/commands/Clean.scala b/modules/cli/src/main/scala/scala/cli/commands/Clean.scala index 43a8c98fb0..f771d78b24 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/Clean.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/Clean.scala @@ -4,9 +4,8 @@ import caseapp._ import scala.build.internal.Constants import scala.build.{Inputs, Os} -import scala.cli.CurrentParams import scala.cli.commands.util.CommonOps._ -import scala.cli.ScalaCli +import scala.cli.{CurrentParams, ScalaCli} object Clean extends ScalaCommand[CleanOptions] { override def group = "Main" diff --git a/modules/cli/src/main/scala/scala/cli/commands/Compile.scala b/modules/cli/src/main/scala/scala/cli/commands/Compile.scala index f4829aa5ba..d063e5aed2 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/Compile.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/Compile.scala @@ -7,9 +7,9 @@ import java.io.File import scala.build.options.Scope import scala.build.{Build, BuildThreads, Builds, Os} import scala.cli.CurrentParams +import scala.cli.commands.util.CommonOps.SharedDirectoriesOptionsOps import scala.cli.commands.util.SharedOptionsUtil._ import scala.cli.config.{ConfigDb, Keys} -import scala.cli.commands.util.CommonOps.SharedDirectoriesOptionsOps object Compile extends ScalaCommand[CompileOptions] { override def group = "Main" diff --git a/modules/cli/src/main/scala/scala/cli/commands/Default.scala b/modules/cli/src/main/scala/scala/cli/commands/Default.scala index 4c4d2598cf..de6a7cdc51 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/Default.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/Default.scala @@ -2,9 +2,9 @@ package scala.cli.commands import caseapp.core.help.RuntimeCommandsHelp import caseapp.core.{Error, RemainingArgs} -import scala.cli.commands.util.SharedOptionsUtil.* import scala.build.internal.Constants +import scala.cli.commands.util.SharedOptionsUtil.* import scala.cli.{CurrentParams, ScalaCliHelp} class Default( diff --git a/modules/cli/src/main/scala/scala/cli/commands/Doc.scala b/modules/cli/src/main/scala/scala/cli/commands/Doc.scala index fb59962e5d..83eab63131 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/Doc.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/Doc.scala @@ -12,11 +12,11 @@ import scala.build.errors.BuildException import scala.build.interactive.InteractiveFileOps import scala.build.internal.Runner import scala.cli.CurrentParams +import scala.cli.commands.util.CommonOps.SharedDirectoriesOptionsOps import scala.cli.commands.util.SharedOptionsUtil._ +import scala.cli.config.{ConfigDb, Keys} import scala.cli.errors.ScaladocGenerationFailedError import scala.util.Properties -import scala.cli.config.{ConfigDb, Keys} -import scala.cli.commands.util.CommonOps.SharedDirectoriesOptionsOps object Doc extends ScalaCommand[DocOptions] { override def group = "Main" diff --git a/modules/cli/src/main/scala/scala/cli/commands/Metabrowse.scala b/modules/cli/src/main/scala/scala/cli/commands/Metabrowse.scala index 718641afce..8397db4aae 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/Metabrowse.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/Metabrowse.scala @@ -8,11 +8,11 @@ import java.io.File import scala.build.internal.{Constants, ExternalBinaryParams, FetchExternalBinary, Runner} import scala.build.{Build, BuildThreads, Logger} import scala.cli.CurrentParams +import scala.cli.commands.util.CommonOps.SharedDirectoriesOptionsOps import scala.cli.commands.util.SharedOptionsUtil._ +import scala.cli.config.{ConfigDb, Keys} import scala.cli.packaging.Library import scala.util.Properties -import scala.cli.config.{ConfigDb, Keys} -import scala.cli.commands.util.CommonOps.SharedDirectoriesOptionsOps object Metabrowse extends ScalaCommand[MetabrowseOptions] { override def hidden = true diff --git a/modules/cli/src/main/scala/scala/cli/commands/Package.scala b/modules/cli/src/main/scala/scala/cli/commands/Package.scala index 8090323f75..e086b2cac1 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/Package.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/Package.scala @@ -15,9 +15,10 @@ import java.io.{ByteArrayOutputStream, OutputStream} import java.nio.charset.StandardCharsets import java.nio.file.attribute.FileTime import java.util.zip.{ZipEntry, ZipOutputStream} -import scala.build.* + import scala.build.EitherCps.{either, value} import scala.build.Ops.* +import scala.build.* import scala.build.errors.* import scala.build.interactive.InteractiveFileOps import scala.build.internal.Util.* diff --git a/modules/cli/src/main/scala/scala/cli/commands/Repl.scala b/modules/cli/src/main/scala/scala/cli/commands/Repl.scala index 2898b64034..44d4d72fd3 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/Repl.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/Repl.scala @@ -6,16 +6,15 @@ import coursier.error.{FetchError, ResolutionError} import scala.build.EitherCps.{either, value} import scala.build._ -import scala.build.errors.{BuildException, FetchingDependenciesError, CantDownloadAmmoniteError} +import scala.build.errors.{BuildException, CantDownloadAmmoniteError, FetchingDependenciesError} import scala.build.internal.Runner import scala.build.options.{BuildOptions, JavaOpt, Scope} import scala.cli.CurrentParams import scala.cli.commands.Run.maybePrintSimpleScalacOutput import scala.cli.commands.util.CommonOps._ import scala.cli.commands.util.SharedOptionsUtil._ -import scala.util.Properties import scala.cli.config.{ConfigDb, Keys} -import scala.cli.commands.util.CommonOps.SharedDirectoriesOptionsOps +import scala.util.Properties object Repl extends ScalaCommand[ReplOptions] { override def group = "Main" diff --git a/modules/cli/src/main/scala/scala/cli/commands/Run.scala b/modules/cli/src/main/scala/scala/cli/commands/Run.scala index fea303ea7f..c4f3793112 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/Run.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/Run.scala @@ -5,11 +5,12 @@ import caseapp.* import java.io.File import java.util.concurrent.CompletableFuture + import scala.build.EitherCps.{either, value} +import scala.build.* import scala.build.errors.BuildException import scala.build.internal.{Constants, Runner, ScalaJsLinkerConfig} import scala.build.options.{BuildOptions, JavaOpt, Platform, ScalacOpt} -import scala.build.* import scala.cli.CurrentParams import scala.cli.commands.run.RunMode import scala.cli.commands.util.CommonOps.SharedDirectoriesOptionsOps diff --git a/modules/cli/src/main/scala/scala/cli/commands/Test.scala b/modules/cli/src/main/scala/scala/cli/commands/Test.scala index 597487c182..4aa1666f4f 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/Test.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/Test.scala @@ -12,9 +12,9 @@ import scala.build.options.{BuildOptions, JavaOpt, Platform, Scope} import scala.build.testrunner.AsmTestRunner import scala.build.{Build, BuildThreads, Builds, CrossKey, Logger, Positioned} import scala.cli.CurrentParams +import scala.cli.commands.util.CommonOps.SharedDirectoriesOptionsOps import scala.cli.commands.util.SharedOptionsUtil._ import scala.cli.config.{ConfigDb, Keys} -import scala.cli.commands.util.CommonOps.SharedDirectoriesOptionsOps object Test extends ScalaCommand[TestOptions] { override def group = "Main" diff --git a/modules/cli/src/main/scala/scala/cli/commands/bloop/Bloop.scala b/modules/cli/src/main/scala/scala/cli/commands/bloop/Bloop.scala index 773e24147d..f3b95d5bde 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/bloop/Bloop.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/bloop/Bloop.scala @@ -4,14 +4,14 @@ import caseapp.core.RemainingArgs import scala.build.Logger import scala.build.bloop.BloopThreads -import scala.build.blooprifle.{BloopRifle, BloopRifleConfig} import scala.build.blooprifle.internal.{Constants, Operations} +import scala.build.blooprifle.{BloopRifle, BloopRifleConfig} import scala.build.internal.OsLibc import scala.cli.CurrentParams -import scala.cli.commands.{ScalaCommand, SharedOptions} import scala.cli.commands.util.CommonOps._ import scala.cli.commands.util.SharedCompilationServerOptionsUtil._ import scala.cli.commands.util.SharedOptionsUtil._ +import scala.cli.commands.{ScalaCommand, SharedOptions} import scala.concurrent.Await import scala.concurrent.duration.Duration diff --git a/modules/cli/src/main/scala/scala/cli/commands/pgp/PgpExternalCommand.scala b/modules/cli/src/main/scala/scala/cli/commands/pgp/PgpExternalCommand.scala index 38dcd0994f..4c3ab70eb9 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/pgp/PgpExternalCommand.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/pgp/PgpExternalCommand.scala @@ -7,13 +7,17 @@ import dependency._ import scala.build.EitherCps.{either, value} import scala.build.Logger import scala.build.errors.BuildException -import scala.build.internal.{Constants, FetchExternalBinary, Runner} +import scala.build.internal.{ + Constants, + ExternalBinary, + ExternalBinaryParams, + FetchExternalBinary, + Runner +} import scala.cli.ScalaCli import scala.cli.commands.util.CommonOps._ -import scala.util.Properties -import scala.build.internal.ExternalBinaryParams -import scala.build.internal.ExternalBinary import scala.cli.commands.util.JvmUtils +import scala.util.Properties abstract class PgpExternalCommand extends ExternalCommand { def progName: String = ScalaCli.progName diff --git a/modules/cli/src/main/scala/scala/cli/commands/publish/Publish.scala b/modules/cli/src/main/scala/scala/cli/commands/publish/Publish.scala index b9be4152da..981206e62c 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/publish/Publish.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/publish/Publish.scala @@ -21,30 +21,30 @@ import java.nio.file.Paths import java.time.{Instant, LocalDateTime, ZoneOffset} import java.util.concurrent.Executors import java.util.function.Supplier -import scala.build.* + import scala.build.EitherCps.{either, value} import scala.build.Ops.* +import scala.build.* import scala.build.compiler.ScalaCompilerMaker import scala.build.errors.{BuildException, CompositeBuildException, NoMainClassFoundError} import scala.build.internal.Util import scala.build.internal.Util.ScalaDependencyOps -import scala.build.options.publish.{ComputeVersion, Developer, License, Vcs, Signer as PSigner} +import scala.build.options.publish.{ComputeVersion, Developer, License, Signer => PSigner, Vcs} import scala.build.options.{BuildOptions, ConfigMonoid, PublishContextualOptions, Scope} import scala.cli.CurrentParams import scala.cli.commands.pgp.PgpExternalCommand import scala.cli.commands.publish.{PublishParamsOptions, PublishRepositoryOptions} import scala.cli.commands.util.CommonOps.SharedDirectoriesOptionsOps import scala.cli.commands.util.MainClassOptionsUtil.* +import scala.cli.commands.util.PublishUtils.* import scala.cli.commands.util.SharedOptionsUtil.* import scala.cli.commands.util.{BuildCommandHelpers, ScalaCliSttpBackend} -import scala.cli.commands.util.SharedOptionsUtil.* -import scala.cli.commands.util.PublishUtils.* import scala.cli.commands.{ MainClassOptions, + Package => PackageCmd, ScalaCommand, SharedOptions, - WatchUtil, - Package as PackageCmd + WatchUtil } import scala.cli.config.{ConfigDb, Keys} import scala.cli.errors.{ diff --git a/modules/cli/src/main/scala/scala/cli/commands/publish/checks/PgpSecretKeyCheck.scala b/modules/cli/src/main/scala/scala/cli/commands/publish/checks/PgpSecretKeyCheck.scala index 8f55670d33..579b5ba3d3 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/publish/checks/PgpSecretKeyCheck.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/publish/checks/PgpSecretKeyCheck.scala @@ -16,11 +16,11 @@ import scala.cli.commands.config.ThrowawayPgpSecret import scala.cli.commands.pgp.{KeyServer, PgpProxyMaker} import scala.cli.commands.publish.{OptionCheck, PublishSetupOptions, SetSecret} import scala.cli.commands.util.JvmUtils +import scala.cli.commands.util.PublishUtils._ import scala.cli.config.{ConfigDb, Keys} import scala.cli.errors.MissingPublishOptionError import scala.cli.signing.shared.PasswordOption import scala.cli.util.ConfigPasswordOptionHelpers._ -import scala.cli.commands.util.PublishUtils._ final case class PgpSecretKeyCheck( options: PublishSetupOptions, diff --git a/modules/cli/src/main/scala/scala/cli/commands/util/BuildCommandHelpers.scala b/modules/cli/src/main/scala/scala/cli/commands/util/BuildCommandHelpers.scala index f22306fd4b..2974601319 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/util/BuildCommandHelpers.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/util/BuildCommandHelpers.scala @@ -1,7 +1,7 @@ package scala.cli.commands.util -import scala.build.{Build, Logger} import scala.build.errors.MainClassError +import scala.build.{Build, Logger} import scala.cli.commands.ScalaCommand trait BuildCommandHelpers { self: ScalaCommand[_] => diff --git a/modules/cli/src/main/scala/scala/cli/commands/util/FmtOptionsUtil.scala b/modules/cli/src/main/scala/scala/cli/commands/util/FmtOptionsUtil.scala index 58e3aa9fcc..dabab3cd5f 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/util/FmtOptionsUtil.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/util/FmtOptionsUtil.scala @@ -1,12 +1,12 @@ package scala.cli.commands.util +import coursier.core.Version + import scala.build.internal.FetchExternalBinary import scala.build.options.BuildOptions import scala.cli.commands.FmtOptions import scala.cli.commands.util.SharedOptionsUtil._ import scala.util.Properties -import coursier.core.Version - object FmtOptionsUtil { implicit class FmtOptionsOps(v: FmtOptions) { import v._ diff --git a/modules/cli/src/main/scala/scala/cli/commands/util/FmtUtil.scala b/modules/cli/src/main/scala/scala/cli/commands/util/FmtUtil.scala index f622385565..5e9b6921b5 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/util/FmtUtil.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/util/FmtUtil.scala @@ -1,13 +1,12 @@ package scala.cli.commands.util -import com.typesafe.config.ConfigParseOptions -import com.typesafe.config.ConfigSyntax -import com.typesafe.config.parser.ConfigDocument -import com.typesafe.config.parser.ConfigDocumentFactory +import com.typesafe.config.parser.{ConfigDocument, ConfigDocumentFactory} +import com.typesafe.config.{ConfigParseOptions, ConfigSyntax} + import scala.build.Logger import scala.build.internal.Constants -import scala.util.control.NonFatal import scala.cli.commands.FmtOptions +import scala.util.control.NonFatal object FmtUtil { private def getGitRoot(workspace: os.Path, logger: Logger): Option[String] = diff --git a/modules/cli/src/main/scala/scala/cli/commands/util/RunHadoop.scala b/modules/cli/src/main/scala/scala/cli/commands/util/RunHadoop.scala index 8f328af859..df5cf2d7ff 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/util/RunHadoop.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/util/RunHadoop.scala @@ -1,11 +1,11 @@ package scala.cli.commands.util import scala.build.EitherCps.{either, value} -import scala.build.{Build, Logger} import scala.build.errors.BuildException import scala.build.internal.Runner -import scala.cli.commands.{Package => PackageCmd} +import scala.build.{Build, Logger} import scala.cli.commands.packaging.Spark +import scala.cli.commands.{Package => PackageCmd} object RunHadoop { diff --git a/modules/cli/src/main/scala/scala/cli/commands/util/RunSpark.scala b/modules/cli/src/main/scala/scala/cli/commands/util/RunSpark.scala index 749fa4b4f3..38d7b86d2a 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/util/RunSpark.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/util/RunSpark.scala @@ -1,12 +1,12 @@ package scala.cli.commands.util import scala.build.EitherCps.{either, value} -import scala.build.{Build, Logger} import scala.build.errors.BuildException import scala.build.internal.Runner -import scala.cli.commands.{Package => PackageCmd} +import scala.build.{Build, Logger} import scala.cli.commands.packaging.Spark import scala.cli.commands.run.RunMode +import scala.cli.commands.{Package => PackageCmd} import scala.cli.packaging.Library import scala.util.Properties diff --git a/modules/cli/src/main/scala/scala/cli/commands/util/SharedOptionsUtil.scala b/modules/cli/src/main/scala/scala/cli/commands/util/SharedOptionsUtil.scala index 346ee5b96f..44868940cb 100644 --- a/modules/cli/src/main/scala/scala/cli/commands/util/SharedOptionsUtil.scala +++ b/modules/cli/src/main/scala/scala/cli/commands/util/SharedOptionsUtil.scala @@ -8,6 +8,7 @@ import dependency.AnyDependency import dependency.parser.DependencyParser import java.io.{File, InputStream} + import scala.build.* import scala.build.blooprifle.BloopRifleConfig import scala.build.compiler.{BloopCompilerMaker, ScalaCompilerMaker, SimpleScalaCompilerMaker} @@ -18,6 +19,7 @@ import scala.build.internal.CsLoggerUtil.* import scala.build.internal.{Constants, FetchExternalBinary, OsLibc, Util} import scala.build.options.{Platform, ScalacOpt, ShadowingSeq} import scala.build.options as bo +import scala.cli.ScalaCli import scala.cli.commands.ScalaJsOptions import scala.cli.commands.util.CommonOps.* import scala.cli.commands.util.SharedCompilationServerOptionsUtil.* @@ -26,7 +28,6 @@ import scala.concurrent.ExecutionContextExecutorService import scala.concurrent.duration.* import scala.util.Properties import scala.util.control.NonFatal -import scala.cli.ScalaCli object SharedOptionsUtil extends CommandHelpers { diff --git a/modules/cli/src/main/scala/scala/cli/config/ConfigDb.scala b/modules/cli/src/main/scala/scala/cli/config/ConfigDb.scala index 347b26d5e2..e8a4987b00 100644 --- a/modules/cli/src/main/scala/scala/cli/config/ConfigDb.scala +++ b/modules/cli/src/main/scala/scala/cli/config/ConfigDb.scala @@ -5,8 +5,9 @@ import com.github.plokhotnyuk.jsoniter_scala.macros.* import coursier.parse.RawJson import java.nio.file.attribute.PosixFilePermission -import scala.build.{Directories, Logger} + import scala.build.errors.BuildException +import scala.build.{Directories, Logger} import scala.cli.commands.SharedOptions import scala.cli.commands.util.CommonOps.SharedDirectoriesOptionsOps import scala.collection.immutable.ListMap diff --git a/modules/cli/src/main/scala/scala/cli/internal/CliLogger.scala b/modules/cli/src/main/scala/scala/cli/internal/CliLogger.scala index fb3118333c..1e48c239f2 100644 --- a/modules/cli/src/main/scala/scala/cli/internal/CliLogger.scala +++ b/modules/cli/src/main/scala/scala/cli/internal/CliLogger.scala @@ -1,7 +1,7 @@ package scala.cli.internal -import ch.epfl.scala.{bsp4j => b} import ch.epfl.scala.bsp4j.Location +import ch.epfl.scala.{bsp4j => b} import coursier.cache.CacheLogger import coursier.cache.loggers.{FallbackRefreshDisplay, RefreshLogger} import org.scalajs.logging.{Level => ScalaJsLevel, Logger => ScalaJsLogger, ScalaConsoleLogger} @@ -9,13 +9,13 @@ import org.scalajs.logging.{Level => ScalaJsLevel, Logger => ScalaJsLogger, Scal import java.io.PrintStream import scala.build.blooprifle.BloopRifleLogger -import scala.build.errors.{BuildException, CompositeBuildException, Diagnostic, Severity} import scala.build.errors.Diagnostic.RelatedInformation +import scala.build.errors.{BuildException, CompositeBuildException, Diagnostic, Severity} import scala.build.internal.CustomProgressBarRefreshDisplay import scala.build.{ConsoleBloopBuildClient, Logger, Position} import scala.collection.mutable -import scala.scalanative.{build => sn} import scala.jdk.CollectionConverters._ +import scala.scalanative.{build => sn} class CliLogger( val verbosity: Int, diff --git a/modules/cli/src/main/scala/scala/cli/internal/ScalaJsLinker.scala b/modules/cli/src/main/scala/scala/cli/internal/ScalaJsLinker.scala index fca6a9865d..080baeead9 100644 --- a/modules/cli/src/main/scala/scala/cli/internal/ScalaJsLinker.scala +++ b/modules/cli/src/main/scala/scala/cli/internal/ScalaJsLinker.scala @@ -10,8 +10,8 @@ import java.io.File import scala.build.EitherCps.{either, value} import scala.build.errors.{BuildException, ScalaJsLinkingError} -import scala.build.internal.{ExternalBinaryParams, FetchExternalBinary, Runner, ScalaJsLinkerConfig} import scala.build.internal.Util.{DependencyOps, ModuleOps} +import scala.build.internal.{ExternalBinaryParams, FetchExternalBinary, Runner, ScalaJsLinkerConfig} import scala.build.options.scalajs.ScalaJsLinkerOptions import scala.build.{Logger, Positioned} import scala.util.Properties diff --git a/modules/cli/src/main/scala/scala/cli/util/ConfigPasswordOptionHelpers.scala b/modules/cli/src/main/scala/scala/cli/util/ConfigPasswordOptionHelpers.scala index 87b249a026..e7d1ad4974 100644 --- a/modules/cli/src/main/scala/scala/cli/util/ConfigPasswordOptionHelpers.scala +++ b/modules/cli/src/main/scala/scala/cli/util/ConfigPasswordOptionHelpers.scala @@ -1,8 +1,8 @@ package scala.cli.util import scala.build.errors.BuildException -import scala.cli.commands.publish.MaybeConfigPasswordOption import scala.build.options.publish.ConfigPasswordOption +import scala.cli.commands.publish.MaybeConfigPasswordOption import scala.cli.config.{ConfigDb, Key} import scala.cli.errors.MissingConfigEntryError import scala.cli.signing.shared.PasswordOption diff --git a/modules/cli/src/test/scala/cli/tests/ScalafmtTest.scala b/modules/cli/src/test/scala/cli/tests/ScalafmtTest.scala index 194ef4384c..b0cea25c29 100644 --- a/modules/cli/src/test/scala/cli/tests/ScalafmtTest.scala +++ b/modules/cli/src/test/scala/cli/tests/ScalafmtTest.scala @@ -2,8 +2,8 @@ package cli.tests import com.eed3si9n.expecty.Expecty.expect import scala.build.tests.{TestInputs, TestLogger} -import scala.cli.commands.util.FmtUtil import scala.cli.commands.FmtOptions +import scala.cli.commands.util.FmtUtil class ScalafmtTests extends munit.FunSuite { diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/UsingPublishContextualDirectiveHandler.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/UsingPublishContextualDirectiveHandler.scala index a8e0974301..675ab47b9e 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/UsingPublishContextualDirectiveHandler.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/UsingPublishContextualDirectiveHandler.scala @@ -3,8 +3,7 @@ package scala.build.preprocessing.directives import scala.build.EitherCps.{either, value} import scala.build.Logger import scala.build.errors.{BuildException, MalformedInputError, UnexpectedDirectiveError} -import scala.build.options.publish.ComputeVersion -import scala.build.options.publish.ConfigPasswordOption +import scala.build.options.publish.{ComputeVersion, ConfigPasswordOption} import scala.build.options.{ BuildOptions, PostBuildOptions, diff --git a/modules/options/src/main/scala/scala/build/Artifacts.scala b/modules/options/src/main/scala/scala/build/Artifacts.scala index 137995d174..dfb88deff1 100644 --- a/modules/options/src/main/scala/scala/build/Artifacts.scala +++ b/modules/options/src/main/scala/scala/build/Artifacts.scala @@ -4,11 +4,12 @@ import coursier.cache.FileCache import coursier.core.{Classifier, Module} import coursier.parse.RepositoryParser import coursier.util.Task -import coursier.{Fetch, Resolution, Dependency as CsDependency, core as csCore, util as csUtil} +import coursier.{Dependency => CsDependency, Fetch, Resolution, core => csCore, util => csUtil} import dependency.* import os.Path import java.net.URL + import scala.build.CoursierUtils.* import scala.build.EitherCps.{either, value} import scala.build.Ops.* diff --git a/modules/options/src/main/scala/scala/build/CoursierUtils.scala b/modules/options/src/main/scala/scala/build/CoursierUtils.scala index 72e35a6611..078bff7719 100644 --- a/modules/options/src/main/scala/scala/build/CoursierUtils.scala +++ b/modules/options/src/main/scala/scala/build/CoursierUtils.scala @@ -1,12 +1,11 @@ package scala.build -import scala.quoted.* - -import coursier.core.{Module, Dependency => CDependency} +import coursier.core.{Dependency => CDependency, Module} import coursier.parse.{DependencyParser, ModuleParser} - import dependency.{DependencyLike, NameAttributes} + import scala.build.internal.Constants +import scala.quoted.* def noArgs(args: Expr[Seq[Any]])(using Quotes): Unit = {} // TODO diff --git a/modules/options/src/main/scala/scala/build/actionable/ActionableDiagnostic.scala b/modules/options/src/main/scala/scala/build/actionable/ActionableDiagnostic.scala index f14a31d440..b56775c2d2 100644 --- a/modules/options/src/main/scala/scala/build/actionable/ActionableDiagnostic.scala +++ b/modules/options/src/main/scala/scala/build/actionable/ActionableDiagnostic.scala @@ -3,8 +3,8 @@ package scala.build.actionable import dependency._ import scala.build.Position -import scala.build.errors.{Diagnostic, Severity} import scala.build.errors.Diagnostic.RelatedInformation +import scala.build.errors.{Diagnostic, Severity} abstract class ActionableDiagnostic extends Diagnostic { diff --git a/modules/options/src/main/scala/scala/build/actionable/ActionablePreprocessor.scala b/modules/options/src/main/scala/scala/build/actionable/ActionablePreprocessor.scala index 2325838ea2..d0d20cbb8c 100644 --- a/modules/options/src/main/scala/scala/build/actionable/ActionablePreprocessor.scala +++ b/modules/options/src/main/scala/scala/build/actionable/ActionablePreprocessor.scala @@ -1,9 +1,8 @@ package scala.build.actionable import scala.build.Ops._ -import scala.build.errors.{BuildException, CompositeBuildException} +import scala.build.errors.{BuildException, CompositeBuildException, Diagnostic} import scala.build.options.BuildOptions -import scala.build.errors.Diagnostic object ActionablePreprocessor { val actionableHandlers = Seq[ActionableHandler[_]]( diff --git a/modules/options/src/main/scala/scala/build/options/BuildOptions.scala b/modules/options/src/main/scala/scala/build/options/BuildOptions.scala index 2012510bfc..63adf2e054 100644 --- a/modules/options/src/main/scala/scala/build/options/BuildOptions.scala +++ b/modules/options/src/main/scala/scala/build/options/BuildOptions.scala @@ -10,6 +10,7 @@ import java.io.File import java.math.BigInteger import java.nio.charset.StandardCharsets import java.security.MessageDigest + import scala.build.EitherCps.{either, value} import scala.build.actionable.{ActionableDiagnostic, ActionablePreprocessor} import scala.build.errors.* diff --git a/modules/options/src/main/scala/scala/build/options/HasHashData.scala b/modules/options/src/main/scala/scala/build/options/HasHashData.scala index 8d9d75fe52..9ee6d396d4 100644 --- a/modules/options/src/main/scala/scala/build/options/HasHashData.scala +++ b/modules/options/src/main/scala/scala/build/options/HasHashData.scala @@ -1,7 +1,7 @@ package scala.build.options -import scala.deriving.* import scala.compiletime.* +import scala.deriving.* trait HasHashData[T]: def add(prefix: String, t: T, update: String => Unit): Unit diff --git a/modules/options/src/main/scala/scala/build/options/JavaOptions.scala b/modules/options/src/main/scala/scala/build/options/JavaOptions.scala index 0c835dd5cf..123a99d2c8 100644 --- a/modules/options/src/main/scala/scala/build/options/JavaOptions.scala +++ b/modules/options/src/main/scala/scala/build/options/JavaOptions.scala @@ -1,17 +1,14 @@ package scala.build.options -import coursier.cache.FileCache +import coursier.cache.{ArchiveCache, FileCache} +import coursier.jvm.{JavaHome, JvmCache, JvmIndex} import coursier.util.Task -import coursier.jvm.JvmIndex -import coursier.jvm.JvmCache -import coursier.jvm.JavaHome -import coursier.cache.ArchiveCache import dependency.AnyDependency -import scala.build.{Position, Positioned} import scala.build.internal.CsLoggerUtil._ import scala.build.internal.OsLibc import scala.build.options.BuildOptions.JavaHomeInfo +import scala.build.{Position, Positioned} import scala.concurrent.ExecutionContextExecutorService import scala.util.control.NonFatal diff --git a/modules/options/src/main/scala/scala/build/options/PublishContextualOptions.scala b/modules/options/src/main/scala/scala/build/options/PublishContextualOptions.scala index ca65eeae24..5ef1c887b9 100644 --- a/modules/options/src/main/scala/scala/build/options/PublishContextualOptions.scala +++ b/modules/options/src/main/scala/scala/build/options/PublishContextualOptions.scala @@ -1,6 +1,6 @@ package scala.build.options -import scala.build.options.publish.{ComputeVersion, Signer, ConfigPasswordOption} +import scala.build.options.publish.{ComputeVersion, ConfigPasswordOption, Signer} import scala.cli.signing.shared.PasswordOption /** Publishing-related options, that can have different values locally and on CIs */ diff --git a/project/deps.sc b/project/deps.sc index 9c742d2cea..adf9cf1a85 100644 --- a/project/deps.sc +++ b/project/deps.sc @@ -99,7 +99,7 @@ object Deps { def munit = ivy"org.scalameta::munit:0.7.29" def nativeTestRunner = ivy"org.scala-native::test-runner:${Versions.scalaNative}" def nativeTools = ivy"org.scala-native::tools:${Versions.scalaNative}" - def organizeImports = ivy"com.github.liancheng::organize-imports:0.5.0" + def organizeImports = ivy"com.github.liancheng::organize-imports:0.6.0" def osLib = ivy"com.lihaoyi::os-lib:0.8.1" def pprint = ivy"com.lihaoyi::pprint:0.7.3" def pythonNativeLibs = ivy"ai.kien::python-native-libs:0.2.3" From 3aa53ba12029e9b822ac15af677da6026e681bc7 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Thu, 8 Sep 2022 16:20:32 +0200 Subject: [PATCH 3/3] NIT --- modules/build/src/main/scala/scala/build/bsp/BspClient.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/build/src/main/scala/scala/build/bsp/BspClient.scala b/modules/build/src/main/scala/scala/build/bsp/BspClient.scala index 859c505db6..62e6dae82d 100644 --- a/modules/build/src/main/scala/scala/build/bsp/BspClient.scala +++ b/modules/build/src/main/scala/scala/build/bsp/BspClient.scala @@ -1,6 +1,5 @@ package scala.build.bsp -import ch.epfl.scala.bsp4j.Location import ch.epfl.scala.{bsp4j => b} import java.lang.{Boolean => JBoolean} @@ -196,7 +195,7 @@ class BspClient( new b.Diagnostic(range, diag.message) diag.relatedInformation.foreach { relatedInformation => - val location = new Location(path.toNIO.toUri.toASCIIString, range) + val location = new b.Location(path.toNIO.toUri.toASCIIString, range) val related = new b.DiagnosticRelatedInformation(location, relatedInformation.message) bDiag.setRelatedInformation(List(related).asJava) }