Astranaut Maven Plugin generates source Java files that describe an abstract syntax tree (AST) model. The plugin works in the Maven compile stage.
See more detail in the description of the basic project.
- Java 1.8
- Maven 3.6.3+ (to build)
Add the astranaut-core dependency to use files generated by Astranaut plugin:
<dependencies>
<dependency>
<groupId>org.cqfn</groupId>
<artifactId>astranaut-core</artifactId>
<version><!-- latest version here --></version>
</dependency>
</dependencies>You can find the latest release number here.
Add Astranaut plugin to your project's POM file:
<plugin>
<groupId>org.cqfn</groupId>
<artifactId>astranaut-maven-plugin</artifactId>
<version><!-- latest version here --></version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>You can find the latest release number here. Note that the plugin version may be different from the core version.
Astranaut plugin uses the following variable data to generate source files:
dsl- the name (path) of the file that contains DSL rules describing an AST model and tree transformationsoutput- the name (path) of the output directory where the Java files should be generated - it must be a directory that is marked as a Sources Root in Maven projectpkg- the package of the generated Java source files - the directory insideoutputwhich is found in generated fileslicense- the name (path) of the file that contains a license header. It is required to add a license to each Java file, therefore the plugin needs this information.version- the version of the implementations which is added to the@sincetag in a Javadoc of each generated class
You can specify all or some of these parameters manually in the plugin's configuration property.
<plugin>
<groupId>org.cqfn</groupId>
<artifactId>astranaut-maven-plugin</artifactId>
<version>0.3.1</version>
<configuration>
<dsl>${basedir}/data/dsl.txt</dsl>
<license>${basedir}/licenses/LICENSE.txt</license>
<output>${basedir}/src/main/java</output>
<version>1.2.3</version>
<pkg>org.uast.generated</pkg>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>By default when the corresponding parameters are not specified in the configuration, Astranaut project will:
- try to find DSL in
${basedir}/src/main/dsl/rules.dslpath and throw an exception if not found; - try to find license in
${basedir}/LICENSE.txtpath and throw an exception if not found; - generate sources in the
${project.build.directory}/generateddirectory marked asGenerated sources root; - generate sources in the
astJava package; - take the version from the Maven project, which is
1.0.0if the project is empty.
- Ivan Kniazkov, @kniazkov
- Polina Volkhontseva, @pollyvolk
See our Contributing policy.