From f03c241a9684f0304b3d51525942823e297c9754 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Fri, 17 Apr 2026 10:16:57 +0200 Subject: [PATCH 1/2] added test mojo that calls the RascalTest CLI --- .../org/rascalmpl/maven/TestRascalMojo.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main/java/org/rascalmpl/maven/TestRascalMojo.java diff --git a/src/main/java/org/rascalmpl/maven/TestRascalMojo.java b/src/main/java/org/rascalmpl/maven/TestRascalMojo.java new file mode 100644 index 0000000..f8be879 --- /dev/null +++ b/src/main/java/org/rascalmpl/maven/TestRascalMojo.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2009-2025, NWO-I Centrum Wiskunde & Informatica (CWI) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.rascalmpl.maven; + +import java.io.File; +import java.util.List; +import java.util.stream.Collectors; + +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * Maven Goal for running all tests in the current project + */ +@Mojo(name="test", defaultPhase = LifecyclePhase.TEST, requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME) +public class TestRascalMojo extends AbstractRascalMojo +{ + @Parameter(defaultValue = "", property = "modules", required = false) + private List modules; + + public TestRascalMojo() { + super("org.rascalmpl.shell.RascalTest","test"); + } + + @Override + protected void setExtraParameters() { + extraParameters.put("modules", allRascalSourceFiles(srcs, ignores).stream().map(Object::toString).collect(Collectors.joining(File.pathSeparator))); + extraParameters.put("reporting", "true"); + extraParameters.put("projectRoot", project.getBasedir().toString()); + } +} From 5bb2d34fc9ee9f793ff7fe896debb7b00582bfdd Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Fri, 17 Apr 2026 10:17:39 +0200 Subject: [PATCH 2/2] forgot to add --- .../rascalmpl/maven/AbstractRascalMojo.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rascalmpl/maven/AbstractRascalMojo.java b/src/main/java/org/rascalmpl/maven/AbstractRascalMojo.java index 237d9c9..e478b7c 100644 --- a/src/main/java/org/rascalmpl/maven/AbstractRascalMojo.java +++ b/src/main/java/org/rascalmpl/maven/AbstractRascalMojo.java @@ -40,6 +40,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.compiler.util.scan.InclusionScanException; +import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner; import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner; import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping; @@ -88,7 +89,7 @@ public abstract class AbstractRascalMojo extends AbstractMojo @Parameter(defaultValue = "${session}", required = true, readonly = true) protected MavenSession session; - @Parameter(defaultValue = "0.42.0", required = false, readonly = false) + @Parameter(defaultValue = "0.42.3-SNAPSHOT", required = false, readonly = false) protected String bootstrapRascalVersion; @SuppressWarnings("deprecation") // Can't get @Parameter to work for the pluginManager. @@ -410,6 +411,25 @@ protected Process runMain(boolean verbose, String moreClasspath, List srcs return runningProcess; } + protected List allRascalSourceFiles(List sourceLocs, List ignoredLocs) { + var result = new LinkedList(); + allRascalSourceFiles(sourceLocs.stream().toArray(File[]::new), ignoredLocs, result); + return result; + } + + private void allRascalSourceFiles(File[] sourceLocs, List ignoredLocs, List result) { + for (File f : sourceLocs) { + if (!ignoredLocs.contains(f)) { + if (f.getName().endsWith(".rsc")) { + result.add(f); + } + else if (f.isDirectory()) { + allRascalSourceFiles(f.listFiles(), ignoredLocs, result); + } + } + } + } + protected List getTodoList(File binLoc, List srcLocs, List ignoredLocs, String dirtyExtension, String binaryExtension, String binaryPrefix) throws InclusionScanException, URISyntaxException { StaleSourceScanner scanner = new StaleSourceScanner(100); scanner.addSourceMapping(new SourceMapping() {