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.PrintWriter;
|
||||
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.LinkedList;
|
||||
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 void doExecute() throws MojoExecutionException, MojoFailureException;
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
package org.apache.activemq.artemis.maven;
|
||||
|
||||
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.cli.commands.Run;
|
||||
|
@ -70,30 +67,6 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin {
|
|||
@Parameter
|
||||
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
|
||||
protected boolean isIgnore() {
|
||||
return ignore;
|
||||
|
@ -106,8 +79,8 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin {
|
|||
|
||||
MavenProject project = (MavenProject) getPluginContext().get("project");
|
||||
|
||||
if (!lookupHome(home.toPath())) {
|
||||
if (lookupHome(alternateHome.toPath())) {
|
||||
if (!isArtemisHome(home.toPath())) {
|
||||
if (isArtemisHome(alternateHome.toPath())) {
|
||||
home = alternateHome;
|
||||
} else {
|
||||
getLog().error("********************************************************************************************");
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.LinkOption;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
|
@ -134,30 +133,6 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin {
|
|||
@Parameter(defaultValue = "${noServer}")
|
||||
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) {
|
||||
for (String s : str) {
|
||||
list.add(s);
|
||||
|
@ -174,8 +149,8 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin {
|
|||
getLog().info("Local " + localRepository);
|
||||
MavenProject project = (MavenProject) getPluginContext().get("project");
|
||||
|
||||
if (!lookupHome(home.toPath())) {
|
||||
if (lookupHome(alternateHome.toPath())) {
|
||||
if (!isArtemisHome(home.toPath())) {
|
||||
if (isArtemisHome(alternateHome.toPath())) {
|
||||
home = alternateHome;
|
||||
} else {
|
||||
getLog().error("********************************************************************************************");
|
||||
|
|
Loading…
Reference in New Issue