xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Wallace <dwall...@udel.edu>
Subject Re: Makefile's & maja
Date Mon, 29 Nov 1999 21:33:58 GMT
I tried out ANT on a small project of mine and found that it doesn't
quite fit with my preferred directory structure.
I too like to keep my source separate from classfiles, but I dislike
having to place my source in a directory mirroring
the package. I use a flatter directory structure i.e. "src/*.java" so I
don't have to dig down through
"edu/udel/webcredit/*.java"  when I am editing.

The maja.sh script adapted quite readily to this style, but is much
messier to add support for other targets and such (like "clean").

Does anyone else use this style, and is ANT flexible enough to work this
way?



Here's the adapted maja.sh to demonstrate:

#!/bin/bash

ADDL_CLASSPATH=/usr/local/jdk/lib/classes.zip:/opt/jrun/lib/servlet.jar:/opt/jrun/lib/jsp.jar:/opt/jrun/servlets:/opt/jrun/classes:/opt/jrun/lib/udel.jar:/opt/jrun/lib/dbgen.jar

if [ -n $CLASSPATH ]; then
  export CLASSPATH=$ADDL_CLASSPATH:$CLASSPATH
else
  export CLASSPATH=$ADDL_CLASSPATH
fi

export JIKESPATH=$CLASSPATH

javac=${MAJA_JAVAC:-jikes}

base=`pwd`

recurse() {
  for source in "$@"; do
    if [ -d $source ]; then
      recurse $source/*
    else
      case $source in
      *.java)
        class=$classes/$package/${source%.java}.class
        if [ $source -nt $class -o ! -e $class ]; then
    echo $source
        #echo $source $class >&2
        fi
      esac
    fi
  done
}

#
# build <srcdir> <classes> <package-path relative to classes>
#
build() {
  src=$1
  classes=$2
  package=$3
  if [ ! -e "$classes" ] ; then
      mkdir $classes
  fi
  cd $src
  files=$(recurse *)
  if [ -n "$files" ]; then
    echo $classes $files
    $javac -d $classes $files
  fi
}

### CLEAN ###
if [ "-clean" = -$1 ]; then
  echo "cleaning"
  (rm -fr /opt/jrun/classes/edu/udel/webcredit)
  (rm -fr /opt/jrun/servlets/edu/udel/webcredit)
  exit
fi

### BUILD ###

build $base/classes /opt/jrun/classes edu/udel/webcredit
build $base/servlets /opt/jrun/servlets edu/udel/webcredit



--
   *************************************
  *  Dave Wallace (dwallace@udel.edu) *
 * MIS-TRG, University of Delaware   *
*************************************




Mime
View raw message