Exemplo n.º 1
0
  @Test
  public void buildAllExampleArchetypes() throws Exception {
    File srcDir = new File(basedir, "../examples").getCanonicalFile();

    builder.configure();
    try {
      List<String> dirs = new ArrayList<String>();
      builder.generateArchetypes(
          "java", srcDir, new File(basedir, "target/test-archetypes"), true, dirs, null);
    } finally {
      LOG.info("Completed the generation. Closing!");
      builder.close();
    }

    Collection<File> files =
        FileUtils.listFilesAndDirs(
            new File("target/test-archetypes/java-hello-world-archetype"),
            TrueFileFilter.INSTANCE,
            TrueFileFilter.INSTANCE);
    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/resources",
          "/src/main/resources/archetype-resources/src/test/resources/logback-test.xml",
          "/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) {
      assertTrue(files.remove(new File("target/test-archetypes/java-hello-world-archetype" + r)));
    }
    assertTrue("Failed to create correct Archetype project", files.isEmpty());
  }
Exemplo n.º 2
0
 @Before
 public void init() throws IOException {
   if (basedir == null) {
     basedir = ".";
   }
   catalogFile =
       new File(basedir, "target/test-archetypes/archetype-catalog.xml").getCanonicalFile();
   builder = new ArchetypeBuilder(catalogFile);
   builder.setIndentSize(4);
   archetypeUtils = new ArchetypeUtils();
 }