How to create documentation of Application in Maven

Last updated on May 27 2022
Mrinalini Pandey

Table of Contents

How to create documentation of Application in Maven

Maven – Project Documents

This blog will teach you how to create documentation of the application in one go. So let’s start, go to C:/MVN directory where you had created your java consumerBanking application using the examples given in the previous chapters. Open consumerBanking folder and execute the next mvn command.

C:\MVN>mvn site

Maven will start building the project.

[INFO] Scanning for projects…

[INFO]———————————————–

[INFO] Building consumerBanking

[INFO] task-segment: [site]

[INFO]———————————————–

[INFO] [site:site {execution: default-site}]

[INFO] artifact org.apache.maven.skins:maven-default-skin:

checking for updates from central

 

[INFO] Generating “About” report.

[INFO] Generating “Issue Tracking” report.

[INFO] Generating “Project Team” report.

[INFO] Generating “Dependencies” report.

[INFO] Generating “Continuous Integration” report.

[INFO] Generating “Source Repository” report.

[INFO] Generating “Project License” report.

[INFO] Generating “Mailing Lists” report.

[INFO] Generating “Plugin Management” report.

[INFO] Generating “Project Summary” report.

 

[INFO]———————————————–

[INFO] BUILD SUCCESSFUL

[INFO]———————————————–

 

[INFO] Total time: 16 seconds

[INFO] Finished at: Wed Jul 11 18:11:18 IST 2012

[INFO] Final Memory: 23M/148M

[INFO]———————————————–

Your project documentation is now ready. Maven has created a site within the target directory.

Page 2 Image 1 7
target directory

Open C:\MVN\consumerBanking\target\site folder. Click on index.html to see the documentation.

Page 2 Image 2 19
Documentation

Maven creates the documentation using a documentation-processing engine called Doxia which reads multiple source formats into a common document model. To write documentation for your project, you can write your content in a next few commonly used formats which are parsed by Doxia.

Format Name Description Reference
XDoc A Maven 1.x documentation format https://jakarta.apache.org/site
FML Used for FAQ documents https://maven.apache.org

 

 Maven – Project Templates

Maven provides users, a very large list of different types of project templates (614 in numbers) using the concept of Archetype. Maven helps users to quickly start a new java project using the next command.

mvn archetype:generate

What is Archetype?

Archetype is a Maven plugin whose task is to create a project structure as per its template. We are going to use quickstart archetype plugin to create a simple java application here.

Using Project Template

Let’s open the command console, go to the C:\ > MVN directory and execute the next mvn command.

C:\MVN>mvn archetype:generate

Maven will start processing and will ask to choose the required archetype.

[INFO] Scanning for projects…

[INFO] Searching repository for plugin with prefix: ‘archetype’.

[INFO] ——————————————————————-

[INFO] Building Maven Default Project

[INFO] task-segment: [archetype:generate] (aggregator-style)

[INFO] ——————————————————————-

[INFO] Preparing archetype:generate

 

600: remote −> org.trailsframework:trails-archetype (-)

601: remote −> org.trailsframework:trails-secure-archetype (-)

602: remote −> org.tynamo:tynamo-archetype (-)

603: remote −> org.wicketstuff.scala:wicket-scala-archetype (-)

604: remote −> org.wicketstuff.scala:wicketstuff-scala-archetype

 

Basic setup for a project that combines Scala and Wicket,

depending on the Wicket-Scala project.

Includes an example Specs test.)

 

605: remote −> org.wikbook:wikbook.archetype (-)

606: remote −> org.xaloon.archetype:xaloon-archetype-wicket-jpa-glassfish (-)

607: remote −> org.xaloon.archetype:xaloon-archetype-wicket-jpa-spring (-)

608: remote −> org.xwiki.commons:xwiki-commons-component-archetype

(Make it easy to create a maven project for creating XWiki Components.)

609: remote −> org.xwiki.rendering:xwiki-rendering-archetype-macro

(Make it easy to create a maven project for creating XWiki Rendering Macros.)

610: remote −> org.zkoss:zk-archetype-component (The ZK Component archetype)

611: remote −> org.zkoss:zk-archetype-webapp (The ZK wepapp archetype)

612: remote −> ru.circumflex:circumflex-archetype (-)

613: remote −> se.vgregion.javg.maven.archetypes:javg-minimal-archetype (-)

614: remote −> sk.seges.sesam:sesam-annotation-archetype (-)

Choose a number or apply filter

(format: [groupId:]artifactId, case sensitive contains): 203:

Press Enter to choose to default option (203: maven-archetype-quickstart)

Maven will ask for particular version of archetype.

Choose org.apache.maven.archetypes:maven-archetype-quickstart version:

1: 1.0-alpha-1

2: 1.0-alpha-2

3: 1.0-alpha-3

4: 1.0-alpha-4

5: 1.0

6: 1.1

Choose a number: 6:

Press Enter to choose to default option (6: maven-archetype-quickstart:1.1)

Maven will ask for the project detail. Enter project detail as asked. Press Enter if the default value is provided. You can override them by entering your own value.

Define value for property ‘groupId’: : com.companyname.insurance

Define value for property ‘artifactId’: : health

Define value for property ‘version’: 1.0-SNAPSHOT:

Define value for property ‘package’: com.companyname.insurance:

Maven will ask for the project detail confirmation. Press enter or press Y.

Confirm properties configuration:

groupId: com.companyname.insurance

artifactId: health

version: 1.0-SNAPSHOT

package: com.companyname.insurance

Y:

Now Maven will start creating the project structure and will display the next −

[INFO]———————————————–

