Re: Summary: Guide for creating archetypes

2005-10-26 Thread Alexander Hars
The .apt version of the Guide for creating archetypes is below (I did 
verify that the conversion of this file to html works).


In section 2 on archetype.xml, I include a note:
"At this point one can only specify individual files to be created but 
not empty directories."

If that is not right, please correct it.

Cheers
-Alexander

.apt file is below

--
Guide to Creating Archetypes
--
Jason van Zyl, Alexander Hars
--
26 October 2005
--

Guide to Creating Archetypes

Creating an archetype is a pretty straight forward process. An 
archetype is a very simple plugin, that
contains the project prototype you wish to create. An archetype is made 
up of:


* an archetype descriptor ( in directory: 
). It lists all the files
  that will be contained in the archetype and categorizes them so they 
can be processed correctly by the

  archetype generation mechanism.

* the prototype files that are copied by the archetype (directory: 
)


* the prototpye pom ( in: )

* a pom for the archetype ( in the archetype's root directory).

[]

To create an archetype follow these steps:

* 1. Create a new project and pom.xml for the archetype plugin

 An example  for an archetype plugin looks as follows:

++


 4.0.0
 my.groupId
 my-archetype-id
 1.0-SNAPSHOT
 maven-plugin


++

 All you need to specify is a ,  and . 
These three parameters will be needed later for
 invoking the archetype via  from the commandline. 


* 2. Create the archetype descriptor

The archetype descriptor is a file called  which must be 
located in 
An example for an archetype descriptor can be found in the quickstart 
archetype:


++


 quickstart
 
   src/main/java/App.java
 
 
   src/test/java/AppTest.java
 


++

The \ tag should be the same as the artifactId in the archetype 
.


An optional \true\ tag makes it possible 
to run the archetype:create even existing projects.


The \, \, \ and 
\ tags represent the different sections of the project:


* \ = src/main/java

* \ = src/main/resources

* \ = src/test/java

* \ = src/test/resources

* \ = src/site
[]

\ and \ can contain \ elements that 
specify a source file.


\ and \ can contain \ 
elements that specify a resource file.


At this point one can only specify individual files to be created but 
not empty directories.


Thus the quickstart archetype shown above defines the following 
directory structure:


++

archetype
|-- pom.xml
`-- src
   `-- main
   `-- resources
   |-- META-INF
   |   `-- archetype.xml
   `-- archetype-resources
   |-- pom.xml
   `-- src
   |-- main
   |   `-- java
   |   `-- App.java
   `-- test
   `-- java
   `-- AppTest.java

++

* 3. Create the prototype files and the prototype pom.xml

The next component of the archetype to be created is the prototype 
. Any  will do, just
don't forget to the set  and  as variables  ( 
<$\{artifactId\}> / <$\{groupId\}> ). Both variables
will be initialized from the commandline when calling 
.  


An example for a prototype  is:

++


 4.0.0
 ${groupId}
 ${artifactId}
 jar
 ${version}
 A custom project
 http://www.myorganization.org
 
   
 junit
 junit
 3.8.1
 test
   
 


++

* 4. Install and run the archetype

Now you are ready to install the archetype:

++

mvn install

++

Now that you have created an archetype you can try it on your local 
system by using the following command:
In this command, you need to specify the full information about the 
archetype you want to use (its groupId, its artifactId, its version) and 
the information about the new project you want to create (artifactId and 
groupId).
Don't forget to include the version of your archetype (if you don't 
include the version, you archetype creation may fail with a message that 
version:RELEASE was not found)



++

mvn archetype:create -DarchetypeGroupId= 
-DarchetypeArtifactId= \
 -DarchetypeVersion= -DgroupId= 
-DartifactId=


++

Once you are happy with the state of your archetype you can deploy (or 
submit it to ibiblio) it as any other artifact and

the archetype will then be available to any user of Maven.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Summary: Guide for creating archetypes

2005-10-26 Thread Jason van Zyl
On Wed, 2005-10-26 at 18:24 +0200, Alexander Hars wrote:
> Hi,
> thank you for all the helpful tips about where to look for creating 
> archetypes. I am summarizing what I learned in a step-by-step guide below:
> 
> The only question that I have not been able to solve is how to use 
> instruct an archetype to create an EMPTY directory ( tag does 
> not work).

If you can integrate it into this:

http://maven.apache.org/guides/mini/guide-creating-archetypes.html

In APT format I would apply the patch immediately. It's hard to
integrate non-standard formats. I greatly appreciate the effort but
doing the doco in our current standard format APT pretty much guarantees
the patch will be applied.

Here's the format of the archetype guide:

http://svn.apache.org/viewcvs.cgi/maven/components/trunk/maven-
site/src/site/apt/guides/mini/guide-creating-archetypes.apt?
rev=326378&view=markup

And here's the guide for APT:

http://maven.apache.org/guides/mini/guide-apt-format.html

Again, not to discourage you but it's just hard at the moment with
everything going on to absorb non APT doco submissions.

> 
>  H O W T O C R E A T E  A  N  A R C H E 
> T Y P E
> 
> 
> 1. Create a new project.
>  add the directories:
> src/main/resources/META-INF  //will hold archetype.xml
> src/main/resources/archetype-resources   //will hold the pom.xml and 
> source tree that need to be copied
> 
> 2. Create a POM for the archetype, e.g.
> 
> 
>   4.0.0
>   my.groupId
>   my-archetype-id
>   1.0-SNAPSHOT
>   maven-plugin
> 
> 
> 3. The file structure for your archetype must be located in the
> directory: src/main/resources/META-INF and 
> src/main/resources/archetype-resources
> 
> 4. create an archetype descriptor in a file called archetype.xml and 
> place it in:
> src/main/resources/META-INF/pom.xml
> Note that true makes it possible to run the 
> archetype creation on an existing project.
> 
> for example:
> 
> 
>   my-archetype-id
>   false
>   
>  src/main/java/App.java
>   
>   
> src/test/java/AppTest.java
>   
>   
> src/site/apt/index.apt
>   
> 
> 
> You can select from the following tags:
>   = src/main/java
>   = src/main/resources
>   = src/test/java
>   = src/test/resources
>   = src/site
> 
> (I have not been able to find a way to create empty directories, though).
> 
> 5. create the pom.xml that the archetype should create and place it
> in:
> src/main/resources/archetype-resources/pom.xml
> 
> for example:
> 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/maven-v4_0_0.xsd";>
>   4.0.0
>   ${groupId}
>   ${artifactId}
>   jar
>   ${version}
>   A custom project
>   http://www.myorganization.org
>   
> 
>   junit
>   junit
>   3.8.1
>   test
> 
>   
> 
> 
> 6. run mvn install
> This installs your archetype locally.
> 
> 7. to create a new project based on your archetype use:
>  mvn archetype:create -DarchetypeGroupId=my.groupId 
> -DarchetypeArtifactId=my-archetype-id -DarchetypeVersion=1.0-SNAPSHOT 
> -DgroupId=my.organization -DartifactId=myArtifactId
> Note: Don't forget -DarchetypeVersion !
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
-- 
jvz.

Jason van Zyl
jason at maven.org
http://maven.apache.org

Our achievements speak for themselves. What we have to keep track
of are our failures, discouragements and doubts. We tend to forget
the past difficulties, the many false starts, and the painful
groping. We see our past achievements as the end result of a
clean forward thrust, and our present difficulties as
signs of decline and decay.

 -- Eric Hoffer, Reflections on the Human Condition


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]