You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2023/10/07 18:37:40 UTC

[maven-archetype] branch ARCHETYPE-650 created (now 12e01de1)

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a change to branch ARCHETYPE-650
in repository https://gitbox.apache.org/repos/asf/maven-archetype.git


      at 12e01de1 [ARCHETYPE-650] point to archetype file in error message

This branch includes the following new commits:

     new 12e01de1 [ARCHETYPE-650] point to archetype file in error message

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-archetype] 01/01: [ARCHETYPE-650] point to archetype file in error message

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch ARCHETYPE-650
in repository https://gitbox.apache.org/repos/asf/maven-archetype.git

commit 12e01de136697bf4f8e01fd4803cb778a8c85cac
Author: Hervé Boutemy <hb...@sonatype.com>
AuthorDate: Sat Oct 7 15:37:19 2023 -0300

    [ARCHETYPE-650] point to archetype file in error message
---
 .../generator/DefaultArchetypeGenerator.java       |  2 +-
 .../DefaultArchetypeGenerationConfigurator.java    | 36 ++++++----------------
 ...efaultArchetypeGenerationConfigurator2Test.java | 15 +++++----
 ...DefaultArchetypeGenerationConfiguratorTest.java | 15 +++++----
 4 files changed, 24 insertions(+), 44 deletions(-)

diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerator.java b/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerator.java
index 4d4f9517..2ef3ef75 100644
--- a/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerator.java
+++ b/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerator.java
@@ -101,7 +101,7 @@ public class DefaultArchetypeGenerator extends AbstractLogEnabled implements Arc
         } else if (archetypeArtifactManager.isOldArchetype(archetypeFile)) {
             processOldArchetype(request, archetypeFile);
         } else {
-            throw new ArchetypeGenerationFailure("The defined artifact is not an archetype");
+            throw new ArchetypeGenerationFailure("The defined artifact is not an archetype: " + archetypeFile);
         }
     }
 
diff --git a/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeGenerationConfigurator.java b/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeGenerationConfigurator.java
index cc7a0af9..1b5f0246 100644
--- a/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeGenerationConfigurator.java
+++ b/maven-archetype-plugin/src/main/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeGenerationConfigurator.java
@@ -18,6 +18,7 @@
  */
 package org.apache.maven.archetype.ui.generation;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.StringReader;
 import java.io.StringWriter;
@@ -134,46 +135,27 @@ public class DefaultArchetypeGenerationConfigurator extends AbstractLogEnabled
 
         ArchetypeConfiguration archetypeConfiguration;
 
