aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nailgun_launcher/NailgunLauncher.java31
-rw-r--r--stage1/CbtPaths.scala2
-rw-r--r--stage1/Stage1.scala19
-rw-r--r--stage1/resolver.scala6
-rw-r--r--stage2/Stage2.scala4
5 files changed, 33 insertions, 29 deletions
diff --git a/nailgun_launcher/NailgunLauncher.java b/nailgun_launcher/NailgunLauncher.java
index 13b9798..1007343 100644
--- a/nailgun_launcher/NailgunLauncher.java
+++ b/nailgun_launcher/NailgunLauncher.java
@@ -60,8 +60,9 @@ public class NailgunLauncher{
_assert(System.getenv("CBT_HOME") != null, "environment variable CBT_HOME not defined");
String CBT_HOME = System.getenv("CBT_HOME");
String cache = CBT_HOME + "/cache/";
+ String compatibilityTarget = CBT_HOME + "/compatibility/" + TARGET;
BuildStage1Result res = buildStage1(
- false, start, cache, CBT_HOME, CBT_HOME + "/compatibility/" + TARGET, classLoaderCache
+ false, start, cache, CBT_HOME, compatibilityTarget, classLoaderCache
);
System.exit(
@@ -71,12 +72,12 @@ public class NailgunLauncher{
.getMethod(
"run",
String[].class, File.class, File.class, Boolean.class,
- Long.class, ConcurrentHashMap.class, ConcurrentHashMap.class
+ File.class, Long.class, ConcurrentHashMap.class, ConcurrentHashMap.class
)
.invoke(
null,
(Object) args, new File(cache), new File(CBT_HOME), res.changed,
- start, classLoaderCache.keys, classLoaderCache.values
+ new File(compatibilityTarget), start, classLoaderCache.keys, classLoaderCache.values
)
);
}
@@ -95,19 +96,23 @@ public class NailgunLauncher{
ClassLoader rootClassLoader = new CbtURLClassLoader( new URL[]{}, ClassLoader.getSystemClassLoader().getParent() ); // wrap for caching
EarlyDependencies earlyDeps = new EarlyDependencies(mavenCache, mavenUrl, classLoaderCache, rootClassLoader);
- List<File> compatibilitySourceFiles = new ArrayList<File>();
- for( File f: compatibilitySources.listFiles() ){
- if( f.isFile() && (f.toString().endsWith(".scala") || f.toString().endsWith(".java")) ){
- compatibilitySourceFiles.add(f);
- }
- }
- changed = compile(changed, start, "", compatibilityTarget, earlyDeps, compatibilitySourceFiles, defaultSecurityManager);
-
ClassLoader compatibilityClassLoader;
- if( classLoaderCache.contains( compatibilityTarget ) ){
+ if(!compatibilityTarget.startsWith(cbtHome)){
compatibilityClassLoader = classLoaderCache.get( compatibilityTarget );
} else {
- compatibilityClassLoader = classLoaderCache.put( classLoader(compatibilityTarget, rootClassLoader), compatibilityTarget );
+ List<File> compatibilitySourceFiles = new ArrayList<File>();
+ for( File f: compatibilitySources.listFiles() ){
+ if( f.isFile() && (f.toString().endsWith(".scala") || f.toString().endsWith(".java")) ){
+ compatibilitySourceFiles.add(f);
+ }
+ }
+ changed = compile(changed, start, "", compatibilityTarget, earlyDeps, compatibilitySourceFiles, defaultSecurityManager);
+
+ if( classLoaderCache.contains( compatibilityTarget ) ){
+ compatibilityClassLoader = classLoaderCache.get( compatibilityTarget );
+ } else {
+ compatibilityClassLoader = classLoaderCache.put( classLoader(compatibilityTarget, rootClassLoader), compatibilityTarget );
+ }
}
String[] nailgunClasspathArray = append( earlyDeps.classpathArray, nailgunTarget );
diff --git a/stage1/CbtPaths.scala b/stage1/CbtPaths.scala
index aa24d4e..71c2ef1 100644
--- a/stage1/CbtPaths.scala
+++ b/stage1/CbtPaths.scala
@@ -11,7 +11,5 @@ case class CbtPaths(private val cbtHome: File, private val cache: File){
val stage2Target: File = stage2 ++ ("/" ++ target)
val stage2StatusFile: File = stage2Target ++ ".last-success"
val compatibility: File = cbtHome ++ "/compatibility"
- val compatibilityTarget: File = compatibility ++ ("/" ++ target)
- val compatibilityStatusFile: File = compatibilityTarget ++ ".last-success"
val nailgunTarget: File = nailgun ++ ("/" ++ target)
}
diff --git a/stage1/Stage1.scala b/stage1/Stage1.scala
index 1bb0dd0..2a826e5 100644
--- a/stage1/Stage1.scala
+++ b/stage1/Stage1.scala
@@ -43,7 +43,8 @@ case class Stage2Args(
cbtHasChanged: Boolean,
classLoaderCache: ClassLoaderCache,
cache: File,
- cbtHome: File
+ cbtHome: File,
+ compatibilityTarget: File
){
val ClassLoaderCache(
logger,
@@ -78,7 +79,7 @@ object Stage1{
}
def buildStage2(
- _compatibilityTarget: File, classLoaderCache: ClassLoaderCache, _cbtChanged: Boolean, cbtHome: File, cache: File
+ compatibilityTarget: File, classLoaderCache: ClassLoaderCache, _cbtChanged: Boolean, cbtHome: File, cache: File
): (Boolean, ClassLoader) = {
import classLoaderCache.logger
@@ -92,7 +93,7 @@ object Stage1{
val cls = this.getClass.getClassLoader.loadClass("cbt.NailgunLauncher")
- val cbtDependency = CbtDependency(cbtHasChanged, mavenCache, nailgunTarget, stage1Target, stage2Target, _compatibilityTarget)
+ val cbtDependency = CbtDependency(cbtHasChanged, mavenCache, nailgunTarget, stage1Target, stage2Target, compatibilityTarget)
logger.stage1("Compiling stage2 if necessary")
compile(
@@ -118,16 +119,14 @@ object Stage1{
{
// a few classloader sanity checks
val compatibilityClassLoader =
- CompatibilityDependency(cbtHasChanged, compatibilityTarget)
- .classLoader(classLoaderCache)
+ cbtDependency.stage1Dependency.compatibilityDependency.classLoader(classLoaderCache)
assert(
classOf[BuildInterface].getClassLoader == compatibilityClassLoader,
classOf[BuildInterface].getClassLoader.toString ++ "\n\nis not the same as\n\n" ++ compatibilityClassLoader.toString
)
//-------------
- val stage1Dependency = Stage1Dependency(cbtHasChanged, mavenCache, nailgunTarget, stage1Target, compatibilityTarget)
val stage1ClassLoader =
- stage1Dependency.classLoader(classLoaderCache)
+ cbtDependency.stage1Dependency.classLoader(classLoaderCache)
assert(
classOf[Stage1Dependency].getClassLoader == stage1ClassLoader,
classOf[Stage1Dependency].getClassLoader.toString ++ "\n\nis not the same as\n\n" ++ stage1ClassLoader.toString
@@ -147,6 +146,7 @@ object Stage1{
cache: File,
cbtHome: File,
_cbtChanged: java.lang.Boolean,
+ compatibilityTarget: File,
start: java.lang.Long,
classLoaderCacheKeys: ConcurrentHashMap[String,AnyRef],
classLoaderCacheValues: ConcurrentHashMap[AnyRef,ClassLoader]
@@ -162,7 +162,7 @@ object Stage1{
)
- val (cbtHasChanged, classLoader) = buildStage2( CbtPaths(cbtHome, cache).compatibilityTarget, classLoaderCache, _cbtChanged, cbtHome, cache )
+ val (cbtHasChanged, classLoader) = buildStage2( compatibilityTarget, classLoaderCache, _cbtChanged, cbtHome, cache )
val stage2Args = Stage2Args(
new File( args.args(0) ),
@@ -171,7 +171,8 @@ object Stage1{
cbtHasChanged = cbtHasChanged,
classLoaderCache = classLoaderCache,
cache,
- cbtHome
+ cbtHome,
+ compatibilityTarget
)
logger.stage1(s"Run Stage2")
diff --git a/stage1/resolver.scala b/stage1/resolver.scala
index f979247..d195fa4 100644
--- a/stage1/resolver.scala
+++ b/stage1/resolver.scala
@@ -144,8 +144,9 @@ case class Stage1Dependency(cbtHasChanged: Boolean, mavenCache: File, nailgunTar
override def needsUpdate = cbtHasChanged
override def targetClasspath = exportedClasspath
override def exportedClasspath = ClassPath( Seq(nailgunTarget, stage1Target) )
+ val compatibilityDependency = CompatibilityDependency(cbtHasChanged, compatibilityTarget)
override def dependencies = Seq(
- CompatibilityDependency(cbtHasChanged, compatibilityTarget),
+ compatibilityDependency,
MavenResolver(cbtHasChanged,mavenCache,MavenResolver.central).resolve(
MavenDependency("org.scala-lang","scala-library",constants.scalaVersion),
MavenDependency("org.scala-lang.modules","scala-xml_"+constants.scalaMajorVersion,constants.scalaXmlVersion)
@@ -162,8 +163,9 @@ case class CbtDependency(cbtHasChanged: Boolean, mavenCache: File, nailgunTarget
override def needsUpdate = cbtHasChanged
override def targetClasspath = exportedClasspath
override def exportedClasspath = ClassPath( Seq( stage2Target ) )
+ val stage1Dependency = Stage1Dependency(cbtHasChanged, mavenCache, nailgunTarget, stage1Target, compatibilityTarget)
override def dependencies = Seq(
- Stage1Dependency(cbtHasChanged, mavenCache, nailgunTarget, stage1Target, compatibilityTarget),
+ stage1Dependency,
MavenResolver(cbtHasChanged, mavenCache,MavenResolver.central).resolve(
MavenDependency("net.incongru.watchservice","barbary-watchservice","1.0"),
MavenDependency("org.eclipse.jgit", "org.eclipse.jgit", "4.2.0.201601211800-r")
diff --git a/stage2/Stage2.scala b/stage2/Stage2.scala
index 9639380..83b660e 100644
--- a/stage2/Stage2.scala
+++ b/stage2/Stage2.scala
@@ -7,8 +7,6 @@ import scala.collection.immutable.Seq
object Stage2 extends Stage2Base{
def getBuild(__context: java.lang.Object, _cbtChanged: java.lang.Boolean) = {
- val cl1 = __context.getClass.getClassLoader
- val cl2 = classOf[Context].getClassLoader
val _context = __context.asInstanceOf[Context]
val context = _context.copy(
cbtHasChanged = _context.cbtHasChanged || _cbtChanged
@@ -48,7 +46,7 @@ object Stage2 extends Stage2Base{
args.permanentClassLoaders,
args.cache,
args.cbtHome,
- compatibilityTarget,
+ args.compatibilityTarget,
null
)
val first = lib.loadRoot( context )