ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Tuft Muller" <...@online.no>
Subject RE: JavaDoc generation
Date Tue, 29 Jan 2002 18:14:11 GMT
Ylan,

The problem is that Javadoc needs to know the directory(ies) to find the
sources. E.g. if you specify com.mycompany.* and test.mycompany.*, the
sourcepath must be set to the folder(s) for which subfolders must be test
and com.

I wanted a generic javadoc task defined in a top-level build file with no
knowledge of actual source paths. I then needed to build this sourcepath in
a generic fashion, which Dave so kindly helped me doing.

My Javadoc task now looks something like:

	<target name="doc" depends="prepare">

		<script language="javascript"> <![CDATA[
			// Customizable variables:
			var PROJECT = MBX;
			var PATHID = "sources.dir";
			var SRCNAME = "src";

			// Global variables:
			var sourcepath = MBX.getReferences().get( PATHID );

			// Depth-first search for source subdirs:
			function addSourceDirs( dir ) {
				var subs = dir.listFiles();
				for( var i = 0; i < subs.length; i++ ) {
					var sub = subs[ i ];
					//java.lang.System.out.println( sub );
					if( sub.isDirectory() ) {
						if( sub.getName().equals( SRCNAME ) ) {
							addToSrc( sub, "main" );
							addToSrc( sub, "test" );
							addToSrc( sub, "classes" );
						} else {
							addSourceDirs( sub );
                        }
					}
				}
			}

			function addToSrc( srcdir, sub ) {
				var f = new java.io.File( srcdir, sub );
				if( f.exists() && f.isDirectory() ) {
					sourcepath.createPathElement().setLocation( f );
				}
			}

			// Do it.
			addSourceDirs( new java.io.File(PROJECT.getProperty( "sandbox.dir" ) ) );
			]]>

		</script>

		<mkdir dir="${build.dir}/javadoc" />

		<javadoc destdir="${build.dir}/javadoc"
			packagenames="com.*,test.*"
			author="yes"
			version="yes"
			access="private"
			windowtitle="MBX JavaDoc"
			doctitle="MBX"
			sourcepathref="sources.dir">
			<group title="MBX Specific Packages"
				packages="com.onrelay.mbx.*" />
			<group title="Generic Packages"
				packages="com.onrelay.*" />
			<group title="MBX Tests"
				packages="test.onrelay.mbx.*" />
			<group title="Generic Tests"
				packages="test.onrelay.*" />
		</javadoc>

</target>

Hope this helps,

--

Thomas

| -----Original Message-----
| From: Ylan Segal [mailto:ylan@digiworks.tv]
| Sent: 29 January 2002 18:05
| To: Ant Users List; ttm@online.no
| Subject: RE: JavaDoc generation
|
|
| One question about this javadoc problem. Can all this be done
| with filesets?
|
| The javadoc page of the manuel says that you can use a PATH-LIKE structure
| for specifing the sourcepath. Wouldn't this be enough,
| considering that you
| can use wildcard in packagenames also, like com.*, org.*, etc.
|
| Just a thought.
|
| Ylan Segal.
|
|
|
| --
| To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
| For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
|
|


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message