[INFO] Using next parameters for creating project

from Old (1.x) Archetype: maven-archetype-quickstart:1.1

[INFO]———————————————–

 

[INFO] Parameter: groupId, Value: com.companyname.insurance

[INFO] Parameter: packageName, Value: com.companyname.insurance

[INFO] Parameter: package, Value: com.companyname.insurance

[INFO] Parameter: artifactId, Value: health

[INFO] Parameter: basedir, Value: C:\MVN

[INFO] Parameter: version, Value: 1.0-SNAPSHOT

 

[INFO] project created from Old (1.x) Archetype in dir: C:\MVN\health

[INFO]———————————————–

[INFO] BUILD SUCCESSFUL

[INFO]———————————————–

[INFO] Total time: 4 minutes 12 seconds

[INFO] Finished at: Fri Jul 13 11:10:12 IST 2012

[INFO] Final Memory: 20M/90M

[INFO]———————————————–

Created Project

Now go to C:\ > MVN directory. You’ll see a java application project created, named health, which was given as artifactId at the time of project creation. Maven will create a standard directory layout for the project as shown below −

Page 6 Image 3 1
Project

Created POM.xml

Maven generates a POM.xml file for the project as listed below −

<project xmlns = “http://maven.apache.org/POM/4.0.0”

xmlns:xsi = “http://www.w3.org/2001/XMLSchema-example”

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.companyname.insurance</groupId>

<artifactId>health</artifactId>

<version>1.0-SNAPSHOT</version>

<packaging>jar</packaging>

<name>health</name>

<url>http://maven.apache.org</url>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

</properties>

<dependencies>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>3.8.1</version>

<scope>test</scope>

</dependency>

</dependencies>

</project>

Created App.java

Maven generates sample java source file, App.java for the project as listed below −

Location: C:\ > MVN > health > src > main > java > com > companyname > insurance > App.java.

package com.companyname.insurance;

 

/**

* Hello world!

*

*/

public class App {

public static void main( String[] args ) {

System.out.println( “Hello World!” );

}

}

Created AppTest.java

Maven generates sample java source test file, AppTest.java for the project as listed below −

Location: C:\ > MVN > health > src > test > java > com > companyname > insurance > AppTest.java.

package com.companyname.insurance;

 

import junit.framework.Test;

import junit.framework.TestCase;

import junit.framework.TestSuite;

 

/**

* Unit test for simple App.

*/

public class AppTest extends TestCase {

/**

* Create the test case

*

* @param testName name of the test case

*/

public AppTest( String testName ) {

super( testName );

}

/**

* @return the suite of tests being tested

*/

public static Test suite() {

return new TestSuite( AppTest.class );

}

/**

* Rigourous Test 🙂

*/

public void testApp() {

assertTrue( true );

}

}

Now you can see the power of Maven. You can create any kind of project using single command in maven and can kick-start your development.

Different Archetypes

Sr.No. Archetype ArtifactIds & Description
1 maven-archetype-archetype

An archetype, which contains a sample archetype.

2 maven-archetype-j2ee-simple

An archetype, which contains a simplified sample J2EE application.

3 maven-archetype-mojo

An archetype, which contains a sample a sample Maven plugin.

4 maven-archetype-plugin

An archetype, which contains a sample Maven plugin.

5 maven-archetype-plugin-site

An archetype, which contains a sample Maven plugin site.

6 maven-archetype-portlet

An archetype, which contains a sample JSR-268 Portlet.

7 maven-archetype-quickstart

An archetype, which contains a sample Maven project.

8 maven-archetype-simple

An archetype, which contains a simple Maven project.

9 maven-archetype-site

An archetype, which contains a sample Maven site to demonstrates some of the supported document types like APT, XDoc, and FML and demonstrates how to i18n your site.

10 maven-archetype-site-simple

An archetype, which contains a sample Maven site.

11 maven-archetype-webapp

An archetype, which contains a sample Maven Webapp project.

 

So, this brings us to the end of blog. This Tecklearn ‘How to create documentation of Application in Maven’ blog helps you with commonly asked questions if you are looking out for a job in DevOps. If you wish to learn Maven and build a career in DevOps domain, then check out our interactive, Maven Training, that comes with 24*7 support to guide you throughout your learning period. Please find the link for course details:

https://www.tecklearn.com/course/maven/

Maven Training

About the Course

Tecklearn has specially designed this Maven Training Course to advance your skills for a successful career in this domain. The course will cover different components of Maven and how they are used in software development operations.  You will get an in-depth knowledge of these concepts and will be able to work on related demos. Upon completion of this online training, you will hold a solid understanding and hands-on experience with Maven.

Why Should you take Maven Training?

  • The average salary for “ant maven” ranges from approximately $71,430 per year for Entry Level Engineer to $126,916 per year for Development Operations Engineer. – Indeed.com
  • According to Grand View Research, the DevOps market size is estimated to be worth $12.85 billion by 2025. DevOps professionals are highly paid and in-demand throughout industries including retail, eCommerce, finance, and technology.

What you will Learn in this Course?

Introduction to DevOps

  • What is Software Development
  • Software Development Life Cycle
  • Why DevOps?
  • What is DevOps?
  • DevOps Lifecycle
  • DevOps Tools
  • Benefits of DevOps
  • How DevOps is related to Agile Delivery
  • DevOps Implementation

Maven

  • Maven
  • Maven Directory
  • Maven Lifecycle
  • Maven Dependencies
  • Maven Repositories
  • Phases and Goals

 

0 responses on "How to create documentation of Application in Maven"

Leave a Message

Your email address will not be published. Required fields are marked *