@Mojo(name="smc",
defaultPhase=GENERATE_SOURCES)
public final class SmcMojo
extends org.apache.maven.plugin.AbstractMojo
.sm files found in the configured
setSourceDirectory(java.io.File) using the configured SMC
parameters. The generated file(s) are placed in
setTargetDirectory(java.io.File).
This mojo has the side effect of adding the
targetDirectory to the project compile source root.
This allows application code to successfully reference the
generated code.
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_GRAPH_LEVEL
The default graph detail level is zero (least detail).
|
static String |
NO_DEBUG_OUTPUT
Set
debugLevel to "-1" to silence SMC debug
output. |
static String |
SM_SUFFIX
SMC target file names must end with ".sm".
|
| Constructor and Description |
|---|
SmcMojo()
Creates a new SMC maven mojo instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
execute()
Firstly validates the mojo settings.
|
void |
setAccess(String access)
Access identifier for generated classes.
|
void |
setCast(String cast)
When generating C++ code, use this cast type
(
dynamic_cast, static_cast, or
reinterpret_cast). |
void |
setCrtp(boolean crtp)
If
true user supplied class must be derives from
state machine. |
void |
setDebugLevel(int debugLevel)
Adds SMC debug output to generated code.
|
void |
setGeneric(boolean generic)
If
true, use a
Map<String, Integer> for reflection
map. |
void |
setGeneric7(boolean generic7)
Use Java 7 generic collections for reflection map.
|
void |
setGraphLevel(int glevel)
Specifies the Graphviz output detail level.
|
void |
setHeaderd(File dir)
Places generated header files into this directory.
|
void |
setHsuffix(String headerSuffix)
Appends generated header target file(s) with this
suffix.
|
void |
setNocatch(boolean nocatch)
If
true, do not generate
try/catch/rethrow code. |
void |
setNoex(boolean noex)
If
true, do not generate C++ exception
throws. |
void |
setNostreams(boolean nostreams)
If
true, do not use C++ iostreams for debugging. |
void |
setProject(org.apache.maven.project.MavenProject project)
Maven uses this method to set the target project.
|
void |
setProtocol(boolean protocol)
User-defined FSM context class extends
@protocol. |
void |
setReflection(boolean reflection)
If
true, generate getTransitions() method
for each state, allowing the state to be interrogated
about its supported transition. |
void |
setSerial(boolean serial)
If
true, generate unique integer identifiers for
each state. |
void |
setSourceDirectory(File dir)
Source directory containing the
.sm files. |
void |
setSources(String[] sources)
Compiles the following target files.
|
void |
setStateStackSize(int stateStackSize)
If > zero, state stack has a fixed size defined by this
setting.
|
void |
setSuffix(String suffix)
Append generated target file(s) with this suffix.
|
void |
setSync(boolean sync)
If
true generates thread-safe code. |
void |
setTargetDirectory(File dir)
Place generated files into this directory.
|
void |
setTargetLanguage(String language)
Output the generated finite state machine in this target
language.
|
void |
setVerbose(boolean verbose)
If
true, execute() outputs more detailed
messages. |
void |
setVverbose(boolean vverbose)
If
true, execute() outputs even more
detailed messages. |
public static final String SM_SUFFIX
public static final String NO_DEBUG_OUTPUT
debugLevel to "-1" to silence SMC debug
output.public static final String DEFAULT_GRAPH_LEVEL
public void execute()
throws org.apache.maven.plugin.MojoExecutionException,
org.apache.maven.plugin.MojoFailureException
Executing this mojo has the side effect of adding the target directory to the project compile source root. This allows application code to reference this generated source code.
org.apache.maven.plugin.MojoExecutionException - if an invalid setting is detected or the FSM compilation
fails. No target code is emitted.org.apache.maven.plugin.MojoFailureException - this exception is never thrown.public void setTargetLanguage(String language)
The defined target languages are:
language - target language name.public void setSourceDirectory(File dir)
.sm files. This
setting is optional and defaults to
${project.basedir}/src/main/smc.dir - source directory.public void setTargetDirectory(File dir)
${project.build.directory}/generated-sources/smc.dir - target directory.public void setSources(String[] sources)
.sm files found
in setSourceDirectory(java.io.File). Specified target files
names must be relative to setSourceDirectory(java.io.File).sources - source file names.public void setSuffix(String suffix)
setTargetLanguage(java.lang.String) is used.suffix - generated source file name suffix.public void setHsuffix(String headerSuffix)
setTargetLanguage(java.lang.String) is used. This parameter is
ignored if setTargetLanguage(java.lang.String) does not use header
files.
Available for c, c++, and objc only.
headerSuffix - generated header file name suffix.public void setHeaderd(File dir)
Available for c, c++, and objc only.
dir - target header file directory.public void setDebugLevel(int debugLevel)
debugLevel - SMC debug output level.public void setNostreams(boolean nostreams)
true, do not use C++ iostreams for debugging.
Application code must provide a TRACE macro to
output debug messages. Default setting is false.
Available for c++ only.
nostreams - flag to turn C++ iostreams output on or
off.public void setCrtp(boolean crtp)
true user supplied class must be derives from
state machine. The default is false.
See CRTP ("curiously recurring template pattern").
Available for c++ only.
crtp - turn CRTP code generation on or off.public void setSync(boolean sync)
true generates thread-safe code. This is not
necessary if application guarantees FSM access is
thread-safe. Default setting is false.
Available for csharp, java, java7, groovy, scala, and vb only because these languages provide thread synchronization constructs in the language.
sync - turns thread synchronization code generation
on or off.public void setNoex(boolean noex)
true, do not generate C++ exception
throws. Default setting is false.
Available for c++ only.
noex - turn C++ exception throw code generation on or
off.public void setNocatch(boolean nocatch)
true, do not generate
try/catch/rethrow code. The try/catch
is used to guarantee that the current state is set before
allowing the exception throw to continue. If current FSM
state is left null, then the FSM is broken and
ceases to function. Default setting is false.
Setting this property to true is
not recommended.
nocatch - turns try/catch block code
generation on or off.public void setStateStackSize(int stateStackSize)
Available for c++ only.
stateStackSize - state stack fixed size.public void setSerial(boolean serial)
true, generate unique integer identifiers for
each state. These identifiers are used to efficiently
serialize the current state stack. Default setting is
false.serial - turns state identifier generation on or off.public void setReflection(boolean reflection)
true, generate getTransitions() method
for each state, allowing the state to be interrogated
about its supported transition. Default setting is
false.
Available for csharp, groovy, java, java7, js, lua, perl, php, python, ruby, scala, tcl, and vb only.
reflection - turns state machine reflection on or
off.public void setGeneric(boolean generic)
true, use a
Map<String, Integer> for reflection
map. Default setting is false.
Available for csharp, java, or vb only when
reflect property is set to true.
generic - turn generic reflection code generation on
or off.public void setGeneric7(boolean generic7)
Available for java, or java7 only when
reflect property is set to true.
generic7 - turns Java 7 generic collections on or
off.public void setVerbose(boolean verbose)
verbose - turn verbose execution output on or off.public void setVverbose(boolean vverbose)
vverbose - turn very verbose execution output on or
off.public void setGraphLevel(int glevel)
Available for graph only.
glevel - Graphviz detail level.public void setCast(String cast)
dynamic_cast, static_cast, or
reinterpret_cast). Default setting is
dynamic_cast.
Available for c++ only.
cast - generated C++ cast code.public void setAccess(String access)
public.
Available for java, java7 only.
access - Java access level.public void setProtocol(boolean protocol)
@protocol.
Generated code references context class via protocol.
Default setting is false.
Available for objc only.
protocol - turns Objective-C @protocol
support on or off.public void setProject(org.apache.maven.project.MavenProject project)
${project}.project - mojo is working for this maven project.Copyright © 2019. All rights reserved.