diff options
-rw-r--r-- | nailgun_launcher/NailgunLauncher.java | 35 | ||||
-rw-r--r-- | stage1/CbtPaths.scala | 2 | ||||
-rw-r--r-- | stage1/Stage1.scala | 19 | ||||
-rw-r--r-- | stage1/resolver.scala | 6 | ||||
-rw-r--r-- | stage2/Stage2.scala | 4 | ||||
-rw-r--r-- | test/simple-fixed/build/build.scala | 5 | ||||
-rw-r--r-- | test/test.scala | 2 |
7 files changed, 39 insertions, 34 deletions
diff --git a/nailgun_launcher/NailgunLauncher.java b/nailgun_launcher/NailgunLauncher.java index 33ae4c2..1007343 100644 --- a/nailgun_launcher/NailgunLauncher.java +++ b/nailgun_launcher/NailgunLauncher.java @@ -29,8 +29,8 @@ public class NailgunLauncher{ @SuppressWarnings("unchecked") public static Object getBuild( Object context ) throws Exception{ BuildStage1Result res = buildStage1( - (Boolean) get(context, "cbtHasChanged"), - (Long) get(context, "start"), + (Boolean) get(context, "cbtHasChangedCompat"), + (Long) get(context, "startCompat"), ((File) get(context, "cache")).toString() + "/", ((File) get(context, "cbtHome")).toString(), ((File) get(context, "compatibilityTarget")).toString() + "/", @@ -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 ) diff --git a/test/simple-fixed/build/build.scala b/test/simple-fixed/build/build.scala index d088a40..88b80e3 100644 --- a/test/simple-fixed/build/build.scala +++ b/test/simple-fixed/build/build.scala @@ -1,15 +1,14 @@ import cbt._ -import cbt.extensions._ // FIXME: do not require this import import scala.collection.immutable.Seq import java.io.File -// cbt:file:///Users/chris/code/cbt/#b65159f95421d9484f29327c11c0fa179eb7483f +// cbt:file:///Users/chris/code/cbt/#bdd6d905807a8cee7655d436401e76196ec4fe67 class Build(context: cbt.Context) extends BasicBuild(context){ override def dependencies = ( super.dependencies ++ Seq( - GitDependency("https://github.com/xdotai/diff.git", "80a08bf45f7c4c3fd20c4bc6dbc9cae0072e3c0f"), + GitDependency("https://github.com/xdotai/diff.git", "698717469b8dd86e8570b86354892be9c0654caf"), MavenResolver(context.cbtHasChanged,context.paths.mavenCache,MavenResolver.central).resolve( ScalaDependency("com.typesafe.play", "play-json", "2.4.4"), MavenDependency("joda-time", "joda-time", "2.9.2"), diff --git a/test/test.scala b/test/test.scala index 4cee1f1..bebd143 100644 --- a/test/test.scala +++ b/test/test.scala @@ -151,6 +151,8 @@ object Main{ compile("multi-build") usage("simple") compile("simple") + usage("simple-fixed") + compile("simple-fixed") System.err.println(" DONE!") System.err.println( successes.toString ++ " succeeded, "++ failures.toString ++ " failed" ) |