diff --git a/build-caching/pom.xml b/build-caching/pom.xml
index be2323bd..c6beb5cb 100644
--- a/build-caching/pom.xml
+++ b/build-caching/pom.xml
@@ -25,11 +25,24 @@
guava
+
+ org.jspecify
+ jspecify
+ 0.2.0
+
+
+
+ org.javassist
+ javassist
+ 3.28.0-GA
+
+
+
io.methvin
directory-watcher
- 0.15.0
+ 0.15.1
diff --git a/build-caching/src/main/java/com/vertispan/j2cl/build/BuildMap.java b/build-caching/src/main/java/com/vertispan/j2cl/build/BuildMap.java
index 9395d3bb..b56dc48c 100644
--- a/build-caching/src/main/java/com/vertispan/j2cl/build/BuildMap.java
+++ b/build-caching/src/main/java/com/vertispan/j2cl/build/BuildMap.java
@@ -1,43 +1,37 @@
package com.vertispan.j2cl.build;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
+import com.google.common.collect.Streams;
+
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.attribute.FileTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import com.google.common.base.Splitter;
-import com.google.common.collect.Streams;
public class BuildMap {
- private Project project;
+ private Project project;
- private Map typeInfos = new HashMap<>();
+ private Map typeInfos = new HashMap<>();
- private Map pathToQualifiedSourceName = new HashMap<>();
- private Map qualifiedSourceNameToPath = new HashMap<>();
+ private Map pathToQualifiedSourceName = new HashMap<>();
+ private Map qualifiedSourceNameToPath = new HashMap<>();
- private List childrenChangedFiles = new ArrayList<>();;
+ private List childrenChangedFiles = new ArrayList<>();
+ ;
- private Set changedFiles = new HashSet<>();;
+ private Set changedFiles = new HashSet<>();
+ ;
- private Set expandedFiles = new HashSet<>();
+ private Set expandedFiles = new HashSet<>();
- private List filesToDelete = new ArrayList<>();
+ private List filesToDelete = new ArrayList<>();
private Map dirToprojectFiles;
@@ -63,7 +57,6 @@ public Map getDirToprojectFiles() {
}
/**
- *
* @param dir
*/
public void build(Path dir) {
@@ -72,7 +65,7 @@ public void build(Path dir) {
}
private void populateFilesToDelete() {
- // Merge all except added - which by it's nature has nothing nothing needed deleting
+ // Merge all except added - which by it's nature has nothing needed deleting
for (ProjectFiles p : dirToprojectFiles.values()) {
filesToDelete.addAll(p.getRemoved());
filesToDelete.addAll(p.getUpdated());
@@ -86,7 +79,7 @@ private void buildAndProcessChangedFiles(Path dir) {
expandChangedFiles();
// Populate the complete list of potentially changed files
- for(ProjectFiles projectFiles : dirToprojectFiles.values()) {
+ for (ProjectFiles projectFiles : dirToprojectFiles.values()) {
changedFiles.addAll(projectFiles.getUpdated());
changedFiles.addAll(projectFiles.getAdded());
}
@@ -98,17 +91,18 @@ public List getFilesToDelete() {
}
public void expandChangedFiles() {
- for(ProjectFiles projectFiles : dirToprojectFiles.values()) {
+ for (ProjectFiles projectFiles : dirToprojectFiles.values()) {
expandChangedFiles(projectFiles.getUpdated(), expandedFiles);
}
expandChangedFiles(childrenChangedFiles, expandedFiles);
}
+
public void expandChangedFiles(Collection files, Set expanded) {
for (String file : files) {
if (!file.endsWith(".java")) {
continue;
}
- String typeName = pathToQualifiedSourceName.get(file);
+ String typeName = pathToQualifiedSourceName.get(file);
TypeInfo typeInfo = typeInfos.get(typeName);
expandChangedFiles(typeInfo, expanded);
}
@@ -116,7 +110,7 @@ public void expandChangedFiles(Collection files, Set expanded) {
private void expandChangedFiles(TypeInfo typeInfo, Set changedFiles) {
// Anything that extends this is added to the set, and it also recurses through the extends
- for (TypeDependency dep : typeInfo.getSuperIn() ) {
+ for (TypeDependency dep : typeInfo.getSuperIn()) {
maybeAddNativeFile(dep.outgoing);
changedFiles.add(qualifiedSourceNameToPath.get(dep.outgoing.getQualifiedSourceName()));
expandChangedFiles(dep.outgoing, changedFiles);
@@ -124,16 +118,18 @@ private void expandChangedFiles(TypeInfo typeInfo, Set changedFiles) {
// Anything that implements (or extends) this interface, is added to the set.
// TODO Does this need to be done for transitive interface impl? (mdp)
- for (TypeDependency dep : typeInfo.getInterfacesIn() ) {
+ for (TypeDependency dep : typeInfo.getInterfacesIn()) {
maybeAddNativeFile(dep.outgoing);
changedFiles.add(qualifiedSourceNameToPath.get(dep.outgoing.getQualifiedSourceName()));
-
// Recurse the ancestors, as the interface may have default methods
// that changes the call hieararchy of the implementor.
expandChangedFiles(dep.outgoing, changedFiles);
}
+
// Now add all the dependencies
+
+
for (TypeDependency dep : typeInfo.getMethodFieldIn()) {
maybeAddNativeFile(dep.outgoing);
changedFiles.add(qualifiedSourceNameToPath.get(dep.outgoing.getQualifiedSourceName()));
@@ -189,12 +185,11 @@ private void createBuildMaps(Map typeInfoDescrs) {
incoming.getInterfacesIn().add(d);
}
}
-
// Add dependencies, that are not one of the above.
for (String type : typeInfoDescr.dependencies) {
TypeInfo incoming = getType(type);
if (incoming != null) {
- TypeDependency d = new TypeDependency(incoming,outgoing);
+ TypeDependency d = new TypeDependency(incoming, outgoing);
outgoing.getMethodFieldOut().add(d);
incoming.getMethodFieldIn().add(d);
}
@@ -208,7 +203,7 @@ private Map readBuildMapDescrForAllFiles(Path dir, Map readBuildMapDescrForAllFiles(Path dir, Map typeInfoDescrs, Path dir) {
+
+
if (javaFileName.endsWith(".java")) {
String fileName = javaFileName.substring(0, javaFileName.lastIndexOf(".java"));
String buildMapFileName = fileName + ".build.map";
- Path buildMapPath = dir.resolve("results").resolve(buildMapFileName);
+ Path buildMapPath = dir.resolve(buildMapFileName);
+
if (Files.notExists(buildMapPath)) {
throw new RuntimeException("build.map files must exist for all changed .java files");
}
@@ -305,7 +303,7 @@ String getAndInc() {
// skip any empty lines
while (lineNbr < lines.size() &&
- lines.get(lineNbr).trim().isEmpty()) {
+ lines.get(lineNbr).trim().isEmpty()) {
lineNbr++;
}
@@ -334,7 +332,7 @@ static class TypeInfoDescr {
public TypeInfoDescr(String qualifiedSourceName, String qualifiedBinaryName, String nativePathName) {
this.qualifiedSourceName = qualifiedSourceName;
- this.qualifiedBinaryName = qualifiedBinaryName != null && !qualifiedBinaryName.trim().isEmpty() ? qualifiedBinaryName : qualifiedSourceName;
+ this.qualifiedBinaryName = qualifiedBinaryName != null && !qualifiedBinaryName.trim().isEmpty() ? qualifiedBinaryName : qualifiedSourceName;
this.nativePathName = nativePathName;
this.innerTypes = new ArrayList<>();
@@ -346,17 +344,18 @@ public List dependencies() {
return dependencies;
}
- @Override public String toString() {
+ @Override
+ public String toString() {
return "TypeInfoDescr{" +
- "qualifiedSourceName='" + qualifiedSourceName + '\'' +
- ", qualifiedBinaryName='" + qualifiedBinaryName + '\'' +
- ", superTypeName='" + superTypeName + '\'' +
- ", nativePathName='" + nativePathName + '\'' +
- ", enclosingType='" + enclosingType + '\'' +
- ", innerTypes=" + innerTypes +
- ", interfaces=" + interfaces +
- ", dependencies=" + dependencies +
- '}';
+ "qualifiedSourceName='" + qualifiedSourceName + '\'' +
+ ", qualifiedBinaryName='" + qualifiedBinaryName + '\'' +
+ ", superTypeName='" + superTypeName + '\'' +
+ ", nativePathName='" + nativePathName + '\'' +
+ ", enclosingType='" + enclosingType + '\'' +
+ ", innerTypes=" + innerTypes +
+ ", interfaces=" + interfaces +
+ ", dependencies=" + dependencies +
+ '}';
}
}
@@ -374,7 +373,7 @@ TypeInfoDescr readBuildMapSources(LineReader reader, Map
}
String nativePathName = null; // optional
- if (!reader.peekNext().startsWith("-") ) {
+ if (!reader.peekNext().startsWith("-")) {
// native file specified
nativePathName = reader.getAndInc();
}
@@ -390,7 +389,7 @@ public void readHierarchyAndInnerTypes(LineReader reader, TypeInfoDescr typeInfo
if (!line.startsWith("- hierarchy")) {
throw new RuntimeException("Illegal File Format, the next element must be '-hierarchy' at line " + reader.lineNbr);
}
- if (!reader.peekNext().startsWith("-") ) {
+ if (!reader.peekNext().startsWith("-")) {
line = reader.getAndInc();
String[] segments = line.split(":", -1);
if (segments.length != 2) {
@@ -415,7 +414,7 @@ public void readHierarchyAndInnerTypes(LineReader reader, TypeInfoDescr typeInfo
if (!line.startsWith("- innerTypes")) {
throw new RuntimeException("Illegal File Format, the next element must be '-innerTypes' at line " + reader.lineNbr);
}
- if (!reader.peekNext().startsWith("-") ) {
+ if (!reader.peekNext().startsWith("-")) {
String[] innerTypes = reader.getAndInc().split(":", -1);
String ext = ".build.map";
@@ -432,9 +431,9 @@ public void readHierarchyAndInnerTypes(LineReader reader, TypeInfoDescr typeInfo
// String fileName = innerTypeName.substring(penDot+1) + "$" + innerTypeName.substring(lastDot+1) + ext;
String fileName = buildMapPath.getFileName().toString();
- fileName = fileName.substring(0, fileName.length() -ext.length()) + "$" + innerTypeName.substring(lastDot+1) + ext;
-
- Path innerBuildMapPath = buildMapPath.getParent().resolve( fileName );
+ //fileName = fileName.substring(0, fileName.length() -ext.length()) + "$" + innerTypeName.substring(lastDot+1) + ext;
+ fileName = innerTypeName.substring(lastDot + 1) + ext;
+ Path innerBuildMapPath = buildMapPath.getParent().resolve(fileName);
if (!Files.exists(innerBuildMapPath)) {
throw new RuntimeException("InnerType .build.map file must exist: " + innerBuildMapPath);
}
@@ -447,15 +446,15 @@ public void readHierarchyAndInnerTypes(LineReader reader, TypeInfoDescr typeInfo
}
void readBuildMapInterfaces(LineReader reader, TypeInfoDescr typeInfoDescr) {
-
- while( reader.hasNext() && !reader.peekNext().startsWith("- ")) {
+
+ while (reader.hasNext() && !reader.peekNext().startsWith("- ")) {
String typeName = reader.getAndInc();
typeInfoDescr.interfaces.add(typeName);
}
}
void readBuildMapDependencies(LineReader reader, TypeInfoDescr typeInfoDescr) {
- while(reader.hasNext() && !reader.peekNext().startsWith("-")) {
+ while (reader.hasNext() && !reader.peekNext().startsWith("-")) {
String typeName = reader.getAndInc();
typeInfoDescr.dependencies.add(typeName);
}
@@ -475,6 +474,7 @@ private void checkFileFormat(String str, int i) {
/**
* Clone the SourceMap to the TargetMap. Exclude MethodField TypeDependency references, these are not relevant to the parent
* projects that consume this BuildMap.
+ *
* @param target
*/
public void cloneToTargetBuildMap(BuildMap target) {
@@ -490,7 +490,7 @@ public void cloneToTargetBuildMap(BuildMap target) {
target.pathToQualifiedSourceName.putAll(pathToQualifiedSourceName);
target.qualifiedSourceNameToPath.putAll(qualifiedSourceNameToPath);
- for(ProjectFiles projectFiles : dirToprojectFiles.values()) {
+ for (ProjectFiles projectFiles : dirToprojectFiles.values()) {
target.childrenChangedFiles.addAll(projectFiles.getUpdated());
}
diff --git a/build-caching/src/main/java/com/vertispan/j2cl/build/BuildService.java b/build-caching/src/main/java/com/vertispan/j2cl/build/BuildService.java
index 618cc8f0..43740251 100644
--- a/build-caching/src/main/java/com/vertispan/j2cl/build/BuildService.java
+++ b/build-caching/src/main/java/com/vertispan/j2cl/build/BuildService.java
@@ -1,7 +1,6 @@
package com.vertispan.j2cl.build;
import com.vertispan.j2cl.build.impl.CollectedTaskInputs;
-import com.vertispan.j2cl.build.task.BuildLog;
import com.vertispan.j2cl.build.task.OutputTypes;
import com.vertispan.j2cl.build.task.TaskFactory;
import org.apache.commons.io.FileUtils;
@@ -15,7 +14,14 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.FileTime;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
@@ -24,6 +30,8 @@
import java.util.stream.Stream;
public class BuildService {
+
+ private Map strippedSources = new HashMap<>();
private final TaskRegistry taskRegistry;
private final TaskScheduler taskScheduler;
private final DiskCache diskCache;
@@ -37,12 +45,18 @@ public class BuildService {
private BlockingBuildListener prevBuild;
- public BuildService(TaskRegistry taskRegistry, TaskScheduler taskScheduler, DiskCache diskCache) {
+ private boolean incremental;
+
+ public BuildService(TaskRegistry taskRegistry, TaskScheduler taskScheduler, DiskCache diskCache, boolean incremental) {
this.taskRegistry = taskRegistry;
this.taskScheduler = taskScheduler;
this.diskCache = diskCache;
this.diskCache.setBuildService(this);
- this.taskScheduler.setBuildService(this);
+ this.incremental = incremental;
+ }
+
+ public void addStrippedSourcesPath(Project project, Path path) {
+ this.strippedSources.put(project, path);
}
public Map getBuildMaps() {
@@ -71,7 +85,7 @@ private void collectTasksFromProject(String taskName, Project project, PropertyT
// return collectedSoFar.get(newInput);
return;
}
- CollectedTaskInputs collectedInputs = new CollectedTaskInputs(project, this);
+ CollectedTaskInputs collectedInputs = new CollectedTaskInputs(project);
if (!taskName.equals(OutputTypes.INPUT_SOURCES)) {
PropertyTrackingConfig propertyTrackingConfig = new PropertyTrackingConfig(config);
@@ -180,20 +194,23 @@ public synchronized void initialHashes() {
AtomicReference