Using Ant in Mobility Projects


As with general Java project types, Mobility project-related commands are controlled by an automatically generated Ant script. This Ant script is named build.xml and is located directly in your project's home folder. Examining this file reveals that that it, by default, simply imports the project's build-impl.xml file. The relationship between these two files is important to understand if you would like to modify the build process in some way. Feel free to modify build.xml however you like, but do not change build-impl.xml. build-impl.xml may be regenerated by the IDE, so changes you make to this file can be lost.

Should your build-impl.xml file become corrupted, you can force it to be regenerated by deleting it and closing and then reopening the project.


Adding functionality to the NetBeans build process can be accomplished by overriding the targets defined in build-impl.xml file that run both before and after the main build targets. These are described in detail in each project build.xml file.

It is also acceptable to override the main project targets if you are interested in completely changing the behavior of the build script. These main targets are invoked by the similarly named project commands within the IDE.

Mobility Ant Library

Mobility Pack ships with a special Ant library responsible for handling J2MEspecific tasks. This library can be freely shared, and is located at NetBeansHome/mobility/modules/org-netbeans-modules-kjava-antext.jar.

Tasks that exist in the Mobility Library are listed here, along with descriptions of what they can do. Each task is listed along with its attributes and nested elements. Required elements are bolded.

  • ExTRactTask: extracts specified JAR and .zip files to a given location.

    *ClassPath: the archives to extract as a full path.

    *ClassPathRef: the archives to extract as a reference to an existing Ant object.

    *Nested ClassPath: the archives to extract specified with a nested Classpath element.

  • Dir: the target directory for extraction.ExcludeManifest: specifies if the META-INF/Manifest.mf files should be excluded from extraction. Defaults to false.

    * one of the class path attributes must be defined.

  • JadTask: support for updating existing JAD file with correct JAR size and URL information. Also provides support for JAR file signing.

    JadFile: location of the source JAD file.

    JarFile: location of the source JAR file.

    Output: destination JAD file. If unspecified, the source location is used.

    Url: value to be set for the MIDlet-Jar-URL property.

    Encoding: the encoding used for the JAD file. Defaults to UTF-8.

    Sign: set to true if signing should be used. Defaults to False.

    *KeyStore: location of the KeyStore file.

    KeyStoreType: use to set the keystore type explicitly. Valid settings are Default and PKCS12. If not set, the extension of the keystore file is used to determine the type.

    *KeyStorePassword: the keystore password.

    *Alias: the owner of the private key to be used for signing

    *AliasPassword: the password to access the alias' private key.

    *Required if Sign is True.

  • ObfuscateTask: support for obfuscation using the ProGuard obfuscator.

    SrcJar: location of source JAR file to be obfuscated.

    DestJar: destination of the obfuscated JAR file.

    ObfuscatorType: specifies which obfuscator to use. If NONE is selected, SrcJar is simply copied to the DestJar location.

    ClassPath: classpath required by SrcJar classes. Can be specified using nested Classpath instead.

    ClassPathRef: classpath for SrcJar classes specified as Ant reference.

    *ObfuscatorClassPath: classpath for the obfuscator.

    *ObfuscatorClassPathRef: classpath for obfuscator as Ant reference.

    *Nested ObfuscatorClassPath: classpath for the obfuscator as a nested element.

    Exclude: a comma-separated list of classes that should not be obfuscated.

    ObfuscationLevel: integer value specifying level of obfuscation. Valid values are 0 through 9, with the default 0.

    ExtraScript: string containing any additional obfuscation commands.

    *Obfuscator classpath must be set using one of these methods.

    The exact commands used by different obfuscation levels can be seen within the IDE. Simply open the Project Properties dialog box and select the Obfuscating panel. Changing the obfuscation level on the slider displays the script commands in the Level Description panel.

  • PreverifyTask: support for preverification.

    SrcDir: location of classes to be preverified.

    DestDir: destination directory for preverified classes.

    PlatformHome: home directory of the emulator platform to be used for preverification.

    PlatformType: controls the format of the preverification command line used. Valid values: UEI-1.0, UEI-1.0.1, or CUSTOM. The default value is UEI-1.0.1.

    Configuration: the configuration to use for preverification. Valid values: CLDC-1.0 and CLDC-1.1. Ignored when PlatformType is set to CUSTOM. ClassPath: classpath for sources in SrcDir. Can also be defined using nested elements.

    ClassPathRef: classpath for sources in SrcDir as an Ant reference.

    CommandLine: command line to be used for preverification. Required when PlatformType is CUSTOM.

  • RunTask: support for running and debugging an application.

    *JadFile: location of target application's JAD file. Required when JadUrl is not set.

    JadUrl: URL for the application's JAD file when using OTA execution.

    PlatformHome: location of emulator platform used for execution.

    PlatformType: controls the format of the execution command line used. Valid values: UEI-1.0, UEI-1.0.1, or CUSTOM. The default value is UEI-1.0.1.

    Device: target emulator platform device.

    ExecMethod: determines if OTA or Standard execution is used. Ignored if JadUrl is not set or PlatformType is CUSTOM.

    ClassPath: classpath for sources in SrcDir. Can also be defined using nested element.

    ClassPathRef: classpath for sources in SrcDir as Ant reference.

    SecurityDomain: security domain in which execution takes place.

    Debug: set to true to run in Debug mode. The default value is False.

    DebugAddress: should just be the port number to use for attaching to the debugger.

    DebuggerAddressProperty: the address to which the debugger tries to connect.

    DebugTransport: specify the transport type to use for debugging. Default is dt_socket.

    DebugServer: specify whether emulator should run in server mode. The default is TRue.

    DebugSuspend: specify whether emulator should wait for connection before starting the application. The default is TRue.

    *CommandLine: command line for running emulator. Required when PlatformType is CUSTOM.



NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net