j2me-maven-plugin

The maven2 J2ME plugin supports the development of J2ME applications. The goals of this plugin cover the packaging, instrumentation, obfuscation, preverification process of the compiled classes and the creation of a java descriptor. The goals are configured using plugin configurations and profiles.

The creation of this plugin was inspired by j2me-maven-plugin.

The plugin itself is using Antenna in many cases. Also you need Sun Java Wireless Toolkit for preverification goal.

Getting started

Use use our midlet-example project or j2me-simple Archetype to start your own maven 2 project.

Usage

Simple MIDlet pom.xml example

<project>
    ...
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.3</source>
                    <target>1.1</target>
                </configuration>
            </plugin>

            <!-- Create application loadable on the phone -->
            <plugin>
                <groupId>com.pyx4me</groupId>
                <artifactId>j2me-maven-plugin</artifactId>
                <executions>
                   <execution>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <wtkHome>${env.WTK_HOME}</wtkHome>
                    <proguard>false</proguard>
                    <obfuscate>false</obfuscate>
                    <jadAttributes>
                        <Created-By>Bartek Teodorczyk</Created-By>
                    </jadAttributes>
                    <midlets>
                        <MIDlet>
                            <name>SimpleDemo</name>
                            <icon>/me2-icon.png</icon>
                            <class>org.microemu.midp.examples.simpledemo.SimpleDemoMIDlet</class>
                        </MIDlet>
                    </midlets>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>

pom.xml example of MIDlet suite with two MIDlets the second one for tests. The application is using JSR-82 and JSR-75.

<project>
    ...
    <dependencies>

        ...

        <dependency>
            <groupId>org.microemu</groupId>
            <artifactId>microemu-jsr-75</artifactId>
            <version>2.0.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>net.sf.bluecove</groupId>
            <artifactId>bluecove</artifactId>
            <version>1.2.2</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

    <properties>
        <wtk.bluetooth.enabled>true</wtk.bluetooth.enabled>
        <wtk.optionalpda.enabled>true</wtk.optionalpda.enabled>
    </properties>

    <build>
        <plugins>
            ...
            <plugin>
                <groupId>com.pyx4me</groupId>
                <artifactId>j2me-maven-plugin</artifactId>
                <executions>
                   <execution>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <wtkHome>${env.WTK_HOME}</wtkHome>
                    <midlets>
                        <MIDlet>
                            <name>Main App</name>
                            <icon>/app-icon.png</icon>
                            <class>com.corp.MainMIDlet</class>
                        </MIDlet>
                        <MIDlet>
                            <name>Test App</name>
                            <icon>/app-icon.png</icon>
                            <test>true</test>
                            <class>com.corp.tests.TestMIDlet</class>
                        </MIDlet>
                    </midlets>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>

pom.xml example of MIDlet using JSR-82.

<project>

    ...

    <dependencies>

        <dependency>
            <groupId>org.microemu</groupId>
            <artifactId>microemulator</artifactId>
            <version>2.0.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>net.sf.bluecove</groupId>
            <artifactId>bluecove</artifactId>
            <version>1.2.2</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            ...
            <plugin>
                <groupId>com.pyx4me</groupId>
                <artifactId>j2me-maven-plugin</artifactId>
                <executions>
                   <execution>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <wtkHome>${env.WTK_HOME}</wtkHome>
                    <useWtkLibs>false</useWtkLibs>
                    <midlets>
                        <MIDlet>
                            <name>Main App</name>
                            <icon>/app-icon.png</icon>
                            <class>com.corp.MainMIDlet</class>
                        </MIDlet>
                    </midlets>
                    <libs>
                        <lib>${java.home}/lib/rt.jar</lib>
                    </libs>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>