use of org.gradle.api.GradleException in project gradle by gradle.
the class SimpleTemplateOperation method generate.
@Override
public void generate() {
try {
target.getParentFile().mkdirs();
SimpleTemplateEngine templateEngine = new SimpleTemplateEngine();
String templateText = Resources.asCharSource(templateURL, CharsetToolkit.getDefaultSystemCharset()).read();
Template template = templateEngine.createTemplate(templateText);
Writer writer = Files.asCharSink(target, Charsets.UTF_8).openStream();
try {
template.make(bindings).writeTo(writer);
} finally {
writer.close();
}
} catch (Exception ex) {
throw new GradleException("Could not generate file " + target + ".", ex);
}
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class InitBuild method setupProjectLayout.
@TaskAction
public void setupProjectLayout() {
final String type = getType();
BuildInitDsl dsl = BuildInitDsl.fromName(getDsl());
BuildInitTestFramework testFramework = BuildInitTestFramework.fromName(getTestFramework());
final ProjectLayoutSetupRegistry projectLayoutRegistry = getProjectLayoutRegistry();
if (!projectLayoutRegistry.supports(type)) {
String supportedTypes = Joiner.on(", ").join(Iterables.transform(projectLayoutRegistry.getSupportedTypes(), new Function<String, String>() {
@Override
public String apply(String input) {
return "'" + input + "'";
}
}));
throw new GradleException("The requested build setup type '" + type + "' is not supported. Supported types: " + supportedTypes + ".");
}
ProjectInitDescriptor initDescriptor = projectLayoutRegistry.get(type);
if (!testFramework.equals(BuildInitTestFramework.NONE) && !initDescriptor.supports(testFramework)) {
throw new GradleException("The requested test framework '" + testFramework.getId() + "' is not supported in '" + type + "' setup type");
}
initDescriptor.generate(dsl, testFramework);
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class JavadocConverter method parse.
public DocComment parse(final PropertyMetaData propertyMetaData, final GenerationListener listener) {
listener.start(String.format("property %s", propertyMetaData));
try {
ClassMetaData ownerClass = propertyMetaData.getOwnerClass();
String rawCommentText = propertyMetaData.getRawCommentText();
try {
CommentSource commentSource = new InheritedPropertyCommentSource(propertyMetaData, listener);
DocCommentImpl docComment = parse(rawCommentText, ownerClass, commentSource, listener);
adjustGetterComment(docComment);
return docComment;
} catch (Exception e) {
throw new GradleException(String.format("Could not convert javadoc comment to docbook.%nClass: %s%nProperty: %s%nComment: %s", ownerClass.getClassName(), propertyMetaData.getName(), rawCommentText), e);
}
} finally {
listener.finish();
}
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class AbstractClasspathSnapshotBuilder method visitFileTreeSnapshot.
@Override
public void visitFileTreeSnapshot(Collection<FileSnapshot> descendants) {
ClasspathEntrySnapshotBuilder entryResourceCollectionBuilder = newClasspathEntrySnapshotBuilder();
try {
new FileTree(descendants).visit(entryResourceCollectionBuilder);
} catch (IOException e) {
throw new GradleException("Error while snapshotting directory in classpath", e);
}
entryResourceCollectionBuilder.collectNormalizedSnapshots(builder);
}
use of org.gradle.api.GradleException in project gradle by gradle.
the class JavadocGenerator method execute.
@Override
public WorkResult execute(JavadocSpec spec) {
JavadocExecHandleBuilder javadocExecHandleBuilder = new JavadocExecHandleBuilder(execActionFactory);
javadocExecHandleBuilder.setExecutable(spec.getExecutable());
javadocExecHandleBuilder.execDirectory(spec.getWorkingDir()).options(spec.getOptions()).optionsFile(spec.getOptionsFile());
ExecAction execAction = javadocExecHandleBuilder.getExecHandle();
if (spec.isIgnoreFailures()) {
execAction.setIgnoreExitValue(true);
}
try {
execAction.execute();
} catch (ExecException e) {
LOG.info("Problems generating Javadoc." + "\n Command line issued: " + execAction.getCommandLine() + "\n Generated Javadoc options file has following contents:\n------\n{}------", GFileUtils.readFileQuietly(spec.getOptionsFile()));
throw new GradleException(String.format("Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '%s'", spec.getOptionsFile()), e);
}
return WorkResults.didWork(true);
}
Aggregations