Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/main/java/org/rascalmpl/maven/AbstractRascalMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -410,6 +411,25 @@ protected Process runMain(boolean verbose, String moreClasspath, List<File> srcs
return runningProcess;
}

protected List<File> allRascalSourceFiles(List<File> sourceLocs, List<File> ignoredLocs) {
var result = new LinkedList<File>();
allRascalSourceFiles(sourceLocs.stream().toArray(File[]::new), ignoredLocs, result);
return result;
}

private void allRascalSourceFiles(File[] sourceLocs, List<File> ignoredLocs, List<File> 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<File> getTodoList(File binLoc, List<File> srcLocs, List<File> ignoredLocs, String dirtyExtension, String binaryExtension, String binaryPrefix) throws InclusionScanException, URISyntaxException {
StaleSourceScanner scanner = new StaleSourceScanner(100);
scanner.addSourceMapping(new SourceMapping() {
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/org/rascalmpl/maven/TestRascalMojo.java
Original file line number Diff line number Diff line change
@@ -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<File> 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());
}
}
Loading