mirror of https://github.com/sbt/sbt.git
Merge pull request #7927 from eed3si9n/wip/uri
[2.x] Avoid the use of URL + Replace tuple with proper record type for licenses
This commit is contained in:
commit
fdc03b782a
|
|
@ -49,6 +49,7 @@ trait LibraryManagementCodec extends sbt.librarymanagement.ConfigRefFormats
|
|||
with sbt.librarymanagement.SftpRepositoryFormats
|
||||
with sbt.librarymanagement.ResolverFormats
|
||||
with sbt.librarymanagement.ModuleConfigurationFormats
|
||||
with sbt.librarymanagement.LicenseFormats
|
||||
with sbt.librarymanagement.ScmInfoFormats
|
||||
with sbt.librarymanagement.ModuleInfoFormats
|
||||
with sbt.librarymanagement.IvyFileConfigurationFormats
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* This code is generated using [[https://www.scala-sbt.org/contraband]].
|
||||
*/
|
||||
|
||||
// DO NOT EDIT MANUALLY
|
||||
package sbt.librarymanagement
|
||||
/** Basic license information for a project module */
|
||||
final class License private (
|
||||
val spdxId: String,
|
||||
val uri: java.net.URI,
|
||||
val distribution: Option[String],
|
||||
val comments: Option[String]) extends Serializable {
|
||||
|
||||
private def this(spdxId: String, uri: java.net.URI) = this(spdxId, uri, None, None)
|
||||
|
||||
override def equals(o: Any): Boolean = this.eq(o.asInstanceOf[AnyRef]) || (o match {
|
||||
case x: License => (this.spdxId == x.spdxId) && (this.uri == x.uri) && (this.distribution == x.distribution) && (this.comments == x.comments)
|
||||
case _ => false
|
||||
})
|
||||
override def hashCode: Int = {
|
||||
37 * (37 * (37 * (37 * (37 * (17 + "sbt.librarymanagement.License".##) + spdxId.##) + uri.##) + distribution.##) + comments.##)
|
||||
}
|
||||
override def toString: String = {
|
||||
"License(" + spdxId + ", " + uri + ", " + distribution + ", " + comments + ")"
|
||||
}
|
||||
private def copy(spdxId: String = spdxId, uri: java.net.URI = uri, distribution: Option[String] = distribution, comments: Option[String] = comments): License = {
|
||||
new License(spdxId, uri, distribution, comments)
|
||||
}
|
||||
def withSpdxId(spdxId: String): License = {
|
||||
copy(spdxId = spdxId)
|
||||
}
|
||||
def withUri(uri: java.net.URI): License = {
|
||||
copy(uri = uri)
|
||||
}
|
||||
def withDistribution(distribution: Option[String]): License = {
|
||||
copy(distribution = distribution)
|
||||
}
|
||||
def withDistribution(distribution: String): License = {
|
||||
copy(distribution = Option(distribution))
|
||||
}
|
||||
def withComments(comments: Option[String]): License = {
|
||||
copy(comments = comments)
|
||||
}
|
||||
def withComments(comments: String): License = {
|
||||
copy(comments = Option(comments))
|
||||
}
|
||||
}
|
||||
object License extends sbt.librarymanagement.LicenseFunctions {
|
||||
|
||||
def apply(spdxId: String, uri: java.net.URI): License = new License(spdxId, uri)
|
||||
def apply(spdxId: String, uri: java.net.URI, distribution: Option[String], comments: Option[String]): License = new License(spdxId, uri, distribution, comments)
|
||||
def apply(spdxId: String, uri: java.net.URI, distribution: String, comments: String): License = new License(spdxId, uri, Option(distribution), Option(comments))
|
||||
}
|
||||
33
lm-core/src/main/contraband-scala/sbt/librarymanagement/LicenseFormats.scala
generated
Normal file
33
lm-core/src/main/contraband-scala/sbt/librarymanagement/LicenseFormats.scala
generated
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* This code is generated using [[https://www.scala-sbt.org/contraband]].
|
||||
*/
|
||||
|
||||
// DO NOT EDIT MANUALLY
|
||||
package sbt.librarymanagement
|
||||
import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError }
|
||||
trait LicenseFormats { self: sjsonnew.BasicJsonProtocol =>
|
||||
implicit lazy val LicenseFormat: JsonFormat[sbt.librarymanagement.License] = new JsonFormat[sbt.librarymanagement.License] {
|
||||
override def read[J](__jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.librarymanagement.License = {
|
||||
__jsOpt match {
|
||||
case Some(__js) =>
|
||||
unbuilder.beginObject(__js)
|
||||
val spdxId = unbuilder.readField[String]("spdxId")
|
||||
val uri = unbuilder.readField[java.net.URI]("uri")
|
||||
val distribution = unbuilder.readField[Option[String]]("distribution")
|
||||
val comments = unbuilder.readField[Option[String]]("comments")
|
||||
unbuilder.endObject()
|
||||
sbt.librarymanagement.License(spdxId, uri, distribution, comments)
|
||||
case None =>
|
||||
deserializationError("Expected JsObject but found None")
|
||||
}
|
||||
}
|
||||
override def write[J](obj: sbt.librarymanagement.License, builder: Builder[J]): Unit = {
|
||||
builder.beginObject()
|
||||
builder.addField("spdxId", obj.spdxId)
|
||||
builder.addField("uri", obj.uri)
|
||||
builder.addField("distribution", obj.distribution)
|
||||
builder.addField("comments", obj.comments)
|
||||
builder.endObject()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
// DO NOT EDIT MANUALLY
|
||||
package sbt.librarymanagement
|
||||
import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError }
|
||||
trait ModuleDescriptorConfigurationFormats { self: sbt.librarymanagement.ScalaModuleInfoFormats & sbt.librarymanagement.ConfigurationFormats & sjsonnew.BasicJsonProtocol & sbt.librarymanagement.ModuleIDFormats & sbt.librarymanagement.ArtifactFormats & sbt.librarymanagement.ConfigRefFormats & sbt.librarymanagement.ChecksumFormats & sbt.librarymanagement.InclExclRuleFormats & sbt.librarymanagement.CrossVersionFormats & sbt.librarymanagement.DisabledFormats & sbt.librarymanagement.BinaryFormats & sbt.librarymanagement.ConstantFormats & sbt.librarymanagement.PatchFormats & sbt.librarymanagement.FullFormats & sbt.librarymanagement.For3Use2_13Formats & sbt.librarymanagement.For2_13Use3Formats & sbt.librarymanagement.ModuleInfoFormats & sbt.librarymanagement.ScmInfoFormats & sbt.librarymanagement.DeveloperFormats & sbt.internal.librarymanagement.formats.NodeSeqFormat & sbt.librarymanagement.ConflictManagerFormats =>
|
||||
trait ModuleDescriptorConfigurationFormats { self: sbt.librarymanagement.ScalaModuleInfoFormats & sbt.librarymanagement.ConfigurationFormats & sjsonnew.BasicJsonProtocol & sbt.librarymanagement.ModuleIDFormats & sbt.librarymanagement.ArtifactFormats & sbt.librarymanagement.ConfigRefFormats & sbt.librarymanagement.ChecksumFormats & sbt.librarymanagement.InclExclRuleFormats & sbt.librarymanagement.CrossVersionFormats & sbt.librarymanagement.DisabledFormats & sbt.librarymanagement.BinaryFormats & sbt.librarymanagement.ConstantFormats & sbt.librarymanagement.PatchFormats & sbt.librarymanagement.FullFormats & sbt.librarymanagement.For3Use2_13Formats & sbt.librarymanagement.For2_13Use3Formats & sbt.librarymanagement.ModuleInfoFormats & sbt.librarymanagement.LicenseFormats & sbt.librarymanagement.ScmInfoFormats & sbt.librarymanagement.DeveloperFormats & sbt.internal.librarymanagement.formats.NodeSeqFormat & sbt.librarymanagement.ConflictManagerFormats =>
|
||||
implicit lazy val ModuleDescriptorConfigurationFormat: JsonFormat[sbt.librarymanagement.ModuleDescriptorConfiguration] = new JsonFormat[sbt.librarymanagement.ModuleDescriptorConfiguration] {
|
||||
override def read[J](__jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.librarymanagement.ModuleDescriptorConfiguration = {
|
||||
__jsOpt match {
|
||||
|
|
|
|||
|
|
@ -10,13 +10,14 @@ final class ModuleInfo private (
|
|||
val description: String,
|
||||
val homepage: Option[java.net.URI],
|
||||
val startYear: Option[Int],
|
||||
val licenses: Vector[scala.Tuple2[String, java.net.URI]],
|
||||
val licenses: Vector[sbt.librarymanagement.License],
|
||||
val organizationName: String,
|
||||
val organizationHomepage: Option[java.net.URI],
|
||||
val scmInfo: Option[sbt.librarymanagement.ScmInfo],
|
||||
val developers: Vector[sbt.librarymanagement.Developer]) extends Serializable {
|
||||
|
||||
private def this(nameFormal: String) = this(nameFormal, "", None, None, Vector.empty, "", None, None, Vector.empty)
|
||||
private def this(nameFormal: String, description: String, homepage: Option[java.net.URI], startYear: Option[Int], organizationName: String, organizationHomepage: Option[java.net.URI], scmInfo: Option[sbt.librarymanagement.ScmInfo], developers: Vector[sbt.librarymanagement.Developer]) = this(nameFormal, description, homepage, startYear, Vector.empty, organizationName, organizationHomepage, scmInfo, developers)
|
||||
|
||||
override def equals(o: Any): Boolean = this.eq(o.asInstanceOf[AnyRef]) || (o match {
|
||||
case x: ModuleInfo => (this.nameFormal == x.nameFormal) && (this.description == x.description) && (this.homepage == x.homepage) && (this.startYear == x.startYear) && (this.licenses == x.licenses) && (this.organizationName == x.organizationName) && (this.organizationHomepage == x.organizationHomepage) && (this.scmInfo == x.scmInfo) && (this.developers == x.developers)
|
||||
|
|
@ -28,7 +29,7 @@ final class ModuleInfo private (
|
|||
override def toString: String = {
|
||||
"ModuleInfo(" + nameFormal + ", " + description + ", " + homepage + ", " + startYear + ", " + licenses + ", " + organizationName + ", " + organizationHomepage + ", " + scmInfo + ", " + developers + ")"
|
||||
}
|
||||
private def copy(nameFormal: String = nameFormal, description: String = description, homepage: Option[java.net.URI] = homepage, startYear: Option[Int] = startYear, licenses: Vector[scala.Tuple2[String, java.net.URI]] = licenses, organizationName: String = organizationName, organizationHomepage: Option[java.net.URI] = organizationHomepage, scmInfo: Option[sbt.librarymanagement.ScmInfo] = scmInfo, developers: Vector[sbt.librarymanagement.Developer] = developers): ModuleInfo = {
|
||||
private def copy(nameFormal: String = nameFormal, description: String = description, homepage: Option[java.net.URI] = homepage, startYear: Option[Int] = startYear, licenses: Vector[sbt.librarymanagement.License] = licenses, organizationName: String = organizationName, organizationHomepage: Option[java.net.URI] = organizationHomepage, scmInfo: Option[sbt.librarymanagement.ScmInfo] = scmInfo, developers: Vector[sbt.librarymanagement.Developer] = developers): ModuleInfo = {
|
||||
new ModuleInfo(nameFormal, description, homepage, startYear, licenses, organizationName, organizationHomepage, scmInfo, developers)
|
||||
}
|
||||
def withNameFormal(nameFormal: String): ModuleInfo = {
|
||||
|
|
@ -43,7 +44,7 @@ final class ModuleInfo private (
|
|||
def withStartYear(startYear: Option[Int]): ModuleInfo = {
|
||||
copy(startYear = startYear)
|
||||
}
|
||||
def withLicenses(licenses: Vector[scala.Tuple2[String, java.net.URI]]): ModuleInfo = {
|
||||
def withLicenses(licenses: Vector[sbt.librarymanagement.License]): ModuleInfo = {
|
||||
copy(licenses = licenses)
|
||||
}
|
||||
def withOrganizationName(organizationName: String): ModuleInfo = {
|
||||
|
|
@ -62,5 +63,6 @@ final class ModuleInfo private (
|
|||
object ModuleInfo {
|
||||
|
||||
def apply(nameFormal: String): ModuleInfo = new ModuleInfo(nameFormal)
|
||||
def apply(nameFormal: String, description: String, homepage: Option[java.net.URI], startYear: Option[Int], licenses: Vector[scala.Tuple2[String, java.net.URI]], organizationName: String, organizationHomepage: Option[java.net.URI], scmInfo: Option[sbt.librarymanagement.ScmInfo], developers: Vector[sbt.librarymanagement.Developer]): ModuleInfo = new ModuleInfo(nameFormal, description, homepage, startYear, licenses, organizationName, organizationHomepage, scmInfo, developers)
|
||||
def apply(nameFormal: String, description: String, homepage: Option[java.net.URI], startYear: Option[Int], organizationName: String, organizationHomepage: Option[java.net.URI], scmInfo: Option[sbt.librarymanagement.ScmInfo], developers: Vector[sbt.librarymanagement.Developer]): ModuleInfo = new ModuleInfo(nameFormal, description, homepage, startYear, organizationName, organizationHomepage, scmInfo, developers)
|
||||
def apply(nameFormal: String, description: String, homepage: Option[java.net.URI], startYear: Option[Int], licenses: Vector[sbt.librarymanagement.License], organizationName: String, organizationHomepage: Option[java.net.URI], scmInfo: Option[sbt.librarymanagement.ScmInfo], developers: Vector[sbt.librarymanagement.Developer]): ModuleInfo = new ModuleInfo(nameFormal, description, homepage, startYear, licenses, organizationName, organizationHomepage, scmInfo, developers)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// DO NOT EDIT MANUALLY
|
||||
package sbt.librarymanagement
|
||||
import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError }
|
||||
trait ModuleInfoFormats { self: sbt.librarymanagement.ScmInfoFormats & sbt.librarymanagement.DeveloperFormats & sjsonnew.BasicJsonProtocol =>
|
||||
trait ModuleInfoFormats { self: sbt.librarymanagement.LicenseFormats & sjsonnew.BasicJsonProtocol & sbt.librarymanagement.ScmInfoFormats & sbt.librarymanagement.DeveloperFormats =>
|
||||
implicit lazy val ModuleInfoFormat: JsonFormat[sbt.librarymanagement.ModuleInfo] = new JsonFormat[sbt.librarymanagement.ModuleInfo] {
|
||||
override def read[J](__jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.librarymanagement.ModuleInfo = {
|
||||
__jsOpt match {
|
||||
|
|
@ -15,7 +15,7 @@ implicit lazy val ModuleInfoFormat: JsonFormat[sbt.librarymanagement.ModuleInfo]
|
|||
val description = unbuilder.readField[String]("description")
|
||||
val homepage = unbuilder.readField[Option[java.net.URI]]("homepage")
|
||||
val startYear = unbuilder.readField[Option[Int]]("startYear")
|
||||
val licenses = unbuilder.readField[Vector[scala.Tuple2[String, java.net.URI]]]("licenses")
|
||||
val licenses = unbuilder.readField[Vector[sbt.librarymanagement.License]]("licenses")
|
||||
val organizationName = unbuilder.readField[String]("organizationName")
|
||||
val organizationHomepage = unbuilder.readField[Option[java.net.URI]]("organizationHomepage")
|
||||
val scmInfo = unbuilder.readField[Option[sbt.librarymanagement.ScmInfo]]("scmInfo")
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@
|
|||
package sbt.librarymanagement
|
||||
|
||||
import _root_.sjsonnew.JsonFormat
|
||||
trait ModuleSettingsFormats { self: sbt.librarymanagement.ScalaModuleInfoFormats & sbt.librarymanagement.ConfigurationFormats & sjsonnew.BasicJsonProtocol & sbt.librarymanagement.IvyFileConfigurationFormats & sbt.librarymanagement.PomConfigurationFormats & sbt.librarymanagement.ModuleIDFormats & sbt.librarymanagement.ArtifactFormats & sbt.librarymanagement.ConfigRefFormats & sbt.librarymanagement.ChecksumFormats & sbt.librarymanagement.InclExclRuleFormats & sbt.librarymanagement.CrossVersionFormats & sbt.librarymanagement.DisabledFormats & sbt.librarymanagement.BinaryFormats & sbt.librarymanagement.ConstantFormats & sbt.librarymanagement.PatchFormats & sbt.librarymanagement.FullFormats & sbt.librarymanagement.For3Use2_13Formats & sbt.librarymanagement.For2_13Use3Formats & sbt.librarymanagement.ModuleInfoFormats & sbt.librarymanagement.ScmInfoFormats & sbt.librarymanagement.DeveloperFormats & sbt.internal.librarymanagement.formats.NodeSeqFormat & sbt.librarymanagement.ConflictManagerFormats & sbt.librarymanagement.ModuleDescriptorConfigurationFormats =>
|
||||
trait ModuleSettingsFormats { self: sbt.librarymanagement.ScalaModuleInfoFormats & sbt.librarymanagement.ConfigurationFormats & sjsonnew.BasicJsonProtocol & sbt.librarymanagement.IvyFileConfigurationFormats & sbt.librarymanagement.PomConfigurationFormats & sbt.librarymanagement.ModuleIDFormats & sbt.librarymanagement.ArtifactFormats & sbt.librarymanagement.ConfigRefFormats & sbt.librarymanagement.ChecksumFormats & sbt.librarymanagement.InclExclRuleFormats & sbt.librarymanagement.CrossVersionFormats & sbt.librarymanagement.DisabledFormats & sbt.librarymanagement.BinaryFormats & sbt.librarymanagement.ConstantFormats & sbt.librarymanagement.PatchFormats & sbt.librarymanagement.FullFormats & sbt.librarymanagement.For3Use2_13Formats & sbt.librarymanagement.For2_13Use3Formats & sbt.librarymanagement.ModuleInfoFormats & sbt.librarymanagement.LicenseFormats & sbt.librarymanagement.ScmInfoFormats & sbt.librarymanagement.DeveloperFormats & sbt.internal.librarymanagement.formats.NodeSeqFormat & sbt.librarymanagement.ConflictManagerFormats & sbt.librarymanagement.ModuleDescriptorConfigurationFormats =>
|
||||
implicit lazy val ModuleSettingsFormat: JsonFormat[sbt.librarymanagement.ModuleSettings] = flatUnionFormat3[sbt.librarymanagement.ModuleSettings, sbt.librarymanagement.IvyFileConfiguration, sbt.librarymanagement.PomConfiguration, sbt.librarymanagement.ModuleDescriptorConfiguration]("type")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -367,11 +367,11 @@
|
|||
{ "name": "description", "type": "String", "default": "\"\"", "since": "0.0.1" },
|
||||
{ "name": "homepage", "type": "Option[java.net.URI]", "default": "None", "since": "0.0.1" },
|
||||
{ "name": "startYear", "type": "Option[Int]", "default": "None", "since": "0.0.1" },
|
||||
{ "name": "licenses", "type": "scala.Tuple2[String, java.net.URI]*", "default": "Vector.empty", "since": "0.0.1" },
|
||||
{ "name": "licenses", "type": "sbt.librarymanagement.License*", "default": "Vector.empty", "since": "2.0.0" },
|
||||
{ "name": "organizationName", "type": "String", "default": "\"\"", "since": "0.0.1" },
|
||||
{ "name": "organizationHomepage", "type": "Option[java.net.URI]", "default": "None", "since": "0.0.1" },
|
||||
{ "name": "scmInfo", "type": "Option[sbt.librarymanagement.ScmInfo]", "default": "None", "since": "0.0.1" },
|
||||
{ "name": "developers", "type": "sbt.librarymanagement.Developer*", "default": "Vector.empty", "since": "0.0.1" }
|
||||
{ "name": "developers", "type": "sbt.librarymanagement.Developer*", "default": "Vector.empty", "since": "0.0.1" }
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -733,6 +733,20 @@
|
|||
{ "name": "devConnection", "type": "String?", "default": "None", "since": "0.0.1" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "License",
|
||||
"namespace": "sbt.librarymanagement",
|
||||
"target": "Scala",
|
||||
"type": "record",
|
||||
"doc": "Basic license information for a project module",
|
||||
"fields": [
|
||||
{ "name": "spdxId", "type": "String" },
|
||||
{ "name": "uri", "type": "java.net.URI" },
|
||||
{ "name": "distribution", "type": "String?", "default": "None", "since": "0.0.1" },
|
||||
{ "name": "comments", "type": "String?", "default": "None", "since": "0.0.1" }
|
||||
],
|
||||
"parentsCompanion": "sbt.librarymanagement.LicenseFunctions"
|
||||
},
|
||||
{
|
||||
"name": "SshAuthentication",
|
||||
"namespace": "sbt.librarymanagement",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package sbt.librarymanagement
|
||||
|
||||
import java.net.URI
|
||||
|
||||
trait LibraryManagementSyntax0 {
|
||||
// See http://www.scala-lang.org/news/2.12.0#traits-compile-to-interfaces
|
||||
// Avoid defining fields (val or var, but a constant is ok – final val without result type)
|
||||
|
|
@ -35,6 +37,9 @@ trait LibraryManagementSyntax
|
|||
// java.lang.System is more important, so don't alias this one
|
||||
// final val System = C.System
|
||||
final val Optional = C.Optional
|
||||
|
||||
given Conversion[(String, URI), License] with
|
||||
inline def apply(x: (String, URI)): License = License(x._1, x._2)
|
||||
}
|
||||
|
||||
object syntax extends LibraryManagementSyntax
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
package sbt.librarymanagement
|
||||
|
||||
import java.net.URL
|
||||
import java.net.URI
|
||||
|
||||
/**
|
||||
* Commonly used software licenses
|
||||
* Names are SPDX ids:
|
||||
* https://raw.githubusercontent.com/spdx/license-list-data/master/json/licenses.json
|
||||
*/
|
||||
object License {
|
||||
lazy val Apache2: (String, URL) =
|
||||
("Apache-2.0", new URI("https://www.apache.org/licenses/LICENSE-2.0.txt").toURL)
|
||||
|
||||
lazy val MIT: (String, URL) =
|
||||
("MIT", new URI("https://opensource.org/licenses/MIT").toURL)
|
||||
|
||||
lazy val CC0: (String, URL) =
|
||||
("CC0-1.0", new URI("https://creativecommons.org/publicdomain/zero/1.0/legalcode").toURL)
|
||||
|
||||
def PublicDomain: (String, URL) = CC0
|
||||
|
||||
lazy val GPL3_or_later: (String, URL) =
|
||||
("GPL-3.0-or-later", new URI("https://spdx.org/licenses/GPL-3.0-or-later.html").toURL)
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package sbt.librarymanagement
|
||||
|
||||
import java.net.URI
|
||||
|
||||
/**
|
||||
* Commonly used software licenses
|
||||
* Names are SPDX ids:
|
||||
* https://raw.githubusercontent.com/spdx/license-list-data/master/json/licenses.json
|
||||
*/
|
||||
trait LicenseFunctions:
|
||||
lazy val Apache2: License =
|
||||
License("Apache-2.0", URI("https://www.apache.org/licenses/LICENSE-2.0.txt"))
|
||||
|
||||
lazy val MIT: License =
|
||||
License("MIT", URI("https://opensource.org/licenses/MIT"))
|
||||
|
||||
lazy val CC0: License =
|
||||
License("CC0-1.0", URI("https://creativecommons.org/publicdomain/zero/1.0/legalcode"))
|
||||
|
||||
def PublicDomain: License = CC0
|
||||
|
||||
lazy val GPL3_or_later: License =
|
||||
License("GPL-3.0-or-later", URI("https://spdx.org/licenses/GPL-3.0-or-later.html"))
|
||||
end LicenseFunctions
|
||||
|
|
@ -332,7 +332,7 @@ final class IvySbt(
|
|||
mod.setHomePage(h.toString)
|
||||
}
|
||||
moduleInfo.licenses foreach { l =>
|
||||
mod.addLicense(new License(l._1, l._2.toString))
|
||||
mod.addLicense(new License(l.spdxId, l.uri.toString))
|
||||
}
|
||||
IvySbt.addConfigurations(mod, configurations)
|
||||
IvySbt.addArtifacts(mod, module.explicitArtifacts)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
package sbt
|
||||
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
import java.time.OffsetDateTime
|
||||
import java.util.jar.{ Attributes, Manifest }
|
||||
import scala.jdk.CollectionConverters.*
|
||||
|
|
@ -196,7 +197,7 @@ object Pkg:
|
|||
def addImplManifestAttributes(
|
||||
name: String,
|
||||
version: String,
|
||||
homepage: Option[java.net.URL],
|
||||
homepage: Option[URI],
|
||||
org: String,
|
||||
orgName: String
|
||||
): PackageOption = {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
package sbt
|
||||
|
||||
import java.io.{ File, PrintWriter }
|
||||
import java.net.URL
|
||||
import java.nio.file.{ Files, Paths, Path => NioPath }
|
||||
import java.util.Optional
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
|
@ -2060,8 +2059,8 @@ object Defaults extends BuildCommon {
|
|||
apiMappings ++= {
|
||||
val dependencyCp = dependencyClasspath.value
|
||||
val log = streams.value.log
|
||||
if (autoAPIMappings.value) APIMappings.extract(dependencyCp, log).toMap
|
||||
else Map.empty[HashedVirtualFileRef, URL]
|
||||
if autoAPIMappings.value then APIMappings.extract(dependencyCp, log).toMap
|
||||
else Map.empty[HashedVirtualFileRef, URI]
|
||||
},
|
||||
fileInputOptions := Seq("-doc-root-content", "-diagrams-dot-path"),
|
||||
scalacOptions := {
|
||||
|
|
@ -3088,11 +3087,11 @@ object Classpaths {
|
|||
projectInfo := ModuleInfo(
|
||||
name.value,
|
||||
description.value,
|
||||
homepage.value.map(_.toURI),
|
||||
homepage.value,
|
||||
startYear.value,
|
||||
licenses.value.map((name, url) => (name, url.toURI)).toVector,
|
||||
licenses.value.toVector,
|
||||
organizationName.value,
|
||||
organizationHomepage.value.map(_.toURI),
|
||||
organizationHomepage.value,
|
||||
scmInfo.value,
|
||||
developers.value.toVector
|
||||
),
|
||||
|
|
@ -3517,21 +3516,18 @@ object Classpaths {
|
|||
val p0 = ModuleID(organization.value, moduleName.value, version.value)
|
||||
.cross((projectID / crossVersion).value)
|
||||
.artifacts(artifacts.value*)
|
||||
val p1 = apiURL.value match {
|
||||
case Some(u) => p0.extra(SbtPomExtraProperties.POM_API_KEY -> u.toExternalForm)
|
||||
val p1 = apiURL.value match
|
||||
case Some(u) => p0.extra(SbtPomExtraProperties.POM_API_KEY -> u.toURL().toExternalForm)
|
||||
case _ => p0
|
||||
}
|
||||
val p2 = versionScheme.value match {
|
||||
val p2 = versionScheme.value match
|
||||
case Some(x) =>
|
||||
VersionSchemes.validateScheme(x)
|
||||
p1.extra(SbtPomExtraProperties.VERSION_SCHEME_KEY -> x)
|
||||
case _ => p1
|
||||
}
|
||||
val p3 = releaseNotesURL.value match {
|
||||
val p3 = releaseNotesURL.value match
|
||||
case Some(u) =>
|
||||
p2.extra(SbtPomExtraProperties.POM_RELEASE_NOTES_KEY -> u.toExternalForm)
|
||||
p2.extra(SbtPomExtraProperties.POM_RELEASE_NOTES_KEY -> u.toURL().toExternalForm)
|
||||
case _ => p2
|
||||
}
|
||||
p3
|
||||
}
|
||||
def pluginProjectID: Initialize[ModuleID] =
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ package sbt
|
|||
|
||||
import java.nio.file.{ Path => NioPath }
|
||||
import java.io.File
|
||||
import java.net.{ URL, URI }
|
||||
import java.net.URI
|
||||
import lmcoursier.definitions.{ CacheLogger, ModuleMatchers, Reconciliation }
|
||||
import lmcoursier.{ CoursierConfiguration, FallbackDependency }
|
||||
import org.apache.ivy.core.module.descriptor.ModuleDescriptor
|
||||
|
|
@ -379,18 +379,18 @@ object Keys {
|
|||
val name = settingKey[String]("Project name.").withRank(APlusSetting)
|
||||
val normalizedName = settingKey[String]("Project name transformed from mixed case and spaces to lowercase and dash-separated.").withRank(BSetting)
|
||||
val description = settingKey[String]("Project description.").withRank(BSetting)
|
||||
val homepage = settingKey[Option[URL]]("Project homepage.").withRank(BSetting)
|
||||
val homepage = settingKey[Option[URI]]("Project homepage.").withRank(BSetting)
|
||||
val startYear = settingKey[Option[Int]]("Year in which the project started.").withRank(BMinusSetting)
|
||||
val licenses = settingKey[Seq[(String, URL)]]("Project licenses as (name, url) pairs.").withRank(BMinusSetting)
|
||||
val licenses = settingKey[Seq[License]]("Project licenses as (name, url) pairs.").withRank(BMinusSetting)
|
||||
val organization = settingKey[String]("Organization/group ID.").withRank(APlusSetting)
|
||||
val organizationName = settingKey[String]("Organization full/formal name.").withRank(BMinusSetting)
|
||||
val organizationHomepage = settingKey[Option[URL]]("Organization homepage.").withRank(BMinusSetting)
|
||||
val organizationHomepage = settingKey[Option[URI]]("Organization homepage.").withRank(BMinusSetting)
|
||||
val developers = settingKey[List[Developer]]("List of developers implicated in the project").withRank(BMinusSetting)
|
||||
val apiURL = settingKey[Option[URL]]("Base URL for API documentation.").withRank(BMinusSetting)
|
||||
val apiURL = settingKey[Option[URI]]("Base URI for API documentation.").withRank(BMinusSetting)
|
||||
val entryApiURL = StringAttributeKey("entryApiURL") // , "Base URL for the API documentation for a classpath entry.")
|
||||
val apiMappings = taskKey[Map[HashedVirtualFileRef, URL]]("Mappings from classpath entry to API documentation base URL.").withRank(BMinusSetting)
|
||||
val apiMappings = taskKey[Map[HashedVirtualFileRef, URI]]("Mappings from classpath entry to API documentation base URL.").withRank(BMinusSetting)
|
||||
val autoAPIMappings = settingKey[Boolean]("If true, automatically manages mappings to the API doc URL.").withRank(BMinusSetting)
|
||||
val releaseNotesURL = settingKey[Option[URL]]("URL for release notes.").withRank(BMinusSetting)
|
||||
val releaseNotesURL = settingKey[Option[URI]]("URL for release notes.").withRank(BMinusSetting)
|
||||
val scmInfo = settingKey[Option[ScmInfo]]("Basic SCM information for the project.").withRank(BMinusSetting)
|
||||
val projectInfo = settingKey[ModuleInfo]("Addition project information like formal name, homepage, licenses etc.").withRank(CSetting)
|
||||
val defaultConfiguration = settingKey[Option[Configuration]]("Defines the configuration used when none is specified for a dependency in ivyXML.").withRank(CSetting)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import sbt.librarymanagement.{ MavenRepository, Resolver }
|
|||
import sbt.librarymanagement.ivy.Credentials
|
||||
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import java.net.URI
|
||||
|
||||
import sbt.io.Path
|
||||
import Path._
|
||||
|
|
@ -33,11 +33,11 @@ object Opts {
|
|||
def sourceUrl(u: String): Seq[String] = Seq("-doc-source-url", u)
|
||||
def title(t: String): Seq[String] = Seq("-doc-title", t)
|
||||
def version(v: String): Seq[String] = Seq("-doc-version", v)
|
||||
def externalAPI(mappings: Iterable[(File, URL)]): Seq[String] =
|
||||
def externalAPI(mappings: Iterable[(File, URI)]): Seq[String] =
|
||||
if (mappings.isEmpty) Nil
|
||||
else
|
||||
mappings
|
||||
.map { case (f, u) => s"${f.getAbsolutePath}#${u.toExternalForm}" }
|
||||
.map { case (f, u) => s"${f.getAbsolutePath}#${u.toURL().toExternalForm}" }
|
||||
.mkString("-doc-external-doc:", ",", "") :: Nil
|
||||
}
|
||||
object resolver {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
package sbt
|
||||
package coursierint
|
||||
|
||||
import java.net.URL
|
||||
import java.net.URI
|
||||
import sbt.librarymanagement._
|
||||
import sbt.util.Logger
|
||||
import sbt.Keys._
|
||||
|
|
@ -46,10 +46,10 @@ object CoursierInputsTasks {
|
|||
configurations: Seq[sbt.librarymanagement.Configuration],
|
||||
sv: String,
|
||||
sbv: String,
|
||||
auOpt: Option[URL],
|
||||
rnOpt: Option[URL],
|
||||
auOpt: Option[URI],
|
||||
rnOpt: Option[URI],
|
||||
description: String,
|
||||
homepage: Option[URL],
|
||||
homepage: Option[URI],
|
||||
vsOpt: Option[String],
|
||||
projectPlatform: Option[String],
|
||||
log: Logger
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
package sbt
|
||||
package internal
|
||||
|
||||
import java.net.{ MalformedURLException, URI, URL }
|
||||
import java.net.{ MalformedURLException, URI }
|
||||
|
||||
import sbt.internal.librarymanagement.mavenint.SbtPomExtraProperties
|
||||
import sbt.librarymanagement.ModuleID
|
||||
|
|
@ -21,15 +21,15 @@ private[sbt] object APIMappings {
|
|||
def extract(
|
||||
cp: Seq[Attributed[HashedVirtualFileRef]],
|
||||
log: Logger
|
||||
): Seq[(HashedVirtualFileRef, URL)] =
|
||||
): Seq[(HashedVirtualFileRef, URI)] =
|
||||
cp.flatMap(entry => extractFromEntry(entry, log))
|
||||
|
||||
def extractFromEntry(
|
||||
entry: Attributed[HashedVirtualFileRef],
|
||||
log: Logger
|
||||
): Option[(HashedVirtualFileRef, URL)] =
|
||||
): Option[(HashedVirtualFileRef, URI)] =
|
||||
entry.get(Keys.entryApiURL) match
|
||||
case Some(u) => Some((entry.data, URI(u).toURL))
|
||||
case Some(u) => Some((entry.data, URI(u)))
|
||||
case None =>
|
||||
entry.get(Keys.moduleIDStr).flatMap { str =>
|
||||
val mid = Classpaths.moduleIdJsonKeyFormat.read(str)
|
||||
|
|
@ -40,22 +40,20 @@ private[sbt] object APIMappings {
|
|||
entry: HashedVirtualFileRef,
|
||||
mid: ModuleID,
|
||||
log: Logger
|
||||
): Option[(HashedVirtualFileRef, URL)] =
|
||||
): Option[(HashedVirtualFileRef, URI)] =
|
||||
for
|
||||
urlString <- mid.extraAttributes.get(SbtPomExtraProperties.POM_API_KEY)
|
||||
u <- parseURL(urlString, entry, log)
|
||||
u <- parseURI(urlString, entry, log)
|
||||
yield (entry, u)
|
||||
|
||||
private def parseURL(s: String, forEntry: HashedVirtualFileRef, log: Logger): Option[URL] =
|
||||
try
|
||||
Some(new URI(s).toURL)
|
||||
catch {
|
||||
private def parseURI(s: String, forEntry: HashedVirtualFileRef, log: Logger): Option[URI] =
|
||||
try Some(new URI(s))
|
||||
catch
|
||||
case e: MalformedURLException =>
|
||||
log.warn(s"Invalid API base URL '$s' for classpath entry '$forEntry': ${e.toString}")
|
||||
log.warn(s"Invalid API base URI '$s' for classpath entry '$forEntry': ${e.toString}")
|
||||
None
|
||||
}
|
||||
|
||||
def store[A](attr: Attributed[A], entryAPI: Option[URL]): Attributed[A] =
|
||||
def store[A](attr: Attributed[A], entryAPI: Option[URI]): Attributed[A] =
|
||||
entryAPI match
|
||||
case None => attr
|
||||
case Some(u) => attr.put(Keys.entryApiURL, u.toString)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ package object sbt
|
|||
// IO
|
||||
def uri(s: String): URI = new URI(s)
|
||||
def file(s: String): File = new File(s)
|
||||
def url(s: String): URL = new URI(s).toURL
|
||||
def url(s: String): URI = new URI(s)
|
||||
implicit def fileToRichFile(file: File): sbt.io.RichFile = new sbt.io.RichFile(file)
|
||||
implicit def filesToFinder(cc: Iterable[File]): sbt.io.PathFinder =
|
||||
sbt.io.PathFinder.strict(cc)
|
||||
|
|
|
|||
|
|
@ -309,8 +309,8 @@ trait Import {
|
|||
given Conversion[DependencyBuilders.OrganizationArtifactName, InclExclRule] =
|
||||
InclExclRule.organizationArtifactNameToExclusionRule
|
||||
|
||||
// todo: fix
|
||||
// val License = sbt.librarymanagement.License
|
||||
type License = sbt.librarymanagement.License
|
||||
val License = sbt.librarymanagement.License
|
||||
|
||||
type LogicalClock = sbt.librarymanagement.LogicalClock
|
||||
val LogicalClock = sbt.librarymanagement.LogicalClock
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ ThisBuild / version := "0.1.0-SNAPSHOT"
|
|||
ThisBuild / organization := "com.example"
|
||||
ThisBuild / organizationName := "example"
|
||||
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
|
||||
// ThisBuild / licenses := List(License.Apache2)
|
||||
ThisBuild / licenses += License.Apache2
|
||||
ThisBuild / licenses += ("foo", uri("https://example.com/"))
|
||||
|
||||
lazy val Dev = config("dev").extend(Compile)
|
||||
.describedAs("Dependencies required for development environments")
|
||||
|
|
|
|||
Loading…
Reference in New Issue