From da2759acbb6fd7fe32d24943e221b79d77b60e2c Mon Sep 17 00:00:00 2001 From: Pablo Ilardi Date: Wed, 21 May 2025 18:11:41 -0400 Subject: [PATCH] Added support for multi modules projects --- pom.xml | 40 ++++++++++++------- .../github/johnpoth/jshell/JShellMojo.java | 14 +++++++ src/main/java/module-info.java | 12 ------ 3 files changed, 39 insertions(+), 27 deletions(-) delete mode 100644 src/main/java/module-info.java diff --git a/pom.xml b/pom.xml index f49fafb..0d621c0 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,9 @@ http://www.apache.org/licenses/LICENSE-2.0.html + + 3.6.3 + @@ -53,20 +56,14 @@ org.apache.maven - maven-plugin-api - 3.9.4 + maven-core + 3.9.9 provided org.apache.maven.plugin-tools maven-plugin-annotations - 3.9.0 - provided - - - org.apache.maven - maven-artifact - 3.9.4 + 3.15.1 provided @@ -77,7 +74,7 @@ org.apache.maven.plugins maven-release-plugin - 3.0.1 + 3.1.1 -Prelease @@ -85,7 +82,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.5.0 + 3.12.2 @@ -93,7 +90,7 @@ org.owasp dependency-check-maven - 8.3.1 + 12.1.1 true @@ -101,7 +98,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.14.0 9 9 @@ -110,7 +107,7 @@ org.apache.maven.plugins maven-plugin-plugin - 3.9.0 + 3.15.1 true @@ -123,6 +120,19 @@ + + org.apache.maven.plugins + maven-jar-plugin + 3.4.2 + + + + com.github.johnpoth.jshell + + + + + @@ -134,7 +144,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.1.0 + 3.2.7 sign-artifacts diff --git a/src/main/java/com/github/johnpoth/jshell/JShellMojo.java b/src/main/java/com/github/johnpoth/jshell/JShellMojo.java index 6756fb5..9f99723 100644 --- a/src/main/java/com/github/johnpoth/jshell/JShellMojo.java +++ b/src/main/java/com/github/johnpoth/jshell/JShellMojo.java @@ -17,6 +17,7 @@ package com.github.johnpoth.jshell; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -86,7 +87,20 @@ public class JShellMojo extends AbstractMojo { @Parameter private Map properties; + @Parameter( + defaultValue = "${session}", + readonly = true, + required = true + ) + private MavenSession session; + + @Override public void execute() throws MojoExecutionException { + List selectedProjects = session.getRequest().getSelectedProjects(); + if (!selectedProjects.isEmpty() && !selectedProjects.contains(session.getCurrentProject().getArtifactId())) { + getLog().debug("Skipping Shell for: " + session.getCurrentProject().getArtifactId()); + return; + } Optional module = ModuleLayer.boot().findModule("jdk.jshell"); ClassLoader classLoader = module.get().getClassLoader(); // Until https://issues.apache.org/jira/browse/MNG-6371 is resolved diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java deleted file mode 100644 index 08f616f..0000000 --- a/src/main/java/module-info.java +++ /dev/null @@ -1,12 +0,0 @@ -module com.github.johnpoth.jshell { - - requires jdk.jshell; - /**not modules yet*/ - requires maven.plugin.api; - requires maven.plugin.annotations; - requires maven.artifact; - - exports com.github.johnpoth.jshell; - - uses javax.tools.Tool; -}