ARTEMIS-996 Simplify what was lookupHome(path) in artemis-maven-plugin and deduplicate it
This commit is contained in:
parent
54a11f023d
commit
da06be192b
|
@ -19,6 +19,9 @@ package org.apache.activemq.artemis.maven;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.LinkOption;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -76,6 +79,15 @@ public abstract class ArtemisAbstractPlugin extends AbstractMojo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isArtemisHome(Path path) {
|
||||||
|
if (path == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Path artemisScript = path.resolve("bin").resolve("artemis");
|
||||||
|
return Files.exists(artemisScript, LinkOption.NOFOLLOW_LINKS);
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract boolean isIgnore();
|
protected abstract boolean isIgnore();
|
||||||
|
|
||||||
protected abstract void doExecute() throws MojoExecutionException, MojoFailureException;
|
protected abstract void doExecute() throws MojoExecutionException, MojoFailureException;
|
||||||
|
|
|
@ -17,9 +17,6 @@
|
||||||
package org.apache.activemq.artemis.maven;
|
package org.apache.activemq.artemis.maven;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.LinkOption;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import org.apache.activemq.artemis.boot.Artemis;
|
import org.apache.activemq.artemis.boot.Artemis;
|
||||||
import org.apache.activemq.artemis.cli.commands.Run;
|
import org.apache.activemq.artemis.cli.commands.Run;
|
||||||
|
@ -70,30 +67,6 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin {
|
||||||
@Parameter
|
@Parameter
|
||||||
private String testPassword = null;
|
private String testPassword = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate if the directory is a artemis.home *
|
|
||||||
*
|
|
||||||
* @param path
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean lookupHome(Path path) {
|
|
||||||
|
|
||||||
if (path == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Path binFolder = path.resolve("bin");
|
|
||||||
|
|
||||||
if (binFolder == null && Files.exists(binFolder, LinkOption.NOFOLLOW_LINKS)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Path artemisScript = binFolder.resolve("artemis");
|
|
||||||
|
|
||||||
return artemisScript != null && Files.exists(artemisScript, LinkOption.NOFOLLOW_LINKS);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isIgnore() {
|
protected boolean isIgnore() {
|
||||||
return ignore;
|
return ignore;
|
||||||
|
@ -106,8 +79,8 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin {
|
||||||
|
|
||||||
MavenProject project = (MavenProject) getPluginContext().get("project");
|
MavenProject project = (MavenProject) getPluginContext().get("project");
|
||||||
|
|
||||||
if (!lookupHome(home.toPath())) {
|
if (!isArtemisHome(home.toPath())) {
|
||||||
if (lookupHome(alternateHome.toPath())) {
|
if (isArtemisHome(alternateHome.toPath())) {
|
||||||
home = alternateHome;
|
home = alternateHome;
|
||||||
} else {
|
} else {
|
||||||
getLog().error("********************************************************************************************");
|
getLog().error("********************************************************************************************");
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.LinkOption;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -134,30 +133,6 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin {
|
||||||
@Parameter(defaultValue = "${noServer}")
|
@Parameter(defaultValue = "${noServer}")
|
||||||
boolean ignore;
|
boolean ignore;
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate if the directory is a artemis.home *
|
|
||||||
*
|
|
||||||
* @param path
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean lookupHome(Path path) {
|
|
||||||
|
|
||||||
if (path == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Path binFolder = path.resolve("bin");
|
|
||||||
|
|
||||||
if (binFolder == null && Files.exists(binFolder, LinkOption.NOFOLLOW_LINKS)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Path artemisScript = binFolder.resolve("artemis");
|
|
||||||
|
|
||||||
return artemisScript != null && Files.exists(artemisScript, LinkOption.NOFOLLOW_LINKS);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void add(List<String> list, String... str) {
|
private void add(List<String> list, String... str) {
|
||||||
for (String s : str) {
|
for (String s : str) {
|
||||||
list.add(s);
|
list.add(s);
|
||||||
|
@ -174,8 +149,8 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin {
|
||||||
getLog().info("Local " + localRepository);
|
getLog().info("Local " + localRepository);
|
||||||
MavenProject project = (MavenProject) getPluginContext().get("project");
|
MavenProject project = (MavenProject) getPluginContext().get("project");
|
||||||
|
|
||||||
if (!lookupHome(home.toPath())) {
|
if (!isArtemisHome(home.toPath())) {
|
||||||
if (lookupHome(alternateHome.toPath())) {
|
if (isArtemisHome(alternateHome.toPath())) {
|
||||||
home = alternateHome;
|
home = alternateHome;
|
||||||
} else {
|
} else {
|
||||||
getLog().error("********************************************************************************************");
|
getLog().error("********************************************************************************************");
|
||||||
|
|
Loading…
Reference in New Issue