I have an ant script that does and hourly build. I want to do a
fresh, complete build every time, so I delete all .class files before
I do a checkout from cvs. The problem is when it comes to the compile
target. It doesn't seem to recognize packages that don't have at
least one .class file as a package, because when I try to import a
package from whatever .java file is trying to be compiled at that
moment, I get a compile error "package doesn't exist" even though the
.java files are there(it just won't compile them). I have tried using
javamake, but get the same results although it's supposed to do
dependency checking.
I know there must be some tool that does this sort of dependency
checking, because I can compile this way in NetBeans. Does someone
know of a way to do this?
Brian
Application Developer
OptData Inc/ATRS
brian.harris@optdatainc.com
> I have an ant script that does and hourly build. I want to do a
> fresh, complete build every time, so I delete all .class files before
[quoted text clipped - 15 lines]
> OptData Inc/ATRS
> brian.harris@optdatainc.com
how about posting the target that does the build for you. Plus all the
properties you have in the script.
I do the same thing as you, and i have around 10 packages. I delete the
entire build directory, recreate it, and then run the compile target. It
works everytime.
Here is my build script;
<!--
demo1 ant build script
-->
<project name="demo1" default="make" basedir="." >
<!-- set up the properties for this project -->
<property name="src" value="src"/>
<property name="src.images" value="src/images"/>
<property name="dist" value="dist"/>
<property name="dist.class" value="${dist}/WEB-INF/classes"/>
<property name="dist.lib" value="${dist}/WEB-INF/lib"/>
<property name="dist.images" value="${dist}/images"/>
<property name="docs" value="docs" />
<!-- set the classpath for this project -->
<path id="local_cp" >
<pathelement path="${classpath}" />
<fileset dir="${dist.lib}" >
<include name ="**/*.jar" />
</fileset >
</path>
<!-- clean out all the class directorys -->
<target name="clean"
description="removes all the class files from the classes
directory." >
<!-- delete and create the classes directory -->
<delete dir="${dist.class}" />
<mkdir dir="${dist.class}" />
<!-- delete and create the images directory -->
<delete dir="${dist.images}" />
<mkdir dir="${dist.images}" />
</target>
<!-- build all the files in the src directory. Put the out put in the
classes directory. -->
<target name="make"
description="makes all the classes in the WebInf classes
directory.">
<!-- make the classes directory -->
<mkdir dir="${dist}" />
<mkdir dir="${dist.class}" />
<mkdir dir="${dist.images}" />
<!-- compile all the source files -->
<javac srcdir="${src}"
destdir="${dist.class}"
debug="true" >
<classpath location="${src}" />
<classpath refid="local_cp" />
</javac>
<copy todir="${dist.class}" includeEmptyDirs="true">
<fileset dir="${src}">
<include name="**/*.jwc"/>
<include name="**/*.application"/>
<include name="**/*.html"/>
<include name="**/*.page"/>
<include name="**/*.hbm.xml"/>
<include name="**/*.properties"/>
</fileset>
</copy>
<copy todir="${dist.images}" includeEmptyDirs="true">
<fileset dir="${src.images}">
<include name="**/*.jpg"/>
<include name="**/*.gif"/>
</fileset>
</copy>
</target
sowbug - 19 Aug 2003 16:10 GMT
> > I have an ant script that does and hourly build. I want to do a
> > fresh, complete build every time, so I delete all .class files before
[quoted text clipped - 98 lines]
>
> </target>
Please, someone take a stab at it. Doesn't seem to work for me.
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="../../java/" default="all" name="BuildAtrmis">
<target name="init">
<property name="hello" value="world"/>
<property name="atrmis_dir" value="/Atrmis/"/>
<property name="java_dir" value="/cvs/ascii/java/"/>
<taskdef name="javamake"
classname="com.sun.tools.javamake.ant.JavaMake">
<classpath><pathelement
location="${atrmis_dir}j2sdk1.4.1/jre/lib/ext/javamake-ant15.jar"/></classpath>
<classpath><pathelement
location="${atrmis_dir}j2sdk1.4.1/jre/lib/ext/javamake.jar"/></classpath>
</taskdef>
</target>
<target depends="init" name="clean" description="Clean all build
products">
<delete>
<fileset dir="${atrmis_dir}">
<include name="**/*.class"/>
<exclude name="j2sdk1.4.1"/>
</fileset>
<fileset dir="${java_dir}">
<include name="**/*.class"/>
</fileset>
</delete>
</target>
<target depends="init,clean" name="checkout">
<exec dir="/" executable="./checkout.sh"/>
</target>
<target depends="init,clean,checkout" name="compile">
<javamake verbose="false" deprecation="true"
destdir="${atrmis_dir}" srcdir="./com/optdatainc/" failonerror="false"
fork="yes" memoryMaximumSize="256m">
<classpath><pathelement
location="${java_dir}"/></classpath>
<classpath><pathelement
location="${atrmis_dir}j2sdk1.4.1/lib/ext/AbsoluteLayout.jar"/></classpath>
</javamake>
<javamake verbose="false" deprecation="true"
destdir="${atrmis_dir}" srcdir="./ar/atrs/atrmis/dclgen/"
failonerror="false" fork="yes" memoryMaximumSize="256m">
<classpath><pathelement
location="${java_dir}"/></classpath>
</javamake>
<javamake verbose="false" deprecation="true"
destdir="${atrmis_dir}" srcdir="./ar/atrs/atrmis/" failonerror="false"
fork="yes" memoryMaximumSize="256m">
<classpath><pathelement location="."/></classpath>
<classpath><pathelement
location="${atrmis_dir}j2sdk1.4.1/lib/ext/AbsoluteLayout.jar"/></classpath>
<classpath><pathelement
location="${atrmis_dir}j2sdk1.4.1/lib/ext/junit-ext.jar"/></classpath>
<classpath><pathelement
location="${atrmis_dir}j2sdk1.4.1/lib/ext/junit.jar"/></classpath>
<classpath><pathelement
location="${atrmis_dir}j2sdk1.4.1/lib/ext/TimerBean.jar"/></classpath>
<classpath><pathelement
location="${atrmis_dir}j2sdk1.4.1/lib/ext/DataVision.jar"/></classpath>
<exclude name="servlet/"/>
<exclude name="ext/"/>
</javamake>
</target>
Thanks in advance.
Brian
Ville Oikarinen - 22 Aug 2003 07:28 GMT
You said that you delete the class files, but do you leave the empty
directories? I have seen the "package does not exist" with empty directories
(source directories though). The error is reported by javac.
Maybe that's your problem. I don't have time to read your ant file, but make
sure to delete the whole directory under which the packages reside.
Regards,
Ville Oikarinen
sowbug - 09 Sep 2003 16:15 GMT
> You said that you delete the class files, but do you leave the empty
> directories? I have seen the "package does not exist" with empty directories
[quoted text clipped - 6 lines]
>
> Ville Oikarinen
I tried that as well, but ant still can't recognize the package with
only .java files in it. Also J, on your script, you are deleting only
the class files from your dest directory, whereas I am trying to
delete all class files from my src directory and recompile them there.
Brian