in artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java [164:315]
protected void doExecute() throws MojoExecutionException, MojoFailureException {
getLog().debug("Local " + localRepository);
MavenProject project = (MavenProject) getPluginContext().get("project");
if (!isArtemisHome(home.toPath())) {
if (isArtemisHome(alternateHome.toPath())) {
home = alternateHome;
} else {
getLog().error("********************************************************************************************");
getLog().error("Could not locate suitable Artemis.home on either " + home + " or " + alternateHome);
getLog().error("Use the binary distribution or build the distribution before running the examples");
getLog().error("********************************************************************************************");
throw new MojoExecutionException("Couldn't find artemis.home");
}
}
Map properties = getPluginContext();
Set<Map.Entry> entries = properties.entrySet();
if (getLog().isDebugEnabled()) {
getLog().debug("Entries.size " + entries.size());
for (Map.Entry entry : entries) {
getLog().debug("... key=" + entry.getKey() + " = " + entry.getValue());
}
}
ArrayList<String> listCommands = new ArrayList<>();
add(listCommands, "create", "--silent", "--force", "--user", user, "--password", password, "--role", role, "--port-offset", "" + portOffset, "--data", dataFolder);
if (allowAnonymous) {
add(listCommands, "--allow-anonymous");
} else {
add(listCommands, "--require-login");
}
if (staticCluster != null) {
add(listCommands, "--staticCluster", staticCluster);
}
if (!javaOptions.isEmpty()) {
add(listCommands, "--java-options", javaOptions);
}
if (noWeb) {
add(listCommands, "--no-web");
}
if (slave) {
add(listCommands, "--slave");
}
if (replicated) {
add(listCommands, "--replicated");
}
if (sharedStore) {
add(listCommands, "--shared-store");
}
if (clustered) {
add(listCommands, "--clustered");
add(listCommands, "--message-load-balancing", messageLoadBalancing);
}
if (failoverOnShutdown) {
add(listCommands, "--failover-on-shutdown");
}
if (noAutoTune) {
add(listCommands, "--no-autotune");
}
add(listCommands, "--verbose");
if ("Linux".equals(System.getProperty("os.name"))) {
add(listCommands, "--aio");
}
for (String str : args) {
add(listCommands, str);
}
add(listCommands, instance.getAbsolutePath());
getLog().debug("***** Server created at " + instance + " with home=" + home + " *****");
instance.mkdirs();
File commandLine = new File(instance.getParentFile(), "create-" + instance.getName() + ".sh");
FileOutputStream outputStream;
try {
outputStream = new FileOutputStream(commandLine);
} catch (Exception e) {
e.printStackTrace();
throw new MojoExecutionException(e.getMessage(), e);
}
try (PrintStream commandLineStream = new PrintStream(outputStream)) {
commandLineStream.println("# These are the commands used to create " + instance.getName());
commandLineStream.println(getCommandline(listCommands));
Artemis.execute(home, null, null, useSystemOutput, listCommands);
if (configuration != null) {
String[] list = configuration.list();
if (list != null) {
getLog().debug("************************************************");
getLog().debug("Copying configuration files:");
copyConfigurationFiles(list, configuration.toPath(), instance.toPath().resolve("etc"), commandLineStream);
}
}
Set<File> files = resolveDependencies(libListWithDeps, libList);
if (!files.isEmpty()) {
commandLineStream.println();
commandLineStream.println("# This is a list of files that need to be installed under ./lib.");
commandLineStream.println("# We are copying them from your maven lib home");
for (File file : files) {
copyToDir("lib", file, commandLineStream);
}
}
files = resolveDependencies(webListWithDeps, webList);
if (!files.isEmpty()) {
commandLineStream.println();
commandLineStream.println("# This is a list of files that need to be installed under ./web.");
commandLineStream.println("# We are copying them from your maven lib home");
for (File file : files) {
copyToDir("web", file, commandLineStream);
}
}
FileUtil.makeExec(commandLine);
if (getLog().isDebugEnabled()) {
getLog().debug("###################################################################################################");
getLog().debug(commandLine.getName() + " created with commands to reproduce " + instance.getName());
getLog().debug("under " + commandLine.getParent());
getLog().debug("###################################################################################################");
}
} catch (Throwable e) {
getLog().error(e);
throw new MojoFailureException(e.getMessage());
}
}