You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Brown, Carlton" <Ca...@BellSouth.com> on 2005/11/19 00:15:07 UTC

Subdirectory problem/always recompiles

I've got a situation where the directory structure of the source code
doesn't exactly correspond to the package structure, and therefore the
javac task always recompiles.   Due to a number of policy considerations
I can't change the dir structure, so I've tried to work around this with
some clever mapping and globbing.   I couldn't come up with a solution
so I thought I'd bring it here.

 

Here's my source directory hierarchy:

 src/gadget/alpha/com/company/foo

 src/gadget/beta/com/company/foo

 src/gadget/gamma/com/company/foo

 

here's the output class hierarchy:

classes/com/company/foo

 

And to make it more difficult, the files in the 3 subdirectories all
depend on each other.

 

What's the correct way to write this so that it compiles only when the
target is not up to date?

 

Sorry if this is a trivial question, I admit I'm new to the product and
am having some trouble with it.


Re: Subdirectory problem/always recompiles

Posted by Steve Loughran <st...@apache.org>.
Brown, Carlton wrote:
> I've got a situation where the directory structure of the source code
> doesn't exactly correspond to the package structure, and therefore the
> javac task always recompiles.   Due to a number of policy considerations
> I can't change the dir structure, so I've tried to work around this with
> some clever mapping and globbing.   I couldn't come up with a solution
> so I thought I'd bring it here.

I really think you ought to compile to the spec. the issue is not just 
that ant's dependency logic demands it, but so does javac, both on the 
command line and in <javac>

when you hand off a .java file to be compiled, and something it imports 
aint there, then javac finds and compiles it first, using the package 
name to locate it. Break the package naming rules, and javac breaks.

Whatever your policy is, it's broken. sorry. try and get it fixed again.

-steve

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


Re: Subdirectory problem/always recompiles

Posted by Matt Benson <gu...@yahoo.com>.
--- "Brown, Carlton" <Ca...@BellSouth.com>
wrote:

> I've got a situation where the directory structure
> of the source code
> doesn't exactly correspond to the package structure,
> and therefore the
> javac task always recompiles.   Due to a number of
> policy considerations
> I can't change the dir structure, so I've tried to
> work around this with
> some clever mapping and globbing.   I couldn't come
> up with a solution
> so I thought I'd bring it here.
> 
>  
> 
> Here's my source directory hierarchy:
> 
>  src/gadget/alpha/com/company/foo
> 
>  src/gadget/beta/com/company/foo
> 
>  src/gadget/gamma/com/company/foo
> 
>  
> 
> here's the output class hierarchy:
> 
> classes/com/company/foo
> 
>  
> 
> And to make it more difficult, the files in the 3
> subdirectories all
> depend on each other.
> 
>  
> 
> What's the correct way to write this so that it
> compiles only when the
> target is not up to date?
> 
>  
> 
> Sorry if this is a trivial question, I admit I'm new
> to the product and
> am having some trouble with it.

This buildfile works fine for me for your "situation."
 ;)

<project default="build">
  <property name="build.dir" location="classes" />
  <property name="srcg" location="src/gadget" />
  <path id="srcpath"
       
path="${srcg}/alpha:${srcg}/beta:${srcg}/gamma"/>

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

  <target name="build">
    <mkdir dir="${build.dir}" />
    <javac destdir="${build.dir}">
      <src refid="srcpath" />
    </javac>
  </target>
</project>

HTH,
Matt
> 
> 



	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

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