Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore jcenter and scala-tools-releases #104

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target
metals.sbt
59 changes: 36 additions & 23 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import Deps._
import Util._
import com.typesafe.tools.mima.core._, ProblemFilters._

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

Global / onChangedBuildSource := ReloadOnSourceChanges
ThisBuild / dynverSonatypeSnapshots := true
Expand All @@ -12,7 +14,7 @@ ThisBuild / version := {
else orig
}
ThisBuild / description := "Standalone launcher for maven/ivy deployed projects"
ThisBuild / scalaVersion := "2.13.6"
ThisBuild / scalaVersion := "2.13.14"
ThisBuild / publishMavenStyle := true
ThisBuild / crossPaths := false
ThisBuild / resolvers += Resolver.typesafeIvyRepo("releases")
Expand All @@ -31,9 +33,9 @@ lazy val root = (project in file("."))
packageDoc in Compile := (packageDoc in Compile in launchSub).value
commands += Command.command("release") { state =>
"clean" ::
"test" ::
"publishSigned" ::
state
"test" ::
"publishSigned" ::
state
}
validNamespaces ++= Set("xsbt", "xsbti", "scala", "org.apache.ivy", "org.fusesource.jansi")
validEntries ++= Set("LICENSE", "NOTICE", "module.properties")
Expand All @@ -56,19 +58,26 @@ def proguardedLauncherSettings = Seq(

def launchSettings =
inConfig(Compile)(Transform.configSettings) ++
inConfig(Compile)(Transform.transSourceSettings ++ Seq(
// TODO - these should be shared between sbt core + sbt-launcher...
Transform.inputSourceDirectory := sourceDirectory.value / "input_sources",
Transform.sourceProperties := Map("cross.package0" -> "xsbt", "cross.package1" -> "boot")
))
inConfig(Compile)(
Transform.transSourceSettings ++ Seq(
// TODO - these should be shared between sbt core + sbt-launcher...
Transform.inputSourceDirectory := sourceDirectory.value / "input_sources",
Transform.sourceProperties := Map("cross.package0" -> "xsbt", "cross.package1" -> "boot")
)
)

// The interface JAR for projects which want to be launched by sbt.
lazy val launchInterfaceSub = (project in file("launcher-interface"))
.settings(javaOnly)
.settings(nocomma {
name := "Launcher Interface"
resourceGenerators in Compile += Def.task{
generateVersionFile("sbt.launcher.version.properties")(version.value, resourceManaged.value, streams.value, (compile in Compile).value)
resourceGenerators in Compile += Def.task {
generateVersionFile("sbt.launcher.version.properties")(
version.value,
resourceManaged.value,
streams.value,
(compile in Compile).value
)
}.taskValue
description := "Interfaces for launching projects with the sbt launcher"
mimaPreviousArtifacts := Set(organization.value % moduleName.value % "1.0.1")
Expand Down Expand Up @@ -119,10 +128,10 @@ lazy val launchSub = (project in file("launcher-implementation"))
Proguard / proguardOptions ++= keepFullClasses.value map ("-keep public class " + _ + " {\n\tpublic protected * ;\n}")
Proguard / proguardInputFilter := { file =>
file.name match {
case x if x.startsWith("scala-library") => Some(libraryFilter)
case x if x.startsWith("ivy-2.3.0") => Some(ivyFilter)
case x if x.startsWith("scala-library") => Some(libraryFilter)
case x if x.startsWith("ivy-2.3.0") => Some(ivyFilter)
case x if x.startsWith("launcher-implementation") => None
case _ => Some(generalFilter)
case _ => Some(generalFilter)
}
}
Proguard / proguardOptions += ProguardOptions.keepMain("xsbt.boot.Boot")
Expand Down Expand Up @@ -156,7 +165,6 @@ def ivyFilter = {
excludeString(ivyResources)
}


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

ThisBuild / organization := "org.scala-sbt"
ThisBuild / pomIncludeRepository := { x => false }
ThisBuild / pomIncludeRepository := { x =>
false
}
ThisBuild / homepage := Some(url("https://scala-sbt.org"))
ThisBuild / licenses += "Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.txt")
ThisBuild / scmInfo := Some(ScmInfo(
browseUrl = url("https://github.com/sbt/launcher"),
connection = "scm:[email protected]:sbt/launcher.git"
))
ThisBuild / scmInfo := Some(
ScmInfo(
browseUrl = url("https://github.com/sbt/launcher"),
connection = "scm:[email protected]:sbt/launcher.git"
)
)
ThisBuild / developers := List(
Developer("eed3si9n", "Eugene Yokota", "@eed3si9n", url("https://github.com/eed3si9n")),
Developer("jsuereth", "Josh Suereth", "@jsuereth", url("https://github.com/jsuereth")),
Developer("dwijnand", "Dale Wijnand", "@dwijnand", url("https://github.com/dwijnand"))
)
ThisBuild / publishTo := {
val nexus = "https://oss.sonatype.org/"
if (version.value.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
if (version.value.trim.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ object CrossVersionUtil
major > minMajor || (major == minMajor && minor >= minMinor)
private[this] def binaryVersionWithApi(full: String, cutoff: String)(apiVersion: String => Option[(Int,Int)]): String =
{
def sub(major: Int, minor: Int) = major + "." + minor
def sub(major: Int, minor: Int) = major.toString() + "." + minor
(apiVersion(full), partialVersion(cutoff)) match {
case (Some((major, minor)), None) => sub(major, minor)
case (Some((major, minor)), Some((minMajor, minMinor))) if isNewer(major, minor, minMajor, minMinor) => sub(major, minor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ object Boot {
}

private def exit(code: Int): Nothing =
System.exit(code).asInstanceOf[Nothing]
sys.exit(code)
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ object Configuration {
case Array("") => Console.err.println(s"[warn] [launcher] invalid system property '$head'")
case Array(key) => sys.props += key -> ""
case Array(key, value) => sys.props += key -> value
case _ => ()
}
()
}
Expand Down Expand Up @@ -79,8 +80,8 @@ object Configuration {
multiPartError("could not find configuration file '" + path + "'. searched:", against)
resolving.next()
}
def multiPartError[T](firstLine: String, lines: List[T]) =
Pre.error((firstLine :: lines).mkString("\n\t"))
def multiPartError[A](firstLine: String, lines: List[A]) =
Pre.error((firstLine :: lines.map(_.toString())).mkString("\n\t"))

def UnspecifiedVersionPart = "Unspecified"
def DefaultVersionPart = "Default"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object ConfigurationParser {
b.toString
}

implicit val readIDs = ids _
implicit val readIDs: String => List[String] = ids _
}
class ConfigurationParser {
def apply(file: File): LaunchConfiguration = Using(newReader(file))(apply)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import java.nio.file.{ Files, StandardCopyOption, Paths }
import java.util.Properties
import java.util.regex.Pattern
import BootConfiguration._
import scala.annotation.nowarn

class CousierUpdate(config: UpdateConfiguration) {
import config.{
Expand Down Expand Up @@ -178,7 +179,7 @@ class CousierUpdate(config: UpdateConfiguration) {
target: UpdateTarget,
deps: List[Dependency]
): UpdateResult = {
val repos = config.repositories.map(toCoursierRepository)
val repos = config.repositories.flatMap(toCoursierRepository)
val params = scalaVersion match {
case Some(sv) if sv != "auto" =>
ResolutionParams()
Expand Down Expand Up @@ -303,11 +304,12 @@ class CousierUpdate(config: UpdateConfiguration) {
)).toList
}

def toCoursierRepository(repo: xsbti.Repository): Repository = {
@nowarn
def toCoursierRepository(repo: xsbti.Repository): Seq[Repository] = {
import xsbti.Predefined._
repo match {
case m: xsbti.MavenRepository =>
mavenRepository(m.url.toString)
mavenRepository(m.url.toString) :: Nil
case i: xsbti.IvyRepository =>
ivyRepository(
i.id,
Expand All @@ -318,22 +320,25 @@ class CousierUpdate(config: UpdateConfiguration) {
i.descriptorOptional,
i.skipConsistencyCheck,
i.allowInsecureProtocol
)
) :: Nil
case p: xsbti.PredefinedRepository =>
p.id match {
case Local =>
localRepository
localRepository :: Nil
case MavenLocal =>
val localDir = new File(new File(new File(sys.props("user.home")), ".m2"), "repository")
mavenRepository(localDir.toPath.toUri.toString)
mavenRepository(localDir.toPath.toUri.toString) :: Nil
case MavenCentral =>
Repositories.central
Repositories.central :: Nil
case SonatypeOSSReleases =>
Repositories.sonatype("releases")
Repositories.sonatype("releases") :: Nil
case SonatypeOSSSnapshots =>
Repositories.sonatype("snapshots")
case Jcenter =>
Repositories.jcenter
Repositories.sonatype("snapshots") :: Nil
case Jcenter | ScalaToolsReleases | ScalaToolsSnapshots =>
log(
s"[warn] [launcher] ${p.id} is deprecated or no longer available; remove from repositories"
)
Nil
Comment on lines +337 to +341
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main change.

}
}
}
Expand Down
2 changes: 0 additions & 2 deletions launcher-implementation/src/main/scala/xsbt/boot/Pre.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package xsbt.boot
import java.io.{ File, FileFilter }
import java.net.URL
import java.util.Locale
import scala.annotation.nowarn
import scala.collection.immutable.List
import scala.reflect.ClassTag

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

@nowarn
def toArray[T: ClassTag](list: List[T]) = {
val arr = new Array[T](list.length)
def copy(i: Int, rem: List[T]): Unit =
Expand Down
43 changes: 20 additions & 23 deletions launcher-implementation/src/main/scala/xsbt/boot/Update.scala
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,10 @@ final class Update(config: UpdateConfiguration) {
}
newDefault.setName("redefined-public")
if (repositories.isEmpty) error("no repositories defined")
for (repo <- repositories if includeRepo(repo))
newDefault.add(toIvyRepository(settings, repo))
for {
repo <- repositories if includeRepo(repo)
irepo <- toIvyRepositories(settings, repo)
} newDefault.add(irepo)
configureCache(settings)
settings.addResolver(newDefault)
settings.setDefaultResolver(newDefault.getName)
Expand Down Expand Up @@ -490,10 +492,14 @@ final class Update(config: UpdateConfiguration) {
}

@nowarn
private def toIvyRepository(settings: IvySettings, repo: xsbti.Repository) = {
private def toIvyRepositories(
settings: IvySettings,
repo: xsbti.Repository
): Seq[plugins.resolver.RepositoryResolver] = {
import xsbti.Predefined._
repo match {
case m: xsbti.MavenRepository => mavenResolver(m.id, m.url.toString, m.allowInsecureProtocol)
case m: xsbti.MavenRepository =>
mavenResolver(m.id, m.url.toString, m.allowInsecureProtocol) :: Nil
case i: xsbti.IvyRepository =>
urlResolver(
i.id,
Expand All @@ -504,7 +510,7 @@ final class Update(config: UpdateConfiguration) {
i.descriptorOptional,
i.skipConsistencyCheck,
i.allowInsecureProtocol
)
) :: Nil
case p: xsbti.PredefinedRepository =>
val sonatypeReleases = mavenResolver(
"Sonatype Releases Repository",
Expand All @@ -513,27 +519,20 @@ final class Update(config: UpdateConfiguration) {
)
p.id match {
case Local =>
localResolver(settings.getDefaultIvyUserDir.getAbsolutePath)
localResolver(settings.getDefaultIvyUserDir.getAbsolutePath) :: Nil
case MavenLocal =>
mavenLocal
mavenLocal :: Nil
case MavenCentral =>
mavenMainResolver
case ScalaToolsReleases =>
log(
s"[warn] [launcher] $ScalaToolsReleases deprecated. use $SonatypeOSSReleases instead."
)
sonatypeReleases
mavenMainResolver :: Nil
case SonatypeOSSReleases =>
sonatypeReleases
case ScalaToolsSnapshots =>
sonatypeReleases :: Nil
case SonatypeOSSSnapshots =>
scalaSnapshots(getScalaVersion) :: Nil
case Jcenter | ScalaToolsReleases | ScalaToolsSnapshots =>
log(
s"[warn] [launcher] $ScalaToolsSnapshots deprecated. use $SonatypeOSSSnapshots instead."
s"[warn] [launcher] ${p.id} is deprecated or no longer available; remove from repositories"
)
scalaSnapshots(getScalaVersion)
case SonatypeOSSSnapshots =>
scalaSnapshots(getScalaVersion)
case Jcenter =>
jcenterResolver
Nil
}
}
}
Expand Down Expand Up @@ -601,11 +600,9 @@ final class Update(config: UpdateConfiguration) {
|| str.startsWith("http://127.0.0.1:"))
}
private def centralRepositoryRoot: String = "https://repo1.maven.org/maven2/"
private def jcenterRepositoryRoot: String = "https://jcenter.bintray.com/"

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

/** Creates a maven-style resolver with the default root.*/
private def defaultMavenResolver(name: String) =
Expand Down
37 changes: 21 additions & 16 deletions launcher-interface/src/main/java/xsbti/Predefined.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package xsbti;

public enum Predefined
{
Local("local"),
MavenLocal("maven-local"),
MavenCentral("maven-central"),
public enum Predefined {
Local("local"), MavenLocal("maven-local"), MavenCentral("maven-central"),
/**
* @deprecated use {@link #SonatypeOSSReleases} instead.
*/
Expand All @@ -14,23 +11,31 @@ public enum Predefined
* @deprecated use {@link #SonatypeOSSSnapshots} instead.
*/
@Deprecated
ScalaToolsSnapshots("scala-tools-snapshots"),
SonatypeOSSReleases("sonatype-oss-releases"),
ScalaToolsSnapshots("scala-tools-snapshots"), SonatypeOSSReleases("sonatype-oss-releases"),
SonatypeOSSSnapshots("sonatype-oss-snapshots"),
Jcenter("jcenter");
/**
* @deprecated
*/
@Deprecated
Jcenter("jcenter");

private final String label;
private Predefined(String label) { this.label = label; }
public String toString() { return label; }

public static Predefined toValue(String s)
{
for(Predefined p : values())
if(s.equals(p.toString()))
private Predefined(String label) {
this.label = label;
}

public String toString() {
return label;
}

public static Predefined toValue(String s) {
for (Predefined p : values())
if (s.equals(p.toString()))
return p;

StringBuilder msg = new StringBuilder("Expected one of ");
for(Predefined p : values())
for (Predefined p : values())
msg.append(p.toString()).append(", ");
msg.append("got '").append(s).append("'.");
throw new RuntimeException(msg.toString());
Expand Down
Loading
Loading