Maven Plugin
rascal-0.43.3
The rascal-maven-plugin offers these Maven plugins for dealing with Rascal projects:
- Compile Mojo for static checking and compiling Rascal projects.
- Tutor Mojo for generating API docs, and compiling documentation courses.
- Package Mojo for packing compiled Rascal code, source code and documentation into a jar file.
- Exec Mojo for executing arbitrary Rascal code during an arbitrary Maven goal.
- Console Mojo for starting a Rascal REPL
- Test Mojo for running Rascal tests.
Each of the above is configured in XML in the local pom.xml file of a Rascal project. All of them are executed during a mvn package or mvn install commandline. If the local pom has the right configuration, then each mojo can also be invoked by the respective stage, or separately:
mvn compileormvn rascal:compileruns the compiler and-Drascal.compile.skipguarantees it is skipped.mvn compileormvn rascal:tutorruns the tutor compiler and-Drascal.tutor.skipguarantees it is skipped.mvn packageormvn rascal:packageruns the package rewriter and-Drascal.package.skipguarantees it is skipped.mvn rascal:execexecutes some Rascal code, while-Drascal.exec.skipmakes sure this goal is skipped.mvn testormvn rascal:testruns all test in all modules and reports the result intarget/rascal-test-results, while-Drascal.test.skipmakes sure this goal is skipped.mvn rascal:consolestarts up a Rascal terminal with the same configuration asmvn rascal:testwould use.
Examples
This is a typical pom.xml file configuring the rascal-maven-plugin that will provide everything
necessary for a Rascal project, except the Tutor Mojo. This is also the setup that is generated by the New Rascal Project function:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.rascalmpl</groupId>
<artifactId>my-project</artifactId>
<version>0.1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>usethesource</id>
<url>https://releases.usethesource.io/maven/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>usethesource</id>
<url>https://releases.usethesource.io/maven/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.rascalmpl</groupId>
<artifactId>rascal</artifactId>
<version>0.43.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<compilerArgument>-parameters</compilerArgument>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.rascalmpl</groupId>
<artifactId>rascal-maven-plugin</artifactId>
<version>0.32.2</version>
<configuration>
<errorsAsWarnings>true</errorsAsWarnings>
<bin>${project.build.outputDirectory}</bin>
<srcs>
<src>${project.basedir}/src/main/rascal</src>
</srcs>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Benefits
- Almost zero configuration (due to sensible defaults) for projects that have:
- Rascal source code in
/src/main/rascal - Dependencies listed in
pom.xml<dependency>tags
- Rascal source code in
- When using the Get Project Path Config function from Reflective, and a local
pom.xmlis available, then the produced configuration will be influenced by what is configured in thepom.xmlfile as well. - All dependencies defined in the
pom.xmlare used to automatically configure the library path of the compiler and the interpreter, as well as the classpath of the compiled or interpreted runtime engine. - Rascal projects can depend on any other Maven project
Pitfalls
- Watch out that
<configuration>tags can be different for each<execution>goal. Specifically<srcs>can be (should be) different between compile and tutor. - Maven will always executer earlies stages first. So
mvn packagewill executecompile,testandpackage(at least). Use-Drascal.<stage>.skipto avoid double work.