public static Archetype buildArchetype(String packageName) { Map<String,URL> resources = MoreResources.findResources(packageName, Pattern.compile(".*"), true); ImmutableList.Builder<ArchetypeEntry> builder = ImmutableList.builder(); for (String r : resources.keySet()) { if (r.substring(r.lastIndexOf('/') + 1).startsWith("_")) { builder.add(buildTemplate(packageName.replace('.', '/') + '/', r.substring(packageName.length() + 1))); } else { builder.add(new StaticArchetypeEntry(r.substring(packageName.length() + 1), Resources.asByteSource(Resources.getResource(r)))); } } return new Archetype(builder.build()); }
if (descriptor.useSrvuiLayout) { Path uiModulePath = appPath.resolve("ui"); rootMainTemplates.generate(appPath, scope); Archetype.buildArchetype(tplDir.toPath()).generate(uiModulePath, scope); useGruntBower = uiModulePath.resolve("bower.json").toFile().exists(); rootGruntBowerTemplates.generate(appPath, scope); } else { rootNoNodeTemplates.generate(appPath, scope); srvMainTemplates.generate(srvModulePath, scope); if (descriptor.buildFiles.contains(ModuleDescriptorType.IVY)) { shell.println("generating module.ivy ..."); srvHelloResourceTemplates.generate(srvModulePath, scope);
public static Archetype buildArchetype(final Path basePath) { try { final ImmutableList.Builder<ArchetypeEntry> builder = ImmutableList.builder(); Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { String name = basePath.relativize(file).toString(); if (file.getFileName().toString().startsWith("_")) { builder.add(buildTemplate(name, asCharSource(file.toFile(), Charsets.UTF_8))); } else { builder.add(new StaticArchetypeEntry(name, asByteSource(file.toFile()))); } return FileVisitResult.CONTINUE; } }); return new Archetype(builder.build()); } catch (IOException e) { throw new RuntimeException(e); } }
public static Archetype buildArchetype(final Path basePath) { try { final ImmutableList.Builder<ArchetypeEntry> builder = ImmutableList.builder(); Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { String name = basePath.relativize(file).toString(); if (file.getFileName().toString().startsWith("_")) { builder.add(buildTemplate(name, asCharSource(file.toFile(), Charsets.UTF_8))); } else { builder.add(new StaticArchetypeEntry(name, asByteSource(file.toFile()))); } return FileVisitResult.CONTINUE; } }); return new Archetype(builder.build()); } catch (IOException e) { throw new RuntimeException(e); } }
public static Archetype buildArchetype(String packageName) { Map<String,URL> resources = MoreResources.findResources(packageName, Pattern.compile(".*"), true); ImmutableList.Builder<ArchetypeEntry> builder = ImmutableList.builder(); for (String r : resources.keySet()) { if (r.substring(r.lastIndexOf('/') + 1).startsWith("_")) { builder.add(buildTemplate(packageName.replace('.', '/') + '/', r.substring(packageName.length() + 1))); } else { builder.add(new StaticArchetypeEntry(r.substring(packageName.length() + 1), Resources.asByteSource(Resources.getResource(r)))); } } return new Archetype(builder.build()); }