-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix window path #5560
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
Fix window path #5560
Changes from 7 commits
1c721d8
a5e60dd
769233a
7727d51
0ff65a5
0a7ffbc
0c3e55b
4b3340f
23764fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,7 +174,7 @@ final class JrtClassPath(fs: java.nio.file.FileSystem) extends ClassPath with No | |
if (inPackage == "") Nil | ||
else { | ||
packageToModuleBases.getOrElse(inPackage, Nil).flatMap(x => | ||
Files.list(x.resolve(inPackage.replace('.', '/'))).iterator().asScala.filter(_.getFileName.toString.endsWith(".class"))).map(x => | ||
Files.list(x.resolve(FileUtils.dirPath(inPackage))).iterator().asScala.filter(_.getFileName.toString.endsWith(".class"))).map(x => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure this is actually broken ? This code comes straight from scalac (https://github.com/scala/scala/blob/2.13.x/src/compiler/scala/tools/nsc/classpath/DirectoryClassPath.scala#L207) which I assume has received adequate testing under Windows /cc @retronym There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if it causes a problem, just get to this by a search. I'm wondering if there is any reason to use |
||
ClassFileEntryImpl(new PlainFile(new dotty.tools.io.File(x)))).toVector | ||
} | ||
} | ||
|
@@ -193,7 +193,7 @@ final class JrtClassPath(fs: java.nio.file.FileSystem) extends ClassPath with No | |
else { | ||
val inPackage = packageOf(className) | ||
packageToModuleBases.getOrElse(inPackage, Nil).iterator.flatMap{x => | ||
val file = x.resolve(className.replace('.', '/') + ".class") | ||
val file = x.resolve(FileUtils.dirPath(className) + ".class") | ||
if (Files.exists(file)) new PlainFile(new dotty.tools.io.File(file)) :: Nil else Nil | ||
}.take(1).toList.headOption | ||
} | ||
|
@@ -207,7 +207,7 @@ case class DirectoryClassPath(dir: JFile) extends JFileDirectoryLookup[ClassFile | |
|
||
def findClassFile(className: String): Option[AbstractFile] = { | ||
val relativePath = FileUtils.dirPath(className) | ||
val classFile = new JFile(s"$dir/$relativePath.class") | ||
val classFile = new JFile(dir, relativePath + ".class") | ||
if (classFile.exists) { | ||
val wrappedClassFile = new dotty.tools.io.File(classFile.toPath) | ||
val abstractClassFile = new PlainFile(wrappedClassFile) | ||
|
@@ -232,7 +232,7 @@ case class DirectorySourcePath(dir: JFile) extends JFileDirectoryLookup[SourceFi | |
private def findSourceFile(className: String): Option[AbstractFile] = { | ||
val relativePath = FileUtils.dirPath(className) | ||
val sourceFile = Stream("scala", "java") | ||
.map(ext => new JFile(s"$dir/$relativePath.$ext")) | ||
.map(ext => new JFile(dir, relativePath + "." + ext)) | ||
.collectFirst { case file if file.exists() => file } | ||
|
||
sourceFile.map { file => | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,8 @@ object QuoteDriver { | |
case cl: URLClassLoader => | ||
// Loads the classes loaded by this class loader | ||
// When executing `run` or `test` in sbt the classpath is not in the property java.class.path | ||
val newClasspath = cl.getURLs.map(_.getFile()) | ||
import java.nio.file.Paths | ||
val newClasspath = cl.getURLs.map(url => Paths.get(url.toURI).toFile) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need a conversion to File here? It seems we are only interested in the String representation of these paths. I would make the conversion to String explicit. E.g. val newClasspath = cl.getURLs.map(url => Paths.get(url.toURI).toString) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like Allan's suggestion and I will test it ASAP: val newClasspath = cl.getURLs.map(url => Paths.get(url.toURI).toString) For comparison here is my local change (pending PR for several weeks now): val newClasspath = cl.getURLs.map(url => new JFile(url.getFile).getAbsolutePath) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way the same issue exists in source file val url = classOf[ChildJVMMain].getProtectionDomain.getCodeSource.getLocation
val cp = Paths.get(url.toURI).toString + JFile.pathSeparator + Properties.scalaLibrary instead of val cp =
classOf[ChildJVMMain].getProtectionDomain.getCodeSource.getLocation.getFile + JFile.pathSeparator +
Properties.scalaLibrary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @michelou . It seems there are a lot of changes needed for the tests. I propose to restrict this PR for the compiler fixes, and make a separate PR for the test fixes. |
||
newClasspath.mkString("", java.io.File.pathSeparator, if (classpath0 == "") "" else java.io.File.pathSeparator + classpath0) | ||
case _ => classpath0 | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import java.io.{ File => JFile, OutputStreamWriter, BufferedWriter, ByteArrayInp | |
import java.util.{ List => JList, Arrays } | ||
import java.nio.file.Path | ||
import java.nio.charset.StandardCharsets | ||
import java.io.File.{ separator => sep } | ||
|
||
import com.vladsch.flexmark.parser.ParserEmulationProfile | ||
import com.vladsch.flexmark.parser.Parser | ||
|
@@ -166,9 +167,9 @@ case class Site( | |
private def defaultParams(pageLocation: JFile, additionalDepth: Int = 0): DefaultParams = { | ||
val pathFromRoot = stripRoot(pageLocation) | ||
val baseUrl: String = { | ||
val rootLen = root.getAbsolutePath.split('/').length | ||
val assetLen = pageLocation.getAbsolutePath.split('/').length | ||
"../" * (assetLen - rootLen - 1 + additionalDepth) + "." | ||
val rootLen = root.toPath.normalize.getNameCount | ||
val assetLen = pageLocation.toPath.normalize.getNameCount | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't you need to convert to absolute path as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usage of absolute path info in URL seems problematic. For now, I added |
||
"../" * (assetLen - rootLen + additionalDepth) + "." | ||
} | ||
|
||
DefaultParams( | ||
|
@@ -197,16 +198,16 @@ case class Site( | |
// Suffix is index.html for packages and therefore the additional depth | ||
// is increased by 1 | ||
val (suffix, offset) = | ||
if (e.kind == "package") ("/index.html", -1) | ||
if (e.kind == "package") (sep + "index.html", -1) | ||
else (".html", 0) | ||
|
||
val path = if (scala.util.Properties.isWin) | ||
e.path.map(_.replace("<", "_").replace(">", "_")) | ||
else | ||
else | ||
e.path | ||
val target = mkdirs(fs.getPath(outDir.getAbsolutePath + "/api/" + path.mkString("/") + suffix)) | ||
val target = mkdirs(fs.getPath(outDir.getAbsolutePath + sep + "api" + sep + path.mkString(sep) + suffix)) | ||
val params = defaultParams(target.toFile, -1).withPosts(blogInfo).withEntity(Some(e)).toMap | ||
val page = new HtmlPage("_layouts/api-page.html", layouts("api-page").content, params, includes) | ||
val page = new HtmlPage("_layouts" + sep + "api-page.html", layouts("api-page").content, params, includes) | ||
|
||
render(page).foreach { rendered => | ||
val source = new ByteArrayInputStream(rendered.getBytes(StandardCharsets.UTF_8)) | ||
|
@@ -223,9 +224,9 @@ case class Site( | |
} | ||
|
||
// generate search page: | ||
val target = mkdirs(fs.getPath(outDir.getAbsolutePath + "/api/search.html")) | ||
val target = mkdirs(fs.getPath(outDir.getAbsolutePath + sep + "api" + sep + "search.html")) | ||
val searchPageParams = defaultParams(target.toFile, -1).withPosts(blogInfo).toMap | ||
val searchPage = new HtmlPage("_layouts/search.html", layouts("search").content, searchPageParams, includes) | ||
val searchPage = new HtmlPage("_layouts" + sep + "search.html", layouts("search").content, searchPageParams, includes) | ||
render(searchPage).foreach { rendered => | ||
Files.copy( | ||
new ByteArrayInputStream(rendered.getBytes(StandardCharsets.UTF_8)), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -628,8 +628,7 @@ object Build { | |
val dottyLib = jars("dotty-library") | ||
|
||
def run(args: List[String]): Unit = { | ||
val sep = File.pathSeparator | ||
val fullArgs = insertClasspathInArgs(args, s".$sep$dottyLib$sep$scalaLib") | ||
val fullArgs = insertClasspathInArgs(args, List(".", dottyLib, scalaLib).mkString(File.pathSeparator)) | ||
runProcess("java" :: fullArgs, wait = true) | ||
} | ||
|
||
|
@@ -645,7 +644,7 @@ object Build { | |
val asm = findLib(attList, "scala-asm") | ||
val dottyCompiler = jars("dotty-compiler") | ||
val dottyInterfaces = jars("dotty-interfaces") | ||
run(insertClasspathInArgs(args1, s"$dottyCompiler:$dottyInterfaces:$asm")) | ||
run(insertClasspathInArgs(args1, List(dottyCompiler, dottyInterfaces, asm).mkString(File.pathSeparator))) | ||
} else run(args) | ||
}, | ||
|
||
|
@@ -1092,8 +1091,8 @@ object Build { | |
Developer( | ||
id = "liufengyun", | ||
name = "Liu Fengyun", | ||
email = "[email protected]", | ||
url = url("http://chaos-lab.com") | ||
email = "[email protected]", | ||
url = url("https://fengy.me") | ||
), | ||
Developer( | ||
id = "nicolasstucki", | ||
|
Uh oh!
There was an error while loading. Please reload this page.