diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/src/mill/main/MainModule.scala | 2 | ||||
-rw-r--r-- | main/src/mill/modules/Jvm.scala | 41 | ||||
-rw-r--r-- | main/test/src/mill/eval/JavaCompileJarTests.scala | 2 | ||||
-rw-r--r-- | main/test/src/mill/util/TestUtil.scala | 5 |
4 files changed, 32 insertions, 18 deletions
diff --git a/main/src/mill/main/MainModule.scala b/main/src/mill/main/MainModule.scala index 9fa6e4dd..4b0a4354 100644 --- a/main/src/mill/main/MainModule.scala +++ b/main/src/mill/main/MainModule.scala @@ -42,7 +42,7 @@ trait MainModule extends mill.Module{ resolved match{ case Left(err) => Result.Failure(err) case Right(rs) => - for(r <- rs){ + for(r <- rs.sorted) { println(r) } Result.Success(()) diff --git a/main/src/mill/modules/Jvm.scala b/main/src/mill/modules/Jvm.scala index 153e1959..d71cf75c 100644 --- a/main/src/mill/modules/Jvm.scala +++ b/main/src/mill/modules/Jvm.scala @@ -104,7 +104,7 @@ object Jvm { body: ClassLoader => T): T = { val cl = if (classLoaderOverrideSbtTesting) { val outerClassLoader = getClass.getClassLoader - new URLClassLoader(classPath.map(_.toIO.toURI.toURL).toArray, null){ + new URLClassLoader(classPath.map(_.toIO.toURI.toURL).toArray, mill.util.ClassLoader.create(Seq(), null)){ override def findClass(name: String) = { if (name.startsWith("sbt.testing.")){ outerClassLoader.loadClass(name) @@ -114,7 +114,7 @@ object Jvm { } } } else { - new URLClassLoader(classPath.map(_.toIO.toURI.toURL).toArray, null) + mill.util.ClassLoader.create(classPath.map(_.toIO.toURI.toURL).toVector, null) } val oldCl = Thread.currentThread().getContextClassLoader Thread.currentThread().setContextClassLoader(cl) @@ -241,7 +241,7 @@ object Jvm { (implicit ctx: Ctx.Dest) = { val tmp = ctx.dest / "out-tmp.jar" - val baseUri = "jar:file:" + tmp + val baseUri = "jar:" + tmp.toIO.getCanonicalFile.toURI.toASCIIString val hm = new java.util.HashMap[String, String]() base match{ @@ -258,13 +258,18 @@ object Jvm { manifest.write(manifestOut) manifestOut.close() + def isSignatureFile(mapping: String): Boolean = + Set("sf", "rsa", "dsa").exists(ext => mapping.toLowerCase.endsWith(s".$ext")) + for(v <- classpathIterator(inputPaths)){ val (file, mapping) = v val p = zipFs.getPath(mapping) if (p.getParent != null) Files.createDirectories(p.getParent) - val outputStream = newOutputStream(p) - IO.stream(file, outputStream) - outputStream.close() + if (!isSignatureFile(mapping)) { + val outputStream = newOutputStream(p) + IO.stream(file, outputStream) + outputStream.close() + } file.close() } zipFs.close() @@ -278,11 +283,13 @@ object Jvm { IO.stream(read.getInputStream(tmp), outputStream) outputStream.close() - val perms = Files.getPosixFilePermissions(output.toNIO) - perms.add(PosixFilePermission.GROUP_EXECUTE) - perms.add(PosixFilePermission.OWNER_EXECUTE) - perms.add(PosixFilePermission.OTHERS_EXECUTE) - Files.setPosixFilePermissions(output.toNIO, perms) + if (!scala.util.Properties.isWin) { + val perms = Files.getPosixFilePermissions(output.toNIO) + perms.add(PosixFilePermission.GROUP_EXECUTE) + perms.add(PosixFilePermission.OWNER_EXECUTE) + perms.add(PosixFilePermission.OTHERS_EXECUTE) + Files.setPosixFilePermissions(output.toNIO, perms) + } } PathRef(output) @@ -328,11 +335,13 @@ object Jvm { write(outputPath, launcherShellScript(mainClass, classPath.map(_.toString), jvmArgs)) - val perms = Files.getPosixFilePermissions(outputPath.toNIO) - perms.add(PosixFilePermission.GROUP_EXECUTE) - perms.add(PosixFilePermission.OWNER_EXECUTE) - perms.add(PosixFilePermission.OTHERS_EXECUTE) - Files.setPosixFilePermissions(outputPath.toNIO, perms) + if (!scala.util.Properties.isWin) { + val perms = Files.getPosixFilePermissions(outputPath.toNIO) + perms.add(PosixFilePermission.GROUP_EXECUTE) + perms.add(PosixFilePermission.OWNER_EXECUTE) + perms.add(PosixFilePermission.OTHERS_EXECUTE) + Files.setPosixFilePermissions(outputPath.toNIO, perms) + } PathRef(outputPath) } diff --git a/main/test/src/mill/eval/JavaCompileJarTests.scala b/main/test/src/mill/eval/JavaCompileJarTests.scala index 78cf09a5..1ac00c79 100644 --- a/main/test/src/mill/eval/JavaCompileJarTests.scala +++ b/main/test/src/mill/eval/JavaCompileJarTests.scala @@ -114,7 +114,7 @@ object JavaCompileJarTests extends TestSuite{ |test/FooTwo.class |hello.txt |""".stripMargin - assert(jarContents == expectedJarContents) + assert(jarContents.lines.toSeq == expectedJarContents.lines.toSeq) val executed = %%('java, "-cp", evaluator.outPath/'jar/'dest/"out.jar", "test.Foo")(evaluator.outPath).out.string assert(executed == (31337 + 271828) + System.lineSeparator) diff --git a/main/test/src/mill/util/TestUtil.scala b/main/test/src/mill/util/TestUtil.scala index d06c7f6a..d0caade7 100644 --- a/main/test/src/mill/util/TestUtil.scala +++ b/main/test/src/mill/util/TestUtil.scala @@ -78,4 +78,9 @@ object TestUtil { } } } + def disableInJava9OrAbove(f: => Any): Unit = { + if (!ammonite.util.Util.java9OrAbove) { + f + } + } } |