Hi Rolf,

In order to integration test an archetype there are a couple of things 
required. [1]

To test your archetype you will need to create a subdirectory for each test.
These subdirectories live in the 'src/test/resources/projects’ folder of your 
archetype project.

E.g. your test ’src/test/resources/projects/my-first-test` will need:
- an (empty) goal.txt file
- an archetype.properties file with the required properties 
        - Note: that groupId, artifactId, version, package are required by 
default, plus any additional required properties defined in your archetype 
descriptor without default value.
- optionally a ‘reference/' directory containing a reference project

The integration test goal will first generate a project from your archetype 
based on the archetype.properties and if any goals are defined, such as verify, 
in the goals.txt it will run that phase against the generated project.

The reference project will need to contain the project to be generated, so the 
outputted project as if you ran mvn generate:archetype on your machine.
So if your archetype has a 
’src/main/resources/archetype-resources/src/main/java/MyApp.java’ the reference 
project with groupId/package com.example would need to contain a 
’reference/src/main/resources/java/com/example/MyApp.java’ with all the 
properties resolved e.g. ${package} would be com.example in the reference.

If you run into the issue that the test fails due to not being allowed to 
override/copy files, make sure to explicitly include all the required files in 
your filesets of your archetype descriptor.

[1] 
https://maven.apache.org/components/archetype-archives/archetype-LATEST/maven-archetype-plugin/integration-test-mojo.html
 

If you have any other questions please feel free to reach out!

Hope this helps,

Giovanni van der Schelde

On 2024/09/02 07:29:49 Rolf Schumacher wrote:
> I tried my first test for my custom archetype, but failed. It's tough 
> for me to grasp, what has to be placed in reference folder of a 
> procect/test-case. Anything I tried failed.
> 
> Also I did not find a working archetype on github that hosts a reference 
> folder in a test, like e.g. ebpro/maven-archetypes 
> <https://github.com/ebpro/maven-archetypes>.
> 
> To start with a working example, is there a - simple as possible - 
> archetype that I could clone, with a reference folder?
> 
> mit freundlichen Grüße, Best Regards
> 
> Rolf

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to