Books
in black and white
Main menu
Share a book About us Home
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

More Java Pitfalls Share Reactor - Daconta M,C.

Daconta M,C. More Java Pitfalls Share Reactor - Wiley publishing, 2003. - 476 p.
ISBN: 0-471-23751-5
Download (direct link): morejavapitfallssharereactor2003.pdf
Previous << 1 .. 33 34 35 36 37 38 < 39 > 40 41 42 43 44 45 .. 166 >> Next

238: <!--
239: ********************************************************
240: ** Splash screen
241: *****************************************************-- >
242: <target name="splash" description="Display splash screen...">
243:
244: <echo message="Display splash screen..."/>
245: <splash imageurl="./ant/images/ant_logo_large.gif"
246: showduration="5000" />
248: </target>
Listing 11.1 (continued)
Checkstyle is a Java development tool that helps programmers write Java code that adheres to a recognized coding standard. It automates the process of visually checking through Java code to ensure that previously established coding rules are incorporated into individual source code components.
Some of the useful standards that Checkstyle looks for are unused or duplicate import statements, that Javadoc tags for a method match the actual code, the incorporation of specified headers, that @author tags exist for class and interface Javadoc
Apache Ant and Lifecycle Management 95
comments, that periods (.) are not surrounded by whitespace, that brackets ({}) are used for if/while/for/do constructs, that lines do not contain tabs, and that files are not longer than a specified number of lines. To implement Checkstyle, a user would need to use lines 254 to 263.
250: <!
251: ********************************************************
252: ** Checkstyle
253* *****************************************************__>
254: <target name="checkStyle" description="Coding standard met?...">
256: <taskdef name="checkstyle"
257: 2
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"/>
258: <echo message="Coding standard met?..."/>
259: <checkstyle allowTabs="yes">
260: <fileset dir="./ant/src" includes="**/*.java"/>
261: </checkstyle>
263: </target>
Listing 11.1 (continued)
Document preparation is an important but often overlooked activity during software implementation. Users often need to understand what APIs are being used to propagate data across systems. Javadoc provides hyperlinked documents for Web browser viewing, which allows users to share copies and facilitates distribution. Javadocs are easily updateable, which helps maintain consistency.
266: <!
2 67: ********************************************************
268: ** Javadoc
269: *****************************************************__>
270: <target name="javadoc" description="Generate Javadoc 2
artifacts">
272: <echo message="Generating Javadoc artifacts..."/>
273: <javadoc packagenames="*"
274 : sourcepath="./ant/src"
275 : sourcefiles="./ant/src/**"
276 : excludepackagenames="com.dummy.test.doc-files *"
277 : defaultexcludes="yes"
278 : destdir="docs/api"
279 : author="true"
280 : version="true"
281 : use="true"
282 : windowtitle="Test API">
283 : <doctitle><![CDATA[<h1>Test</h1>]]></doctitle>
284: <bottom><![CDATA[<i>Copyright &#169; 2002 Java 2
Pitfalls II All Rights Reserved.</i>]]></bottom>
285 : </javadoc>
286:
287: </target>
Listing 11.1 (continued)
96 Item 11
In the Servlet/JavaServer Page model, Web ARchive (WAR) files are portable components that can be deployed across a wide range of J2EE Web containers. The code below shows how Java source is compiled and packaged for deployment.
288
289 <!--
290 ********************************************************
291 ** Build WAR file
292 *****************************************************__>
293 <target name="distribute" depends="prepare">
294
295 <echo message="Compiling source..."/>
296
297 <javac srcdir="cache/beans" destdir="${builddir}/WEB- 2
INF/classes/">
298 <classpath><path
refid="classpath.path"/></classpath>
299 </javac>
300
301 <echo message="Creating WAR file [cache.war]..."/>
302 <war warfile="${builddir}/cache.war" 2
webxml="cache/deployment/web.xml">
303 <fileset dir="${builddir}">
304
<patternset id="_source">
305 <include name="*.jsp"/>
306 </patternset>
307 <patternset id="_stylesheet">
308 <include name="*.css"/>
309 </patternset>
310 </fileset>
311 <webinf dir="${builddir}/WEB-INF">
312 <patternset id="_tld">
313 <include name="*.tld"/>
314 </patternset>
315 </webinf>
316 <classes dir="${builddir}/WEB-INF/classes" >
317 <patternset id="_classes">
318 <include name="**"/>
319 </patternset>
320 </classes>
321 <lib dir="${builddir}/WEB-INF/lib" />
322 </war>
324 </target>
Listing 11.1 (continued)
Database creation, population, and destruction can also be accomplished with Ant scripts. Prior to discovering this capability, our development team was experiencing great difficulties in performing these operations on both Intel and Unix platforms. Different scripts needed to be maintained in order to run the SQL commands, which proved quite cumbersome. By employing Ant, we were able to use the same script on both platforms, which allowed us to facilitate operations.
Apache Ant and Lifecycle Management 97
326 <!--
327 ********************************************************
Previous << 1 .. 33 34 35 36 37 38 < 39 > 40 41 42 43 44 45 .. 166 >> Next