You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Erik Price <er...@gmail.com> on 2011/01/30 03:34:43 UTC

two questions about archetypes

I have two questions about creating a Maven archetype:


1. How do I get my Maven archetype project to show up in the interactive
list of archetypes that appear when running "mvn archetype:generate"? I've
installed my project into my local repository, but when I run that command,
I only see the standard 366 archetypes show up. I am able to generate the
archetype by specifying the archetype identifiers via project properties
(e.g., -DarchetypeArtifactId=my-archetype -DarchetypeGroupId=com.company.my ),
but I was curious how I would get it listed in the main listing. It's not
important that I do so, I'm really just curious at this point what one has
to do.


2. When I generate an instance of my archetype, why does a folder named
after the group I specify as the generated project's groupId appear in
generated project between src/main/webapp/ and the webapp files themselves?
Two pictures are worth two thousand words:


my-archetype/

├── pom.xml

└── src

    └── main

        └── resources

            ├── META-INF

            │   └── maven

            │       └── archetype-metadata.xml

            └── archetype-resources

                ├── pom.xml

                └── src

                    ├── main

                    │   ├── java

                    │   │   ├── App.java

                    │   └── webapp

                    │       ├── WEB-INF

                    │       │   └── web.xml

                    │       └── index.jsp

                    └── test

                        └── java

                            └── AppTest.java



testArtifact/

├── pom.xml

└── src

    ├── main

    │   ├── java

    │   │   └── testGroup

    │   │       ├── App.java

    │   └── webapp

    │       └── testGroup *<--- why is this here?*

    │           ├── WEB-INF

    │           │   └── web.xml

    │           └── index.jsp

    └── test

        └── java

            └── testGroup

                └── AppTest.java


I can see why it might add this for the "main/java" and "test/java"
directories, because Maven might be trying to helpfully insert a Java
package name based on the supplied groupId, but it doesn't make sense (to
me) that it does so for the "webapp" directory. And in my particular case, I
don't even want it for the "java" directories. Is there some way to suppress
this?


e

Re: two questions about archetypes

Posted by Anders Hammar <an...@hammar.net>.
1. The simplest way (that I know of) to do this is to use Nexus as your repo
manager and make sure to have the archetype-plugin installed. It will
produce the (remote) archetype catalog file that makes this happen.

/Anders

On Sun, Jan 30, 2011 at 03:34, Erik Price <er...@gmail.com> wrote:

> I have two questions about creating a Maven archetype:
>
>
> 1. How do I get my Maven archetype project to show up in the interactive
> list of archetypes that appear when running "mvn archetype:generate"? I've
> installed my project into my local repository, but when I run that command,
> I only see the standard 366 archetypes show up. I am able to generate the
> archetype by specifying the archetype identifiers via project properties
> (e.g., -DarchetypeArtifactId=my-archetype -DarchetypeGroupId=
> com.company.my ),
> but I was curious how I would get it listed in the main listing. It's not
> important that I do so, I'm really just curious at this point what one has
> to do.
>
>
> 2. When I generate an instance of my archetype, why does a folder named
> after the group I specify as the generated project's groupId appear in
> generated project between src/main/webapp/ and the webapp files themselves?
> Two pictures are worth two thousand words:
>
>
> my-archetype/
>
> ├── pom.xml
>
> └── src
>
>    └── main
>
>        └── resources
>
>            ├── META-INF
>
>            │   └── maven
>
>            │       └── archetype-metadata.xml
>
>            └── archetype-resources
>
>                ├── pom.xml
>
>                └── src
>
>                    ├── main
>
>                    │   ├── java
>
>                    │   │   ├── App.java
>
>                    │   └── webapp
>
>                    │       ├── WEB-INF
>
>                    │       │   └── web.xml
>
>                    │       └── index.jsp
>
>                    └── test
>
>                        └── java
>
>                            └── AppTest.java
>
>
>
> testArtifact/
>
> ├── pom.xml
>
> └── src
>
>    ├── main
>
>    │   ├── java
>
>    │   │   └── testGroup
>
>    │   │       ├── App.java
>
>    │   └── webapp
>
>    │       └── testGroup *<--- why is this here?*
>
>    │           ├── WEB-INF
>
>    │           │   └── web.xml
>
>    │           └── index.jsp
>
>    └── test
>
>        └── java
>
>            └── testGroup
>
>                └── AppTest.java
>
>
> I can see why it might add this for the "main/java" and "test/java"
> directories, because Maven might be trying to helpfully insert a Java
> package name based on the supplied groupId, but it doesn't make sense (to
> me) that it does so for the "webapp" directory. And in my particular case,
> I
> don't even want it for the "java" directories. Is there some way to
> suppress
> this?
>
>
> e
>