diff --git a/src/main/scala/sbtbuildinfo/JavaRenderer.scala b/src/main/scala/sbtbuildinfo/JavaRenderer.scala index bfa71e7..3538aac 100644 --- a/src/main/scala/sbtbuildinfo/JavaRenderer.scala +++ b/src/main/scala/sbtbuildinfo/JavaRenderer.scala @@ -33,7 +33,7 @@ abstract class JavaRenderer(pkg: String, cl: String, makeStatic: Boolean) extend protected val buildUrlLines: String = """ private static java.net.URL internalAsUrl(String urlString) { | try { - | return new java.net.URL(urlString); + | return new java.net.URI(urlString).toURL(); | } catch (Exception e) { | return null; | } diff --git a/src/main/scala/sbtbuildinfo/ScalaRenderer.scala b/src/main/scala/sbtbuildinfo/ScalaRenderer.scala index 0c70365..36465d3 100644 --- a/src/main/scala/sbtbuildinfo/ScalaRenderer.scala +++ b/src/main/scala/sbtbuildinfo/ScalaRenderer.scala @@ -97,7 +97,7 @@ abstract class ScalaRenderer extends BuildInfoRenderer { case mp: Map[_, _] => mp.toList.map(quote(_)).mkString("Map(", ", ", ")") case seq: collection.Seq[_] => seq.map(quote).mkString("scala.collection.immutable.Seq(", ", ", ")") case op: Option[_] => op map { x => "scala.Some(" + quote(x) + ")" } getOrElse {"scala.None"} - case url: java.net.URL => "new java.net.URL(%s)" format quote(url.toString) + case url: java.net.URL => "new java.net.URI(%s).toURL" format quote(url.toString) case file: java.io.File => "new java.io.File(%s)" format quote(file.toString) case attr: sbt.Attributed[_] => quote(attr.data) case date: java.time.LocalDate => "java.time.LocalDate.parse(%s)" format quote(date.toString) diff --git a/src/sbt-test/sbt-buildinfo/caseclassrenderer/build.sbt b/src/sbt-test/sbt-buildinfo/caseclassrenderer/build.sbt index 9a440e3..0f52c0c 100644 --- a/src/sbt-test/sbt-buildinfo/caseclassrenderer/build.sbt +++ b/src/sbt-test/sbt-buildinfo/caseclassrenderer/build.sbt @@ -107,8 +107,8 @@ lazy val root = (project in file(".")) """ projectVersion = 0.1,""" :: """ scalaVersion = "2.12.12",""" :: """ ivyXML = scala.xml.NodeSeq.Empty,""" :: - """ homepage = scala.Some(new java.net.URL("http://example.com")),""" :: - """ licenses = scala.collection.immutable.Seq(("MIT License" -> new java.net.URL("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE"))),""" :: + """ homepage = scala.Some(new java.net.URI("http://example.com").toURL),""" :: + """ licenses = scala.collection.immutable.Seq(("MIT License" -> new java.net.URI("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE").toURL)),""" :: """ apiMappings = Map(),""" :: """ isSnapshot = false,""" :: """ year = 2012,""" :: diff --git a/src/sbt-test/sbt-buildinfo/constantvalue/build.sbt b/src/sbt-test/sbt-buildinfo/constantvalue/build.sbt index a1fc856..e4f1875 100644 --- a/src/sbt-test/sbt-buildinfo/constantvalue/build.sbt +++ b/src/sbt-test/sbt-buildinfo/constantvalue/build.sbt @@ -57,10 +57,10 @@ lazy val root = (project in file(".")). scalaVersionInfo :: """ /** The value is scala.xml.NodeSeq.Empty. */""" :: """ val ivyXML: scala.xml.NodeSeq = scala.xml.NodeSeq.Empty""" :: - """ /** The value is scala.Some(new java.net.URL("http://example.com")). */""" :: - """ val homepage: scala.Option[java.net.URL] = scala.Some(new java.net.URL("http://example.com"))""" :: - """ /** The value is scala.collection.immutable.Seq(("MIT License" -> new java.net.URL("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE"))). */""" :: - """ val licenses: scala.collection.immutable.Seq[(String, java.net.URL)] = scala.collection.immutable.Seq(("MIT License" -> new java.net.URL("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE")))""" :: + """ /** The value is scala.Some(new java.net.URI("http://example.com").toURL). */""" :: + """ val homepage: scala.Option[java.net.URL] = scala.Some(new java.net.URI("http://example.com").toURL)""" :: + """ /** The value is scala.collection.immutable.Seq(("MIT License" -> new java.net.URI("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE").toURL)). */""" :: + """ val licenses: scala.collection.immutable.Seq[(String, java.net.URL)] = scala.collection.immutable.Seq(("MIT License" -> new java.net.URI("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE").toURL))""" :: """ /** The value is Map(). */""" :: """ val apiMappings: Map[java.io.File, java.net.URL] = Map()""" :: """ /** The value is false. */""" :: diff --git a/src/sbt-test/sbt-buildinfo/javasingletonrenderer/build.sbt b/src/sbt-test/sbt-buildinfo/javasingletonrenderer/build.sbt index 79890f2..15ac512 100644 --- a/src/sbt-test/sbt-buildinfo/javasingletonrenderer/build.sbt +++ b/src/sbt-test/sbt-buildinfo/javasingletonrenderer/build.sbt @@ -98,7 +98,7 @@ lazy val root = (project in file(".")) """""" :: """ private static java.net.URL internalAsUrl(String urlString) {""" :: """ try {""" :: - """ return new java.net.URL(urlString);""" :: + """ return new java.net.URI(urlString).toURL();""" :: """ } catch (Exception e) {""" :: """ return null;""" :: """ }""" :: diff --git a/src/sbt-test/sbt-buildinfo/javastaticfieldsrenderer/build.sbt b/src/sbt-test/sbt-buildinfo/javastaticfieldsrenderer/build.sbt index 494e535..01933ff 100644 --- a/src/sbt-test/sbt-buildinfo/javastaticfieldsrenderer/build.sbt +++ b/src/sbt-test/sbt-buildinfo/javastaticfieldsrenderer/build.sbt @@ -96,7 +96,7 @@ lazy val root = (project in file(".")) """""" :: """ private static java.net.URL internalAsUrl(String urlString) {""" :: """ try {""" :: - """ return new java.net.URL(urlString);""" :: + """ return new java.net.URI(urlString).toURL();""" :: """ } catch (Exception e) {""" :: """ return null;""" :: """ }""" :: diff --git a/src/sbt-test/sbt-buildinfo/multi/build.sbt b/src/sbt-test/sbt-buildinfo/multi/build.sbt index 8b6bda9..5252b9d 100644 --- a/src/sbt-test/sbt-buildinfo/multi/build.sbt +++ b/src/sbt-test/sbt-buildinfo/multi/build.sbt @@ -39,8 +39,8 @@ lazy val app = (project in file("app")) """ val projectID: String = "com.example:root:0.1"""" :: """ /** The value is "0.1". */""" :: """ val version: String = "0.1"""" :: - """ /** The value is new java.net.URL("http://example.com"). */""" :: - """ val homepage = new java.net.URL("http://example.com")""" :: + """ /** The value is new java.net.URI("http://example.com").toURL. */""" :: + """ val homepage = new java.net.URI("http://example.com").toURL""" :: scalaVersionInfoComment :: scalaVersionInfo :: """ override val toString: String = {""" :: diff --git a/src/sbt-test/sbt-buildinfo/simple/build.sbt b/src/sbt-test/sbt-buildinfo/simple/build.sbt index 7657149..9522fb7 100644 --- a/src/sbt-test/sbt-buildinfo/simple/build.sbt +++ b/src/sbt-test/sbt-buildinfo/simple/build.sbt @@ -50,10 +50,10 @@ lazy val root = (project in file(".")) scalaVersionInfo :: """ /** The value is scala.xml.NodeSeq.Empty. */""" :: """ val ivyXML: scala.xml.NodeSeq = scala.xml.NodeSeq.Empty""" :: - """ /** The value is scala.Some(new java.net.URL("http://example.com")). */""" :: - """ val homepage: scala.Option[java.net.URL] = scala.Some(new java.net.URL("http://example.com"))""" :: - """ /** The value is scala.collection.immutable.Seq(("MIT License" -> new java.net.URL("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE"))). */""" :: - """ val licenses: scala.collection.immutable.Seq[(String, java.net.URL)] = scala.collection.immutable.Seq(("MIT License" -> new java.net.URL("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE")))""" :: + """ /** The value is scala.Some(new java.net.URI("http://example.com").toURL). */""" :: + """ val homepage: scala.Option[java.net.URL] = scala.Some(new java.net.URI("http://example.com").toURL)""" :: + """ /** The value is scala.collection.immutable.Seq(("MIT License" -> new java.net.URI("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE").toURL)). */""" :: + """ val licenses: scala.collection.immutable.Seq[(String, java.net.URL)] = scala.collection.immutable.Seq(("MIT License" -> new java.net.URI("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE").toURL))""" :: """ /** The value is Map(). */""" :: """ val apiMappings: Map[java.io.File, java.net.URL] = Map()""" :: """ /** The value is false. */""" :: diff --git a/src/sbt-test/sbt-buildinfo/skipimportscaseclass/build.sbt b/src/sbt-test/sbt-buildinfo/skipimportscaseclass/build.sbt index 13741aa..a4bd6ab 100644 --- a/src/sbt-test/sbt-buildinfo/skipimportscaseclass/build.sbt +++ b/src/sbt-test/sbt-buildinfo/skipimportscaseclass/build.sbt @@ -98,8 +98,8 @@ lazy val root = (project in file(".")) """ projectVersion = 0.1,""" :: """ scalaVersion = "2.12.12",""" :: """ ivyXML = scala.xml.NodeSeq.Empty,""" :: - """ homepage = scala.Some(new java.net.URL("http://example.com")),""" :: - """ licenses = scala.collection.immutable.Seq(("MIT License" -> new java.net.URL("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE"))),""" :: + """ homepage = scala.Some(new java.net.URI("http://example.com").toURL),""" :: + """ licenses = scala.collection.immutable.Seq(("MIT License" -> new java.net.URI("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE").toURL)),""" :: """ apiMappings = Map(),""" :: """ isSnapshot = false,""" :: """ year = 2012,""" :: diff --git a/src/sbt-test/sbt-buildinfo/usepackageaspath/build.sbt b/src/sbt-test/sbt-buildinfo/usepackageaspath/build.sbt index b029267..167b89e 100644 --- a/src/sbt-test/sbt-buildinfo/usepackageaspath/build.sbt +++ b/src/sbt-test/sbt-buildinfo/usepackageaspath/build.sbt @@ -47,10 +47,10 @@ lazy val root = (project in file(".")) """ val scalaVersion: String = "2.12.12"""" :: """ /** The value is scala.xml.NodeSeq.Empty. */""" :: """ val ivyXML: scala.xml.NodeSeq = scala.xml.NodeSeq.Empty""" :: - """ /** The value is scala.Some(new java.net.URL("http://example.com")). */""" :: - """ val homepage: scala.Option[java.net.URL] = scala.Some(new java.net.URL("http://example.com"))""" :: - """ /** The value is scala.collection.immutable.Seq(("MIT License" -> new java.net.URL("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE"))). */""" :: - """ val licenses: scala.collection.immutable.Seq[(String, java.net.URL)] = scala.collection.immutable.Seq(("MIT License" -> new java.net.URL("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE")))""" :: + """ /** The value is scala.Some(new java.net.URI("http://example.com").toURL). */""" :: + """ val homepage: scala.Option[java.net.URL] = scala.Some(new java.net.URI("http://example.com").toURL)""" :: + """ /** The value is scala.collection.immutable.Seq(("MIT License" -> new java.net.URI("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE").toURL)). */""" :: + """ val licenses: scala.collection.immutable.Seq[(String, java.net.URL)] = scala.collection.immutable.Seq(("MIT License" -> new java.net.URI("https://github.com/sbt/sbt-buildinfo/blob/master/LICENSE").toURL))""" :: """ /** The value is Map(). */""" :: """ val apiMappings: Map[java.io.File, java.net.URL] = Map()""" :: """ /** The value is false. */""" ::