You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by COUVREUR jacques <ex...@agf.fr> on 2006/08/03 16:52:23 UTC
Generated sources by an archetype
Hi,
Our project consists to develop a maven archetype in order to quickly
setup each new project from our in-house development teams.
Basically we will be able to produce a new project by typing the
following maven command:
>mvn archetype:create -DgroupId=com.agf.gabi -DartifactId=gabi
-DarchetypeArtifactId=agf-app-archetype
By calling this command, we would like that the Java packages are named
according to the values of groupId and artifactId.
src
|-- main
| `-- java
| `-- <groupId> <-- WANTED
| `-- <artifactId> <-- WANTED
| `-- App.java
Our problem is that we don't know how to use these variables in order to
create the packages for the Java sources.
########################################################################
######################
The default maven archetypes don't generate any package: all the sources
are placed in the root folder (src/main/java).
Does anyone could help us?
Thanks.
Jacques
------------------------------
Ce message est protege par les regles relatives au secret des correspondances ; il peut en outre contenir des informations a caractere confidentiel ou protegees par differentes regles et notamment le secret des affaires ; il est etabli a destination exclusive de son destinataire. Toute divulgation, utilisation, diffusion ou reproduction (totale ou partielle) de ce message, ou des informations qu'il contient, doit etre prealablement autorisee.
Tout message electronique est susceptible d'alteration et son integrite ne peut etre assuree. Les AGF declinent toute responsabilite au titre de ce message s'il a ete modifie ou falsifie.
Si vous n'etes pas destinataire de ce message, merci de le detruire immediatement et d'avertir l'expediteur de l'erreur de distribution et de la destruction du message.
This message is protected by the secrecy of correspondence rules ; furthermore it may contain privileged or confidential information that is protected by law, notably by the secrecy of business relations rule ; it is intended solely for the attention of the addressee . Any disclosure, use, dissemination or reproduction (either whole or partial) of this message or the information contained herein is strictly prohibited without prior consent.
Any electronic message is susceptible to alteration and its integrity can not be assured. AGF declines any responsibility for this message in the event of alteration or falsification..
If you are not the intended recipient, please destroy it immediately and notify the sender of the wrong delivery and the mail deletion.
------------------------------
Re: Generated sources by an archetype
Posted by franz see <fr...@gmail.com>.
COUVREUR jacques wrote:
>
> Hi,
>
>
>
> Our project consists to develop a maven archetype in order to quickly
> setup each new project from our in-house development teams.
>
>
>
> Basically we will be able to produce a new project by typing the
> following maven command:
>
>
>
>>mvn archetype:create -DgroupId=com.agf.gabi -DartifactId=gabi
> -DarchetypeArtifactId=agf-app-archetype
>
>
>
> By calling this command, we would like that the Java packages are named
> according to the values of groupId and artifactId.
>
>
>
> src
> |-- main
> | `-- java
> | `-- <groupId> <-- WANTED
> | `-- <artifactId> <-- WANTED
> | `-- App.java
>
>
>
>
>
> Our problem is that we don't know how to use these variables in order to
> create the packages for the Java sources.
>
>
To set the package of your Java sources, simply specify your package name.
In your example that's
>mvn archetype:create
-DgroupId=com.agf.gabi
-DartifactId=gabi
-DarchetypeArtifactId=agf-app-archetype
-DpackageName=com.agf.gabi.gabi
However, if you want your agf-app-archetype to always use groupId.artifactId
as its projects' packag name, I don't think that's possible.
(Note: the following would be just FYIs)
AFAIK there are three ways to set the packages of your source files:
1. using the packageName
2. setting your project's groupId, and
3. adding a directories in between your
.../archetype-resources/src/main/java and your Java files
#1 was the first thing i explained ( either do that, or set it through a
parent pom. eitherway, you wont be able to set your sources' package name
just by setting your project's groupId and artifactId ).
But if don't want to specify the packageName, you do #2 instead. This will
equate your package name with your groupId since it (packageName) is its
default value.
Also, you can do #3, the result would be your source's packageName (either
set through #1 or #2) concatenated with the directories you set. For
example, if we have
[...]
.
`-- archetype-resources
|-- src
| `-- main
| `-- java
| |-- package1
| | `-- App1.java
| `-- package2
| `-- App2.java
`-- pom.xml
upon calling
>mvn archetype:create
-DgroupId=com.agf.gabi
-DartifactId=gabi
-DarchetypeArtifactId=agf-app-archetype
You will get,
.
|-- src
| `-- main
| `-- java
| `-- com
| `-- agf
| `-- gabi
| |-- package1
| | `-- App1.java
| `-- package2
| `-- App2.java
`-- pom.xml
But of course, #3 will also not meet your needs since the "extra package"
(in the example above: package1, package2) appended to your packageName is
constant.
All in all, you will not be able to set your package name the way you desire
it without specifying the packageName.
However, you may want to use your groupId as your sources' packageName (the
default setup) since it is maven's recommended way.
COUVREUR jacques wrote:
>
>
> The default maven archetypes don't generate any package: all the sources
> are placed in the root folder (src/main/java).
>
>
If you are referring to maven-quickstart-archetype, although its sources are
placed src/main/java, when used (mvn archetype:create), those sources will
be placed in src/main/java/[packageName]/*.java
Furthermore, if im not mistaken, all archetypes follow the same structure (
.../archetype-resources/src/main/java/[extra package name]/*.java ) and the
packageName will just be concatenated with the extra package name.
You may also want to check out
http://maven.apache.org/guides/mini/guide-creating-archetypes.html for more
info regarding creating archetypes.
COUVREUR jacques wrote:
>
>
> Does anyone could help us?
>
>
>
> Thanks.
>
>
>
>
>
> Jacques
>
>
>
> ------------------------------
> Ce message est protege par les regles relatives au secret des
> correspondances ; il peut en outre contenir des informations a caractere
> confidentiel ou protegees par differentes regles et notamment le secret
> des affaires ; il est etabli a destination exclusive de son destinataire.
> Toute divulgation, utilisation, diffusion ou reproduction (totale ou
> partielle) de ce message, ou des informations qu'il contient, doit etre
> prealablement autorisee.
> Tout message electronique est susceptible d'alteration et son integrite ne
> peut etre assuree. Les AGF declinent toute responsabilite au titre de ce
> message s'il a ete modifie ou falsifie.
> Si vous n'etes pas destinataire de ce message, merci de le detruire
> immediatement et d'avertir l'expediteur de l'erreur de distribution et de
> la destruction du message.
> This message is protected by the secrecy of correspondence rules ;
> furthermore it may contain privileged or confidential information that is
> protected by law, notably by the secrecy of business relations rule ; it
> is intended solely for the attention of the addressee . Any disclosure,
> use, dissemination or reproduction (either whole or partial) of this
> message or the information contained herein is strictly prohibited without
> prior consent.
> Any electronic message is susceptible to alteration and its integrity
> can not be assured. AGF declines any responsibility for this message in
> the event of alteration or falsification..
> If you are not the intended recipient, please destroy it immediately and
> notify the sender of the wrong delivery and the mail deletion.
> ------------------------------
>
>
>
--
View this message in context: http://www.nabble.com/Generated-sources-by-an-archetype-tf2046111.html#a5643763
Sent from the Maven - Users forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: Generated sources by an archetype
Posted by Adam Leggett <Ad...@upco.co.uk>.
Ive never tried it, but I believe using
-Dpackage=[my.group.id.my.artifactid for example] will override the
default behaviour of simply substituting groupId for ${package} in your
sources.
-----Original Message-----
From: COUVREUR jacques [mailto:externe.jacques.couvreur@agf.fr]
Sent: Thursday, August 03, 2006 3:52 PM
To: Maven Users List
Subject: Generated sources by an archetype
Hi,
Our project consists to develop a maven archetype in order to quickly
setup each new project from our in-house development teams.
Basically we will be able to produce a new project by typing the
following maven command:
>mvn archetype:create -DgroupId=com.agf.gabi -DartifactId=gabi
-DarchetypeArtifactId=agf-app-archetype
By calling this command, we would like that the Java packages are named
according to the values of groupId and artifactId.
src
|-- main
| `-- java
| `-- <groupId> <-- WANTED
| `-- <artifactId> <-- WANTED
| `-- App.java
Our problem is that we don't know how to use these variables in order to
create the packages for the Java sources.
########################################################################
######################
The default maven archetypes don't generate any package: all the sources
are placed in the root folder (src/main/java).
Does anyone could help us?
Thanks.
Jacques
------------------------------
Ce message est protege par les regles relatives au secret des
correspondances ; il peut en outre contenir des informations a caractere
confidentiel ou protegees par differentes regles et notamment le secret
des affaires ; il est etabli a destination exclusive de son
destinataire. Toute divulgation, utilisation, diffusion ou reproduction
(totale ou partielle) de ce message, ou des informations qu'il contient,
doit etre prealablement autorisee.
Tout message electronique est susceptible d'alteration et son integrite
ne peut etre assuree. Les AGF declinent toute responsabilite au titre de
ce message s'il a ete modifie ou falsifie.
Si vous n'etes pas destinataire de ce message, merci de le detruire
immediatement et d'avertir l'expediteur de l'erreur de distribution et
de la destruction du message.
This message is protected by the secrecy of correspondence rules ;
furthermore it may contain privileged or confidential information that
is protected by law, notably by the secrecy of business relations rule ;
it is intended solely for the attention of the addressee . Any
disclosure, use, dissemination or reproduction (either whole or
partial) of this message or the information contained herein is strictly
prohibited without prior consent.
Any electronic message is susceptible to alteration and its integrity
can not be assured. AGF declines any responsibility for this message
in the event of alteration or falsification.. If you are not the
intended recipient, please destroy it immediately and notify the
sender of the wrong delivery and the mail deletion.
------------------------------
===========================================================================
The contents of this email are intended for the named addresses and may
contain confidential and/or privileged material. If received in error,
please contact UPCO head office on +44(0)113 201 0600 and then delete
the entire mail from your system. Unauthorised review, distribution,
disclosure or other use of information could constitute a breach of
confidence. Your co-operation in this matter is greatly appreciated.
Every effort has been taken to ensure that this email and any
attachments are virus-free. However, UPCO does not make any warranty
to this effect, and is not liable for any damage done by an infected
email message or attachment. UPCO recommends that all emails and
attachments are checked before opening.
All views or opinions expressed in this electronic message and its
attachements are those of the sender and do not necessarily reflect
the views and opinions of The Ultimate People Company Ltd.
===========================================================================
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org