当前位置: 首页>>代码示例>>Java>>正文


Java IoActions类代码示例

本文整理汇总了Java中org.gradle.internal.IoActions的典型用法代码示例。如果您正苦于以下问题:Java IoActions类的具体用法?Java IoActions怎么用?Java IoActions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IoActions类属于org.gradle.internal包,在下文中一共展示了IoActions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMetaData

import org.gradle.internal.IoActions; //导入依赖的package包/类
public ExternalResourceMetaData getMetaData(URI location, boolean revalidate) {
    LOGGER.debug("Attempting to get resource metadata: {}", location);
    S3Object s3Object = s3Client.getMetaData(location);
    if (s3Object == null) {
        return null;
    }
    try {
        ObjectMetadata objectMetadata = s3Object.getObjectMetadata();
        return new DefaultExternalResourceMetaData(location,
            objectMetadata.getLastModified().getTime(),
            objectMetadata.getContentLength(),
            objectMetadata.getContentType(),
            objectMetadata.getETag(),
            null); // Passing null for sha1 - TODO - consider using the etag which is an MD5 hash of the file (when less than 5Gb)
    } finally {
        IoActions.closeQuietly(s3Object);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:S3ResourceConnector.java

示例2: writeTo

import org.gradle.internal.IoActions; //导入依赖的package包/类
@Override
public org.gradle.api.java.archives.Manifest writeTo(Object path) {
    File manifestFile = fileResolver.resolve(path);
    try {
        File parentFile = manifestFile.getParentFile();
        if (parentFile != null) {
            FileUtils.forceMkdir(parentFile);
        }
        IoActions.withResource(new FileOutputStream(manifestFile), new Action<FileOutputStream>() {
            @Override
            public void execute(FileOutputStream fileOutputStream) {
                writeTo(fileOutputStream);
            }
        });
        return this;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:DefaultManifest.java

示例3: serialize

import org.gradle.internal.IoActions; //导入依赖的package包/类
public SerializedPayload serialize(Object payload) {
    final SerializeMap map = classLoaderRegistry.newSerializeSession();
    try {
        StreamByteBuffer buffer = new StreamByteBuffer();
        final ObjectOutputStream objectStream = new PayloadSerializerObjectOutputStream(buffer.getOutputStream(), map);

        try {
            objectStream.writeObject(payload);
        } finally {
            IoActions.closeQuietly(objectStream);
        }

        Map<Short, ClassLoaderDetails> classLoaders = new HashMap<Short, ClassLoaderDetails>();
        map.collectClassLoaderDefinitions(classLoaders);
        return new SerializedPayload(classLoaders, buffer.readAsListOfByteArrays());
    } catch (IOException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:PayloadSerializer.java

示例4: readPrefixes

import org.gradle.internal.IoActions; //导入依赖的package包/类
private static Trie readPrefixes(RuntimeShadedJarType type) {
    final Trie.Builder builder = new Trie.Builder();
    IoActions.withResource(ImplementationDependencyRelocator.class.getResourceAsStream(type.getIdentifier() + "-relocated.txt"), new ErroringAction<InputStream>() {
        @Override
        protected void doExecute(InputStream thing) throws Exception {
            BufferedReader reader = new BufferedReader(new InputStreamReader(thing, Charset.forName("UTF-8")));
            String line;
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.length() > 0) {
                    builder.addWord(line);
                }
            }
        }
    });
    return builder.build();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:ImplementationDependencyRelocator.java

示例5: generate

import org.gradle.internal.IoActions; //导入依赖的package包/类
@TaskAction
public void generate() {
    IoActions.writeTextFile(getOutputFile(), new ErroringAction<BufferedWriter>() {
        @Override
        public void doExecute(final BufferedWriter bufferedWriter) throws Exception {
            Trie packages = collectPackages();
            packages.dump(false, new ErroringAction<String>() {
                @Override
                public void doExecute(String s) throws Exception {
                    bufferedWriter.write(s);
                    bufferedWriter.newLine();
                }
            });
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:PackageListGenerator.java

示例6: getMetaData

import org.gradle.internal.IoActions; //导入依赖的package包/类
public ExternalResourceMetaData getMetaData(URI uri, boolean revalidate) {
    String location = uri.toString();
    LOGGER.debug("Constructing external resource metadata: {}", location);
    CloseableHttpResponse response = http.performHead(location, revalidate);

    ExternalResourceMetaData result = null;
    if (response != null) {
        HttpResponseResource resource = new HttpResponseResource("HEAD", uri, response);
        try {
            result = resource.getMetaData();
        } finally {
            IoActions.closeQuietly(resource);
        }
    }
    return result;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:HttpResourceAccessor.java

示例7: write

import org.gradle.internal.IoActions; //导入依赖的package包/类
void write(File outputFile) throws IOException {
    IoActions.writeTextFile(outputFile, new ErroringAction<BufferedWriter>() {
        @Override
        protected void doExecute(BufferedWriter writer) throws Exception {
            final Map<String, JavadocOptionFileOption<?>> options = new TreeMap<String, JavadocOptionFileOption<?>>(optionFile.getOptions());
            JavadocOptionFileWriterContext writerContext = new JavadocOptionFileWriterContext(writer);

            JavadocOptionFileOption<?> localeOption = options.remove("locale");
            if (localeOption != null) {
                localeOption.write(writerContext);
            }

            for (final String option : options.keySet()) {
                options.get(option).write(writerContext);
            }

            optionFile.getSourceNames().write(writerContext);
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:JavadocOptionFileWriter.java

示例8: pack

import org.gradle.internal.IoActions; //导入依赖的package包/类
@Override
public void pack(final TaskOutputsInternal taskOutputs, OutputStream output, final TaskOutputOriginWriter writeOrigin) {
    IoActions.withResource(new TarOutputStream(output, "utf-8"), new Action<TarOutputStream>() {
        @Override
        public void execute(TarOutputStream outputStream) {
            outputStream.setLongFileMode(TarOutputStream.LONGFILE_POSIX);
            outputStream.setBigNumberMode(TarOutputStream.BIGNUMBER_POSIX);
            outputStream.setAddPaxHeadersForNonAsciiNames(true);
            try {
                packMetadata(writeOrigin, outputStream);
                pack(taskOutputs, outputStream);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:TarTaskOutputPacker.java

示例9: write

import org.gradle.internal.IoActions; //导入依赖的package包/类
void write(File outputFile) throws IOException {
    IoActions.writeTextFile(outputFile, new ErroringAction<BufferedWriter>() {
        @Override
        protected void doExecute(BufferedWriter writer) throws Exception {
            final Map<String, JavadocOptionFileOption> options = new TreeMap<String, JavadocOptionFileOption>(optionFile.getOptions());
            JavadocOptionFileWriterContext writerContext = new JavadocOptionFileWriterContext(writer);

            JavadocOptionFileOption localeOption = options.remove("locale");
            if (localeOption != null) {
                localeOption.write(writerContext);
            }

            for (final String option : options.keySet()) {
                options.get(option).write(writerContext);
            }

            optionFile.getSourceNames().write(writerContext);
        }
    });
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:21,代码来源:JavadocOptionFileWriter.java

示例10: execute

import org.gradle.internal.IoActions; //导入依赖的package包/类
public WorkResult execute(final CopyActionProcessingStream stream) {
    ZipOutputStream zipOutStr;

    try {
        zipOutStr = new ZipOutputStream(new FileOutputStream(zipFile));
    } catch (Exception e) {
        throw new GradleException(String.format("Could not create ZIP '%s'.", zipFile), e);
    }

    IoActions.withResource(zipOutStr, new Action<ZipOutputStream>() {
        public void execute(ZipOutputStream outputStream) {
            stream.process(new StreamAction(outputStream));
        }
    });

    return new SimpleWorkResult(true);
}
 
开发者ID:EvidentSolutions,项目名称:gradle-gzjar-plugin,代码行数:18,代码来源:GzJarCopyAction.java

示例11: build

import org.gradle.internal.IoActions; //导入依赖的package包/类
public void build(File initScriptFile, final List<File> classpath) {
  IoActions.writeTextFile(initScriptFile, new ErroringAction<Writer>() {
    @Override
    protected void doExecute(Writer writer) throws Exception {
      writer.write("allprojects {\n");
      writer.write("  buildscript {\n");
      writer.write("    dependencies {\n");
      writer.write("      classpath files(\n");
      int i = 0;
      for (File file : classpath) {
        writer.write(
            String.format("        '%s'", TextUtil.escapeString(file.getAbsolutePath())));
        if (++i != classpath.size()) {
          writer.write(",\n");
        }
      }
      writer.write("\n");
      writer.write("      )\n");
      writer.write("    }\n");
      writer.write("  }\n");
      writer.write("}\n");
    }
  });
}
 
开发者ID:JakeWharton,项目名称:paraphrase,代码行数:25,代码来源:ClasspathAddingInitScriptBuilder.java

示例12: build

import org.gradle.internal.IoActions; //导入依赖的package包/类
public void build(File initScriptFile, final List<File> classpath) {
    IoActions.writeTextFile(initScriptFile, new ErroringAction<Writer>() {
        @Override
        protected void doExecute(Writer writer) throws Exception {
            writer.write("allprojects {\n");
            writer.write("  buildscript {\n");
            writer.write("    dependencies {\n");
            writer.write("      classpath files(\n");
            int i = 0;
            for (File file : classpath) {
                writer.write(String.format("        '%s'", TextUtil.escapeString(file.getAbsolutePath())));
                if (++i != classpath.size()) {
                    writer.write(",\n");
                }
            }
            writer.write("\n");
            writer.write("      )\n");
            writer.write("    }\n");
            writer.write("  }\n");
            writer.write("}\n");
        }
    });
}
 
开发者ID:werval,项目名称:werval,代码行数:24,代码来源:ClasspathAddingInitScriptBuilder.java

示例13: writeProbe

import org.gradle.internal.IoActions; //导入依赖的package包/类
private static void writeProbe(File workingDir) {
    File probeFile = new File(workingDir, JavaProbe.CLASSNAME + ".class");
    try {
        IoActions.withResource(new FileOutputStream(probeFile), new ErroringAction<FileOutputStream>() {
            @Override
            protected void doExecute(FileOutputStream thing) throws Exception {
                thing.write(JavaProbe.dump());
            }
        });
    } catch (FileNotFoundException e) {
        throw new GradleException("Unable to write Java probe file", e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:14,代码来源:JavaInstallationProbe.java

示例14: writeTo

import org.gradle.internal.IoActions; //导入依赖的package包/类
public DefaultMavenPom writeTo(Object path) {
    IoActions.writeTextFile(fileResolver.resolve(path), POM_FILE_ENCODING, new Action<BufferedWriter>() {
        public void execute(BufferedWriter writer) {
            writeTo(writer);
        }
    });
    return this;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:DefaultMavenPom.java

示例15: createFatJar

import org.gradle.internal.IoActions; //导入依赖的package包/类
private void createFatJar(final File outputJar, final Iterable<? extends File> files, final ProgressLogger progressLogger) {
    final File tmpFile = tempFileFor(outputJar);

    IoActions.withResource(openJarOutputStream(tmpFile), new ErroringAction<ZipOutputStream>() {
        @Override
        protected void doExecute(ZipOutputStream jarOutputStream) throws Exception {
            processFiles(jarOutputStream, files, new byte[BUFFER_SIZE], new HashSet<String>(), new LinkedHashMap<String, List<String>>(), progressLogger);
            jarOutputStream.finish();
        }
    });

    GFileUtils.moveFile(tmpFile, outputJar);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:14,代码来源:RuntimeShadedJarCreator.java


注:本文中的org.gradle.internal.IoActions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。