Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/main/java/com/unic/maven/plugins/aem/mojos/Start.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.unic.maven.plugins.aem.util.AwaitableProcess.ExecutionResult;
import com.unic.maven.plugins.aem.util.Expectation;
import com.unic.maven.plugins.aem.util.FileUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
Expand All @@ -36,8 +37,6 @@
import static java.util.Collections.addAll;
import static java.util.concurrent.Executors.newCachedThreadPool;
import static java.util.concurrent.TimeUnit.*;
import static org.codehaus.plexus.util.StringUtils.isEmpty;
import static org.codehaus.plexus.util.StringUtils.join;

/**
* Starts a local AEM instance using a quickstart jar. The quickstart jar must have been provided before hand. Supports setting arbitrary VM parameters
Expand Down Expand Up @@ -230,14 +229,14 @@ private List<String> getCommands() throws MojoFailureException, MojoExecutionExc
"-nofork",
"-nobrowser",
"-verbose",
"-r", join(runModes.iterator(), ","),
"-r", StringUtils.join(runModes.iterator(), ","),
"-port", Integer.toString(getHttpPort())));
if (isUseControlPort()) {
commands.add("-use-control-port");
}

// Servlet context path - by default, AEM runs at the root context.
if (!isEmpty(getContextPath())) {
if (StringUtils.isNotBlank(getContextPath())) {
commands.add("-contextpath");
commands.add(getContextPath());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package com.unic.maven.plugins.aem.mojos;

import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
Expand All @@ -32,14 +33,17 @@
import javax.xml.xpath.XPathExpressionException;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static com.unic.maven.plugins.aem.util.ExceptionUtil.getRootCause;
import static javax.xml.xpath.XPathConstants.NODESET;
import static javax.xml.xpath.XPathFactory.newInstance;
import static org.codehaus.plexus.util.FileUtils.getFiles;
import static org.codehaus.plexus.util.StringUtils.join;

/**
* Performs XML validation of all XML files within a directory, by default within src/main/content (see {@link #contentDirectory}). This can be used
Expand Down Expand Up @@ -82,7 +86,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}

if (!validationErrors.isEmpty()) {
throw new MojoFailureException(validationErrors.size() + " invalid XML files found: \n" + join(validationErrors.iterator(), "\n"));
throw new MojoFailureException(validationErrors.size() + " invalid XML files found: \n" + StringUtils.join(validationErrors.iterator(), "\n"));
}
}

Expand Down Expand Up @@ -112,14 +116,16 @@ private List<ValidationError> validateXmlFilesIn(@NotNull File directory) throws
return failedValidations;
}

private List<File> getXmlFiles(@NotNull File directory) throws MojoExecutionException {
List<File> files;
try {
files = getFiles(directory, "**/*.xml", null);
public Set<File> getXmlFiles(@NotNull File directory) throws MojoExecutionException {
try (Stream<Path> stream = Files.list(directory.toPath())) {
return stream
.filter(file -> !Files.isDirectory(file))
.filter(path -> path.endsWith("xml"))
.map(Path::toFile)
.collect(Collectors.toSet());
} catch (IOException e) {
throw new MojoExecutionException("Unable to collect all XML files in " + directory.getAbsolutePath() + ": " + e.getMessage(), e);
}
return files;
}

private List<ValidationError> validateDocumentContainsNoUUIDs(File file, Document document) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
package com.unic.maven.plugins.aem.util;

import org.codehaus.plexus.util.ExceptionUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.jetbrains.annotations.NotNull;

/**
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/unic/maven/plugins/aem/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
*/
package com.unic.maven.plugins.aem.util;

import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.jetbrains.annotations.NotNull;

import java.io.File;

import static org.codehaus.plexus.util.StringUtils.join;

public class FileUtil {

/**
Expand All @@ -36,7 +35,7 @@ public static String getJarFileName(@NotNull File directory) throws MojoExecutio
}
if (jarFiles.length > 1) {
throw new MojoExecutionException("Unable to determine the jar file, more than one jar file " +
"was found in the AEM directory " + directory + ": " + join(jarFiles, ", ") + ".");
"was found in the AEM directory " + directory + ": " + StringUtils.join(jarFiles, ", ") + ".");
}
return jarFiles[0].getName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package com.unic.maven.plugins.aem.util;

import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import unirest.HttpRequest;
import unirest.HttpResponse;
Expand All @@ -21,7 +22,6 @@
import java.net.MalformedURLException;
import java.net.URL;

import static org.codehaus.plexus.util.StringUtils.isEmpty;

/**
* Used to check for responses from HTTP endpoints in a given time.
Expand Down Expand Up @@ -72,7 +72,7 @@ public HttpExpectation withCredentials(@NotNull String user, @NotNull String pas
protected Outcome fulfill() {
HttpRequest<?> request = method == HttpMethod.GET ? Unirest.get(this.url.toExternalForm()) : Unirest.post(this.url.toExternalForm());
try {
if (!isEmpty(this.user)) {
if (StringUtils.isNotBlank(this.user)) {
request = request.basicAuth(this.user, this.password);
}
HttpResponse<String> response = request.asString();
Expand Down