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

Preserve caches between interactive and client/server mode #342

Merged
merged 1 commit into from
May 20, 2018
Merged
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
6 changes: 5 additions & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,10 @@ object dev extends MillModule{
val classpath = runClasspath().map(_.path.toString)
val args = forkArgs().distinct
val (shellArgs, cmdArgs) =
if (!scala.util.Properties.isWin) (args, args)
if (!scala.util.Properties.isWin) (
Seq("-DMILL_CLASSPATH=" + classpath.mkString(":")) ++ args,
Seq("-DMILL_CLASSPATH=" + classpath.mkString(";")) ++ args
)
else (
Seq("""-XX:VMOptionsFile="$( dirname "$0" )"/mill.vmoptions"""),
Seq("""-XX:VMOptionsFile=%~dp0\mill.vmoptions""")
Expand Down Expand Up @@ -345,6 +348,7 @@ def release = T{
val dest = T.ctx().dest
val filename = if (scala.util.Properties.isWin) "mill.bat" else "mill"
val args = Seq(
"-DMILL_CLASSPATH=$0",
"-DMILL_VERSION=" + publishVersion()._2,
// Workaround for Zinc/JNA bug
// https://github.com/sbt/sbt/blame/6718803ee6023ab041b045a6988fafcfae9d15b5/main/src/main/scala/sbt/Main.scala#L130
Expand Down
16 changes: 2 additions & 14 deletions main/client/src/mill/main/client/MillClientMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,8 @@

public class MillClientMain {
static void initServer(String lockBase, boolean setJnaNoSys) throws IOException,URISyntaxException{
ArrayList<String> selfJars = new ArrayList<String>();
ClassLoader current = MillClientMain.class.getClassLoader();
while(current != null){
if (current instanceof java.net.URLClassLoader) {
URL[] urls = ((java.net.URLClassLoader) current).getURLs();
for (URL url: urls) {
selfJars.add(new File(url.toURI()).getCanonicalPath());
}
}
current = current.getParent();
}
if (Util.isJava9OrAbove) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robby-phd do you remember what this was for, or why we need it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was always there before I worked on changing mill client; I assume it's to propagate classpath to the spawned server.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robby-phd how about the System.getProperty("java.class.path") logic? It looks like you added it in a9d4eea#diff-00b5b77d5f332c03ac7aa4d9ac51c941R29

selfJars.addAll(Arrays.asList(System.getProperty("java.class.path").split(File.pathSeparator)));
}
String[] selfJars = System.getProperty("MILL_CLASSPATH").split(File.pathSeparator);

ArrayList<String> l = new java.util.ArrayList<String>();
l.add("java");
Properties props = System.getProperties();
Expand Down
19 changes: 19 additions & 0 deletions main/src/mill/main/RunScript.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ object RunScript{
instantiateInterpreter match{
case Left((res, watched)) => (res, watched)
case Right(interp) =>
val mainThread = Thread.currentThread()
val allClassloaders = {
val all = mutable.Buffer.empty[ClassLoader]
var current = mainThread.getContextClassLoader
while(current != null){
all.append(current)
current = current.getParent
}
all
}

log.outputStream.println(pprint.apply(allClassloaders, height = 9999))
log.outputStream.println(pprint.apply(
allClassloaders
.collect{case cl: java.net.URLClassLoader => cl -> cl.getURLs.filter(_.getProtocol == "file")},
height = 9999
))
// log.outputStream.println(pprint.apply(SpecialClassLoader.initialClasspathSignature(mainThread.getContextClassLoader), height = 9999))
interp.watch(path)
val eval =
for(rootModule <- evaluateRootModule(wd, path, interp, log))
Expand Down Expand Up @@ -76,6 +94,7 @@ object RunScript{
log: Logger
): Res[mill.define.BaseModule] = {

log.info("RunScript.evaluateRootModule")
val (pkg, wrapper) = Util.pathToPackageWrapper(Seq(), path relativeTo wd)

for {
Expand Down
2 changes: 1 addition & 1 deletion scratch/build.sc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
def thingy = T {
1234567
12345678
}