javamavenmaven-archetypearchetypes

Maven archetype generation does not include files from archetype-resources


I'm creating a maven archetype but when I generate a project with this archetype the sources are empty.

Is there something missing?

Is there any simple archetype to start with? I tried maven-archetypes but every project inherits from a parent artifactId maven-archetype-bundles.

Maven archetype

base-archetype
  -src
    -main
      -java
      -resources
        -archetype-resources
          -resources
            -META-INF
              messages.properties
          -webapp
            -WEB-INF
              beans.xml
          pom.xml(b)
        -META-INF
          -maven
            archetype-metadata.xml
    -test
  -target
  pom.xml(a)

pom.xml(a)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.javalabs</groupId>
    <artifactId>simple-archetype</artifactId>
    <version>0.0.1</version>
    <packaging>maven-archetype</packaging>
...    

    <build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.archetype</groupId>
                <artifactId>archetype-packaging</artifactId>
                <version>3.1.2</version>
            </extension>
        </extensions>

        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-archetype-plugin</artifactId>
                    <version>3.0.1</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            ...
        </plugins>
    </build>
    ...
</project>

archetype-metadata.xml

<archetype-descriptor
        xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0
        http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
        xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        name="jakartaee-essentials-archetype">

    <fileSets>
        <fileSet filtered="true" packaged="true" encoding="UTF-8">
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.java</include>
            </includes>
        </fileSet>

        <fileSet filtered="true" packaged="true" encoding="UTF-8">
            <directory>src/main/resources</directory>
            <includes>
                <include>**/*.xml</include>
                <include>**/*.properties</include>
            </includes>
        </fileSet>

        <fileSet filtered="true" packaged="false" encoding="UTF-8">
            <directory>src/main/webapp</directory>
            <includes>
                <include>**/*.xml</include>
                <include>**/*.properties</include>
            </includes>
        </fileSet>

        <fileSet>
            <directory>src/test/java</directory>
        </fileSet>

        <fileSet filtered="false" packaged="false" encoding="UTF-8">
            <directory></directory>
            <includes>
                <include>.gitignore</include>
            </includes>
        </fileSet>
    </fileSets>

</archetype-descriptor>

Solution

  • There were some mistakes on the structure of the archetype, it lacks src and main levels in the archetype-resources folder.

    base-archetype
      -src
        -main
          -java
          -resources
            -archetype-resources
              -**src**
                -**main**
                  -resources
                    -META-INF
                      messages.properties
                    -webapp
                      -WEB-INF
                        beans.xml
                pom.xml(b)
            -META-INF
              -maven
                archetype-metadata.xml
        -test
      -target
      pom.xml(a)