Examples of ArchetypeCatalog


Examples of org.apache.maven.archetype.catalog.ArchetypeCatalog

      else
      {
         ArchetypeCatalogFactory archetypeCatalogFactory = archetypeRegistry.getArchetypeCatalogFactory(name);
         if (archetypeCatalogFactory != null)
         {
            ArchetypeCatalog archetypeCatalog = archetypeCatalogFactory.getArchetypeCatalog();
            if (archetypeCatalog != null)
            {
               for (Archetype archetype : archetypeCatalog.getArchetypes())
               {
                  out.println(archetype);
               }
            }
         }
View Full Code Here

Examples of org.apache.maven.archetype.catalog.ArchetypeCatalog

    }

    public void testArchetype()
        throws Exception
    {
        ArchetypeCatalog catalog = nexusArchetypeDataSource.getArchetypeCatalog( null );

        assertEquals( "Not correct numbers of archetypes in catalog!", 4, catalog.getArchetypes().size() );
    }
View Full Code Here

Examples of org.apache.maven.archetype.catalog.ArchetypeCatalog

  public void testArchetypeCatalog()
      throws Exception
  {
    Response response;

    ArchetypeCatalog catalog;

    ArchetypeCatalogXpp3Reader acr = new ArchetypeCatalogXpp3Reader();

    // path of catalog
    String relativePath = "archetype-catalog.xml";
    String url = getRepositoryUrl(getTestRepositoryId()) + relativePath;

    // request the catalog
    response = RequestFacade.sendMessage(new URL(url), Method.GET, null);

    // read and check
    catalog = acr.read(response.getEntity().getReader());
    Assert.assertEquals(catalog.getArchetypes().size(), 1);

    // deploy one new archetype
    int httpResponseCode =
        getDeployUtils().deployUsingPomWithRest(getTestRepositoryId(), getTestFile("simple-archetype2.jar"),
            getTestFile("simple-archetype2.pom"), null, null);
    Assert.assertTrue("Unable to deploy artifact " + httpResponseCode, Status.isSuccess(httpResponseCode));

    // wait
    getEventInspectorsUtil().waitForCalmPeriod();

    // request the catalog
    response = RequestFacade.sendMessage(new URL(url), Method.GET, null);

    // read and check
    catalog = acr.read(response.getEntity().getReader());
    Assert.assertEquals(catalog.getArchetypes().size(), 2);
  }
View Full Code Here

Examples of org.apache.maven.archetype.catalog.ArchetypeCatalog

      throws IOException
  {
    final IteratorSearchResponse infos = listArchetypes(request, ctx);

    try {
      final ArchetypeCatalog catalog = new ArchetypeCatalog();
      Archetype archetype = null;
      // fill it in
      for (ArtifactInfo info : infos) {
        archetype = new Archetype();
        archetype.setGroupId(info.groupId);
        archetype.setArtifactId(info.artifactId);
        archetype.setVersion(info.version);
        archetype.setDescription(info.description);

        if (StringUtils.isNotEmpty(request.getRepositoryUrl())) {
          archetype.setRepository(request.getRepositoryUrl());
        }
        catalog.addArchetype(archetype);
      }
      return catalog;
    }
    finally {
      if (infos != null) {
View Full Code Here

Examples of org.apache.maven.archetype.catalog.ArchetypeCatalog

          "Archetype Catalog for repository {} is not buildable as it lacks IndexingContext (indexable=false?).",
          RepositoryStringUtils.getHumanizedNameString(repository));
    }

    // get the catalog
    final ArchetypeCatalog catalog = macPlugin.listArcherypesAsCatalog(req, context);
    // serialize it to XML
    final StringWriter sw = new StringWriter();
    final ArchetypeCatalogXpp3Writer writer = new ArchetypeCatalogXpp3Writer();
    writer.write(sw, catalog);
    return sw.toString();
View Full Code Here

Examples of org.apache.maven.archetype.catalog.ArchetypeCatalog

  {
    prepareNexusIndexer(nexusIndexer);
    try {
      final MacRequest request = new MacRequest(context.getRepositoryId());
      // get catalog
      ArchetypeCatalog catalog = macPlugin.listArcherypesAsCatalog(request, context);
      // repo has 3 artifacts indexed (plus 3 "internal" fields)
      assertThat("We have at least 3 Lucene documents in there for 3 artifacts!", context.getSize() >= 6);
      // repo has only 1 archetype
      assertThat("Catalog not exact!", catalog.getArchetypes(), hasSize(1));
      // add one archetype
      ArtifactInfo artifactInfo =
          new ArtifactInfo(context.getRepositoryId(), "org.sonatype.nexus.plugins", "nexus-archetype-plugin", "1.0",
              null);
      artifactInfo.packaging = "maven-archetype";
      ArtifactContext ac = new ArtifactContext(null, null, null, artifactInfo, artifactInfo.calculateGav());
      nexusIndexer.addArtifactToIndex(ac, context);
      // get catalog again
      catalog = macPlugin.listArcherypesAsCatalog(request, context);
      // repo has 4 artifacts indexed (plus 3 "internal" fields)
      assertThat("We have at least 4 Lucene documents in there for 3 artifacts!", context.getSize() >= 7);
      // repo has only 2 archetypes
      assertThat("Catalog not exact!", catalog.getArchetypes(), hasSize(2));
    }
    finally {
      unprepareNexusIndexer(nexusIndexer);
    }
  }
View Full Code Here

Examples of org.apache.maven.archetype.catalog.ArchetypeCatalog

    private NexusIndexer indexer;

    public ArchetypeCatalog getArchetypeCatalog( Properties properties )
        throws ArchetypeDataSourceException
    {
        ArchetypeCatalog catalog = new ArchetypeCatalog();

        try
        {
            Map<String, String> repositories = getRepositoryMap();

            Collection<ArtifactInfo> artifacts = indexer.searchFlat( //
                ArtifactInfo.VERSION_COMPARATOR, //
                new TermQuery( new Term( ArtifactInfo.PACKAGING, "maven-archetype" ) ) );

            for ( ArtifactInfo info : artifacts )
            {
                Archetype archetype = new Archetype();
                archetype.setGroupId( info.groupId );
                archetype.setArtifactId( info.artifactId );
                archetype.setVersion( info.version );
                archetype.setDescription( info.description );
                archetype.setRepository( repositories.get( info.repository ) );

                catalog.addArchetype( archetype );
            }
        }
        catch ( Exception ex )
        {
            getLogger().error( "Unable to retrieve archetypes", ex );
View Full Code Here

Examples of org.apache.maven.archetype.catalog.ArchetypeCatalog

        new FileAssert(repository).exists().isDirectory();

        RepositoryCrawler crawler = plexus.lookup(RepositoryCrawler.class);

        log.debug("Crawling repository: {}", repository);
        ArchetypeCatalog catalog = crawler.crawl(repository);
        if (catalogFile == null) {
            catalogFile = new File(repository, "archetype-catalog.xml");
        }

        log.debug("Writing catalog file: {}", catalogFile);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.