use of org.gradle.api.tasks.Classpath in project spring-boot by spring-projects.
the class CheckClasspathForConflicts method checkForConflicts.
@TaskAction
public void checkForConflicts() throws IOException {
ClasspathContents classpathContents = new ClasspathContents();
for (File file : this.classpath) {
if (file.isDirectory()) {
Path root = file.toPath();
Files.walk(root).filter((path) -> Files.isRegularFile(path)).forEach((entry) -> classpathContents.add(root.relativize(entry).toString(), root.toString()));
} else {
try (JarFile jar = new JarFile(file)) {
for (JarEntry entry : Collections.list(jar.entries())) {
if (!entry.isDirectory()) {
classpathContents.add(entry.getName(), file.getAbsolutePath());
}
}
}
}
}
Map<String, List<String>> conflicts = classpathContents.getConflicts(this.ignores);
if (!conflicts.isEmpty()) {
StringBuilder message = new StringBuilder(String.format("Found classpath conflicts:%n"));
conflicts.forEach((entry, locations) -> {
message.append(String.format(" %s%n", entry));
locations.forEach((location) -> message.append(String.format(" %s%n", location)));
});
throw new GradleException(message.toString());
}
}
use of org.gradle.api.tasks.Classpath in project gradle by gradle.
the class AbstractInputFilePropertyAnnotationHandler method visitPropertyValue.
@Override
public void visitPropertyValue(String propertyName, PropertyValue value, PropertyMetadata propertyMetadata, PropertyVisitor visitor, BeanPropertyContext context) {
Annotation fileNormalization = propertyMetadata.getAnnotationForCategory(NORMALIZATION);
Class<? extends FileNormalizer> fileNormalizer;
if (fileNormalization == null) {
fileNormalizer = null;
} else if (fileNormalization instanceof PathSensitive) {
PathSensitivity pathSensitivity = ((PathSensitive) fileNormalization).value();
fileNormalizer = FileParameterUtils.determineNormalizerForPathSensitivity(pathSensitivity);
} else if (fileNormalization instanceof Classpath) {
fileNormalizer = ClasspathNormalizer.class;
} else if (fileNormalization instanceof CompileClasspath) {
fileNormalizer = CompileClasspathNormalizer.class;
} else {
throw new IllegalStateException("Unknown normalization annotation used: " + fileNormalization);
}
visitor.visitInputFileProperty(propertyName, propertyMetadata.isAnnotationPresent(Optional.class), propertyMetadata.isAnnotationPresent(SkipWhenEmpty.class), determineDirectorySensitivity(propertyMetadata), propertyMetadata.isAnnotationPresent(NormalizeLineEndings.class) ? LineEndingSensitivity.NORMALIZE_LINE_ENDINGS : LineEndingSensitivity.DEFAULT, propertyMetadata.isAnnotationPresent(Incremental.class), fileNormalizer, value, getFilePropertyType());
}
Aggregations