use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class DefaultCopySpec method filesNotMatching.
public CopySpec filesNotMatching(Iterable<String> patterns, Action<? super FileCopyDetails> action) {
if (!patterns.iterator().hasNext()) {
throw new InvalidUserDataException("must provide at least one pattern to not match");
}
List<Spec> matchers = new ArrayList<Spec>();
for (String pattern : patterns) {
matchers.add(PatternMatcherFactory.getPatternMatcher(true, isCaseSensitive(), pattern));
}
Spec unionMatcher = Specs.union(matchers.toArray(new Spec[matchers.size()]));
return eachFile(new MatchingCopyAction(Specs.<RelativePath>negate(unionMatcher), action));
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class JettyRun method validateConfiguration.
public void validateConfiguration() {
// check the location of the static content/jsps etc
try {
if ((getWebAppSourceDirectory() == null) || !getWebAppSourceDirectory().exists()) {
throw new InvalidUserDataException("Webapp source directory " + (getWebAppSourceDirectory() == null ? "null" : getWebAppSourceDirectory().getCanonicalPath()) + " does not exist");
} else {
LOGGER.info("Webapp source directory = " + getWebAppSourceDirectory().getCanonicalPath());
}
} catch (IOException e) {
throw new InvalidUserDataException("Webapp source directory does not exist", e);
}
// check reload mechanic
if (!"automatic".equalsIgnoreCase(reload) && !"manual".equalsIgnoreCase(reload)) {
throw new InvalidUserDataException("invalid reload mechanic specified, must be 'automatic' or 'manual'");
} else {
LOGGER.info("Reload Mechanic: " + reload);
}
// get the web.xml file if one has been provided, otherwise assume it is in the webapp src directory
if (getWebXml() == null) {
setWebXml(new File(new File(getWebAppSourceDirectory(), "WEB-INF"), "web.xml"));
}
LOGGER.info("web.xml file = " + getWebXml());
//check if a jetty-env.xml location has been provided, if so, it must exist
if (getJettyEnvXml() != null) {
setJettyEnvXmlFile(jettyEnvXml);
try {
if (!getJettyEnvXmlFile().exists()) {
throw new InvalidUserDataException("jetty-env.xml file does not exist at location " + jettyEnvXml);
} else {
LOGGER.info(" jetty-env.xml = " + getJettyEnvXmlFile().getCanonicalPath());
}
} catch (IOException e) {
throw new InvalidUserDataException("jetty-env.xml does not exist");
}
}
setExtraScanTargets(new ArrayList<File>());
if (scanTargets != null) {
for (File scanTarget : scanTargets) {
LOGGER.info("Added extra scan target:" + scanTarget);
getExtraScanTargets().add(scanTarget);
}
}
if (scanTargetPatterns != null) {
for (ScanTargetPattern scanTargetPattern : scanTargetPatterns) {
ConfigurableFileTree files = getProject().fileTree(scanTargetPattern.getDirectory());
files.include(scanTargetPattern.getIncludes());
files.exclude(scanTargetPattern.getExcludes());
Set<File> currentTargets = getExtraScanTargets();
if (currentTargets != null && !currentTargets.isEmpty()) {
currentTargets.addAll(files.getFiles());
} else {
setExtraScanTargets(files.getFiles());
}
}
}
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class TaskFactory method validateArgs.
private void validateArgs(Map<String, Object> args) {
if (!validTaskArguments.containsAll(args.keySet())) {
Map unknownArguments = new HashMap<String, Object>(args);
unknownArguments.keySet().removeAll(validTaskArguments);
throw new InvalidUserDataException(String.format("Could not create task '%s': Unknown argument(s) in task definition: %s", args.get(Task.TASK_NAME), unknownArguments.keySet()));
}
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class LazyPublishArtifact method getFile.
@Override
public File getFile() {
if (file == null) {
Object value = provider.get();
if (value instanceof FileSystemLocation) {
FileSystemLocation location = (FileSystemLocation) value;
file = location.getAsFile();
} else if (value instanceof File) {
file = (File) value;
} else {
throw new InvalidUserDataException(String.format("Cannot convert provided value (%s) to a file.", value));
}
}
return file;
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class GetInputPropertiesVisitor method getPropertyValuesFactory.
public Factory<Map<String, Object>> getPropertyValuesFactory() {
return new Factory<Map<String, Object>>() {
@Override
public Map<String, Object> create() {
Map<String, Object> result = new HashMap<String, Object>();
for (TaskInputPropertySpec inputProperty : inputProperties) {
String propertyName = inputProperty.getPropertyName();
try {
Object value = prepareValue(inputProperty.getValue());
result.put(propertyName, value);
} catch (Exception ex) {
throw new InvalidUserDataException(String.format("Error while evaluating property '%s' of %s", propertyName, beanName), ex);
}
}
return result;
}
};
}
Aggregations