aboutsummaryrefslogtreecommitdiff
path: root/compatibility
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2017-02-09 21:20:11 -0500
committerChristopher Vogt <oss.nsp@cvogt.org>2017-02-09 22:43:00 -0500
commite8673866b79f7473391dcee26243eee80d5d3cb6 (patch)
tree16146affeebdb58cd302a1f8527220c906818c96 /compatibility
parentbee13ba7a4458482ce00a5c6bae4cd64328c4e5e (diff)
downloadcbt-e8673866b79f7473391dcee26243eee80d5d3cb6.tar.gz
cbt-e8673866b79f7473391dcee26243eee80d5d3cb6.tar.bz2
cbt-e8673866b79f7473391dcee26243eee80d5d3cb6.zip
idempotent change propagation
using lastModified instead of a non-idempotent needsUpdate flag this fixes a bug where dependees would not be rebuilt if cbt exited or was killed after dependencies were already rebuilt.
Diffstat (limited to 'compatibility')
-rw-r--r--compatibility/Context.java32
-rw-r--r--compatibility/Dependency.java16
-rw-r--r--compatibility/IncompatibleCbtVersionException.java10
3 files changed, 51 insertions, 7 deletions
diff --git a/compatibility/Context.java b/compatibility/Context.java
index a7af740..afd0b15 100644
--- a/compatibility/Context.java
+++ b/compatibility/Context.java
@@ -1,21 +1,43 @@
package cbt;
import java.io.*;
import java.util.*;
+import java.util.concurrent.*;
// TODO: try to reduce the number of members
-public abstract class Context{
+public interface Context{
+ // recently added methods that needs default values for old versions to work
+ public default long cbtLastModified(){
+ throw new IncompatibleCbtVersionException("You need to define method cbtLastModified.");
+ };
+ public default Map<Object,Object> persistentCache(){
+ throw new IncompatibleCbtVersionException("You need to define method persistentCache.");
+ };
+ public default Map<Object,Object> transientCache(){
+ throw new IncompatibleCbtVersionException("You need to define method transientCache.");
+ };
+ public default long start(){
+ throw new IncompatibleCbtVersionException("You need to define method start.");
+ };
+
+ // methods that exist for longer which every CBT version in use should have by now, no default values needed
public abstract File projectDirectory();
public abstract File cwd(); // REPLACE by something that allows to run cbt on some other directly
public abstract String[] argsArray(); // replace this by https://github.com/cvogt/cbt/issues/172 ?
public abstract String[] enabledLoggersArray();
- public abstract Long startCompat();
- public abstract Boolean cbtHasChangedCompat();
public abstract String scalaVersionOrNull(); // needed to propagate scalaVersion to dependendee builds
- public abstract Map<Object,Object> persistentCache();
- public abstract Map<Object,Object> transientCache();
public abstract File cache();
public abstract File cbtHome();
public abstract File cbtRootHome(); // REMOVE
public abstract File compatibilityTarget(); // maybe replace this with search in the classloader for it?
public abstract BuildInterface parentBuildOrNull();
+
+ // deprecated methods
+ @java.lang.Deprecated
+ public abstract Long startCompat();
+ @java.lang.Deprecated
+ public abstract Boolean cbtHasChangedCompat();
+ @java.lang.Deprecated
+ public abstract ConcurrentHashMap<String,Object> permanentKeys();
+ @java.lang.Deprecated
+ public abstract ConcurrentHashMap<Object,ClassLoader> permanentClassLoaders();
}
diff --git a/compatibility/Dependency.java b/compatibility/Dependency.java
index efb9214..1f719c2 100644
--- a/compatibility/Dependency.java
+++ b/compatibility/Dependency.java
@@ -2,10 +2,22 @@ package cbt;
import java.io.*;
public interface Dependency{
+ // recently added methods that needs default values for old versions to work
+ public default String moduleKey(){
+ throw new IncompatibleCbtVersionException("You need to define method moduleKey.");
+ };
+ public default long lastModified(){
+ throw new IncompatibleCbtVersionException("You need to define method lastModified.");
+ };
+
+ // methods that exist for longer which every CBT version in use should have by now, no default values needed
public abstract String show();
- public abstract String moduleKey();
- public abstract Boolean needsUpdateCompat();
public abstract Dependency[] dependenciesArray();
public abstract File[] dependencyClasspathArray();
public abstract File[] exportedClasspathArray();
+
+ // deprecated methods
+ @java.lang.Deprecated
+ public abstract boolean needsUpdateCompat();
}
+
diff --git a/compatibility/IncompatibleCbtVersionException.java b/compatibility/IncompatibleCbtVersionException.java
new file mode 100644
index 0000000..dee50fb
--- /dev/null
+++ b/compatibility/IncompatibleCbtVersionException.java
@@ -0,0 +1,10 @@
+package cbt;
+
+public class IncompatibleCbtVersionException extends RuntimeException{
+ public IncompatibleCbtVersionException( String msg, Throwable parent ){
+ super( msg, parent );
+ }
+ public IncompatibleCbtVersionException( String msg ){
+ super( msg );
+ }
+}