@Test public void buildAllExampleArchetypes() throws Exception { File srcDir = new File(basedir, "src/test/examples").getCanonicalFile(); try { List<String> dirs = new ArrayList<String>(); archetypeBuilder.generateArchetypes("java", srcDir, new File(basedir, "target/test-archetypes"), true, dirs); } finally { LOG.info("Completed the generation. Closing!"); } Collection<File> files = Files.recursiveList(new File("target/test-archetypes/java-hello-world-archetype"), new FilenameFilter() { @Override public boolean accept(File dir, String name) { return true; } }); String[] resources = new String[] { "", "/pom.xml", "/.gitignore", "/src", "/src/main", "/src/main/resources", "/src/main/resources/archetype-resources", "/src/main/resources/archetype-resources/ReadMe.txt", "/src/main/resources/archetype-resources/pom.xml", "/src/main/resources/archetype-resources/src", "/src/main/resources/archetype-resources/src/test", "/src/main/resources/archetype-resources/src/test/java", "/src/main/resources/archetype-resources/src/test/java/HelloTest.java", "/src/main/resources/archetype-resources/src/main", "/src/main/resources/archetype-resources/src/main/resources", "/src/main/resources/archetype-resources/src/main/resources/application.properties", "/src/main/resources/archetype-resources/src/main/java", "/src/main/resources/archetype-resources/src/main/java/impl", "/src/main/resources/archetype-resources/src/main/java/impl/DefaultHello.java", "/src/main/resources/archetype-resources/src/main/java/HelloInterface.java", "/src/main/resources-filtered", "/src/main/resources-filtered/META-INF", "/src/main/resources-filtered/META-INF/maven", "/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml", }; for (String r : resources) { File file = new File("target/test-archetypes/java-hello-world-archetype" + r); assertTrue(r + " should exists", files.remove(file)); } assertTrue("Failed to create correct Archetype project", files.isEmpty()); }
public void generateArchetypes(String containerType, File baseDir, File outputDir, boolean clean, List<String> dirs) throws IOException { LOG.debug("Generating archetypes from {} to {}", baseDir.getCanonicalPath(), outputDir.getCanonicalPath()); File[] files = baseDir.listFiles(); if (files != null) { for (File file: files) { if (file.isDirectory()) { File projectDir = file; File projectPom = new File(projectDir, "pom.xml"); if (projectPom.exists() && !skipImport(projectDir)) { if (archetypeUtils.isValidProjectPom(projectPom)) { String fileName = file.getName(); String archetypeDirName = fileName.replace("example", "archetype"); if (fileName.equals(archetypeDirName)) { archetypeDirName += "-archetype"; } archetypeDirName = containerType + "-" + archetypeDirName; File archetypeDir = new File(outputDir, archetypeDirName); generateArchetype(projectDir, projectPom, archetypeDir, clean, dirs); } else { String childContainerType = file.getName(); if (Strings.isNotBlank(containerType)) { childContainerType = containerType + "-" + childContainerType; } generateArchetypes(childContainerType, file, outputDir, clean, dirs); } } } } } }
ArchetypeBuilder extends AbstractBuilder { public void generateArchetypes(String containerType, File baseDir, File outputDir, boolean clean, List<String> dirs) throws IOException { LOG.debug("Generating archetypes from {} to {}", baseDir.getCanonicalPath(), outputDir.getCanonicalPath()); File[] files = baseDir.listFiles(); if (files != null) { for (File file: files) { if (file.isDirectory()) { File projectDir = file; File projectPom = new File(projectDir, "pom.xml"); if (projectPom.exists() && !skipImport(projectDir)) { if (archetypeUtils.isValidProjectPom(projectPom)) { String fileName = file.getName(); String archetypeDirName = fileName.replace("example", "archetype"); if (fileName.equals(archetypeDirName)) { archetypeDirName += "-archetype"; } archetypeDirName = containerType + "-" + archetypeDirName; File archetypeDir = new File(outputDir, archetypeDirName); generateArchetype(projectDir, projectPom, archetypeDir, clean, dirs); } else { String childContainerType = file.getName(); if (Strings.isNotBlank(containerType)) { childContainerType = containerType + "-" + childContainerType; } generateArchetypes(childContainerType, file, outputDir, clean, dirs); } } } } } } }
ArchetypeBuilder extends AbstractBuilder { public void generateArchetypes(String containerType, File baseDir, File outputDir, boolean clean, List<String> dirs) throws IOException { LOG.debug("Generating archetypes from {} to {}", baseDir.getCanonicalPath(), outputDir.getCanonicalPath()); File[] files = baseDir.listFiles(); if (files != null) { for (File file: files) { if (file.isDirectory()) { File projectDir = file; File projectPom = new File(projectDir, "pom.xml"); if (projectPom.exists() && !skipImport(projectDir)) { if (archetypeUtils.isValidProjectPom(projectPom)) { String fileName = file.getName(); String archetypeDirName = fileName.replace("example", "archetype"); if (fileName.equals(archetypeDirName)) { archetypeDirName += "-archetype"; } archetypeDirName = containerType + "-" + archetypeDirName; File archetypeDir = new File(outputDir, archetypeDirName); generateArchetype(projectDir, projectPom, archetypeDir, clean, dirs); } else { String childContainerType = file.getName(); if (Strings.isNotBlank(containerType)) { childContainerType = containerType + "-" + childContainerType; } generateArchetypes(childContainerType, file, outputDir, clean, dirs); } } } } } }  }
ArchetypeBuilder extends AbstractBuilder { public void generateArchetypes(String containerType, File baseDir, File outputDir, boolean clean, List<String> dirs) throws IOException { LOG.debug("Generating archetypes from {} to {}", baseDir.getCanonicalPath(), outputDir.getCanonicalPath()); File[] files = baseDir.listFiles(); if (files != null) { for (File file: files) { if (file.isDirectory()) { File projectDir = file; File projectPom = new File(projectDir, "pom.xml"); if (projectPom.exists() && !skipImport(projectDir)) { if (archetypeUtils.isValidProjectPom(projectPom)) { String fileName = file.getName(); String archetypeDirName = fileName.replace("example", "archetype"); if (fileName.equals(archetypeDirName)) { archetypeDirName += "-archetype"; } archetypeDirName = containerType + "-" + archetypeDirName; File archetypeDir = new File(outputDir, archetypeDirName); generateArchetype(projectDir, projectPom, archetypeDir, clean, dirs); } else { String childContainerType = file.getName(); if (Strings.isNotBlank(containerType)) { childContainerType = containerType + "-" + childContainerType; } generateArchetypes(childContainerType, file, outputDir, clean, dirs); } } } } } }  void generateArchetypesFromGithubOrganisation(String githubOrg, File outputDir, List<String> dirs); void generateArchetypesFromGitRepoList(File file, File outputDir, List<String> dirs); void generateArchetypes(String containerType, File baseDir, File outputDir, boolean clean, List<String> dirs); }
ArchetypeBuilder extends AbstractBuilder { public void generateArchetypes(String containerType, File baseDir, File outputDir, boolean clean, List<String> dirs) throws IOException { LOG.debug("Generating archetypes from {} to {}", baseDir.getCanonicalPath(), outputDir.getCanonicalPath()); File[] files = baseDir.listFiles(); if (files != null) { for (File file: files) { if (file.isDirectory()) { File projectDir = file; File projectPom = new File(projectDir, "pom.xml"); if (projectPom.exists() && !skipImport(projectDir)) { if (archetypeUtils.isValidProjectPom(projectPom)) { String fileName = file.getName(); String archetypeDirName = fileName.replace("example", "archetype"); if (fileName.equals(archetypeDirName)) { archetypeDirName += "-archetype"; } archetypeDirName = containerType + "-" + archetypeDirName; File archetypeDir = new File(outputDir, archetypeDirName); generateArchetype(projectDir, projectPom, archetypeDir, clean, dirs); } else { String childContainerType = file.getName(); if (Strings.isNotBlank(containerType)) { childContainerType = containerType + "-" + childContainerType; } generateArchetypes(childContainerType, file, outputDir, clean, dirs); } } } } } }  void generateArchetypesFromGithubOrganisation(String githubOrg, File outputDir, List<String> dirs); void generateArchetypesFromGitRepoList(File file, File outputDir, List<String> dirs); void generateArchetypes(String containerType, File baseDir, File outputDir, boolean clean, List<String> dirs); static Logger LOG; static final String ARCHETYPE_RESOURCES_PATH; static final String ARCHETYPE_RESOURCES_XML; static final String FUNKTION_YML; }