use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class DefaultDeploymentDescriptor method readFrom.
@Override
public DeploymentDescriptor readFrom(Reader reader) {
try {
Node appNode = createParser().parse(reader);
version = (String) appNode.attribute("version");
for (final Node child : Cast.<List<Node>>uncheckedCast(appNode.children())) {
String childLocalName = localNameOf(child);
if (childLocalName.equals("application-name")) {
applicationName = child.text();
} else if (childLocalName.equals("initialize-in-order")) {
initializeInOrder = Boolean.valueOf(child.text());
} else if (childLocalName.equals("description")) {
description = child.text();
} else if (childLocalName.equals("display-name")) {
displayName = child.text();
} else if (childLocalName.equals("library-directory")) {
libraryDirectory = child.text();
} else if (childLocalName.equals("module")) {
EarModule module = null;
for (Node moduleNode : Cast.<List<Node>>uncheckedCast(child.children())) {
String moduleNodeLocalName = localNameOf(moduleNode);
if (moduleNodeLocalName.equals("web")) {
String webUri = childNodeText(moduleNode, "web-uri");
String contextRoot = childNodeText(moduleNode, "context-root");
module = new DefaultEarWebModule(webUri, contextRoot);
modules.add(module);
moduleTypeMappings.put(module.getPath(), "web");
} else if (moduleNodeLocalName.equals("alt-dd")) {
assert module != null;
module.setAltDeployDescriptor(moduleNode.text());
} else {
module = new DefaultEarModule(moduleNode.text());
modules.add(module);
moduleTypeMappings.put(module.getPath(), moduleNodeLocalName);
}
}
} else if (childLocalName.equals("security-role")) {
String roleName = childNodeText(child, "role-name");
String description = childNodeText(child, "description");
securityRoles.add(new DefaultEarSecurityRole(roleName, description));
} else {
withXml(new Action<XmlProvider>() {
@Override
public void execute(XmlProvider xmlProvider) {
xmlProvider.asNode().append(child);
}
});
}
}
} catch (IOException ex) {
throw new UncheckedIOException(ex);
} catch (SAXException ex) {
throw new UncheckedException(ex);
} finally {
IOUtils.closeQuietly(reader);
}
return this;
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class DependencyResolverIvyPublisher method publish.
public void publish(IvyNormalizedPublication publication, PublicationAwareRepository repository) {
ModuleVersionPublisher publisher = repository.createPublisher();
IvyPublicationIdentity projectIdentity = publication.getProjectIdentity();
ModuleComponentIdentifier moduleVersionIdentifier = DefaultModuleComponentIdentifier.newId(projectIdentity.getOrganisation(), projectIdentity.getModule(), projectIdentity.getRevision());
// This indicates the IvyPublishMetaData should probably not be responsible for creating a ModuleDescriptor...
BuildableIvyModulePublishMetadata publishMetaData = new DefaultIvyModulePublishMetadata(moduleVersionIdentifier, "");
try {
for (IvyArtifact publishArtifact : publication.getArtifacts()) {
publishMetaData.addArtifact(createIvyArtifact(publishArtifact), publishArtifact.getFile());
}
IvyArtifactName artifact = new DefaultIvyArtifactName("ivy", "ivy", "xml");
publishMetaData.addArtifact(artifact, publication.getDescriptorFile());
publisher.publish(publishMetaData);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class BrowserEvaluate method doEvaluate.
@TaskAction
void doEvaluate() {
HttpFileServer fileServer = new SimpleHttpFileServerFactory().start(getContent(), 0);
try {
Writer resultWriter = new FileWriter(getResult());
getEvaluator().evaluate(fileServer.getResourceUrl(getResource()), resultWriter);
resultWriter.close();
} catch (IOException e) {
throw new UncheckedIOException(e);
} finally {
fileServer.stop();
}
setDidWork(true);
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class EnvJsBrowserEvaluator method evaluate.
public void evaluate(String url, Writer writer) {
EnvJvEvaluateProtocol evaluator = rhinoWorkerHandleFactory.create(rhinoClasspath, EnvJvEvaluateProtocol.class, EnvJsEvaluateWorker.class, logLevel, workingDir);
final String result = evaluator.process(new EnvJsEvaluateSpec(envJsFactory.create(), url));
try {
IOUtils.copy(new StringReader(result), writer);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class RhinoWorkerUtils method parse.
public static Scriptable parse(File source, String encoding, Action<Context> contextConfig) {
Context context = Context.enter();
if (contextConfig != null) {
contextConfig.execute(context);
}
Scriptable scope = context.initStandardObjects();
try {
Reader reader = new InputStreamReader(new FileInputStream(source), encoding);
try {
context.evaluateReader(scope, reader, source.getName(), 0, null);
} finally {
reader.close();
}
} catch (IOException e) {
throw new UncheckedIOException(e);
} finally {
Context.exit();
}
return scope;
}
Aggregations