You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Jesse Glick <je...@oracle.com> on 2010/09/28 16:34:13 UTC

Is maven-archetype required/recommended for archetypes?

[Originally posted to dev@mojo without response. This might be the more appropriate list, so reposting here also with some updates.]


Recently I worked on an IDE feature [1] which enumerates archetypes available in your local repository that you might want to instantiate projects from, so you can pick 
from a list, and ran into a problem which I'm not sure I have solved satisfactorily.

If the archetype used <packaging>maven-archetype</packaging> then the install phase seems to insert an entry in archetype-catalog.xml, which makes it easy to find in the 
local repo. Archetypes from a remote repo are also easy to find because the Nexus indexer records the packaging for every artifact, so you can do a Lucene search on it, 
even if the remote archetype-catalog.xml was missing or not up to date. And archetype:create-from-project sets up this packaging - fine.

But it seems that many real archetypes just use jar packaging. Those in mojo-archetypes always have as far as I can tell. [2] Official ones like Quick Start sometimes use 
the custom packaging. [3] To find these in the local repository you need to add a custom index field looking for archetype-metadata.xml [4] in the JAR artifact, and there 
is no clear way to find them in a remote repository.

So should mojo-archetypes/* be converted to use maven-archetype packaging and new releases made?


[1] https://netbeans.org/bugzilla/show_bug.cgi?id=190401


[2] Another curious thing: though the mojo-archetypes appear to have always used jar packaging, and e.g. webapp-javaee6 in Central lists the packaging as jar when you 
download the POM for 1.0, 1.0.1, 1.0.2, and 1.1, the Central index lists the packaging as maven-archetype for 1.0, 1.0.1, and 1.0.2 - but not 1.1. Why?

Furthermore, http://repo1.maven.org/maven2/archetype-catalog.xml lists 1.0, 1.0.1, and 1.0.2, but not 1.1. Nor, now, 1.2 - as someone was just complaining on users@mojo, 
webapp-javaee6 1.2 is not offered by m2eclipse.


[3] It seems that newer "official" archetypes use the special packaging:

http://svn.apache.org/viewvc/maven/archetype/tags/maven-archetype-quickstart-1.1/pom.xml?revision=938664&view=co

(I cannot find the "trunk" version of this code - was the source tree reorganized?) Older releases use jar packaging, as far as I can tell.


[4] archetype.xml seems to be an older and semideprecated format - right? Yet quickstart 1.1 uses it.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Is maven-archetype required/recommended for archetypes?

Posted by Tamás Cservenák <ta...@cservenak.net>.
Howdy,

As for [2], the nexus-indexer tries it's best to "recognize" (or guess is
maybe better) is an artifact an archetype or not, exactly because of that
mixup with packaging, etc. Considering all archetypes out there in central,
there is no "unique way" to decide... when an artifact is recognized as
archetype (or even "partial archetype"), the indexer _overrides_ the
packaging on index and makes it uniformly "maven-archetype" packaging (yes,
even for those that has POMs saying different).

And finally, the nexus-archetype CLI (used on central to generate the
catalog, but same stands for Nexus Archetype Plugin, that uses same
components) will simply put only those artifacts into catalog, that on index
have packaging (are "recognized" as) maven-archetype.

Actually, this index creator is meant to "override" the packaging to
maven-archetype if needed, hence, to recognize "older" archetypes, since
newer ones already presents themselves with correct packaging, and packaging
is handled in generic fashion by MinimalArtifactInfoIndexCreator:

Following steps are done to recognize archetypes (below).

- if packaging is "maven-archetype", or extension is not "jar", no action
needed (the "minimal" index creator already sets packaging)
- if extension is "jar", and the JAR contains some of these resources:
"/META-INF/maven/archetype.xml", "/META-INF/archetype.xml",
"/META-INF/maven/archetype-metadata.xml", override it's packaging to
"maven-archetype"


Source code is here:
https://sventon.sonatype.org/repos/nexus-oss/show/trunk/nexus-indexer/src/main/java/org/sonatype/nexus/index/creator/MavenArchetypeArtifactInfoIndexCreator.java?revision=HEAD


Hope this helps to resolve problems about version 1.1 of webapp-javaee6

===

And as Herve said, it is best to use "proper" archetype packaging for any
new archetype.


Thanks,
~t~

On Tue, Sep 28, 2010 at 4:34 PM, Jesse Glick <je...@oracle.com> wrote:

> [2] Another curious thing: though the mojo-archetypes appear to have always
> used jar packaging, and e.g. webapp-javaee6 in Central lists the packaging
> as jar when you download the POM for 1.0, 1.0.1, 1.0.2, and 1.1, the Central
> index lists the packaging as maven-archetype for 1.0, 1.0.1, and 1.0.2 - but
> not 1.1. Why?
>
> Furthermore, http://repo1.maven.org/maven2/archetype-catalog.xml lists
> 1.0, 1.0.1, and 1.0.2, but not 1.1. Nor, now, 1.2 - as someone was just
> complaining on users@mojo, webapp-javaee6 1.2 is not offered by m2eclipse.
>
>

Re: Is maven-archetype required/recommended for archetypes?

Posted by Hervé BOUTEMY <he...@free.fr>.
yes, using maven-archetype packaging is recommended since it adds some 
lifecycle bindings to simple jar:
- add-archetype-metadata
- integration-tests
- update-local-catalog
see [1]


for your second point, I don't know: perhaps the nexus plugin that generates 
archetype-catalog.xml only considers jar packaging when querying its index.


I added maven-archetype packaging in recent archetypes, when I discovered this 
quite unknown feature.

For current archetypes trunk, see [2]: yes, svn structure has been reworked.

Regards,

Hervé


[1] http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-
packaging/src/main/resources/META-INF/plexus/components.xml?view=markup

[2] http://svn.apache.org/viewvc/maven/archetypes/trunk/


Le mardi 28 septembre 2010, Jesse Glick a écrit :
> [Originally posted to dev@mojo without response. This might be the more
> appropriate list, so reposting here also with some updates.]
> 
> 
> Recently I worked on an IDE feature [1] which enumerates archetypes
> available in your local repository that you might want to instantiate
> projects from, so you can pick from a list, and ran into a problem which
> I'm not sure I have solved satisfactorily.
> 
> If the archetype used <packaging>maven-archetype</packaging> then the
> install phase seems to insert an entry in archetype-catalog.xml, which
> makes it easy to find in the local repo. Archetypes from a remote repo are
> also easy to find because the Nexus indexer records the packaging for
> every artifact, so you can do a Lucene search on it, even if the remote
> archetype-catalog.xml was missing or not up to date. And
> archetype:create-from-project sets up this packaging - fine.
> 
> But it seems that many real archetypes just use jar packaging. Those in
> mojo-archetypes always have as far as I can tell. [2] Official ones like
> Quick Start sometimes use the custom packaging. [3] To find these in the
> local repository you need to add a custom index field looking for
> archetype-metadata.xml [4] in the JAR artifact, and there is no clear way
> to find them in a remote repository.
> 
> So should mojo-archetypes/* be converted to use maven-archetype packaging
> and new releases made?
> 
> 
> [1] https://netbeans.org/bugzilla/show_bug.cgi?id=190401
> 
> 
> [2] Another curious thing: though the mojo-archetypes appear to have always
> used jar packaging, and e.g. webapp-javaee6 in Central lists the packaging
> as jar when you download the POM for 1.0, 1.0.1, 1.0.2, and 1.1, the
> Central index lists the packaging as maven-archetype for 1.0, 1.0.1, and
> 1.0.2 - but not 1.1. Why?
> 
> Furthermore, http://repo1.maven.org/maven2/archetype-catalog.xml lists 1.0,
> 1.0.1, and 1.0.2, but not 1.1. Nor, now, 1.2 - as someone was just
> complaining on users@mojo, webapp-javaee6 1.2 is not offered by m2eclipse.
> 
> 
> [3] It seems that newer "official" archetypes use the special packaging:
> 
> http://svn.apache.org/viewvc/maven/archetype/tags/maven-archetype-quickstar
> t-1.1/pom.xml?revision=938664&view=co
> 
> (I cannot find the "trunk" version of this code - was the source tree
> reorganized?) Older releases use jar packaging, as far as I can tell.
> 
> 
> [4] archetype.xml seems to be an older and semideprecated format - right?
> Yet quickstart 1.1 uses it.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org