Skip to content

Commit

Permalink
[ARCHETYPE-677] Upgrade versions of archetypes in internal catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed Sep 14, 2024
1 parent c159afe commit 054e22d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 30 deletions.
18 changes: 9 additions & 9 deletions archetype-common/src/main/resources/archetype-catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,32 @@ under the License.
<archetype>
<groupId>org.apache.maven.archetypes</groupId>
<artifactId>maven-archetype-archetype</artifactId>
<version>1.0</version>
<version>1.5</version>
<description>An archetype which contains a sample archetype.</description>
</archetype>
<archetype>
<groupId>org.apache.maven.archetypes</groupId>
<artifactId>maven-archetype-j2ee-simple</artifactId>
<version>1.0</version>
<version>1.5</version>
<description>An archetype which contains a simplifed sample J2EE application.</description>
</archetype>
<archetype>
<groupId>org.apache.maven.archetypes</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<version>1.2</version>
<version>1.5</version>
<description>An archetype which contains a sample Maven plugin.</description>
</archetype>
<archetype>
<groupId>org.apache.maven.archetypes</groupId>
<artifactId>maven-archetype-plugin-site</artifactId>
<version>1.1</version>
<version>1.5</version>
<description>An archetype which contains a sample Maven plugin site.
This archetype can be layered upon an existing Maven plugin project.</description>
</archetype>
<archetype>
<groupId>org.apache.maven.archetypes</groupId>
<artifactId>maven-archetype-portlet</artifactId>
<version>1.0.1</version>
<version>1.5</version>
<description>An archetype which contains a sample JSR-268 Portlet.</description>
</archetype>
<archetype>
Expand All @@ -64,27 +64,27 @@ under the License.
<archetype>
<groupId>org.apache.maven.archetypes</groupId>
<artifactId>maven-archetype-quickstart</artifactId>
<version>1.1</version>
<version>1.5</version>
<description>An archetype which contains a sample Maven project.</description>
</archetype>
<archetype>
<groupId>org.apache.maven.archetypes</groupId>
<artifactId>maven-archetype-site</artifactId>
<version>1.1</version>
<version>1.5</version>
<description>An archetype which contains a sample Maven site which demonstrates
some of the supported document types like APT, XDoc, and FML and demonstrates how
to i18n your site. This archetype can be layered upon an existing Maven project.</description>
</archetype>
<archetype>
<groupId>org.apache.maven.archetypes</groupId>
<artifactId>maven-archetype-site-simple</artifactId>
<version>1.1</version>
<version>1.5</version>
<description>An archetype which contains a sample Maven site.</description>
</archetype>
<archetype>
<groupId>org.apache.maven.archetypes</groupId>
<artifactId>maven-archetype-webapp</artifactId>
<version>1.0</version>
<version>1.5</version>
<description>An archetype which contains a sample Maven Webapp project.</description>
</archetype>
</archetypes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.maven.archetype.test;

import java.io.File;
import java.util.Properties;

import org.apache.maven.archetype.ArchetypeGenerationRequest;
import org.apache.maven.archetype.ArchetypeGenerationResult;
Expand Down Expand Up @@ -63,31 +64,27 @@ public void testInternalCatalog() throws Exception {
outputDirectory.mkdirs();
FileUtils.cleanDirectory(outputDirectory);

ArchetypeManager archetype = (ArchetypeManager) lookup(ArchetypeManager.class.getName());
ArchetypeManager archetypeManager = (ArchetypeManager) lookup(ArchetypeManager.class.getName());
ArchetypeCatalog catalog = archetypeManager.getInternalCatalog();

ArchetypeCatalog catalog = archetype.getInternalCatalog();
// quickstart has a parameters with defaults ... so it should not be needed
// can be connected with ARCHETYPE-574
Properties props = new Properties();
props.put("javaCompilerVersion", "11");
props.put("junitVersion", "5.11.0");

int count = 1;
for (Archetype a : catalog.getArchetypes()) {
Archetype ar = new Archetype();
ar.setGroupId(a.getGroupId());
ar.setArtifactId(a.getArtifactId());
ar.setVersion(a.getVersion());
ar.setDescription(a.getDescription());
ar.setGoals(a.getGoals());
ar.setProperties(a.getProperties());
ar.setRepository(a.getRepository());
if (ar.getRepository() == null) {
ar.setRepository(CENTRAL);
}

ArchetypeGenerationRequest request = new ArchetypeGenerationRequest(ar)
.setGroupId("org.apache.maven.archetype.test")
.setArtifactId("archetype" + count)
for (Archetype archetype : catalog.getArchetypes()) {
// this should be also default ...
archetype.setRepository(CENTRAL);

ArchetypeGenerationRequest request = new ArchetypeGenerationRequest(archetype)
.setGroupId("org.apache.maven.archetypeManager.test")
.setArtifactId("archetypeManager" + count)
.setVersion("1.0-SNAPSHOT")
.setPackage("com.acme")
.setProperties(props)
.setOutputDirectory(outputDirectory.getPath());
// .setLocalRepository(localRepository);

ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest();
DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
Expand All @@ -98,9 +95,11 @@ public void testInternalCatalog() throws Exception {
buildingRequest.setRepositorySession(repositorySession);
request.setProjectBuildingRequest(buildingRequest);

ArchetypeGenerationResult generationResult = archetype.generateProjectFromArchetype(request);
ArchetypeGenerationResult generationResult = archetypeManager.generateProjectFromArchetype(request);

assertNull("Archetype wasn't generated successfully", generationResult.getCause());
assertNull(
"Archetype wasn't generated successfully: " + generationResult.getCause(),
generationResult.getCause());

count++;
}
Expand Down

0 comments on commit 054e22d

Please sign in to comment.