I am trying to configure my Eclipse J2ME projects such that I can do
command line builds. I can build and run the emulator from Eclipse, but
I cannot build with the generated Antenna Build files.  The issue seems
be when one project is a dependency of the other.  I was able to come up
with a workaround by modifying the eclipseme-build.xml file, but I'm
looking for a better solution.

Here's what I did:
- Create a TestLib J2ME Suite
- Put a single Java class called TestClass in a package called com.foo.
It's constructor does a System.out.println() so I can tell when it's
called
- Create a TestApp J2ME Suite
- Put a single Midlet class whose startApp() also does a
System.out.println(), then creates an instance of com.foo.TestClass
- Add TestLib to the Java Build Path of TestApp, and have it checked in
the Order and Export tab.

When I run this from within Eclipse, the Emulator starts and I see both
of my print messages and everything seems happy.

Then I started trying to work on getting things working from the command
line.  First I export the Antenna build files for the TestLib library
and built that.  Then I export the Antenna build files for the main
TestApp application, try to build that, and get this error:
===================================================
C:\Documents and Settings\swilliams\workspace\TestApp>%ANT_HOME%\bin\ant
Buildfile: build.xml

-initialize:
     [echo] Initializing build environment...

-eclipseme-initialize:
     [echo] Initializing EclipseME Antenna build environment...

-eclipseme-build:
     [echo] Building source files...
 [wtkbuild]
**************************************************************
 [wtkbuild] * Antenna 0.9.15 initialized for project "TestApp"
*
 [wtkbuild] * Using Sun Wireless Toolkit 2.5 (CLDC-1.1; MIDP-2.1)
*
 [wtkbuild]
**************************************************************
 [wtkbuild] Compiling 1 source file to C:\Documents and
Settings\swilliams\workspace\TestApp\9db49ca5.tmp\tmpclasses
 [wtkbuild] C:\Documents and
Settings\swilliams\workspace\TestApp\src\TestMidlet.java:23: package
com.foo does not exist
 [wtkbuild]             new com.foo.TestClass();
 [wtkbuild]                        ^
 [wtkbuild] 1 error

BUILD FAILED
C:\Documents and
Settings\swilliams\workspace\TestApp\eclipseme-build.xml:25: Compile
failed; see the compiler error output for details.
===================================================

I came up with a workaround by changing three things in
eclipseme-build.xml:

I changed the locations of classpath.TestLib (they were oddly the same
as classpath.TestApp?  Is this right?)  I changed this:
   <path id="classpath.TestLib">
      <path location="${path.build.classes}"/>
      <path location="${path.build.classes}/_no_export"/>
   </path>
To this:
   <path id="classpath.TestLib">
      <path location="${project.root.TestLib}/build/classes"/>
      <path
location="${project.root.TestLib}/build/classes/_no_export"/>
   </path>

And then I changed the classpath being used in the -eclipseme-build
target to refer to classpath.TestLib instead of classpath.TestLib.  I
changed this:
   <target depends="-eclipseme-initialize" name="-eclipseme-build">
      <echo message="Building source files..."/>
      <wtkbuild destdir="${path.build.classes}"
encoding="${src.encoding}" source="1.3" sourcepath=""
srcdir="${project.root.TestApp}/src">
         <classpath refid="classpath.TestApp"/>
      </wtkbuild>
      <wtkbuild destdir="${path.build.classes}"
encoding="${src.encoding}" source="1.3" sourcepath=""
srcdir="${project.root.TestApp}/res">
         <classpath refid="classpath.TestApp"/>
      </wtkbuild>
   </target>
To this:
   <target depends="-eclipseme-initialize" name="-eclipseme-build">
      <echo message="Building source files..."/>
      <wtkbuild destdir="${path.build.classes}"
encoding="${src.encoding}" source="1.3" sourcepath=""
srcdir="${project.root.TestApp}/src">
         <classpath refid="classpath.TestLib"/>
      </wtkbuild>
      <wtkbuild destdir="${path.build.classes}"
encoding="${src.encoding}" source="1.3" sourcepath=""
srcdir="${project.root.TestApp}/res">
         <classpath refid="classpath.TestLib"/>
      </wtkbuild>
   </target>

And then in the -eclipseme-internal-package task I changed the
classpath.TestLib to be a libclasspath instead of a classpath so it
would be included in the final jar.  I changed this:
   <target depends="-eclipseme-build"
name="-eclipseme-internal-package">
      <copy file="${midlet.name}.jad" todir="${path.build.output}"/>
      <wtkpackage autoversion="${flag.autoversion}"
jadfile="${path.build.output}/${midlet.name}.jad"
jarfile="${path.build.output}/${midlet.name}.jar" obfuscate="false"
preverify="${flag.preverify}">
         <fileset dir="${path.build.classes}">
            <exclude name="_no_export/"/>
         </fileset>
         <classpath refid="classpath.TestApp"/>
         <fileset dir="${project.root.TestApp}/src">
            <exclude name="**/*.java"/>
            <exclude name="build/"/>
         </fileset>
         <fileset dir="${project.root.TestApp}/res">
            <exclude name="**/*.java"/>
            <exclude name="build/"/>
         </fileset>
         <classpath refid="classpath.TestLib"/>
      </wtkpackage>
      <antcall target="-eclipseme-obfuscate"/>
   </target>
To this:
   <target depends="-eclipseme-build"
name="-eclipseme-internal-package">
      <copy file="${midlet.name}.jad" todir="${path.build.output}"/>
      <wtkpackage autoversion="${flag.autoversion}"
jadfile="${path.build.output}/${midlet.name}.jad"
jarfile="${path.build.output}/${midlet.name}.jar" obfuscate="false"
preverify="${flag.preverify}">
         <fileset dir="${path.build.classes}">
            <exclude name="_no_export/"/>
         </fileset>
         <classpath refid="classpath.TestApp"/>
         <fileset dir="${project.root.TestApp}/src">
            <exclude name="**/*.java"/>
            <exclude name="build/"/>
         </fileset>
         <fileset dir="${project.root.TestApp}/res">
            <exclude name="**/*.java"/>
            <exclude name="build/"/>
         </fileset>
         <libclasspath refid="classpath.TestLib"/>
      </wtkpackage>
      <antcall target="-eclipseme-obfuscate"/>
   </target>

And then everything built, and I can run the emulator from the command
line and it printed out both messages.  

So I don't really want to modify eclipseme-build.xml; so my questions
are did I figure my project(s) wrong, or did I uncover a bug in how
eclipseme-build.xml is being generated?  And, if so, is there a
different/better way for me to work around the issue than to change the
eclipseme-build.xml file?

Here's my configuration:
Eclipse: Version: 3.3.2 (Build id: M20080221-1800)
Antenna 1.0.0 (although it seems to report itself as 0.9.15)
Eclipse ME 1.7.7
Wireless Toolkit 2.5.2
Ant 1.7.0

Thanks.

---
Scott Williams


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Eclipseme-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/eclipseme-users

Reply via email to