diff --git a/src/main/java/org/rascalmpl/maven/AbstractRascalMojo.java b/src/main/java/org/rascalmpl/maven/AbstractRascalMojo.java index 7098885..be141d3 100644 --- a/src/main/java/org/rascalmpl/maven/AbstractRascalMojo.java +++ b/src/main/java/org/rascalmpl/maven/AbstractRascalMojo.java @@ -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 ) @@ -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. @@ -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) { @@ -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); } } @@ -273,7 +274,7 @@ protected List 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 { @@ -391,7 +392,18 @@ protected Process runMain(boolean verbose, String moreClasspath, List 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 getTodoList(File binLoc, List srcLocs, List ignoredLocs, String dirtyExtension, String binaryExtension, String binaryPrefix) throws InclusionScanException, URISyntaxException { diff --git a/src/main/java/org/rascalmpl/maven/PackageRascalMojo.java b/src/main/java/org/rascalmpl/maven/PackageRascalMojo.java index 245dd05..c55cd6d 100644 --- a/src/main/java/org/rascalmpl/maven/PackageRascalMojo.java +++ b/src/main/java/org/rascalmpl/maven/PackageRascalMojo.java @@ -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; @@ -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); } } diff --git a/src/main/java/org/rascalmpl/maven/TutorRascalMojo.java b/src/main/java/org/rascalmpl/maven/TutorRascalMojo.java index cfca4f5..918b646 100644 --- a/src/main/java/org/rascalmpl/maven/TutorRascalMojo.java +++ b/src/main/java/org/rascalmpl/maven/TutorRascalMojo.java @@ -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, @@ -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); } }