Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » packages vs directory structor
packages vs directory structor [message #145732] Thu, 26 February 2004 10:43 Go to next message
Eclipse UserFriend
Originally posted by: cdouglass.mtbj.com

I am trying to use eclipse to do development on an existing project but
I'm running into issues with packages vs directory structure. The original
projects is layed out as

abc/def/XYZ/src/fred.java

where fred.java implements a class in package XYZ. I can create a package
XYZ and set it's directory to be under abc/def but then building fred.java
complains that the package should be XYZ.src not XYZ. If instead I set the
directory for package XYZ to abc/def/XYZ eclipse creates a new XYZ
directory as abc/def/XYZ/XYZ ...

Because the existing ANT scripts rely on existing directory layout I would
really prefer not to have to move the source files.

Setting the source directory property for the project effectively
decouples the leading directory structure from the package name. Is there
a mechanism for decoupling the trailing directory structure from the
package name so I can leave the source in the src subdirectories?

Thanks

Clay
Re: packages vs directory structor [message #145890 is a reply to message #145732] Thu, 26 February 2004 17:48 Go to previous message
Eclipse UserFriend
Originally posted by: rtayek.no.spam.freightgate.com

"Clay Douglass" <cdouglass@mtbj.com> wrote in message
news:c1l46i$95h$1@eclipse.org...
> I am trying to use eclipse to do development on an existing project but
> I'm running into issues with packages vs directory structure. The original
> projects is layed out as
>
> abc/def/XYZ/src/fred.java
>
> where fred.java implements a class in package XYZ. I can create a package
> XYZ and set it's directory to be under abc/def but then building fred.java
> complains that the package should be XYZ.src not XYZ. If instead I set the
> directory for package XYZ to abc/def/XYZ eclipse creates a new XYZ
> directory as abc/def/XYZ/XYZ ...
>
> Because the existing ANT scripts rely on existing directory layout I would
> really prefer not to have to move the source files.
>

i solved a similar problem (using 3.0m07 i think) by fooling around in the
project|properties|java build path|source tab. specify abc/def/XYZ/src as a
source folder (i use projectname/src and projectname/tst). then check the
"allow output folders for source folders". then supply an output foder that
agrees with your ant script (i use projectname/build/srcobj and
projectname/build/tstobj). (see my ant script below)

> Setting the source directory property for the project effectively
> decouples the leading directory structure from the package name. Is there
> a mechanism for decoupling the trailing directory structure from the
> package name so I can leave the source in the src subdirectories?
> ...
i would thing you could point the obj to wherever you like/

hth

<?xml version="1.0" encoding="UTF-8"?>

<project basedir="." default="all" name="mappingtools">

<property environment="env"/>

<property file="${user.home}/build.properties"/>

<property file="build.properties"/>

<!-- may want to set out own build compiler -->

<target name="checkforeclipse" if="eclipse.running">

<property name="build.compiler"
value="org.eclipse.jdt.core.JDTCompilerAdapter"/>

<echo message="junit.home=${junit.home}"/>

<echo message="env.JUNIT_HOME=${env.JUNIT.HOME}"/>

<echo message="JUNIT_HOME=${JUNIT.HOME}"/>

<property name="junit.jar"
value="${eclipse.home}\plugins\org.junit_3.8.1\junit.jar"/ >

</target>

<target name="init" depends="checkforeclipse">

<echo message="env.JAVA_HOME=${env.JAVA_HOME}"/>

<echo message="env.ANT_HOME=${env.ANT_HOME}"/>

<echo message="user.home=${user.home}"/>

<echo message="java.home=${java.home}"/>

<echo message="ant.home=${ant.home}"/>

<property name="junit.jar" value="${ant.home}/lib/junit.jar"/><!-- usually
one hangs out here -->

<echo message="junit.jar=${junit.jar}"/><!-- this has /'s and \'s on windoze
xp! -->

<fail unless="junit.jar">no ant.home!</fail>

<mkdir dir="build"/>

</target>

<target name="clean" depends="init" description="clean">

<delete dir="dist"/>

<delete dir="build"/>

<delete dir="doc/apidoc"/>

<delete dir="deleted"/>

</target>

<target name="compile" depends="init" description="compile">

<mkdir dir="build"/>

<mkdir dir="build/classes"/>

<mkdir dir="build/classes/srcobj"/>

<javac debug="true" deprecation="true" destdir="build/classes/srcobj"
srcdir="src">

<classpath>

<pathelement location="lib/ostermillerutils_1_02_21.jar"/>

</classpath>

</javac>

</target>

<target name="compiletst" depends="init,compile" description="compile
tests">

<mkdir dir="build/classes/tstobj"/>

<javac debug="true" deprecation="true" destdir="build/classes/tstobj"
srcdir="tst">

<classpath>

<pathelement location="lib/ostermillerutils_1_02_21.jar"/>

<pathelement location="${junit.jar}"/>

<pathelement location="build/classes/srcobj"/>

</classpath>

</javac>

<mkdir dir="build/classes/tstobj/com/ediidea/mappingtools/testfiles "/>

<copy todir="build/classes/tstobj/com/ediidea/mappingtools/testfiles ">

<fileset dir="tst/com/ediidea/mappingtools/testfiles" includes="*.*"
excludes="*.nbattrs"/>

</copy>

</target>

<target name="jar" depends="init,compile" description="jar">

<mkdir dir="build/lib"/>

<jar basedir="build/classes/srcobj" compress="true"
jarfile="build/lib/mappingtools.jar">

<exclude name="**/deleted/**"/>

<exclude name="**/RCS/**"/>

<exclude name="*.class"/><!-- exclude default package classes-->

</jar>

</target>

<target name="all" depends="init,junit">

</target>

<!-- figure out how (where) to deliver stuff -->

<target name="deliver" depends="init,jar" description="deliver">

<property name="delivery.dir" value="${user.home}/java/tmp/rel"/>

<mkdir dir="${delivery.dir}"/>

<mkdir dir="${delivery.dir}/lib"/>

<copy todir="${delivery.dir}/lib">

<fileset dir="build/lib" includes="*.jar"/>

</copy>

<mkdir dir="${delivery.dir}/bin"/>

<copy todir="${delivery.dir}/bin">

<fileset dir="sh" includes="checkcsv,csvtocsv,fast,fuv,splitcsv,"/>

</copy>

</target>

<target name="test" depends="init,compiletst" description="test">

<java classname="com.ediidea.mappingtools.MappingToolsTestCase"
failonerror="true" fork="true">

<classpath>

<pathelement location="${ant.home}/lib/xercesImpl.jar"/>

<pathelement location="lib/xalan.jar"/>

<pathelement location="lib/ostermillerutils_1_02_21.jar"/>

<pathelement location="${junit.jar}"/>

<pathelement location="build/classes/srcobj"/>

<pathelement location="build/classes/tstobj"/>

</classpath>

</java>

</target>

<target name="testjar" depends="init,jar,compiletst" description="test jar">

<java classname="com.ediidea.mappingtools.MappingToolsTestCase"
failonerror="true" fork="true">

<classpath>

<pathelement location="${ant.home}/lib/xercesImpl.jar"/>

<pathelement location="lib/xalan.jar"/>

<pathelement location="lib/ostermillerutils_1_02_21.jar"/>

<pathelement location="${junit.jar}"/>

<pathelement location="build/lib/mappingtools.jar"/>

<pathelement location="build/classes/tstobj"/>

</classpath>

</java>

</target>

<target name="junit" depends="init,jar,compiletst" description="test jar
using junit">

<junit printsummary="true" haltonfailure="true">

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

<test name="com.ediidea.mappingtools.MappingToolsTestCase"/>

<classpath>

<pathelement location="lib/xalan.jar"/>

<pathelement location="lib/ostermillerutils_1_02_21.jar"/>

<pathelement location="build/lib/mappingtools.jar"/>

<pathelement location="build/classes/tstobj"/>

</classpath>

</junit>

</target>

<target name="javadoc" depends="init" description="javadoc">

<mkdir dir="doc/apidoc"/>

<javadoc destdir="doc/apidoc" packagenames="com.ediidea.mappingtools.*">

<sourcepath>

<pathelement location="src"/>

</sourcepath>

<classpath>

<pathelement location="${junit.jar}"/>

<pathelement location="lib/xalan.jar"/>

<pathelement location="lib/ostermillerutils_1_02_21.jar"/>

<pathelement location="build/classes/srcobj"/>

</classpath>

</javadoc>

</target>

</project>
Previous Topic:Newbie stuck at HelloWorld
Next Topic:Strip out unneeded plugins
Goto Forum:
  


Current Time: Wed Jul 16 02:28:49 EDT 2025

Powered by FUDForum. Page generated in 0.06055 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top