diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..09ddec9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/cmdline/maven/target/
diff --git a/cmdline/maven/pom.xml b/cmdline/maven/pom.xml
index 65e9f12..30c970c 100644
--- a/cmdline/maven/pom.xml
+++ b/cmdline/maven/pom.xml
@@ -28,7 +28,7 @@
org.apache.netbeans
netbeans-parent
- 2
+ 5
https://netbeans.apache.org
@@ -41,39 +41,38 @@
UTF-8
${env.M2_HOME}/bin/mvn
+ 3.9.16
+ 3.15.2
org.apache.maven
maven-plugin-api
- 2.1.0
-
-
- org.apache.maven
- maven-toolchain
- 2.1.0
+ ${maven.version}
+ provided
org.apache.maven
maven-core
- 2.1.0
+ ${maven.version}
+ provided
org.apache.netbeans.modules.jackpot30
tool
- ${version}
+ ${project.version}
junit
junit
- 3.8.1
+ 4.13.2
test
- org.apache.maven
- maven-project
- 2.0
+ org.apache.maven.plugin-tools
+ maven-plugin-annotations
+ ${maven.plugin.version}
jar
@@ -83,36 +82,29 @@
org.apache.maven.plugins
maven-surefire-plugin
- 2.12
+ 3.6.0
-
-
- basedir
- ${basedir}
-
-
- maven.executable
- ${maven.executable}
-
-
+
+ ${basedir}
+ ${maven.executable}
+
org.apache.maven.plugins
maven-compiler-plugin
- 3.8.0
+ 3.16.0
-AdisableJackpotProcessor=true
- 1.8
- 1.8
+ 17
org.apache.maven.plugins
maven-plugin-plugin
- 3.10.2
+ ${maven.plugin.version}
diff --git a/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunAnalyze.java b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunAnalyze.java
index 234c6a0..46d1110 100644
--- a/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunAnalyze.java
+++ b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunAnalyze.java
@@ -20,24 +20,18 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.ResolutionScope;
/**
- * @goal analyze
- * @requiresDependencyResolution compile
* @author Jan Lahoda
*/
+@Mojo(name = "analyze", requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true)
public class RunAnalyze extends RunJackpot30 {
- /**
- * @parameter property="project"
- * @required
- * @readonly
- */
- private MavenProject project;
-
+ @Override
public void execute() throws MojoExecutionException, MojoFailureException {
- doRun(project, false);
+ doRun(false);
}
}
diff --git a/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunApply.java b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunApply.java
index 84863bb..9f9d915 100644
--- a/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunApply.java
+++ b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunApply.java
@@ -20,24 +20,18 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.ResolutionScope;
/**
- * @goal apply
- * @requiresDependencyResolution compile
* @author Jan Lahoda
*/
+@Mojo(name = "apply", requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true)
public class RunApply extends RunJackpot30 {
- /**
- * @parameter property="project"
- * @required
- * @readonly
- */
- private MavenProject project;
-
+ @Override
public void execute() throws MojoExecutionException, MojoFailureException {
- doRun(project, true);
+ doRun(true);
}
}
diff --git a/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunJackpot30.java b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunJackpot30.java
index c86be4c..97a3fd9 100644
--- a/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunJackpot30.java
+++ b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/RunJackpot30.java
@@ -20,7 +20,6 @@
import java.io.File;
import java.io.IOException;
-import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -33,13 +32,23 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.netbeans.modules.jackpot30.cmdline.Main;
public abstract class RunJackpot30 extends AbstractMojo {
- protected final void doRun(MavenProject project, boolean apply) throws MojoExecutionException, MojoFailureException {
+ @Parameter(defaultValue = "${project}", required = true, readonly = true)
+ private MavenProject project;
+
+ @Parameter(property = "failOnWarnings", defaultValue = "true")
+ private boolean failOnWarnings;
+
+ @Parameter(property = "configurationFile")
+ private String configurationFile = null;
+
+ protected final void doRun(boolean apply) throws MojoExecutionException, MojoFailureException {
try {
String sourceLevel = "1.5";
Xpp3Dom sourceLevelConfiguration = Utils.getPluginConfiguration(project, "org.apache.maven.plugins", "maven-compiler-plugin");
@@ -52,15 +61,13 @@ protected final void doRun(MavenProject project, boolean apply) throws MojoExecu
}
}
- String configurationFile = Utils.getJackpotConfigurationFile(project);
- boolean failOnWarnings = Utils.getJackpotFailOnWarnings(project);
+ List cmdLine = new ArrayList<>();
- List cmdLine = new ArrayList();
-
- if (apply)
+ if (apply) {
cmdLine.add("--apply");
- else
+ } else {
cmdLine.add("--no-apply");
+ }
cmdLine.addAll(sourceAndCompileClassPaths(Collections.singletonList(project)));
cmdLine.add("--source");
@@ -86,29 +93,25 @@ protected final void doRun(MavenProject project, boolean apply) throws MojoExecu
if (!hasSourceRoots) {
getLog().debug("jackpot30 analyze: Not source roots to operate on");
- return ;
+ return;
}
Path bin = Paths.get(System.getProperty("java.home"))
- .resolve("bin");
+ .resolve("bin");
Path launcher = bin.resolve("java");
if (!Files.exists(launcher)) {
launcher = bin.resolve("java.exe");
}
cmdLine.addAll(0, Arrays.asList(launcher.toAbsolutePath().toString(),
- "-classpath", Main.class.getProtectionDomain().getCodeSource().getLocation().getPath(),
- "-XX:+IgnoreUnrecognizedVMOptions",
- "--add-opens=java.base/java.net=ALL-UNNAMED",
- "--add-opens=java.desktop/sun.awt=ALL-UNNAMED",
- Main.class.getCanonicalName()));
+ "-classpath", Main.class.getProtectionDomain().getCodeSource().getLocation().getPath(),
+ "-XX:+IgnoreUnrecognizedVMOptions",
+ "--add-opens=java.base/java.net=ALL-UNNAMED",
+ "--add-opens=java.desktop/sun.awt=ALL-UNNAMED",
+ Main.class.getCanonicalName()));
if (new ProcessBuilder(cmdLine).inheritIO().start().waitFor() != 0) {
throw new MojoExecutionException("jackpo30 failed.");
}
- } catch (IOException ex) {
- throw new MojoExecutionException(ex.getMessage(), ex);
- } catch (InterruptedException ex) {
- throw new MojoExecutionException(ex.getMessage(), ex);
- } catch (DependencyResolutionRequiredException ex) {
+ } catch (IOException | InterruptedException | DependencyResolutionRequiredException ex) {
throw new MojoExecutionException(ex.getMessage(), ex);
}
}
@@ -117,7 +120,9 @@ private static String toClassPathString(List entries) {
StringBuilder classPath = new StringBuilder();
for (String root : entries) {
- if (classPath.length() > 0) classPath.append(File.pathSeparatorChar);
+ if (classPath.length() > 0) {
+ classPath.append(File.pathSeparatorChar);
+ }
classPath.append(root);
}
@@ -126,8 +131,8 @@ private static String toClassPathString(List entries) {
@SuppressWarnings("unchecked")
public static List sourceAndCompileClassPaths(Iterable extends MavenProject> projects) throws DependencyResolutionRequiredException {
- List compileSourceRoots = new ArrayList();
- List compileClassPath = new ArrayList();
+ List compileSourceRoots = new ArrayList<>();
+ List compileClassPath = new ArrayList<>();
for (MavenProject project : projects) {
compileSourceRoots.addAll((List) project.getCompileSourceRoots());
@@ -135,13 +140,13 @@ public static List sourceAndCompileClassPaths(Iterable extends MavenPr
for (Resource r : (List) project.getResources()) {
compileSourceRoots.add(r.getDirectory());
}
-
+
compileClassPath.addAll((List) project.getCompileClasspathElements());
}
return Arrays.asList("--sourcepath",
- toClassPathString(compileSourceRoots),
- "--classpath",
- toClassPathString(compileClassPath));
+ toClassPathString(compileSourceRoots),
+ "--classpath",
+ toClassPathString(compileClassPath));
}
}
diff --git a/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/ShowGuiJackpot30.java b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/ShowGuiJackpot30.java
index d96a1df..ca33972 100644
--- a/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/ShowGuiJackpot30.java
+++ b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/ShowGuiJackpot30.java
@@ -25,32 +25,36 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.netbeans.modules.jackpot30.cmdline.Main;
/**
- * @goal showgui
+ *
* @author Jan Lahoda
*/
+@Mojo(name = "showgui", requiresProject = true)
public class ShowGuiJackpot30 extends AbstractMojo {
- /**
- * @parameter property="project"
- * @required
- * @readonly
- */
+ @Parameter(defaultValue = "${project}", required = true, readonly = true)
private MavenProject project;
+ @Parameter(property = "configurationFile")
+ private String configurationFile;
+
+ @Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
- if (!project.isExecutionRoot()) return;
-
- String configurationFile = Utils.getJackpotConfigurationFile(project);
+ if (!project.isExecutionRoot()) {
+ return;
+ }
- if (configurationFile == null)
+ if (configurationFile == null) {
throw new MojoExecutionException("No configuration file specified, cannot show configuration GUI");
+ }
- List cmdLine = new ArrayList();
+ List cmdLine = new ArrayList<>();
cmdLine.add("--config-file");
cmdLine.add(configurationFile);
@@ -59,11 +63,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
System.err.println(cmdLine);
Main.compile(cmdLine.toArray(new String[0]));
- } catch (IOException ex) {
- throw new MojoExecutionException(ex.getMessage(), ex);
- } catch (ClassNotFoundException ex) {
- throw new MojoExecutionException(ex.getMessage(), ex);
- } catch (DependencyResolutionRequiredException ex) {
+ } catch (IOException | ClassNotFoundException | DependencyResolutionRequiredException ex) {
throw new MojoExecutionException(ex.getMessage(), ex);
}
}
diff --git a/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/Utils.java b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/Utils.java
index 8310a22..cd93484 100644
--- a/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/Utils.java
+++ b/cmdline/maven/src/main/java/org/netbeans/modules/jackpot30/maven/Utils.java
@@ -30,12 +30,14 @@ public class Utils {
public static Xpp3Dom getPluginConfiguration(MavenProject project, String groupId, String artifactId) {
for (Object o : project.getBuild().getPlugins()) {
- if (!(o instanceof Plugin)) continue;
+ if (!(o instanceof Plugin)) {
+ continue;
+ }
Plugin p = (Plugin) o;
- if ( groupId.equals(p.getGroupId())
- && artifactId.equals(p.getArtifactId())) {
+ if (groupId.equals(p.getGroupId())
+ && artifactId.equals(p.getArtifactId())) {
if (p.getConfiguration() instanceof Xpp3Dom) {
return (Xpp3Dom) p.getConfiguration();
}
@@ -46,35 +48,4 @@ public static Xpp3Dom getPluginConfiguration(MavenProject project, String groupI
return null;
}
- public static String getJackpotConfigurationFile(MavenProject project) {
- Xpp3Dom configuration = getJackpotPluginConfiguration(project);
-
- if (configuration != null) {
- Xpp3Dom configurationFileElement = configuration.getChild("configurationFile");
-
- if (configurationFileElement != null) {
- return configurationFileElement.getValue();
- }
- }
-
- return null;
- }
-
- public static boolean getJackpotFailOnWarnings(MavenProject project) {
- Xpp3Dom configuration = getJackpotPluginConfiguration(project);
-
- if (configuration != null) {
- Xpp3Dom configurationFileElement = configuration.getChild("failOnWarnings");
-
- if (configurationFileElement != null) {
- return "true".equalsIgnoreCase(configurationFileElement.getValue());
- }
- }
-
- return true;
- }
-
- private static Xpp3Dom getJackpotPluginConfiguration(MavenProject project) {
- return getPluginConfiguration(project, "org.apache.netbeans.modules.jackpot30", "jackpot30-maven-plugin");
- }
}