Search in sources :

Example 11 with UncheckedIOException

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;
}
Also used : DomNode(org.gradle.api.internal.DomNode) Node(groovy.util.Node) UncheckedIOException(org.gradle.api.UncheckedIOException) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) UncheckedException(org.gradle.internal.UncheckedException) XmlProvider(org.gradle.api.XmlProvider) EarModule(org.gradle.plugins.ear.descriptor.EarModule) List(java.util.List)

Example 12 with UncheckedIOException

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);
    }
}
Also used : DefaultIvyModulePublishMetadata(org.gradle.internal.component.external.model.DefaultIvyModulePublishMetadata) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) DefaultModuleComponentIdentifier(org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) BuildableIvyModulePublishMetadata(org.gradle.internal.component.external.model.BuildableIvyModulePublishMetadata) UncheckedIOException(org.gradle.api.UncheckedIOException) IvyArtifact(org.gradle.api.publish.ivy.IvyArtifact) IOException(java.io.IOException) UncheckedIOException(org.gradle.api.UncheckedIOException) ModuleVersionPublisher(org.gradle.api.internal.artifacts.ModuleVersionPublisher)

Example 13 with UncheckedIOException

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);
}
Also used : SimpleHttpFileServerFactory(org.gradle.plugins.javascript.envjs.http.simple.SimpleHttpFileServerFactory) FileWriter(java.io.FileWriter) HttpFileServer(org.gradle.plugins.javascript.envjs.http.HttpFileServer) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(org.gradle.api.UncheckedIOException) FileWriter(java.io.FileWriter) Writer(java.io.Writer)

Example 14 with UncheckedIOException

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);
    }
}
Also used : StringReader(java.io.StringReader) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(org.gradle.api.UncheckedIOException)

Example 15 with UncheckedIOException

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;
}
Also used : Context(org.mozilla.javascript.Context) UncheckedIOException(org.gradle.api.UncheckedIOException) UncheckedIOException(org.gradle.api.UncheckedIOException) Scriptable(org.mozilla.javascript.Scriptable)

Aggregations

UncheckedIOException (org.gradle.api.UncheckedIOException)82 IOException (java.io.IOException)60 File (java.io.File)25 InputStream (java.io.InputStream)7 OutputStream (java.io.OutputStream)6 FileOutputStream (java.io.FileOutputStream)5 FileInputStream (java.io.FileInputStream)4 URI (java.net.URI)4 URL (java.net.URL)4 ArrayList (java.util.ArrayList)4 Manifest (java.util.jar.Manifest)4 ZipInputStream (java.util.zip.ZipInputStream)4 FileVisitDetails (org.gradle.api.file.FileVisitDetails)4 FileVisitor (org.gradle.api.file.FileVisitor)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 FileReader (java.io.FileReader)3 URISyntaxException (java.net.URISyntaxException)3 Matcher (java.util.regex.Matcher)3 ZipEntry (java.util.zip.ZipEntry)3