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

Handle semver metadata in version string #142

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion src/main/scala/explicitdeps/BoringStuff.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ object BoringStuff {
val rawName = (xml \ "artifactId").text

// We use the parent dir to get the version because it's sometimes not present in the pom file
val version = file.getParentFile.getName
// We use URL decoder to cater for characters that are valid in version strings but encoded
// in the file path, such as "+" used for semver metadata, encoded as "%2B"
val version = java.net.URLDecoder.decode(
file.getParentFile.getName,
java.nio.charset.Charset.forName("utf8")
)

val (name, crossVersion) = parseModuleName(scalaVersion)(rawName)

Expand Down
5 changes: 5 additions & 0 deletions src/sbt-test/basic/semver-metadata/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scalaVersion := sys.props("scala.version")
resolvers ++= Seq("Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots")
libraryDependencies ++= Seq(
"org.scalaz" %% "scalaz-core" % "7.2.27+33-04a1ea9e-SNAPSHOT"
)
1 change: 1 addition & 0 deletions src/sbt-test/basic/semver-metadata/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % sys.props("plugin.version"))
10 changes: 10 additions & 0 deletions src/sbt-test/basic/semver-metadata/src/main/scala/Main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import scalaz._
import scalaz.std.anyVal._
import scalaz.std.list._
import scalaz.std.option._
import scalaz.syntax.equal._

object Main {
val list1: List[Option[Int]] = List(Some(1), Some(2), Some(3), Some(4))
assert(Traverse[List].sequence(list1) === Some(List(1,2,3,4)))
}
2 changes: 2 additions & 0 deletions src/sbt-test/basic/semver-metadata/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
> unusedCompileDependenciesTest
> undeclaredCompileDependenciesTest