ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ego <m47841-mailingli...@yahoo.it>
Subject Newbie: <javac> task can't find my source files
Date Sat, 20 Aug 2011 13:02:08 GMT
I've read thoroughly the manual and examples but still can't find the reason for this behavior.
First, some pointers to state my case.

- Environment: Windows XP SP3, Ant 1.8.1, jdk1.6.0_02

- My project builds and run fine from the cmdline, provided that the CLASSPATH env. variable
is set. I can even get a working jar executable from it, so the manifest file (created manually)
is also ok. So I tried to repeat the development & deployment process using Ant.

First, I deleted the CLASSPATH env variable to avoid problems. Rebooted my system.
This is my package structure (relative paths):

[root.dir]\ant builfiles\            //contains the xml buildfiles for my projects
[root.dir]\projects\
[root.dir]\projects\modules\
[root.dir]\projects\modules\src\
[root.dir]\projects\modules\src\packages\    // source code for general purpose auxiliary

                        // classes, w/ subpackages

[root.dir]\projects\modules\src\apps\        // source code for the actual project classes

[root.dir]\projects\modules\src\resources\    // icons and other files required by projects

[root.dir]\projects\WEB-INF\
[root.dir]\projects\WEB-INF\build\        // destdir for the <javac> task
[root.dir]\projects\WEB-INF\dist\        // destdir for the <jar> task


Both the build.xml and build.properties files are located in the "ant buildfiles" folder.
The following is the build.properties file:

src.dir=../projects/modules/src
build.dir=../projects/WEB-INF/build
dist.dir=../projects/WEB-INF/dist
project.name=gdv
main-class=apps.gdv.v1_0_0.GDVLauncher
jar-classpath=.\\gdv.jar            // the double backslash is an escape sequence
                        // and it works fine (more details later)
                        
and this is build.xml file:

<?xml version="1.0"?>
<project name="gdv" default="run">
<property file="build.properties"/>

    <target name="clean">   
        <delete dir="${build.dir}"/>
        <delete dir="${dist.dir}"/>        
    </target>
    
    <target name="init" depends="clean">
    <echo>Creating the build directories</echo>
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${dist.dir}"/>
    
<!-- this section is an alternate method to include resource files:    
    
    <copy todir="${build.dir}/resources">
    <fileset dir="${src.dir}/resources"/>
    </copy>
    
Basically is a workaround to get a jar file containing the resource files and a valid manifest
despite the whenmanifestonly="skip" property set in the <jar> task. I inspected the
resulting manifest file and found it exactly as expected. Manifest and resources are present,
the packages with the bytecode obviously not (compilation fails).

-->    

    </target>
    
    <target name="compile" depends="init">
         <javac sourcepath="${src.dir}" srcdir="${src.dir}"
            destdir="${build.dir}" 
            includeantruntime="false" 
            debug="on"
            optimize="on"
            fork="true">
               <compilerarg value="-Xlint:unchecked"/>
               <compilerarg value="-Xlint:deprecated"/>
               <compilerarg value="-g"/>
               <include name="${src.dir}/packages/sde/actor"/>
               <include name="${src.dir}/packages/sde/semaphore"/>
               <include name="${src.dir}/packages/sde/monitor"/>
               <include name="${src.dir}/packages/synch"/>
               <include name="${src.dir}/apps/gdv/v1_0_0"/>
               <include name="${src.dir}/resources/gdv/icons"/>
         </javac>
    </target>

    <target name="jar" depends="compile">
        <jar destfile="${dist.dir}/${ant.project.name}.jar" 
             basedir="${build.dir}"
             whenmanifestonly="skip"
             >
            <manifest>
        <attribute name="Main-Class" value="${main-class}"/>
        <attribute name="Classpath" value="${jar-classpath}"/>
            <!-- Who is building this jar? -->
            <attribute name="Built-By" value="${user.name}"/>
            <!-- Information about the program itself -->
            <attribute name="Implementation-Vendor" value="Bogus Inc."/>
            <attribute name="Implementation-Title" value="gdv"/>
            <attribute name="Implementation-Version" value="1.0.0"/>
            <!-- details -->
        <attribute name="Sealed" value="false"/>
            </manifest>
        </jar>
    </target>

    <target name="run" depends="jar">
        <java jar="${dist.dir}/${ant.project.name}.jar" fork="true"/>
    </target>

</project>

Finally, here's the verbose output of the ant command:

Apache Ant version 1.8.1 compiled on April 30 2010
Trying the default build file: build.xml
Buildfile: D:\Workspaces\Java\ant buildfiles\build.xml
Detected Java version: 1.6 in: C:\Programmi\Java\jdk1.6.0_02\jre
Detected OS: Windows XP
parsing buildfile D:\Workspaces\Java\ant buildfiles\build.xml with URI = file:/D:/Workspaces/Java/ant%20buildfiles/build.xml
Project base dir set to: D:\Workspaces\Java\ant buildfiles
parsing buildfile jar:file:/C:/apache-ant-1.8.1/lib/ant.jar!/org/apache/tools/ant/antlib.xml
with URI = jar:file:/C:/apache-ant-1.8.1/lib/ant.jar!/org/apache/tools/ant/antlib.xml from
a zip file
 [property] Loading D:\Workspaces\Java\ant buildfiles\build.properties
Build sequence for target(s) `run' is [clean, init, compile, jar, run]
Complete build sequence is [clean, init, compile, jar, run, ]

clean:
   [delete] Deleting directory D:\Workspaces\Java\projects\WEB-INF\build
   [delete] Deleting directory D:\Workspaces\Java\projects\WEB-INF\build
   [delete] Deleting directory D:\Workspaces\Java\projects\WEB-INF\dist
   [delete] Deleting directory D:\Workspaces\Java\projects\WEB-INF\dist

init:
     [echo] Creating the build directories
    [mkdir] Created dir: D:\Workspaces\Java\projects\WEB-INF\build
    [mkdir] Created dir: D:\Workspaces\Java\projects\WEB-INF\dist

compile:
    [javac] No sources found.

jar:
      [jar] Warning: skipping jar archive D:\Workspaces\Java\projects\WEB-INF\dist\gdv.jar
because no files were included.
      [jar] Warning: skipping jar archive D:\Workspaces\Java\projects\WEB-INF\dist\gdv.jar
because no files were included.

run:
     [java] Executing 'C:\Programmi\Java\jdk1.6.0_02\jre\bin\java.exe' with arguments:
     [java] '-jar'
     [java] 'D:\Workspaces\Java\projects\WEB-INF\dist\gdv.jar'
     [java] 
     [java] The ' characters around the executable and arguments are
     [java] not part of the command.
     [java] Unable to access jarfile D:\Workspaces\Java\projects\WEB-INF\dist\gdv.jar

BUILD SUCCESSFUL
Total time: 5 seconds

I apologize for this long, boring report, I hope you find the time to read it entirely. 
Any help will be greatly appreciated, thanks in advance for your patience.


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


Mime
View raw message