File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes ant javac task not copying directory with no java files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "ant javac task not copying directory with no java files" Watch "ant javac task not copying directory with no java files" New topic
Author

ant javac task not copying directory with no java files

Zenikko Sugiarto
Ranch Hand

Joined: Jan 09, 2005
Posts: 58
Situation:

Writing ant script to build web application
/src --compile to--> /build/WEB-INF/classes

in the source directory, there is a directory that contains
no class, but it contains the ApplicationResouce.properties file

let's say it's sitting in
/src/some/package/name/ApplicationResource.properties

this directory ONLY contain this file

Problem:

When I am running ant javac task, all class got compiled nicely but the ApplicationResource.properties is *NOT* copied over. WHY? I tought compile would take care of that?

In eclipse, if I set the source directory to point to /src and have it compile to some directory like /build/WEB-INF/classes

the ApplicationRespurce.properties *DOES* get copied over.

Why am I still compiling via ant? because the source will be checked out in the server and compiled using ant by logging in via SSH. So I need to get ant javac to compile AND copy the ApplicationResource.properties even tho there's no .java in that directory.

Here's my ant javac task:


Restraint:
I can get away by manually putting a copy task to copy over the ApplicationResouce.properties file, but what if I have 20 files? I hate to do that manually. It should does it automaticallt on compile but I'm not sure how

Settings:
I'm using java 1.5.0_03, I'm running ant using javac fork=true


---

So... HELP!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

Compiling means "Turn Java source code into class files". Copying was NEVER part of the process, whether standalone javac or as an Ant invocation of javac.

However, the copy task can certainly do as many files as you like. People often do an exclude for "**/*.java", for example.

Myself, I prefer to keep the invariant stuff in a protype exploded WAR and just copy the whole thing over to the build directory. That included properties files, struts, JSF and Spring config files, WEB-INF/lib jars, etc.
[ March 24, 2006: Message edited by: Tim Holloway ]

Customer surveys are for companies who didn't pay proper attention to begin with.
Vincy Kaczanowski
Greenhorn

Joined: Sep 22, 2005
Posts: 19
Zenikko,
i too have faced simillar problem,i am not sure this will help u out ,try this

<target description="Build JAR files" name="javajar" depends="init">
<move verbose="true" todir="ABCDE/bin" >
<fileset dir="ABCDE/src">
<include name="**/*.properties" />
</fileset>
</move>
<jar jarfile="MyEarModule/ABCDE.jar" >
<fileset dir="ABCDE/bin" includes="**/*.class" excludes="META-INF/**/*"/>
<fileset dir="ABCDE/bin">
<include name="**/*.properties" />
</fileset>
</jar>
</target>
Zenikko Sugiarto
Ranch Hand

Joined: Jan 09, 2005
Posts: 58
Thx for the reply, was a bit too late but I actually figured workaround already.

@Tim Holloway
you were right, it was never meant to do any copying. And my workaround did just what you described, copy the lot excluding *.java before compile.

like so



hehe was busy doing something before, forgot I posted here :-pp thx for ur reply anyhoo
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ant javac task not copying directory with no java files
 
Similar Threads
JNDI properties for JBoss 4.2.2
Build failed- ejb3.deployer not found
package javax.ejb does not exist
ant tomcat dist -wrong file structure specified
${env.JBOSS_HOME}\client not found.