Skip to content
Merged
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
36 changes: 24 additions & 12 deletions src/main/java/org/rascalmpl/maven/AbstractRascalMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public abstract class AbstractRascalMojo extends AbstractMojo
@Parameter(defaultValue="${project}", readonly=true, required=true)
protected MavenProject project;

@Parameter(property="memory", defaultValue="2G", readonly=true, required=false)
@Parameter(property="memory", defaultValue="2G", readonly=false, required=false)
protected String memory;

@Parameter(defaultValue = "${project.build.outputDirectory}", property = "bin", required = true )
Expand All @@ -88,7 +88,7 @@ public abstract class AbstractRascalMojo extends AbstractMojo
@Parameter(defaultValue = "${session}", required = true, readonly = true)
protected MavenSession session;

@Parameter(defaultValue = "0.41.2", required = false, readonly = false)
@Parameter(defaultValue = "0.41.3-RC1", required = false, readonly = false)
protected String bootstrapRascalVersion;

@SuppressWarnings("deprecation") // Can't get @Parameter to work for the pluginManager.
Expand Down Expand Up @@ -169,11 +169,9 @@ public void execute() throws MojoExecutionException {
}

for (File resource : resources) {
getLog().debug("\tcopying resources: " + resource);
getLog().debug("\tregistered resource: " + resource);
}

getLog().info("Checking if any files need compilation...");

libs.addAll(collectDependentArtifactLibraries(project));

for (File lib : libs) {
Expand All @@ -196,17 +194,20 @@ public void execute() throws MojoExecutionException {
true)
.waitFor();

if (exitVal != 0) {
throw new MojoExecutionException(mainClass + " exited with error code " + exitVal);
}
if (exitVal != 0) {
throw new MojoExecutionException(mainClass + " exited with error code " + exitVal);
}

return;
}
catch (InterruptedException e) {
throw new MojoExecutionException("nested " + mainClass + " was killed", e);
throw new MojoExecutionException(mainClass + " process was killed.", e);
}
catch (MojoExecutionException e) {
throw e;
}
catch (Throwable e) {
throw new MojoExecutionException("error launching " + mainClass, e);
throw new MojoExecutionException(mainClass + " process execution threw an unexpected exception.", e);
}
}

Expand Down Expand Up @@ -273,7 +274,7 @@ protected List<File> collectDependentArtifactLibraries(MavenProject project) thr
}

protected final ArtifactVersion getReferenceRascalVersion() {
return new DefaultArtifactVersion("0.41.2");
return new DefaultArtifactVersion("0.41.3-RC1");
}

protected Path installBootstrapRascalVersion(MavenProject project, MavenSession session) throws MojoExecutionException {
Expand Down Expand Up @@ -391,7 +392,18 @@ protected Process runMain(boolean verbose, String moreClasspath, List<File> srcs
p.redirectErrorStream(true);
}

return p.start();
Process runningProcess = p.start();

// try to clean up the forked process as nicely as possible if we get killed prematurely ourselves
if (runningProcess != null) {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (runningProcess.isAlive()) {
runningProcess.destroy();
}
}));
}

return runningProcess;
}

protected List<File> getTodoList(File binLoc, List<File> srcLocs, List<File> ignoredLocs, String dirtyExtension, String binaryExtension, String binaryPrefix) throws InclusionScanException, URISyntaxException {
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/rascalmpl/maven/PackageRascalMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package org.rascalmpl.maven;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
Expand All @@ -31,12 +32,24 @@ public class PackageRascalMojo extends AbstractRascalMojo
@Parameter(defaultValue = "|mvn://${project.groupId}--${project.name}--${project.version}/|", property = "sourceLookup", required = true )
private String sourceLookup;

@Parameter(defaultValue = "${project.basedir}/target/relocatedClasses", property = "relocatedClasses", required = true )
private String relocatedClasses;

public PackageRascalMojo() {
super("org.rascalmpl.shell.RascalPackage", "package");
}

@Override
public void execute() throws MojoExecutionException {
super.execute();

// after this the other plugins (like the shader) should use the new folder
project.getBuild().setOutputDirectory(relocatedClasses);
}

@Override
protected void setExtraParameters() {
extraParameters.put("sourceLookup", sourceLookup);
extraParameters.put("relocatedClasses", relocatedClasses);
}
}
16 changes: 8 additions & 8 deletions src/main/java/org/rascalmpl/maven/TutorRascalMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,23 @@ public void execute() throws MojoExecutionException {
return;
}

getLog().info("configuring paths");
getLog().debug("configuring paths");
for (File src : srcs) {
getLog().info("\tregistered source location: " + src);
getLog().debug("\tregistered source location: " + src);
}

for (File ignore : ignores) {
getLog().warn("\tignoring sources in: " + ignore);
getLog().debug("\tignoring sources in: " + ignore);
}

var deps = collectDependentArtifactLibraries(project);
libs.addAll(deps);

for (File lib : libs) {
getLog().info("\tregistered library location: " + lib);
getLog().debug("\tregistered library location: " + lib);
}

getLog().info("Paths have been configured.");
getLog().debug("Paths have been configured.");

extraParameters.putAll(Map.of(
"license", license,
Expand Down Expand Up @@ -159,15 +159,15 @@ public void execute() throws MojoExecutionException {
.waitFor();

if (exitCode != 0) {
throw new MojoExecutionException("tutor returned non-zero exit status");
throw new MojoExecutionException(mainClass + " terminated with errors.");
}

}
catch (InterruptedException e) {
throw new MojoExecutionException("nested " + mainClass + " was killed", e);
throw new MojoExecutionException(mainClass + " was killed.", e);
}
catch (Throwable e) {
throw new MojoExecutionException("error launching " + mainClass, e);
throw new MojoExecutionException(mainClass + " terminated with an exception.", e);
}
}

Expand Down