| If your source directory structure does not correspond to the package
| structure, then the classes will be recompiled every time.  For example,
| if your class is org.foo.mypack.Class, then your source must be in
| srcdir/org/foo/mypack/Class.java.

You are right. But please note the following:

I do indeed have the source files in the proper file structure
(corresponding to the package structure). Interestingly this happened after
I re-orgianized the sourcecode, and upgraded Ant from 1.3 to 1.4.1. One of
the major differences regarding sourcecode organization is that I now have
the sourcecode under <project-home>/src/main and <project-home>/src/test.
Packages under 'main' is com.onrelay.*. Packages under 'test' is
test.onrelay.* e.g.
.../JUtils/src/main/com/onrelay/collections/SingleLinkedList.java and
.../JUtils/src/test/test/onrelay/collections/SingleLinkedListJUnitTest.java

Now, my javac task is instructed to compile everything below .../JUtils/src,
and with this setting it won't appreciate that classes in the target
directory is newer than the sourcefiles. However, if I use nested <src>
instead of 'srcdir' then everything works fine.

I consider this a bug in Ant.

Thanx a lot for your valuable help!

--

Thomas




|
| Thomas Tuft Muller wrote:
|
| >Hi,
| >
| >>From the Javac task documentation:
| >
| >"The source and destination directory will be recursively
| scanned for Java
| >source files to compile. Only Java files that have no corresponding class
| >file or where the class file is older than the java file will be
| compiled."
| >
| >My javac task(s) recompile(s) the full source *every single*
| time I run the
| >project file irrespective of the class files exist in the build
| directory or
| >not, and irrespective whether the source-files have been altered.
| >
| >Extract from one of the project files:
| >
| ><target name="compile" depends="prepare">
| >             <javac destdir="${build.classes}"
| >                     srcdir="${src.dir}"
| >                     debug="${java.compiler.debug}"
| >                     deprecation="${java.compiler.deprecation}"
| >                     optimize="${java.compiler.optimize}">
| >                     <classpath refid="classpath"/>
| >             </javac>
| ></target>
| >
| >Ant version: Ant version 1.4.1 compiled on November 12 2001
| >OS: Win2k, service pack 2
| >
| >Any ideas why?
| >
| >--
| >
| >Thomas
| >
| >
| >
| >
| >
| >
| >
| >
| >
| >
| >
| >
| >
| >
| >
| >*************************************************************************
| >Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights
| reserved.
| >Confidential. No liability whatsoever is accepted for any loss or damage
| >suffered as a result of accessing this message or any attachments.
| >
| >--
| >To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
>

--
Furthermore, I believe bacon prevents hair loss.

Peter Davis
Developer, Speaklink Inc.
[EMAIL PROTECTED]




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

<?xml version="1.0"?>

<!-- ======================================================================= -->
<!-- JavaUtils Build file                                                    -->
<!-- $Id: build.xml,v 1.1.1.1 2001/11/09 15:35:24 ttm Exp $                  -->
<!-- ======================================================================= -->

