Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Incremental compilation #128

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use classpath only
stephanenicolas committed Jul 14, 2017
commit 3eea4bbf74f2395c8e07266451f45c0095f17d6e
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ private static URI uriForFileObject(Location location, String packageName, Strin

@Override
public String inferBinaryName(Location location, JavaFileObject file) {
if (location == StandardLocation.SOURCE_PATH && file instanceof SimpleJavaFileObject) {
if (location == StandardLocation.CLASS_PATH && file instanceof SimpleJavaFileObject) {
return toBinaryName(file);
}
return super.inferBinaryName(location, file);
@@ -172,9 +172,10 @@ public boolean hasLocation(Location location) {
@Override
public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException {
List<JavaFileObject> result = new ArrayList();
if (location == StandardLocation.SOURCE_PATH || location == StandardLocation.CLASS_PATH) {
if (location == StandardLocation.CLASS_PATH) {
String packageAsPath = packageName.replace('.', '/');
for (Entry<URI, JavaFileObject> entry : inMemoryFileObjects.asMap().entrySet()) {
if (entry.getKey().toString().contains("mem:///" + location.getName())) {
if (entry.getKey().toString().contains("mem:///" + StandardLocation.CLASS_OUTPUT.getName() + '/' + packageAsPath)) {
result.add(entry.getValue());
}
}
Original file line number Diff line number Diff line change
@@ -59,21 +59,7 @@ public final Compilation fullBuild(Iterable<? extends JavaFileObject> files, Ite

public final Compilation incrementalBuild(Iterable<? extends JavaFileObject> files, Iterable<? extends Processor> processors,
ImmutableList<String> options) {
Set<JavaFileObject> incrementalSources = new HashSet<>();
for (JavaFileObject file : files) {
incrementalSources.add(file);
}
for (JavaFileObject file : fullBuildSources) {
if (!incrementalSources.contains(file)) {
addToSourcePath(file);
}
}
Compilation compilation = compile(files, processors, options);
return compilation;
}

public void addToSourcePath(JavaFileObject... sourceFiles) {
fileManager.addToSourcePath(sourceFiles);
return compile(files, processors, options);
}

public InMemoryJavaFileManager.InMemoryJavaFileObject getGeneratedJavaFile(String FQNclassName) {