use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class ResolveChangesStep method createIncrementalInputProperties.
private static IncrementalInputProperties createIncrementalInputProperties(UnitOfWork work) {
UnitOfWork.InputChangeTrackingStrategy inputChangeTrackingStrategy = work.getInputChangeTrackingStrategy();
switch(inputChangeTrackingStrategy) {
case NONE:
return IncrementalInputProperties.NONE;
// noinspection deprecation
case ALL_PARAMETERS:
// When using IncrementalTaskInputs, keep the old behaviour of all file inputs being incremental
return IncrementalInputProperties.ALL;
case INCREMENTAL_PARAMETERS:
ImmutableBiMap.Builder<String, Object> builder = ImmutableBiMap.builder();
InputVisitor visitor = new InputVisitor() {
@Override
public void visitInputFileProperty(String propertyName, InputPropertyType type, FileValueSupplier valueSupplier) {
if (type.isIncremental()) {
Object value = valueSupplier.getValue();
if (value == null) {
throw new InvalidUserDataException("Must specify a value for incremental input property '" + propertyName + "'.");
}
builder.put(propertyName, value);
}
}
};
work.visitIdentityInputs(visitor);
work.visitRegularInputs(visitor);
return new DefaultIncrementalInputProperties(builder.build());
default:
throw new AssertionError("Unknown InputChangeTrackingStrategy: " + inputChangeTrackingStrategy);
}
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class DefaultFileOperations method mkdir.
@Override
public File mkdir(Object path) {
File dir = fileResolver.resolve(path);
if (dir.isFile()) {
throw new InvalidUserDataException(String.format("Can't create directory. The path=%s points to an existing file.", path));
}
GFileUtils.mkdirs(dir);
return dir;
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class DefaultSourceDirectorySet method getSourceTrees.
protected Set<DirectoryFileTree> getSourceTrees() {
Set<DirectoryFileTree> result = new LinkedHashSet<>();
for (Object path : source) {
if (path instanceof DefaultSourceDirectorySet) {
DefaultSourceDirectorySet nested = (DefaultSourceDirectorySet) path;
result.addAll(nested.getSourceTrees());
} else {
for (File srcDir : fileCollectionFactory.resolving(path)) {
if (srcDir.exists() && !srcDir.isDirectory()) {
throw new InvalidUserDataException(String.format("Source directory '%s' is not a directory.", srcDir));
}
result.add(directoryFileTreeFactory.create(srcDir, patterns));
}
}
}
return result;
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class DefaultCatalogProblemBuilder method maybeThrowError.
public static void maybeThrowError(String error, List<VersionCatalogProblem> problems) {
if (!problems.isEmpty()) {
TreeFormatter formatter = new TreeFormatter();
formatter.node(error);
formatter.startChildren();
for (VersionCatalogProblem problem : problems) {
problem.reportInto(formatter);
}
formatter.endChildren();
throw new InvalidUserDataException(formatter.toString());
}
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class DefaultTaskContainer method findByPath.
@Override
public Task findByPath(String path) {
if (Strings.isNullOrEmpty(path)) {
throw new InvalidUserDataException("A path must be specified!");
}
if (!path.contains(Project.PATH_SEPARATOR)) {
return findByName(path);
}
String projectPath = StringUtils.substringBeforeLast(path, Project.PATH_SEPARATOR);
ProjectInternal project = this.project.findProject(Strings.isNullOrEmpty(projectPath) ? Project.PATH_SEPARATOR : projectPath);
if (project == null) {
return null;
}
project.getOwner().ensureTasksDiscovered();
return project.getTasks().findByName(StringUtils.substringAfterLast(path, Project.PATH_SEPARATOR));
}
Aggregations