- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.android.tools.build.bundletool.io.ZipBuilder.<init>()
方法的一些代码示例,展示了ZipBuilder.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipBuilder.<init>()
方法的具体详情如下:
包路径:com.android.tools.build.bundletool.io.ZipBuilder
类名称:ZipBuilder
方法名:<init>
暂无
代码示例来源:origin: google/bundletool
public ApkSetArchiveBuilder(
SplitApkSerializer splitApkSerializer,
StandaloneApkSerializer standaloneApkSerializer,
Path tempDirectory) {
this.splitApkSerializer = splitApkSerializer;
this.standaloneApkSerializer = standaloneApkSerializer;
this.tempDirectory = tempDirectory;
this.apkSetZipBuilder = new ZipBuilder();
}
代码示例来源:origin: google/bundletool
private ZipFile createZipFileWithFiles(String... fileNames) throws IOException {
ZipBuilder zipBuilder = new ZipBuilder();
for (String fileName : fileNames) {
zipBuilder.addFileWithContent(ZipPath.create(fileName), new byte[1]);
}
Path zipPath = zipBuilder.writeTo(tmp.getRoot().toPath().resolve("output.jar"));
return new ZipFile(zipPath.toFile());
}
}
代码示例来源:origin: google/bundletool
@Test
public void validateBundleZipEntry_file_ok() throws Exception {
Path bundlePath =
new ZipBuilder()
.addFileWithContent(ZipPath.create("file.txt"), DUMMY_CONTENT)
.writeTo(tempFolder.resolve("bundle.aab"));
try (ZipFile bundleZip = new ZipFile(bundlePath.toFile())) {
ArrayList<? extends ZipEntry> entries = Collections.list(bundleZip.entries());
// Sanity check.
assertThat(entries).hasSize(1);
new BundleZipValidator().validateBundleZipEntry(bundleZip, entries.get(0));
}
}
}
代码示例来源:origin: google/bundletool
public static Path createApksArchiveFile(BuildApksResult result, Path location) throws Exception {
ZipBuilder archiveBuilder = new ZipBuilder();
result.getVariantList().stream()
.flatMap(variant -> variant.getApkSetList().stream())
.flatMap(apkSet -> apkSet.getApkDescriptionList().stream())
.forEach(
apkDesc ->
archiveBuilder.addFileWithContent(ZipPath.create(apkDesc.getPath()), DUMMY_BYTES));
archiveBuilder.addFileWithProtoContent(ZipPath.create("toc.pb"), result);
return archiveBuilder.writeTo(location);
}
代码示例来源:origin: google/bundletool
private Path createSimpleBaseModule() throws IOException {
return new ZipBuilder()
.addFileWithProtoContent(
ZipPath.create("manifest/AndroidManifest.xml"), androidManifest(PKG_NAME))
.writeTo(tmpDir.resolve("base.zip"));
}
代码示例来源:origin: google/bundletool
@Test
public void moduleZipFile_withAllMandatoryFiles_ok() throws Exception {
Path modulePath =
new ZipBuilder()
.addFileWithContent(ZipPath.create("manifest/AndroidManifest.xml"), DUMMY_CONTENT)
.writeTo(tempFolder.resolve("base.zip"));
try (ZipFile moduleZip = new ZipFile(modulePath.toFile())) {
new MandatoryFilesPresenceValidator().validateModuleZipFile(moduleZip);
}
}
代码示例来源:origin: google/bundletool
private static ZipBuilder createBasicZipBuilder(BundleConfig config) {
ZipBuilder zipBuilder = new ZipBuilder();
zipBuilder.addFileWithContent(ZipPath.create("BundleConfig.pb"), config.toByteArray());
return zipBuilder;
}
代码示例来源:origin: google/bundletool
@Test
public void validateBundleZipFile_invokesRightSubValidatorMethods() throws Exception {
Path bundlePath =
new ZipBuilder()
.addDirectory(ZipPath.create("directory"))
.addFileWithContent(ZipPath.create("file.txt"), DUMMY_CONTENT)
.writeTo(tempFolder.resolve("bundle.aab"));
try (ZipFile bundleZip = new ZipFile(bundlePath.toFile())) {
new ValidatorRunner(ImmutableList.of(validator)).validateBundleZipFile(bundleZip);
ArgumentCaptor<ZipEntry> zipEntryArgs = ArgumentCaptor.forClass(ZipEntry.class);
verify(validator).validateBundleZipFile(eq(bundleZip));
verify(validator, atLeastOnce())
.validateBundleZipEntry(eq(bundleZip), zipEntryArgs.capture());
verifyNoMoreInteractions(validator);
assertThat(zipEntryArgs.getAllValues().stream().map(ZipEntry::getName))
.containsExactly("directory/", "file.txt");
}
}
代码示例来源:origin: google/bundletool
@Test
public void validateModuleZipFile_invokesRightSubValidatorMethods() throws Exception {
Path modulePath =
new ZipBuilder()
.addDirectory(ZipPath.create("module"))
.addFileWithContent(ZipPath.create("module/file.txt"), DUMMY_CONTENT)
.writeTo(tempFolder.resolve("module.zip"));
try (ZipFile moduleZip = new ZipFile(modulePath.toFile())) {
new ValidatorRunner(ImmutableList.of(validator)).validateModuleZipFile(moduleZip);
verify(validator).validateModuleZipFile(eq(moduleZip));
verifyNoMoreInteractions(validator);
}
}
}
代码示例来源:origin: google/bundletool
@Test
public void validateBundleZipEntry_directory_throws() throws Exception {
Path bundlePath =
new ZipBuilder()
.addDirectory(ZipPath.create("directory"))
.writeTo(tempFolder.resolve("bundle.aab"));
try (ZipFile bundleZip = new ZipFile(bundlePath.toFile())) {
ArrayList<? extends ZipEntry> entries = Collections.list(bundleZip.entries());
// Sanity check.
assertThat(entries).hasSize(1);
ValidationException exception =
assertThrows(
ValidationException.class,
() -> new BundleZipValidator().validateBundleZipEntry(bundleZip, entries.get(0)));
assertThat(exception).hasMessageThat().contains("zip file contains directory zip entry");
}
}
代码示例来源:origin: google/bundletool
@Test
public void bundleZipFile_withAllMandatoryFiles_ok() throws Exception {
Path bundlePath =
new ZipBuilder()
.addFileWithContent(ZipPath.create("base/manifest/AndroidManifest.xml"), DUMMY_CONTENT)
.addFileWithContent(ZipPath.create("BundleConfig.pb"), DUMMY_CONTENT)
.writeTo(tempFolder.resolve("bundle.aab"));
try (ZipFile bundleZip = new ZipFile(bundlePath.toFile())) {
new MandatoryFilesPresenceValidator().validateBundleZipFile(bundleZip);
}
}
}
代码示例来源:origin: google/bundletool
@Test
public void bundleZipFile_withoutBundleConfig_throws() throws Exception {
Path bundlePath =
new ZipBuilder()
.addFileWithContent(ZipPath.create("base/manifest/AndroidManifest.xml"), DUMMY_CONTENT)
.writeTo(tempFolder.resolve("bundle.aab"));
try (ZipFile bundleZip = new ZipFile(bundlePath.toFile())) {
MandatoryBundleFileMissingException exception =
assertThrows(
MandatoryBundleFileMissingException.class,
() -> new MandatoryFilesPresenceValidator().validateBundleZipFile(bundleZip));
assertThat(exception).hasMessageThat().contains("missing required file 'BundleConfig.pb'");
}
}
代码示例来源:origin: google/bundletool
private Path buildSimpleModule(String moduleName) throws IOException {
ManifestMutator[] manifestMutators =
moduleName.equals("base")
? new ManifestMutator[0]
: new ManifestMutator[] {withSplitId(moduleName)};
return new ZipBuilder()
.addFileWithProtoContent(
ZipPath.create("manifest/AndroidManifest.xml"),
androidManifest(PKG_NAME, manifestMutators))
.writeTo(FileUtils.getRandomFilePath(tmp, moduleName, ".zip"));
}
代码示例来源:origin: google/bundletool
@Test
public void directoryZipEntriesInModuleFiles_notIncludedInBundle() throws Exception {
Path tmpBaseModulePath = Files.move(buildSimpleModule("base"), tmpDir.resolve("base.zip.tmp"));
Path baseModulePath;
// Copy the valid bundle, only add a directory zip entry.
try (ZipFile tmpBaseModuleZip = new ZipFile(tmpBaseModulePath.toFile())) {
baseModulePath =
new ZipBuilder()
.copyAllContentsFromZip(ZipPath.create(""), tmpBaseModuleZip)
.addDirectory(ZipPath.create("directory-entry"))
.writeTo(tmpDir.resolve("base.zip"));
}
BuildBundleCommand.builder()
.setOutputPath(bundlePath)
.setModulesPaths(ImmutableList.of(baseModulePath))
.build()
.execute();
try (ZipFile bundleZip = new ZipFile(bundlePath.toFile())) {
assertThat(Collections.list(bundleZip.entries()).stream().filter(ZipEntry::isDirectory))
.isEmpty();
}
}
代码示例来源:origin: google/bundletool
@Test
public void moduleZipFile_withoutAndroidManifest_throws() throws Exception {
Path modulePath =
new ZipBuilder()
.addFileWithContent(ZipPath.create("assets/file.txt"), DUMMY_CONTENT)
.writeTo(tempFolder.resolve("base.zip"));
try (ZipFile moduleZip = new ZipFile(modulePath.toFile())) {
MandatoryModuleFileMissingException exception =
assertThrows(
MandatoryModuleFileMissingException.class,
() -> new MandatoryFilesPresenceValidator().validateModuleZipFile(moduleZip));
assertThat(exception)
.hasMessageThat()
.contains("Module 'base' is missing mandatory file 'manifest/AndroidManifest.xml'");
}
}
代码示例来源:origin: google/bundletool
@Test
public void moduleWithWrongExtension_throws() throws Exception {
Path nonZipModule = new ZipBuilder().writeTo(tmpDir.resolve("not_a_zip.txt"));
IllegalArgumentException exception =
assertThrows(
IllegalArgumentException.class,
() ->
BuildBundleCommand.builder()
.setOutputPath(bundlePath)
.setModulesPaths(ImmutableList.of(nonZipModule))
.build()
.execute());
assertThat(exception).hasMessageThat().contains("expected to have '.zip' extension");
}
代码示例来源:origin: google/bundletool
@Test
public void bundleZipFile_withoutAndroidManifestInModule_throws() throws Exception {
Path bundlePath =
new ZipBuilder()
.addFileWithContent(ZipPath.create("base/assets/file.txt"), DUMMY_CONTENT)
.addFileWithContent(ZipPath.create("BundleConfig.pb"), DUMMY_CONTENT)
.writeTo(tempFolder.resolve("bundle.aab"));
try (ZipFile bundleZip = new ZipFile(bundlePath.toFile())) {
MandatoryModuleFileMissingException exception =
assertThrows(
MandatoryModuleFileMissingException.class,
() -> new MandatoryFilesPresenceValidator().validateBundleZipFile(bundleZip));
assertThat(exception)
.hasMessageThat()
.contains("Module 'base' is missing mandatory file 'manifest/AndroidManifest.xml'");
}
}
代码示例来源:origin: google/bundletool
@Test
public void runsBundleFilesValidator_rogueFileInModuleRoot_throws() throws Exception {
Path module =
new ZipBuilder()
.addFileWithContent(ZipPath.create("rogue.txt"), "".getBytes(UTF_8))
.addFileWithProtoContent(
ZipPath.create("manifest/AndroidManifest.xml"), androidManifest(PKG_NAME))
.writeTo(tmpDir.resolve("base.zip"));
BuildBundleCommand command =
BuildBundleCommand.builder()
.setOutputPath(bundlePath)
.setModulesPaths(ImmutableList.of(module))
.build();
ValidationException exception =
assertThrows(ValidationException.class, () -> command.execute());
assertThat(exception)
.hasMessageThat()
.contains("Module files can be only in pre-defined directories");
}
代码示例来源:origin: google/bundletool
@Test
public void runsResourceTableValidator_resourceTableReferencingNonExistingFile_throws()
throws Exception {
ResourceTable resourceTable =
new ResourceTableBuilder()
.addPackage(PKG_NAME)
.addDrawableResource("icon", "res/drawable/icon.png")
.build();
Path module =
new ZipBuilder()
.addFileWithProtoContent(ZipPath.create("resources.pb"), resourceTable)
.addFileWithProtoContent(
ZipPath.create("manifest/AndroidManifest.xml"), androidManifest(PKG_NAME))
.writeTo(tmpDir.resolve("base.zip"));
BuildBundleCommand command =
BuildBundleCommand.builder()
.setOutputPath(bundlePath)
.setModulesPaths(ImmutableList.of(module))
.build();
ValidationException exception =
assertThrows(ValidationException.class, () -> command.execute());
assertThat(exception).hasMessageThat().contains("contains references to non-existing files");
}
代码示例来源:origin: google/bundletool
@Test
public void bundleWithDirectoryZipEntries_throws() throws Exception {
Path tmpBundlePath = FileUtils.getRandomFilePath(tmp, "bundle-", ".aab");
AppBundle tmpBundle =
new AppBundleBuilder()
.addModule("base", module -> module.setManifest(androidManifest("com.app")))
.build();
bundleSerializer.writeToDisk(tmpBundle, tmpBundlePath);
// Copy the valid bundle, only add a directory zip entry.
try (ZipFile tmpBundleZip = new ZipFile(tmpBundlePath.toFile())) {
bundlePath =
new ZipBuilder()
.copyAllContentsFromZip(ZipPath.create(""), tmpBundleZip)
.addDirectory(ZipPath.create("directory-entries-are-forbidden"))
.writeTo(FileUtils.getRandomFilePath(tmp, "bundle-", ".aab"));
}
BuildApksCommand command =
BuildApksCommand.builder()
.setBundlePath(bundlePath)
.setOutputFile(outputFilePath)
.setAapt2Command(aapt2Command)
.build();
ValidationException exception = assertThrows(ValidationException.class, () -> execute(command));
assertThat(exception)
.hasMessageThat()
.contains("zip file contains directory zip entry 'directory-entries-are-forbidden/'");
}
Xcode 4 中的以下操作有什么作用? 为测试而构建 为运行而构建 为分析而构建 为存档而构建 我不确定何时使用这些(或是否使用其中任何一个)。 最佳答案 Running 用于运行您的应用(在 Ma
工具: Jenkins 版1.470 Maven 2 颠覆 环境 假设我的构建有许多项目 A-D。如图所示,依赖关系图存在。也就是说:B 依赖于 A 中的类,C 依赖于 B 中的类,D 依赖于 A 中
我正在创建一个软件项目,我想使用 autotools 为我生成 makefile 等脚本,我手动创建了 Makefile.am 和 configure.in 文件,我正在使用 autogen.sh 脚
什么yarn build命令做什么? 是 yarn build和 npm build相同?如果不是有什么区别? 最佳答案 yarn build和 npm build默认情况下不是现有的命令。我想你是说
如果我有一个包含许多相互依赖的项目的大型代码库,例如,projects/A、projects/B 和 projects/C ,其中 A 需要 B,B 需要 C,每个项目都有一个Cake 构建脚本,例如
我正在尝试使用 Wix/Detox 来测试我的 react-native 应用程序(iOS 版本)。我已成功遵循 https://github.com/wix/detox/blob/master/do
我们有许多编译 .NET 代码的 Nant 脚本。这些构建需要 5 到 10 分钟才能运行,我想找到一种方法来加速它们。 我们的 Nant 脚本看起来像
你好 当我在 windows 下使用 gnu 构建 ffmpeg-3.4.1 时,谁能帮我解决这个错误: /tmp/9747a756ee05ef34cc3fcf51eabde826/sysroot/u
构建解决方案/项目/程序意味着什么?我想确保我的定义是正确的(所以我在交谈时听起来不像个白痴)。在 IDE 中,您可以(如果我错了,请纠正我)编译源代码/编程代码为计算机可读的机器代码。您可以调试程序
为什么 Eclipse 在构建 Android 项目时会陷入无限循环,用于构建工作区...和(重新)构建工作区...和(重新)构建工作区... 这是一个已知的错误吗? 摆脱这个循环的正确方法是什么?
我的 Angular 项目是 @Angular4.3.3 ng build -prod 构建需要 77 秒 ng build --prod --build-optimizer=true 构建需要 19
所以我刚刚使用命令创建了一个 React Native 项目 react-native init "项目名称" 我进入应用程序级别的 build.gradle 以连接 firebase,但出现错误提示
我想弄清楚 TFS Online 2017 中的两个预定义变量之间是否存在差异:$(Build.Repository.LocalPath)和 $(Build.SourcesDirectory) .我有
编译项目时,当系统用户名匹配时,此脚本应将 Xcode 项目的构建版本递增 1。请记住,这些只是 Target->Build Phases->Run Script in Xcode 中脚本(不是 Ap
是否有一种工具可以在给定 MS Build 项目文件的情况下构建一个视觉对象,显示将在何时以及从哪个导入文件执行哪个目标? 如果给定一个解决方案文件,它会构建项目构建顺序的视觉效果? 最佳答案 是的,
我正在尝试使用 Bazel 进行以下设置。通过调用“bazel build”,Python 脚本应该生成未知数量的具有随机名称的 *.cc 文件,然后将这些文件编译成单个静态库(.a 文件),所有这些
我正在将我的 Cmake 项目迁移到 Bazel。我项目的根目录是 build我用来运行 Cmake 的文件夹。 迁移到 Bazel ,我需要创建一个 BUILD我的项目根目录下的文件。但是,在 ma
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 5 年前。 此帖子已于
当我的Dockerfile如下所示时,它运行良好。 ... RUN pip install git+https://user_name:my_password@github.com/repo_name
当前的自动构建功能集是否可以从存储库中添加新标签并标记生成的图像?还是我需要3party服务将新标签自动推送到Docker Registry? 最佳答案 目前不行。 当前(2014年10月)尚无Doc
我是一名优秀的程序员,十分优秀!