Good news for Java developers using SMC: the latest SMC is now available on Maven Central and this includes an updated smc-maven-plugin which supports the same options as Smc.jar. This section describes how to access smc-maven-plugin from your pom.xml and the available configuration settings. You will also need to add a dependency on the SMC library module. The repository provides example-java-ex6 with a pom.xml that uses smc-maven-plugin to compile TcpConnection.sm.
<plugin>
<groupId>net.sf.smc</groupId>
<artifactId>smc-maven-plugin</artifactId>
<version>7.0.0</version>
<executions>
<execution>
<id>src-build</id>
<phase>generate-sources</phase>
<goals>
<goal>smc</goal>
</goals>
<configuration>
<targetLanguage>java7</targetLanguage>
<verbose>true</verbose>
</configuration>
</execution>
<execution>
<id>test-build</id>
<phase>generate-test-sources</phase>
<goals>
<goal>smc</goal>
</goals>
<configuration>
<sourceDirectory>${project.basedir}/src/test/smc</sourceDirectory>
<targetDirectory>${project.build.directory}/generated-test-sources/smc</targetDirectory>
<targetLanguage>java7</targetLanguage>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
This pom.xml examples shows how smc-maven-plugin may be
used to generate both application and test sources. This
is done by given each execution a different
<id>
and specifying the Maven build
<phase>
. Note that
<id>src-build</id>
does not
specify <sourceDirectory>
and
<targetDirectory>
. This is because the
default settings are
${project.basedir}/src/main/smc
and
${project.build.directory}/generated-sources
respectively. These defaults work for generating
application source code. But for
<id>test-build<id>
the SMC source
and target directory options must be defined so that SMC
will find and build the test state machines. In both cases
the target programming language is java7
and
SMC <verbose>
option is turned on.
The library dependency needed to run an application is:
<dependency>
<groupId>net.sf.smc</groupId>
<artifactId>library</artifactId>
<version>7.0.0</version>
</dependency>
As with all Maven dependencies, it is up to the developer
to track the correct artifactId version desired for the
project. These examples use
<version>7.0.0</version>
because that is the most recent, stable production
version at the time of this writing. This will change
over time.