Skip to content

Commit eb6ef4f

Browse files
authored
Merge pull request #104 from eed3si9n/wip/repos
Ignore jcenter and scala-tools-releases
2 parents ab72937 + 0ec30a6 commit eb6ef4f

File tree

14 files changed

+174
-124
lines changed

14 files changed

+174
-124
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
target
2+
metals.sbt

build.sbt

+36-23
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import Deps._
22
import Util._
33
import com.typesafe.tools.mima.core._, ProblemFilters._
44

5-
lazy val keepFullClasses = settingKey[Seq[String]]("Fully qualified names of classes that proguard should preserve the non-private API of.")
5+
lazy val keepFullClasses = settingKey[Seq[String]](
6+
"Fully qualified names of classes that proguard should preserve the non-private API of."
7+
)
68

79
Global / onChangedBuildSource := ReloadOnSourceChanges
810
ThisBuild / dynverSonatypeSnapshots := true
@@ -12,7 +14,7 @@ ThisBuild / version := {
1214
else orig
1315
}
1416
ThisBuild / description := "Standalone launcher for maven/ivy deployed projects"
15-
ThisBuild / scalaVersion := "2.13.6"
17+
ThisBuild / scalaVersion := "2.13.14"
1618
ThisBuild / publishMavenStyle := true
1719
ThisBuild / crossPaths := false
1820
ThisBuild / resolvers += Resolver.typesafeIvyRepo("releases")
@@ -31,9 +33,9 @@ lazy val root = (project in file("."))
3133
packageDoc in Compile := (packageDoc in Compile in launchSub).value
3234
commands += Command.command("release") { state =>
3335
"clean" ::
34-
"test" ::
35-
"publishSigned" ::
36-
state
36+
"test" ::
37+
"publishSigned" ::
38+
state
3739
}
3840
validNamespaces ++= Set("xsbt", "xsbti", "scala", "org.apache.ivy", "org.fusesource.jansi")
3941
validEntries ++= Set("LICENSE", "NOTICE", "module.properties")
@@ -56,19 +58,26 @@ def proguardedLauncherSettings = Seq(
5658

5759
def launchSettings =
5860
inConfig(Compile)(Transform.configSettings) ++
59-
inConfig(Compile)(Transform.transSourceSettings ++ Seq(
60-
// TODO - these should be shared between sbt core + sbt-launcher...
61-
Transform.inputSourceDirectory := sourceDirectory.value / "input_sources",
62-
Transform.sourceProperties := Map("cross.package0" -> "xsbt", "cross.package1" -> "boot")
63-
))
61+
inConfig(Compile)(
62+
Transform.transSourceSettings ++ Seq(
63+
// TODO - these should be shared between sbt core + sbt-launcher...
64+
Transform.inputSourceDirectory := sourceDirectory.value / "input_sources",
65+
Transform.sourceProperties := Map("cross.package0" -> "xsbt", "cross.package1" -> "boot")
66+
)
67+
)
6468

6569
// The interface JAR for projects which want to be launched by sbt.
6670
lazy val launchInterfaceSub = (project in file("launcher-interface"))
6771
.settings(javaOnly)
6872
.settings(nocomma {
6973
name := "Launcher Interface"
70-
resourceGenerators in Compile += Def.task{
71-
generateVersionFile("sbt.launcher.version.properties")(version.value, resourceManaged.value, streams.value, (compile in Compile).value)
74+
resourceGenerators in Compile += Def.task {
75+
generateVersionFile("sbt.launcher.version.properties")(
76+
version.value,
77+
resourceManaged.value,
78+
streams.value,
79+
(compile in Compile).value
80+
)
7281
}.taskValue
7382
description := "Interfaces for launching projects with the sbt launcher"
7483
mimaPreviousArtifacts := Set(organization.value % moduleName.value % "1.0.1")
@@ -119,10 +128,10 @@ lazy val launchSub = (project in file("launcher-implementation"))
119128
Proguard / proguardOptions ++= keepFullClasses.value map ("-keep public class " + _ + " {\n\tpublic protected * ;\n}")
120129
Proguard / proguardInputFilter := { file =>
121130
file.name match {
122-
case x if x.startsWith("scala-library") => Some(libraryFilter)
123-
case x if x.startsWith("ivy-2.3.0") => Some(ivyFilter)
131+
case x if x.startsWith("scala-library") => Some(libraryFilter)
132+
case x if x.startsWith("ivy-2.3.0") => Some(ivyFilter)
124133
case x if x.startsWith("launcher-implementation") => None
125-
case _ => Some(generalFilter)
134+
case _ => Some(generalFilter)
126135
}
127136
}
128137
Proguard / proguardOptions += ProguardOptions.keepMain("xsbt.boot.Boot")
@@ -156,7 +165,6 @@ def ivyFilter = {
156165
excludeString(ivyResources)
157166
}
158167

159-
160168
// used to test the retrieving and loading of an application: sample app is packaged and published to the local repository
161169
lazy val testSamples = (project in file("test-sample"))
162170
.dependsOn(launchInterfaceSub)
@@ -169,20 +177,25 @@ lazy val testSamples = (project in file("test-sample"))
169177
})
170178

171179
ThisBuild / organization := "org.scala-sbt"
172-
ThisBuild / pomIncludeRepository := { x => false }
180+
ThisBuild / pomIncludeRepository := { x =>
181+
false
182+
}
173183
ThisBuild / homepage := Some(url("https://scala-sbt.org"))
174184
ThisBuild / licenses += "Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.txt")
175-
ThisBuild / scmInfo := Some(ScmInfo(
176-
browseUrl = url("https://github.com/sbt/launcher"),
177-
connection = "scm:[email protected]:sbt/launcher.git"
178-
))
185+
ThisBuild / scmInfo := Some(
186+
ScmInfo(
187+
browseUrl = url("https://github.com/sbt/launcher"),
188+
connection = "scm:[email protected]:sbt/launcher.git"
189+
)
190+
)
179191
ThisBuild / developers := List(
180192
Developer("eed3si9n", "Eugene Yokota", "@eed3si9n", url("https://github.com/eed3si9n")),
181193
Developer("jsuereth", "Josh Suereth", "@jsuereth", url("https://github.com/jsuereth")),
182194
Developer("dwijnand", "Dale Wijnand", "@dwijnand", url("https://github.com/dwijnand"))
183195
)
184196
ThisBuild / publishTo := {
185197
val nexus = "https://oss.sonatype.org/"
186-
if (version.value.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
187-
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
198+
if (version.value.trim.endsWith("SNAPSHOT"))
199+
Some("snapshots" at nexus + "content/repositories/snapshots")
200+
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
188201
}

launcher-implementation/src/main/input_sources/CrossVersionUtil.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ object CrossVersionUtil
6161
major > minMajor || (major == minMajor && minor >= minMinor)
6262
private[this] def binaryVersionWithApi(full: String, cutoff: String)(apiVersion: String => Option[(Int,Int)]): String =
6363
{
64-
def sub(major: Int, minor: Int) = major + "." + minor
64+
def sub(major: Int, minor: Int) = major.toString() + "." + minor
6565
(apiVersion(full), partialVersion(cutoff)) match {
6666
case (Some((major, minor)), None) => sub(major, minor)
6767
case (Some((major, minor)), Some((minMajor, minMinor))) if isNewer(major, minor, minMajor, minMinor) => sub(major, minor)

launcher-implementation/src/main/scala/xsbt/boot/Boot.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,5 @@ object Boot {
9393
}
9494

9595
private def exit(code: Int): Nothing =
96-
System.exit(code).asInstanceOf[Nothing]
96+
sys.exit(code)
9797
}

launcher-implementation/src/main/scala/xsbt/boot/Configuration.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ object Configuration {
5050
case Array("") => Console.err.println(s"[warn] [launcher] invalid system property '$head'")
5151
case Array(key) => sys.props += key -> ""
5252
case Array(key, value) => sys.props += key -> value
53+
case _ => ()
5354
}
5455
()
5556
}
@@ -79,8 +80,8 @@ object Configuration {
7980
multiPartError("could not find configuration file '" + path + "'. searched:", against)
8081
resolving.next()
8182
}
82-
def multiPartError[T](firstLine: String, lines: List[T]) =
83-
Pre.error((firstLine :: lines).mkString("\n\t"))
83+
def multiPartError[A](firstLine: String, lines: List[A]) =
84+
Pre.error((firstLine :: lines.map(_.toString())).mkString("\n\t"))
8485

8586
def UnspecifiedVersionPart = "Unspecified"
8687
def DefaultVersionPart = "Default"

launcher-implementation/src/main/scala/xsbt/boot/ConfigurationParser.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ object ConfigurationParser {
3838
b.toString
3939
}
4040

41-
implicit val readIDs = ids _
41+
implicit val readIDs: String => List[String] = ids _
4242
}
4343
class ConfigurationParser {
4444
def apply(file: File): LaunchConfiguration = Using(newReader(file))(apply)

launcher-implementation/src/main/scala/xsbt/boot/CoursierUpdate.scala

+16-11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import java.nio.file.{ Files, StandardCopyOption, Paths }
1313
import java.util.Properties
1414
import java.util.regex.Pattern
1515
import BootConfiguration._
16+
import scala.annotation.nowarn
1617

1718
class CousierUpdate(config: UpdateConfiguration) {
1819
import config.{
@@ -178,7 +179,7 @@ class CousierUpdate(config: UpdateConfiguration) {
178179
target: UpdateTarget,
179180
deps: List[Dependency]
180181
): UpdateResult = {
181-
val repos = config.repositories.map(toCoursierRepository)
182+
val repos = config.repositories.flatMap(toCoursierRepository)
182183
val params = scalaVersion match {
183184
case Some(sv) if sv != "auto" =>
184185
ResolutionParams()
@@ -303,11 +304,12 @@ class CousierUpdate(config: UpdateConfiguration) {
303304
)).toList
304305
}
305306

306-
def toCoursierRepository(repo: xsbti.Repository): Repository = {
307+
@nowarn
308+
def toCoursierRepository(repo: xsbti.Repository): Seq[Repository] = {
307309
import xsbti.Predefined._
308310
repo match {
309311
case m: xsbti.MavenRepository =>
310-
mavenRepository(m.url.toString)
312+
mavenRepository(m.url.toString) :: Nil
311313
case i: xsbti.IvyRepository =>
312314
ivyRepository(
313315
i.id,
@@ -318,22 +320,25 @@ class CousierUpdate(config: UpdateConfiguration) {
318320
i.descriptorOptional,
319321
i.skipConsistencyCheck,
320322
i.allowInsecureProtocol
321-
)
323+
) :: Nil
322324
case p: xsbti.PredefinedRepository =>
323325
p.id match {
324326
case Local =>
325-
localRepository
327+
localRepository :: Nil
326328
case MavenLocal =>
327329
val localDir = new File(new File(new File(sys.props("user.home")), ".m2"), "repository")
328-
mavenRepository(localDir.toPath.toUri.toString)
330+
mavenRepository(localDir.toPath.toUri.toString) :: Nil
329331
case MavenCentral =>
330-
Repositories.central
332+
Repositories.central :: Nil
331333
case SonatypeOSSReleases =>
332-
Repositories.sonatype("releases")
334+
Repositories.sonatype("releases") :: Nil
333335
case SonatypeOSSSnapshots =>
334-
Repositories.sonatype("snapshots")
335-
case Jcenter =>
336-
Repositories.jcenter
336+
Repositories.sonatype("snapshots") :: Nil
337+
case Jcenter | ScalaToolsReleases | ScalaToolsSnapshots =>
338+
log(
339+
s"[warn] [launcher] ${p.id} is deprecated or no longer available; remove from repositories"
340+
)
341+
Nil
337342
}
338343
}
339344
}

launcher-implementation/src/main/scala/xsbt/boot/Pre.scala

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package xsbt.boot
66
import java.io.{ File, FileFilter }
77
import java.net.URL
88
import java.util.Locale
9-
import scala.annotation.nowarn
109
import scala.collection.immutable.List
1110
import scala.reflect.ClassTag
1211

@@ -32,7 +31,6 @@ object Pre {
3231
def prefixError(msg: String): String = "error during sbt launcher: " + msg
3332
def toBoolean(s: String) = java.lang.Boolean.parseBoolean(s)
3433

35-
@nowarn
3634
def toArray[T: ClassTag](list: List[T]) = {
3735
val arr = new Array[T](list.length)
3836
def copy(i: Int, rem: List[T]): Unit =

launcher-implementation/src/main/scala/xsbt/boot/Update.scala

+20-23
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,10 @@ final class Update(config: UpdateConfiguration) {
436436
}
437437
newDefault.setName("redefined-public")
438438
if (repositories.isEmpty) error("no repositories defined")
439-
for (repo <- repositories if includeRepo(repo))
440-
newDefault.add(toIvyRepository(settings, repo))
439+
for {
440+
repo <- repositories if includeRepo(repo)
441+
irepo <- toIvyRepositories(settings, repo)
442+
} newDefault.add(irepo)
441443
configureCache(settings)
442444
settings.addResolver(newDefault)
443445
settings.setDefaultResolver(newDefault.getName)
@@ -490,10 +492,14 @@ final class Update(config: UpdateConfiguration) {
490492
}
491493

492494
@nowarn
493-
private def toIvyRepository(settings: IvySettings, repo: xsbti.Repository) = {
495+
private def toIvyRepositories(
496+
settings: IvySettings,
497+
repo: xsbti.Repository
498+
): Seq[plugins.resolver.RepositoryResolver] = {
494499
import xsbti.Predefined._
495500
repo match {
496-
case m: xsbti.MavenRepository => mavenResolver(m.id, m.url.toString, m.allowInsecureProtocol)
501+
case m: xsbti.MavenRepository =>
502+
mavenResolver(m.id, m.url.toString, m.allowInsecureProtocol) :: Nil
497503
case i: xsbti.IvyRepository =>
498504
urlResolver(
499505
i.id,
@@ -504,7 +510,7 @@ final class Update(config: UpdateConfiguration) {
504510
i.descriptorOptional,
505511
i.skipConsistencyCheck,
506512
i.allowInsecureProtocol
507-
)
513+
) :: Nil
508514
case p: xsbti.PredefinedRepository =>
509515
val sonatypeReleases = mavenResolver(
510516
"Sonatype Releases Repository",
@@ -513,27 +519,20 @@ final class Update(config: UpdateConfiguration) {
513519
)
514520
p.id match {
515521
case Local =>
516-
localResolver(settings.getDefaultIvyUserDir.getAbsolutePath)
522+
localResolver(settings.getDefaultIvyUserDir.getAbsolutePath) :: Nil
517523
case MavenLocal =>
518-
mavenLocal
524+
mavenLocal :: Nil
519525
case MavenCentral =>
520-
mavenMainResolver
521-
case ScalaToolsReleases =>
522-
log(
523-
s"[warn] [launcher] $ScalaToolsReleases deprecated. use $SonatypeOSSReleases instead."
524-
)
525-
sonatypeReleases
526+
mavenMainResolver :: Nil
526527
case SonatypeOSSReleases =>
527-
sonatypeReleases
528-
case ScalaToolsSnapshots =>
528+
sonatypeReleases :: Nil
529+
case SonatypeOSSSnapshots =>
530+
scalaSnapshots(getScalaVersion) :: Nil
531+
case Jcenter | ScalaToolsReleases | ScalaToolsSnapshots =>
529532
log(
530-
s"[warn] [launcher] $ScalaToolsSnapshots deprecated. use $SonatypeOSSSnapshots instead."
533+
s"[warn] [launcher] ${p.id} is deprecated or no longer available; remove from repositories"
531534
)
532-
scalaSnapshots(getScalaVersion)
533-
case SonatypeOSSSnapshots =>
534-
scalaSnapshots(getScalaVersion)
535-
case Jcenter =>
536-
jcenterResolver
535+
Nil
537536
}
538537
}
539538
}
@@ -601,11 +600,9 @@ final class Update(config: UpdateConfiguration) {
601600
|| str.startsWith("http://127.0.0.1:"))
602601
}
603602
private def centralRepositoryRoot: String = "https://repo1.maven.org/maven2/"
604-
private def jcenterRepositoryRoot: String = "https://jcenter.bintray.com/"
605603

606604
/** Creates a resolver for Maven Central.*/
607605
private def mavenMainResolver = defaultMavenResolver("Maven Central")
608-
private def jcenterResolver = mavenResolver("JCenter", jcenterRepositoryRoot, false)
609606

610607
/** Creates a maven-style resolver with the default root.*/
611608
private def defaultMavenResolver(name: String) =

launcher-interface/src/main/java/xsbti/Predefined.java

+21-16
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package xsbti;
22

3-
public enum Predefined
4-
{
5-
Local("local"),
6-
MavenLocal("maven-local"),
7-
MavenCentral("maven-central"),
3+
public enum Predefined {
4+
Local("local"), MavenLocal("maven-local"), MavenCentral("maven-central"),
85
/**
96
* @deprecated use {@link #SonatypeOSSReleases} instead.
107
*/
@@ -14,23 +11,31 @@ public enum Predefined
1411
* @deprecated use {@link #SonatypeOSSSnapshots} instead.
1512
*/
1613
@Deprecated
17-
ScalaToolsSnapshots("scala-tools-snapshots"),
18-
SonatypeOSSReleases("sonatype-oss-releases"),
14+
ScalaToolsSnapshots("scala-tools-snapshots"), SonatypeOSSReleases("sonatype-oss-releases"),
1915
SonatypeOSSSnapshots("sonatype-oss-snapshots"),
20-
Jcenter("jcenter");
16+
/**
17+
* @deprecated
18+
*/
19+
@Deprecated
20+
Jcenter("jcenter");
2121

2222
private final String label;
23-
private Predefined(String label) { this.label = label; }
24-
public String toString() { return label; }
2523

26-
public static Predefined toValue(String s)
27-
{
28-
for(Predefined p : values())
29-
if(s.equals(p.toString()))
24+
private Predefined(String label) {
25+
this.label = label;
26+
}
27+
28+
public String toString() {
29+
return label;
30+
}
31+
32+
public static Predefined toValue(String s) {
33+
for (Predefined p : values())
34+
if (s.equals(p.toString()))
3035
return p;
31-
36+
3237
StringBuilder msg = new StringBuilder("Expected one of ");
33-
for(Predefined p : values())
38+
for (Predefined p : values())
3439
msg.append(p.toString()).append(", ");
3540
msg.append("got '").append(s).append("'.");
3641
throw new RuntimeException(msg.toString());

0 commit comments

Comments
 (0)