Instrumentation in J2ME maven build

preprocess in j2me-maven-plugin configuration will enable classes bytecode instrumentation.

Java bytecode instrumentation is done using Javassist with the help of Jour library.

See Jour http://jour.sourceforge.net/ website to understand how to configure bytecode instrumentation filters and Instrumentors.

Example preprocessing to create CLDC Unit tests.

            <plugin>
                <groupId>com.pyx4me</groupId>
                <artifactId>j2me-maven-plugin</artifactId>
                <executions>
                   <execution>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>

                <dependencies>
                    <dependency>
                        <groupId>com.pyx4me</groupId>
                        <artifactId>cldcunit-instrument</artifactId>
                        <version>2.0.2</version>
                    </dependency>
                </dependencies>

                <configuration>
                    <wtkHome>${env.WTK_HOME}</wtkHome>
                    <useWtkLibs>true</useWtkLibs>

                    <test>true</test>
                    <proguard>true</proguard>
                    <obfuscate>false</obfuscate>
                    <proguardInclude>${basedir}/proguard.conf</proguardInclude>
                    <proguardPreverify>true</proguardPreverify>
                    <preprocess>true</preprocess>
                    <jourConfigTest>${basedir}/process-test-classes.jour.xml</jourConfigTest>

                    <midlets>
                        <MIDlet>
                            <name>Example</name>
                            <icon>/pyx.png</icon>
                            <class>CharacterCounterMIDlet</class>
                        </MIDlet>
                        <MIDlet>
                            <name>UnitTests</name>
                            <icon>/pyx.png</icon>
                            <class>UnitTestsMIDLet</class>
                            <test>true</test>
                        </MIDlet>
                    </midlets>
                </configuration>
            </plugin>