-        if (archetypeArtifactManager.isFileSetArchetype(
+        File archetypeFile = archetypeArtifactManager.getArchetypeFile(
                 ad.getGroupId(),
                 ad.getArtifactId(),
                 ad.getVersion(),
                 archetypeRepository,
                 localRepository,
                 repositories,
-                request.getProjectBuildingRequest())) {
+                request.getProjectBuildingRequest());
+        if (archetypeArtifactManager.isFileSetArchetype(archetypeFile)) {
             org.apache.maven.archetype.metadata.ArchetypeDescriptor archetypeDescriptor =
-                    archetypeArtifactManager.getFileSetArchetypeDescriptor(
-                            ad.getGroupId(),
-                            ad.getArtifactId(),
-                            ad.getVersion(),
-                            archetypeRepository,
-                            localRepository,
-                            repositories,
-                            request.getProjectBuildingRequest());
+                    archetypeArtifactManager.getFileSetArchetypeDescriptor(archetypeFile);
 
             archetypeConfiguration = archetypeFactory.createArchetypeConfiguration(archetypeDescriptor, properties);
-        } else if (archetypeArtifactManager.isOldArchetype(
-                ad.getGroupId(),
-                ad.getArtifactId(),
-                ad.getVersion(),
-                archetypeRepository,
-                localRepository,
-                repositories,
-                request.getProjectBuildingRequest())) {
+        } else if (archetypeArtifactManager.isOldArchetype(archetypeFile)) {
             org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor archetypeDescriptor =
-                    archetypeArtifactManager.getOldArchetypeDescriptor(
-                            ad.getGroupId(),
-                            ad.getArtifactId(),
-                            ad.getVersion(),
-                            archetypeRepository,
-                            localRepository,
-                            repositories,
-                            request.getProjectBuildingRequest());
+                    archetypeArtifactManager.getOldArchetypeDescriptor(archetypeFile);
 
             archetypeConfiguration = archetypeFactory.createArchetypeConfiguration(archetypeDescriptor, properties);
         } else {
-            throw new ArchetypeGenerationConfigurationFailure("The defined artifact is not an archetype");
+            throw new ArchetypeGenerationConfigurationFailure(
+                    "The defined artifact is not an archetype: " + archetypeFile);
         }
 
         List<String> propertiesRequired = archetypeConfiguration.getRequiredProperties();
diff --git a/maven-archetype-plugin/src/test/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeGenerationConfigurator2Test.java b/maven-archetype-plugin/src/test/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeGenerationConfigurator2Test.java
index 4036a409..a6959eeb 100644
--- a/maven-archetype-plugin/src/test/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeGenerationConfigurator2Test.java
+++ b/maven-archetype-plugin/src/test/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeGenerationConfigurator2Test.java
@@ -18,6 +18,7 @@
  */
 package org.apache.maven.archetype.ui.generation;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
@@ -74,19 +75,17 @@ public class DefaultArchetypeGenerationConfigurator2Test extends PlexusTestCase
 
         ArchetypeArtifactManager manager = EasyMock.createMock(ArchetypeArtifactManager.class);
 
+        File archetype = new File("archetype.jar");
         List<ArtifactRepository> x = new ArrayList<>();
         EasyMock.expect(manager.exists(
                         "archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, x, buildingRequest))
                 .andReturn(true);
-        EasyMock.expect(manager.isFileSetArchetype(
+        EasyMock.expect(manager.getArchetypeFile(
                         "archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, x, buildingRequest))
-                .andReturn(true);
-        EasyMock.expect(manager.isOldArchetype(
-                        "archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, x, buildingRequest))
-                .andReturn(false);
-        EasyMock.expect(manager.getFileSetArchetypeDescriptor(
-                        "archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, x, buildingRequest))
-                .andReturn(descriptor);
+                .andReturn(archetype);
+        EasyMock.expect(manager.isFileSetArchetype(archetype)).andReturn(true);
+        EasyMock.expect(manager.isOldArchetype(archetype)).andReturn(false);
+        EasyMock.expect(manager.getFileSetArchetypeDescriptor(archetype)).andReturn(descriptor);
 
         EasyMock.replay(manager);
         configurator.setArchetypeArtifactManager(manager);
diff --git a/maven-archetype-plugin/src/test/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeGenerationConfiguratorTest.java b/maven-archetype-plugin/src/test/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeGenerationConfiguratorTest.java
index 22857ba6..98edc596 100644
--- a/maven-archetype-plugin/src/test/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeGenerationConfiguratorTest.java
+++ b/maven-archetype-plugin/src/test/java/org/apache/maven/archetype/ui/generation/DefaultArchetypeGenerationConfiguratorTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.maven.archetype.ui.generation;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
@@ -54,20 +55,18 @@ public class DefaultArchetypeGenerationConfiguratorTest extends PlexusTestCase {
 
         ArchetypeArtifactManager manager = EasyMock.createMock(ArchetypeArtifactManager.class);
 
+        File archetype = new File("archetype.jar");
         List<ArtifactRepository> x = new ArrayList<>();
         EasyMock.expect(manager.exists(
                         "archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, x, buildingRequest))
                 .andReturn(true);
-        EasyMock.expect(manager.isFileSetArchetype(
+        EasyMock.expect(manager.getArchetypeFile(
                         "archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, x, buildingRequest))
-                .andReturn(false);
-        EasyMock.expect(manager.isOldArchetype(
-                        "archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, x, buildingRequest))
-                .andReturn(true);
+                .andReturn(archetype);
+        EasyMock.expect(manager.isFileSetArchetype(archetype)).andReturn(false);
+        EasyMock.expect(manager.isOldArchetype(archetype)).andReturn(true);
 
-        EasyMock.expect(manager.getOldArchetypeDescriptor(
-                        "archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, x, buildingRequest))
-                .andReturn(new ArchetypeDescriptor());
+        EasyMock.expect(manager.getOldArchetypeDescriptor(archetype)).andReturn(new ArchetypeDescriptor());
 
         EasyMock.replay(manager);
         configurator.setArchetypeArtifactManager(manager);