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

Allow an incremental build to perform less weaving #1962

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
// Billforward - added fileNeedsProcessingPredicate for incremental build support
package org.eclipse.persistence.tools.weaving.jpa;

import java.io.ByteArrayOutputStream;
Expand All @@ -26,6 +27,7 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Iterator;
import java.util.function.Predicate;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;

Expand Down Expand Up @@ -57,6 +59,7 @@ public class StaticWeaveProcessor {
private Writer logWriter;
private ClassLoader classLoader;
private int logLevel = SessionLog.OFF;
private Predicate<String> fileNeedsProcessingPredicate;

private static final int NUMBER_OF_BYTES = 1024;

Expand Down Expand Up @@ -256,6 +259,12 @@ private void process() throws IOException,URISyntaxException{
Iterator<String> entries = sourceArchive.getEntries();
while (entries.hasNext()){
String entryName = entries.next();

if (fileNeedsProcessingPredicate != null &&
!fileNeedsProcessingPredicate.test(entryName)) {
continue;
}

InputStream entryInputStream = sourceArchive.getEntry(entryName);

// Add a directory entry
Expand Down Expand Up @@ -372,4 +381,8 @@ private URL[] getURLs(){
}
return new URL[]{};
}

public void setFileNeedsProcessingPredicate(Predicate<String> fileNeedsProcessingPredicate) {
this.fileNeedsProcessingPredicate = fileNeedsProcessingPredicate;
}
}