Sign in

E-mail *, (xx@domain.com)
Password *

Register | Forgot password

Blogs

Recent blogs

RSS - Blogs
March 9, 2010
State of OSGi in the Java world
March 4, 2010
Reach more people with Google Translate
March 3, 2010
Get My Advice
February 26, 2010
What? Where!?!
February 11, 2010
Split it!

All Blogs...


WCB Sharing FTW!

July 29, 2008

One of the good things of Java is the “create once, use everywhere” message. The modular architecture of GX WebManager supports this message in the form of WCBs. But, given a nice source tree, how can you create a nice ZIP file that contains anything you need to share? You just add some additional things to your pom.xml and MaVeN will do it for you!

Generating JavaDoc

To help developers downloading your WCB finding their way through your functionality, you should generate JavaDoc and include this in the distribution package you create. MaVeN can start the generation process for you, but you can help a little by configuring some settings in the pom.xml file. Add the following snippet to the reporting plugins section:

<!-- plugin to create the javadoc -->
<plugin>
	<artifactId>maven-javadoc-plugin</artifactId>
	<configuration>
		<reportOutputDirectory>
			target/apidocs
		</reportOutputDirectory>
		<links>
			<link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
			<link>http://java.sun.com/j2ee/1.5/docs/api/</link>
			<link>http://www.gxdeveloperweb.com/documentation/javadoc/</link>
		</links>
	</configuration>
</plugin>

With reportOutputDirectory you set the directory where the HTML files that JavaDoc generates have to be placed. By including a list of links to external JavaDoc sites, standard Java and WebManager class and method names are automatically linked to the online JavaDoc pages. For example, if you have a service with a method that returns a Page object, this return type will become a link to the Page class documentation on GX DeveloperWeb.

To run this step automatically, the following snippet can be added to the build plugins section:

<!-- plugin to create the javadoc on the package phase -->
<plugin>
	<artifactId>maven-javadoc-plugin</artifactId>
	<executions>
		<execution>
			<id>create-javadoc</id>
			<phase>package</phase>
			<goals>
				<goal>javadoc</goal>
			</goals>
		</execution>
	</executions>
</plugin>

Now there is only one catch left. JavaDoc generation will fail when it encounters an annotation in the source file that it cannot resolve in the classpath. Because WebManager uses annotation to define JCR nodetypes and for instructing the EntityManager, you need to add a dependency to the webmanager-api library.

Creating the distribution ZIP

Now we have everything we might want to include in our distrubition package: the source code, the compiled WCB and the generated JavaDoc  files. To automatically pack them up in a single ZIP file, you can use the assembly plugin. This plugin takes a XML file with instructions about which files and directories to include in the ZIP file. The example dist-assembly.xml file includes some files from the root, the documentation from /doc, the generated JavaDoc from /target/apidocs, the compiled WCB from the /target subdirectory and the source code from /src. You can modify this file to customize the ZIP file, for example if you don’t want the source code to be included. Most times, this examples is what you want when preparing a ZIP file for certification by Professional Services.

After preparing the assembly instructions file and placing it somewhere in the src directory (like src/main/assembly/dist-assembly.xml if you plan to use the snippet below), you need to instruct MaVeN to assemble the ZIP file by placing the following snippet to the build plugins section:

<!-- plugin to create the distribution zip on the package phase -->
<plugin>
	<artifactId>maven-assembly-plugin</artifactId>
	<executions>
		<execution>
			<id>assemble-zip</id>
			<phase>package</phase>
			<goals>
				<goal>attached</goal>
			</goals>
		</execution>
	</executions>
	<configuration>
		<descriptors>
			<descriptor>
				src/main/assembly/dist-assembly.xml
			</descriptor>
		</descriptors>
	</configuration>
</plugin>

For reference purposes I’ve prepared an example pom.xml which might help you figuring out some things.

 
marcr | 08-08-2008 15:38

Hi Mark,

where can I find instructions on how to add the webmanager-api library dependency to the pom.xml?

Grz. Marc



ivol | 18-09-2008 14:46

Note that if you are running maven in offline mode, this will not work. Change the offline mode in the settings.xml to online and it will...

Regards, Ivo


About the Author

Return to all blogs


Mark is software engineer with a special interest in Security and Digital WebTV. Mark writes about daily engineering with GX WebManager

Read all Marks blog entries

Other blog entries:

March 3, 2010
Get My Advice
February 11, 2010
Split it!
April 22, 2009
What goes in, must come out!
June 17, 2008
Found me on LinkedIn?
April 18, 2008
Tosti
April 7, 2008
Baking apple pie at 347
March 21, 2008
Short story about not inventing another wheel
March 13, 2008
Files in and files out
February 29, 2008
Big Brother is watching


Share:

del.icio.us
digg
Technorati
Slashdot
Reddit
YahooMyWeb
NewsVine
ekudos
© 2010 GX creative online development B.V.

Disclaimer

This website (GXdeveloperweb.com) may discuss or contain opinions, (sample) coding, software or other information that does not include GX official interfaces, instructions or guidelines and therefore is not supported by GX. Changes made based on this information are not supported.  GX will not be held liable for any damages caused by using or misusing the information, software, instructions, code or methods suggested on this website, and anyone using these methods does so at his/her own risk. GX offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this website, including any liability resulting from incompatibility between the content of this website and the materials and services offered by GX. By using this website you will not hold, or seek to hold, GX responsible or liable with respect to the content of this website.