aboutsummaryrefslogtreecommitdiff
path: root/nailgun_launcher
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2017-03-12 22:00:00 -0400
committerChristopher Vogt <oss.nsp@cvogt.org>2017-03-12 22:34:02 -0400
commit828adac48d0e08766d192c7ce01021083cfc4d67 (patch)
tree06e19c3f9117c24e6c6a5e8a95990011a0efe4b3 /nailgun_launcher
parentc14e288996d2b56b6b06a0624f4f2fca315369c7 (diff)
downloadcbt-828adac48d0e08766d192c7ce01021083cfc4d67.tar.gz
cbt-828adac48d0e08766d192c7ce01021083cfc4d67.tar.bz2
cbt-828adac48d0e08766d192c7ce01021083cfc4d67.zip
fix file watching for real
last file watching update didn’t work well enough. This now - rips out barbary watch service as it seems buggy crashing the jvm - make cbt exclusively write files to watch to a file - uses fswatch instead watching all files in that file
Diffstat (limited to 'nailgun_launcher')
-rw-r--r--nailgun_launcher/NailgunLauncher.java43
1 files changed, 37 insertions, 6 deletions
diff --git a/nailgun_launcher/NailgunLauncher.java b/nailgun_launcher/NailgunLauncher.java
index 958b052..fe9f27f 100644
--- a/nailgun_launcher/NailgunLauncher.java
+++ b/nailgun_launcher/NailgunLauncher.java
@@ -6,6 +6,8 @@ import java.security.*;
import java.util.*;
import static cbt.Stage0Lib.*;
import static java.io.File.pathSeparator;
+import java.nio.file.*;
+import static java.nio.file.Files.write;
/**
* This launcher allows to start the JVM without loading anything else permanently into its
@@ -33,7 +35,9 @@ public class NailgunLauncher{
((File) get(context, "compatibilityTarget")).toString() + "/",
new ClassLoaderCache(
(HashMap) get(context, "persistentCache")
- )
+ ),
+ (File) get(context, "cwd"),
+ (Boolean) get(context, "loop")
);
return
res
@@ -97,8 +101,11 @@ public class NailgunLauncher{
String nailgunTarget = CBT_HOME + "/" + NAILGUN + TARGET;
long nailgunLauncherLastModified = new File( nailgunTarget + "../classes.last-success" ).lastModified();
+ File cwd = new File(args[1]);
+ boolean loop = args[2].equals("0");
+
BuildStage1Result res = buildStage1(
- nailgunLauncherLastModified, start, cache, CBT_HOME, compatibilityTarget, classLoaderCache
+ nailgunLauncherLastModified, start, cache, CBT_HOME, compatibilityTarget, classLoaderCache, cwd, loop
);
try{
@@ -106,9 +113,9 @@ public class NailgunLauncher{
.classLoader
.loadClass("cbt.Stage1")
.getMethod(
- "run", String[].class, File.class, File.class, BuildStage1Result.class, Map.class
+ "run", String[].class, File.class, File.class, boolean.class, BuildStage1Result.class, Map.class
).invoke(
- null, (Object) args, new File(cache), new File(CBT_HOME), res, classLoaderCache.hashMap
+ null, (Object) args, new File(cache), new File(CBT_HOME), loop, res, classLoaderCache.hashMap
);
System.exit( exitCode );
@@ -132,7 +139,7 @@ public class NailgunLauncher{
public static BuildStage1Result buildStage1(
final long lastModified, final long start, final String cache, final String cbtHome,
- final String compatibilityTarget, final ClassLoaderCache classLoaderCache
+ final String compatibilityTarget, final ClassLoaderCache classLoaderCache, File cwd, boolean loop
) throws Throwable {
_assert(TARGET != null, "environment variable TARGET not defined");
String nailgunSources = cbtHome + "/" + NAILGUN;
@@ -142,6 +149,10 @@ public class NailgunLauncher{
File compatibilitySources = new File(cbtHome + "/compatibility");
String mavenCache = cache + "maven";
String mavenUrl = "https://repo1.maven.org/maven2";
+ File loopFile = new File(cwd + "/target/.cbt-loop.tmp");
+ if(loop){
+ loopFile.getParentFile().mkdirs();
+ }
ClassLoader rootClassLoader = new CbtURLClassLoader( new URL[]{}, ClassLoader.getSystemClassLoader().getParent() ); // wrap for caching
EarlyDependencies earlyDeps = new EarlyDependencies(mavenCache, mavenUrl, classLoaderCache, rootClassLoader);
@@ -166,7 +177,16 @@ public class NailgunLauncher{
}
}
- compatibilityLastModified = compile( 0L, "", compatibilityTarget, earlyDeps, compatibilitySourceFiles);
+ if(loop){
+ File[] _compatibilitySourceFiles = new File[compatibilitySourceFiles.size()];
+ compatibilitySourceFiles.toArray(_compatibilitySourceFiles);
+ write(
+ loopFile.toPath(),
+ (mkString( "\n", _compatibilitySourceFiles ) + "\n").getBytes(),
+ StandardOpenOption.CREATE
+ );
+ }
+ compatibilityLastModified = compile( 0L, "", compatibilityTarget, earlyDeps, compatibilitySourceFiles) ;
if( !classLoaderCache.containsKey( compatibilityTarget, compatibilityLastModified ) ){
classLoaderCache.put( compatibilityTarget, classLoader(compatibilityTarget, rootClassLoader), compatibilityLastModified );
@@ -197,6 +217,17 @@ public class NailgunLauncher{
lastModified,
Math.max( lastModified, compatibilityLastModified )
);
+
+ if(loop){
+ File[] _stage1SourceFiles = new File[stage1SourceFiles.size()];
+ stage1SourceFiles.toArray(_stage1SourceFiles);
+ write(
+ loopFile.toPath(),
+ (mkString( "\n", _stage1SourceFiles ) + "\n").getBytes(),
+ StandardOpenOption.APPEND
+ );
+ }
+
final long stage1LastModified = compile(
stage0LastModified, stage1Classpath, stage1Target, earlyDeps, stage1SourceFiles
);