use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class JettyStop method stop.
@TaskAction
public void stop() {
if (getStopPort() == null) {
throw new InvalidUserDataException("Please specify a valid port");
}
if (getStopKey() == null) {
throw new InvalidUserDataException("Please specify a valid stopKey");
}
ProgressLogger progressLogger = getServices().get(ProgressLoggerFactory.class).newOperation(JettyStop.class).start("Stop Jetty server", "Stopping Jetty");
try {
Socket s = new Socket(InetAddress.getByName("127.0.0.1"), getStopPort());
s.setSoLinger(false, 0);
OutputStream out = s.getOutputStream();
out.write((getStopKey() + "\r\nstop\r\n").getBytes());
out.flush();
s.close();
} catch (ConnectException e) {
LOGGER.info("Jetty not running!");
} catch (Exception e) {
LOGGER.error("Exception during stopping", e);
} finally {
progressLogger.completed();
}
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class TaskFactory method createTask.
public TaskInternal createTask(Map<String, ?> args) {
Map<String, Object> actualArgs = new HashMap<String, Object>(args);
checkTaskArgsAndCreateDefaultValues(actualArgs);
String name = actualArgs.get(Task.TASK_NAME).toString();
if (!GUtil.isTrue(name)) {
throw new InvalidUserDataException("The task name must be provided.");
}
Class<? extends TaskInternal> type = (Class) actualArgs.get(Task.TASK_TYPE);
TaskInternal task = create(name, type);
Object dependsOnTasks = actualArgs.get(Task.TASK_DEPENDS_ON);
if (dependsOnTasks != null) {
task.dependsOn(dependsOnTasks);
}
Object description = actualArgs.get(Task.TASK_DESCRIPTION);
if (description != null) {
task.setDescription(description.toString());
}
Object group = actualArgs.get(Task.TASK_GROUP);
if (group != null) {
task.setGroup(group.toString());
}
Object action = actualArgs.get(Task.TASK_ACTION);
if (action instanceof Action) {
Action<? super Task> taskAction = (Action<? super Task>) action;
task.doFirst(taskAction);
} else if (action != null) {
Closure closure = (Closure) action;
task.doFirst(closure);
}
return task;
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class ArtifactTransformBackedTransformer method apply.
@Override
public List<File> apply(File file, File outputDir) {
ArtifactTransform artifactTransform = create();
artifactTransform.setOutputDirectory(outputDir);
List<File> outputs = artifactTransform.transform(file);
if (outputs == null) {
throw new InvalidUserDataException("Transform returned null result.");
}
String inputFilePrefix = file.getPath() + File.separator;
String outputDirPrefix = outputDir.getPath() + File.separator;
for (File output : outputs) {
if (!output.exists()) {
throw new InvalidUserDataException("Transform output file " + output.getPath() + " does not exist.");
}
if (output.equals(file) || output.equals(outputDir)) {
continue;
}
if (output.getPath().startsWith(outputDirPrefix)) {
continue;
}
if (output.getPath().startsWith(inputFilePrefix)) {
continue;
}
throw new InvalidUserDataException("Transform output file " + output.getPath() + " is not a child of the transform's input file or output directory.");
}
return outputs;
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class DefaultCopySpec method filesMatching.
public CopySpec filesMatching(Iterable<String> patterns, Action<? super FileCopyDetails> action) {
if (!patterns.iterator().hasNext()) {
throw new InvalidUserDataException("must provide at least one pattern to 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(unionMatcher, action));
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class DefaultSourceDirectorySet method doGetSrcDirTrees.
private Set<DirectoryTree> doGetSrcDirTrees() {
Set<DirectoryTree> result = new LinkedHashSet<DirectoryTree>();
for (Object path : source) {
if (path instanceof SourceDirectorySet) {
SourceDirectorySet nested = (SourceDirectorySet) path;
result.addAll(nested.getSrcDirTrees());
} else {
for (File srcDir : fileResolver.resolveFiles(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;
}
Aggregations