![JAR search and dependency download from the Maven repository](/logo.png)
net.bytebuddy.build.gradle.IncrementalResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of byte-buddy-gradle-plugin Show documentation
Show all versions of byte-buddy-gradle-plugin Show documentation
A plugin for post-processing class files via Byte Buddy in a Gradle build.
/*
* Copyright 2014 - Present Rafael Winterhalter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.bytebuddy.build.gradle;
import org.gradle.api.logging.Logger;
import org.gradle.work.ChangeType;
import org.gradle.work.FileChange;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* An incremental resolver is responsible to determine the file set to transform after a change.
*/
public interface IncrementalResolver {
/**
* Returns a list of files to transform after an incremental change.
*
* @param logger A logger for the resolver.
* @param changes An iterable of all changes that were found.
* @param sourceRoot The source directory.
* @param targetRoot The target directory.
* @param classPath The class path available.
* @return A list of files to include in the transformation.
*/
List apply(Logger logger, Iterable changes, File sourceRoot, File targetRoot, Iterable classPath);
/**
* An incremental resolver that retransforms any file that has changed but no other files.
*/
enum ForChangedFiles implements IncrementalResolver {
/**
* The singleton instance.
*/
INSTANCE;
/**
* {@inheritDoc}
*/
public List apply(Logger logger, Iterable changes, File sourceRoot, File targetRoot, Iterable classPath) {
List files = new ArrayList();
for (FileChange change : changes) {
if (change.getChangeType() == ChangeType.REMOVED) {
File target = new File(targetRoot, sourceRoot.toURI().relativize(change.getFile().toURI()).getPath());
if (AbstractByteBuddyTask.deleteRecursively(target)) {
logger.debug("Deleted removed file {} to prepare incremental build", target);
}
} else {
files.add(change.getFile());
}
}
return files;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy