@Test public void testBasicTinyDir() throws Exception { File templates[] = templates( new File("../third_party/tinydir/")); File output = new File(".test-files/testBasicTinyDir").getAbsoluteFile(); List<File> result = Fullfill.multiple(environment, templates, output, new File("../third_party/tinydir"), "1.2.3"); assertThat(result).hasSize(2); }
@NotNull public static List<File> multiple( GeneratorEnvironment environment, @NotNull File templates[], File outputFolder, @NotNull File sourceFolder, String version) throws IOException, NoSuchAlgorithmException { List<File> result = new ArrayList<>(); CDepManifestYml manifests[] = new CDepManifestYml[templates.length]; File layout = new File(outputFolder, "layout"); if (!layout.isDirectory()) { layout.mkdirs(); } File staging = new File(outputFolder, "staging"); if (!staging.isDirectory()) { staging.mkdirs(); } for (int i = 0; i < manifests.length; ++i) { String body = FileUtils.readAllText(templates[i]); manifests[i] = CDepManifestYmlUtils.convertStringToManifest(body); } SubstituteStringsRewriter substitutor = new SubstituteStringsRewriter() .replace("${source}", sourceFolder.getAbsolutePath()) .replace("${layout}", layout.getAbsolutePath()) .replace("${version}", version); for (int i = 0; i < manifests.length; ++i) { manifests[i] = substitutor.visitCDepManifestYml(manifests[i]); } Resolver resolver = new Resolver(environment); ResolutionScope scope = new ResolutionScope(); infoln("Fullfilling %s manifests", templates.length); for (int i = 0; i < manifests.length; ++i) { Coordinate coordinate = manifests[i].coordinate; FillMissingFieldsBasedOnFilepathRewriter filler = new FillMissingFieldsBasedOnFilepathRewriter(); infoln(" guessing archive details from path names in %s", coordinate); manifests[i] = filler.visitCDepManifestYml(manifests[i]); if (errorsInScope() > 0) { return result; } ZipFilesRewriter zipper = new ZipFilesRewriter(layout, staging); infoln(" zipping files referenced in %s", coordinate); manifests[i] = zipper.visitCDepManifestYml(manifests[i]); result.addAll(zipper.getZips()); if (errorsInScope() > 0) { return result; } FileHashAndSizeRewriter hasher = new FileHashAndSizeRewriter(layout); infoln(" computing hashes and file sizes of archives in %s", coordinate); manifests[i] = hasher.visitCDepManifestYml(manifests[i]); if (errorsInScope() > 0) { return result; } DependencyHashRewriter dependencyHasher = new DependencyHashRewriter(environment); infoln(" hashing dependencies in %s", coordinate); manifests[i] = dependencyHasher.visitCDepManifestYml(manifests[i]); if (errorsInScope() > 0) { return result; } File output = new File(layout, templates[i].getName()); infoln(" writing manifest file %s", new File(".") .toURI().relativize(output.toURI()).getPath()); String body = CDepManifestYmlUtils.convertManifestToString(manifests[i]); FileUtils.writeTextToFile(output, body); result.add(output); if (errorsInScope() > 0) { return result; } infoln(" checking sanity of result %s", coordinate); CDepManifestYml readFromDisk = CDepManifestYmlUtils.convertStringToManifest( FileUtils.readAllText(output)); CDepManifestYmlEquality.areDeeplyIdentical(manifests[i], readFromDisk); if (errorsInScope() > 0) { return result; } CDepManifestYmlUtils.checkManifestSanity(manifests[i]); SoftNameDependency softname = new SoftNameDependency(coordinate.toString()); scope.addUnresolved(softname); scope.recordResolved( softname, new ResolvedManifest(output.toURI().toURL(), manifests[i]), CDepManifestYmlUtils.getTransitiveDependencies(manifests[i])); if (errorsInScope() > 0) { return result; } } infoln(" checking consistency of all manifests"); resolver.resolveAll(scope); BuildFindModuleFunctionTable table = new BuildFindModuleFunctionTable(); GeneratorEnvironmentUtils.addAllResolvedToTable(table, scope); table.build(); if (errorsInScope() > 0) { return result; } return result; }
Fullfill { @NotNull public static List<File> multiple( GeneratorEnvironment environment, @NotNull File templates[], File outputFolder, @NotNull File sourceFolder, String version) throws IOException, NoSuchAlgorithmException { List<File> result = new ArrayList<>(); CDepManifestYml manifests[] = new CDepManifestYml[templates.length]; File layout = new File(outputFolder, "layout"); if (!layout.isDirectory()) { layout.mkdirs(); } File staging = new File(outputFolder, "staging"); if (!staging.isDirectory()) { staging.mkdirs(); } for (int i = 0; i < manifests.length; ++i) { String body = FileUtils.readAllText(templates[i]); manifests[i] = CDepManifestYmlUtils.convertStringToManifest(body); } SubstituteStringsRewriter substitutor = new SubstituteStringsRewriter() .replace("${source}", sourceFolder.getAbsolutePath()) .replace("${layout}", layout.getAbsolutePath()) .replace("${version}", version); for (int i = 0; i < manifests.length; ++i) { manifests[i] = substitutor.visitCDepManifestYml(manifests[i]); } Resolver resolver = new Resolver(environment); ResolutionScope scope = new ResolutionScope(); infoln("Fullfilling %s manifests", templates.length); for (int i = 0; i < manifests.length; ++i) { Coordinate coordinate = manifests[i].coordinate; FillMissingFieldsBasedOnFilepathRewriter filler = new FillMissingFieldsBasedOnFilepathRewriter(); infoln(" guessing archive details from path names in %s", coordinate); manifests[i] = filler.visitCDepManifestYml(manifests[i]); if (errorsInScope() > 0) { return result; } ZipFilesRewriter zipper = new ZipFilesRewriter(layout, staging); infoln(" zipping files referenced in %s", coordinate); manifests[i] = zipper.visitCDepManifestYml(manifests[i]); result.addAll(zipper.getZips()); if (errorsInScope() > 0) { return result; } FileHashAndSizeRewriter hasher = new FileHashAndSizeRewriter(layout); infoln(" computing hashes and file sizes of archives in %s", coordinate); manifests[i] = hasher.visitCDepManifestYml(manifests[i]); if (errorsInScope() > 0) { return result; } DependencyHashRewriter dependencyHasher = new DependencyHashRewriter(environment); infoln(" hashing dependencies in %s", coordinate); manifests[i] = dependencyHasher.visitCDepManifestYml(manifests[i]); if (errorsInScope() > 0) { return result; } File output = new File(layout, templates[i].getName()); infoln(" writing manifest file %s", new File(".") .toURI().relativize(output.toURI()).getPath()); String body = CDepManifestYmlUtils.convertManifestToString(manifests[i]); FileUtils.writeTextToFile(output, body); result.add(output); if (errorsInScope() > 0) { return result; } infoln(" checking sanity of result %s", coordinate); CDepManifestYml readFromDisk = CDepManifestYmlUtils.convertStringToManifest( FileUtils.readAllText(output)); CDepManifestYmlEquality.areDeeplyIdentical(manifests[i], readFromDisk); if (errorsInScope() > 0) { return result; } CDepManifestYmlUtils.checkManifestSanity(manifests[i]); SoftNameDependency softname = new SoftNameDependency(coordinate.toString()); scope.addUnresolved(softname); scope.recordResolved( softname, new ResolvedManifest(output.toURI().toURL(), manifests[i]), CDepManifestYmlUtils.getTransitiveDependencies(manifests[i])); if (errorsInScope() > 0) { return result; } } infoln(" checking consistency of all manifests"); resolver.resolveAll(scope); BuildFindModuleFunctionTable table = new BuildFindModuleFunctionTable(); GeneratorEnvironmentUtils.addAllResolvedToTable(table, scope); table.build(); if (errorsInScope() > 0) { return result; } return result; } }
Fullfill { @NotNull public static List<File> multiple( GeneratorEnvironment environment, @NotNull File templates[], File outputFolder, @NotNull File sourceFolder, String version) throws IOException, NoSuchAlgorithmException { List<File> result = new ArrayList<>(); CDepManifestYml manifests[] = new CDepManifestYml[templates.length]; File layout = new File(outputFolder, "layout"); if (!layout.isDirectory()) { layout.mkdirs(); } File staging = new File(outputFolder, "staging"); if (!staging.isDirectory()) { staging.mkdirs(); } for (int i = 0; i < manifests.length; ++i) { String body = FileUtils.readAllText(templates[i]); manifests[i] = CDepManifestYmlUtils.convertStringToManifest(body); } SubstituteStringsRewriter substitutor = new SubstituteStringsRewriter() .replace("${source}", sourceFolder.getAbsolutePath()) .replace("${layout}", layout.getAbsolutePath()) .replace("${version}", version); for (int i = 0; i < manifests.length; ++i) { manifests[i] = substitutor.visitCDepManifestYml(manifests[i]); } Resolver resolver = new Resolver(environment); ResolutionScope scope = new ResolutionScope(); infoln("Fullfilling %s manifests", templates.length); for (int i = 0; i < manifests.length; ++i) { Coordinate coordinate = manifests[i].coordinate; FillMissingFieldsBasedOnFilepathRewriter filler = new FillMissingFieldsBasedOnFilepathRewriter(); infoln(" guessing archive details from path names in %s", coordinate); manifests[i] = filler.visitCDepManifestYml(manifests[i]); if (errorsInScope() > 0) { return result; } ZipFilesRewriter zipper = new ZipFilesRewriter(layout, staging); infoln(" zipping files referenced in %s", coordinate); manifests[i] = zipper.visitCDepManifestYml(manifests[i]); result.addAll(zipper.getZips()); if (errorsInScope() > 0) { return result; } FileHashAndSizeRewriter hasher = new FileHashAndSizeRewriter(layout); infoln(" computing hashes and file sizes of archives in %s", coordinate); manifests[i] = hasher.visitCDepManifestYml(manifests[i]); if (errorsInScope() > 0) { return result; } DependencyHashRewriter dependencyHasher = new DependencyHashRewriter(environment); infoln(" hashing dependencies in %s", coordinate); manifests[i] = dependencyHasher.visitCDepManifestYml(manifests[i]); if (errorsInScope() > 0) { return result; } File output = new File(layout, templates[i].getName()); infoln(" writing manifest file %s", new File(".") .toURI().relativize(output.toURI()).getPath()); String body = CDepManifestYmlUtils.convertManifestToString(manifests[i]); FileUtils.writeTextToFile(output, body); result.add(output); if (errorsInScope() > 0) { return result; } infoln(" checking sanity of result %s", coordinate); CDepManifestYml readFromDisk = CDepManifestYmlUtils.convertStringToManifest( FileUtils.readAllText(output)); CDepManifestYmlEquality.areDeeplyIdentical(manifests[i], readFromDisk); if (errorsInScope() > 0) { return result; } CDepManifestYmlUtils.checkManifestSanity(manifests[i]); SoftNameDependency softname = new SoftNameDependency(coordinate.toString()); scope.addUnresolved(softname); scope.recordResolved( softname, new ResolvedManifest(output.toURI().toURL(), manifests[i]), CDepManifestYmlUtils.getTransitiveDependencies(manifests[i])); if (errorsInScope() > 0) { return result; } } infoln(" checking consistency of all manifests"); resolver.resolveAll(scope); BuildFindModuleFunctionTable table = new BuildFindModuleFunctionTable(); GeneratorEnvironmentUtils.addAllResolvedToTable(table, scope); table.build(); if (errorsInScope() > 0) { return result; } return result; }  }
Fullfill { @NotNull public static List<File> multiple( GeneratorEnvironment environment, @NotNull File templates[], File outputFolder, @NotNull File sourceFolder, String version) throws IOException, NoSuchAlgorithmException { List<File> result = new ArrayList<>(); CDepManifestYml manifests[] = new CDepManifestYml[templates.length]; File layout = new File(outputFolder, "layout"); if (!layout.isDirectory()) { layout.mkdirs(); } File staging = new File(outputFolder, "staging"); if (!staging.isDirectory()) { staging.mkdirs(); } for (int i = 0; i < manifests.length; ++i) { String body = FileUtils.readAllText(templates[i]); manifests[i] = CDepManifestYmlUtils.convertStringToManifest(body); } SubstituteStringsRewriter substitutor = new SubstituteStringsRewriter() .replace("${source}", sourceFolder.getAbsolutePath()) .replace("${layout}", layout.getAbsolutePath()) .replace("${version}", version); for (int i = 0; i < manifests.length; ++i) { manifests[i] = substitutor.visitCDepManifestYml(manifests[i]); } Resolver resolver = new Resolver(environment); ResolutionScope scope = new ResolutionScope(); infoln("Fullfilling %s manifests", templates.length); for (int i = 0; i < manifests.length; ++i) { Coordinate coordinate = manifests[i].coordinate; FillMissingFieldsBasedOnFilepathRewriter filler = new FillMissingFieldsBasedOnFilepathRewriter(); infoln(" guessing archive details from path names in %s", coordinate); manifests[i] = filler.visitCDepManifestYml(manifests[i]); if (errorsInScope() > 0) { return result; } ZipFilesRewriter zipper = new ZipFilesRewriter(layout, staging); infoln(" zipping files referenced in %s", coordinate); manifests[i] = zipper.visitCDepManifestYml(manifests[i]); result.addAll(zipper.getZips()); if (errorsInScope() > 0) { return result; } FileHashAndSizeRewriter hasher = new FileHashAndSizeRewriter(layout); infoln(" computing hashes and file sizes of archives in %s", coordinate); manifests[i] = hasher.visitCDepManifestYml(manifests[i]); if (errorsInScope() > 0) { return result; } DependencyHashRewriter dependencyHasher = new DependencyHashRewriter(environment); infoln(" hashing dependencies in %s", coordinate); manifests[i] = dependencyHasher.visitCDepManifestYml(manifests[i]); if (errorsInScope() > 0) { return result; } File output = new File(layout, templates[i].getName()); infoln(" writing manifest file %s", new File(".") .toURI().relativize(output.toURI()).getPath()); String body = CDepManifestYmlUtils.convertManifestToString(manifests[i]); FileUtils.writeTextToFile(output, body); result.add(output); if (errorsInScope() > 0) { return result; } infoln(" checking sanity of result %s", coordinate); CDepManifestYml readFromDisk = CDepManifestYmlUtils.convertStringToManifest( FileUtils.readAllText(output)); CDepManifestYmlEquality.areDeeplyIdentical(manifests[i], readFromDisk); if (errorsInScope() > 0) { return result; } CDepManifestYmlUtils.checkManifestSanity(manifests[i]); SoftNameDependency softname = new SoftNameDependency(coordinate.toString()); scope.addUnresolved(softname); scope.recordResolved( softname, new ResolvedManifest(output.toURI().toURL(), manifests[i]), CDepManifestYmlUtils.getTransitiveDependencies(manifests[i])); if (errorsInScope() > 0) { return result; } } infoln(" checking consistency of all manifests"); resolver.resolveAll(scope); BuildFindModuleFunctionTable table = new BuildFindModuleFunctionTable(); GeneratorEnvironmentUtils.addAllResolvedToTable(table, scope); table.build(); if (errorsInScope() > 0) { return result; } return result; }  @NotNull static List<File> multiple(
      GeneratorEnvironment environment,
      @NotNull File templates[],
      File outputFolder,
      @NotNull File sourceFolder,
      String version); }
Fullfill { @NotNull public static List<File> multiple( GeneratorEnvironment environment, @NotNull File templates[], File outputFolder, @NotNull File sourceFolder, String version) throws IOException, NoSuchAlgorithmException { List<File> result = new ArrayList<>(); CDepManifestYml manifests[] = new CDepManifestYml[templates.length]; File layout = new File(outputFolder, "layout"); if (!layout.isDirectory()) { layout.mkdirs(); } File staging = new File(outputFolder, "staging"); if (!staging.isDirectory()) { staging.mkdirs(); } for (int i = 0; i < manifests.length; ++i) { String body = FileUtils.readAllText(templates[i]); manifests[i] = CDepManifestYmlUtils.convertStringToManifest(body); } SubstituteStringsRewriter substitutor = new SubstituteStringsRewriter() .replace("${source}", sourceFolder.getAbsolutePath()) .replace("${layout}", layout.getAbsolutePath()) .replace("${version}", version); for (int i = 0; i < manifests.length; ++i) { manifests[i] = substitutor.visitCDepManifestYml(manifests[i]); } Resolver resolver = new Resolver(environment); ResolutionScope scope = new ResolutionScope(); infoln("Fullfilling %s manifests", templates.length); for (int i = 0; i < manifests.length; ++i) { Coordinate coordinate = manifests[i].coordinate; FillMissingFieldsBasedOnFilepathRewriter filler = new FillMissingFieldsBasedOnFilepathRewriter(); infoln(" guessing archive details from path names in %s", coordinate); manifests[i] = filler.visitCDepManifestYml(manifests[i]); if (errorsInScope() > 0) { return result; } ZipFilesRewriter zipper = new ZipFilesRewriter(layout, staging); infoln(" zipping files referenced in %s", coordinate); manifests[i] = zipper.visitCDepManifestYml(manifests[i]); result.addAll(zipper.getZips()); if (errorsInScope() > 0) { return result; } FileHashAndSizeRewriter hasher = new FileHashAndSizeRewriter(layout); infoln(" computing hashes and file sizes of archives in %s", coordinate); manifests[i] = hasher.visitCDepManifestYml(manifests[i]); if (errorsInScope() > 0) { return result; } DependencyHashRewriter dependencyHasher = new DependencyHashRewriter(environment); infoln(" hashing dependencies in %s", coordinate); manifests[i] = dependencyHasher.visitCDepManifestYml(manifests[i]); if (errorsInScope() > 0) { return result; } File output = new File(layout, templates[i].getName()); infoln(" writing manifest file %s", new File(".") .toURI().relativize(output.toURI()).getPath()); String body = CDepManifestYmlUtils.convertManifestToString(manifests[i]); FileUtils.writeTextToFile(output, body); result.add(output); if (errorsInScope() > 0) { return result; } infoln(" checking sanity of result %s", coordinate); CDepManifestYml readFromDisk = CDepManifestYmlUtils.convertStringToManifest( FileUtils.readAllText(output)); CDepManifestYmlEquality.areDeeplyIdentical(manifests[i], readFromDisk); if (errorsInScope() > 0) { return result; } CDepManifestYmlUtils.checkManifestSanity(manifests[i]); SoftNameDependency softname = new SoftNameDependency(coordinate.toString()); scope.addUnresolved(softname); scope.recordResolved( softname, new ResolvedManifest(output.toURI().toURL(), manifests[i]), CDepManifestYmlUtils.getTransitiveDependencies(manifests[i])); if (errorsInScope() > 0) { return result; } } infoln(" checking consistency of all manifests"); resolver.resolveAll(scope); BuildFindModuleFunctionTable table = new BuildFindModuleFunctionTable(); GeneratorEnvironmentUtils.addAllResolvedToTable(table, scope); table.build(); if (errorsInScope() > 0) { return result; } return result; }  @NotNull static List<File> multiple(
      GeneratorEnvironment environment,
      @NotNull File templates[],
      File outputFolder,
      @NotNull File sourceFolder,
      String version);  }