<project name="JUtils" default="dist">

	<taskdef name="junit"
		classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" />

  	<property file="${jutils-build-prop.home}/build.properties" />

	<property
			file="${sandbox.dir}/OnRelay/Libraries/Software/Java/JUtils/build/build.properties" />

	<!-- Name -->
	<property name="jutils.Name" value="JUtils" />
	<property name="jutils.name" value="jutils" />

	<!-- Build directory -->
	<property name="build.classes" value="${build.dir}/classes" />

	<!-- Distribution directory -->
	<property name="dist.home"
			value="${dist.dir}/${jutils.Name}-${version}" />

	<!-- Source-code directory -->
	<property name="src.dir"
			value="${sandbox.dir}/OnRelay/Libraries/Software/Java/JUtils/src"/>

	<!-- Library versions -->
	<property name="log4j.version" value="1.1.3" />
	<property name="junit.version" value="3.7" />

	<!-- Library needed for compiling -->
	<property name="log4j.lib"
			value="${lib.dir}/Libraries/Java/Jakarta/Log4j/${log4j.version}/lib/log4j.jar" />

	<!-- Library needed for testing -->
	<property name="junit.lib"
			value="${lib.dir}/Libraries/Java/ObjectMentor/junit/${junit.version}/lib/junit.jar" />

	<!-- Classpath -->
  	<path id="classpath">
  		<pathelement location="${build.classes}" />
  		<pathelement location="${log4j.lib}" />
  		<pathelement location="${junit.lib}" />
  	</path>

 	<target name="clean">
    	<delete dir="${build.dir}" />
    	<delete dir="${dist.home}" />
  	</target>

  	<target name="prepare">
  		<echo message="Preparing: ${ant.project.name}" />
		<tstamp>
			<format property="today" pattern="d-MMMM-yyyy" locale="en" />
		</tstamp>
		<mkdir dir="${build.dir}" />
		<mkdir dir="${build.dir}/classes" />
  	</target>

	<target name="compile" depends="prepare">
		<javac destdir="${build.classes}"
			srcdir="${src.dir}"
			debug="${java.compiler.debug}"
			deprecation="${java.compiler.deprecation}"
			optimize="${java.compiler.optimize}">
			<classpath refid="classpath"/>
		</javac>
	</target>

	<target name="test" depends="compile">
		<junit printsummary="no" fork="yes" haltonfailure="yes">

			<jvmarg value="-Dlog4j.configuration=
					file:/fake.url#com.onrelay.log.SimpleConfigurator" />

			<classpath>
				<pathelement path="${java.class.path}" />
				<pathelement location="${build.classes}" />
				<pathelement location="${log4j.lib}" />
  				<pathelement location="${junit.lib}" />
			</classpath>

			<formatter type="plain" usefile="false" />

			<batchtest>
				<fileset dir="${jutils.src.dir}/test">
			    	<include name="**/*JUnitTest.java" />
			    </fileset>
			</batchtest>

		</junit>
	</target>

  	<target name="jar" depends="prepare,compile">
  		<mkdir dir="${build.dir}/lib"/>
    	<jar jarfile="${build.dir}/lib/${jutils.name}.jar"
    			basedir="${build.classes}"
    			excludes="**/Tester.class,**/JUnitTest.class"
    	/>
  	</target>

  	<target name="doc" depends="prepare">
		<mkdir dir="${build.dir}/javadocs" />
	    <javadoc packagenames="com.onrelay.*"
	             destdir="${build.dir}/javadocs"
	             private="true"
	             author="true"
	             version="true"
	             windowtitle="${Name} API"
	             doctitle="${Name}"
	             bottom="Copyright &#169; 2001 OnRelay. All Rights Reserved.">
	             <sourcepath>
					<pathelement location="${src.dir}/main" />
					<pathelement location="${src.dir}/test" />
	             </sourcepath>
	    </javadoc>
	</target>

 	<target name="dist" depends="compile,test,jar,doc">
    	<mkdir dir="${dist.home}" />
     	<mkdir dir="${dist.home}/lib" />
     	<mkdir dir="${dist.home}/doc" />
     	<mkdir dir="${dist.home}/doc/api" />
     	<mkdir dir="${dist.home}/src" />

     	<copy todir="${dist.home}/src">
     		<fileset dir="${jutils.src.dir}" />
     	</copy>

     	<copy todir="${dist.home}/lib">
     		<fileset dir="${build.dir}/lib" />
     	</copy>

     	<copy file="${log4j.lib}" todir="${dist.home}/lib" />

     	<copy todir="${dist.home}/doc/api">
     		<fileset dir="${build.dir}/javadocs" />
     	</copy>

     	<copy todir="${dist.home}/doc/api">
    		<fileset dir="${build.dir}/javadocs" />
     	</copy>
 	</target>

 	<target name="all" depends="clean,dist,doc">
 	</target>

</project>

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

Reply via email to