Reformat code using Eclipse Mars
This commit is contained in:
@@ -144,7 +144,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
||||
* @return {@code true} if the application process should be forked
|
||||
*/
|
||||
protected boolean isFork() {
|
||||
return (Boolean.TRUE.equals(this.fork) || (this.fork == null && (hasAgent() || hasJvmArgs())));
|
||||
return (Boolean.TRUE.equals(this.fork)
|
||||
|| (this.fork == null && (hasAgent() || hasJvmArgs())));
|
||||
}
|
||||
|
||||
private boolean hasAgent() {
|
||||
@@ -171,7 +172,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
||||
}
|
||||
CodeSource source = loaded.getProtectionDomain().getCodeSource();
|
||||
if (source != null) {
|
||||
this.agent = new File[] { new File(source.getLocation().getFile()) };
|
||||
this.agent = new File[] {
|
||||
new File(source.getLocation().getFile()) };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,8 +186,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
||||
}
|
||||
}
|
||||
|
||||
private void run(String startClassName) throws MojoExecutionException,
|
||||
MojoFailureException {
|
||||
private void run(String startClassName)
|
||||
throws MojoExecutionException, MojoFailureException {
|
||||
findAgent();
|
||||
if (isFork()) {
|
||||
doRunWithForkedJvm(startClassName);
|
||||
@@ -195,16 +197,15 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
||||
getLog().warn("Fork mode disabled, ignoring agent");
|
||||
}
|
||||
if (hasJvmArgs()) {
|
||||
getLog().warn(
|
||||
"Fork mode disabled, ignoring JVM argument(s) ["
|
||||
+ this.jvmArguments + "]");
|
||||
getLog().warn("Fork mode disabled, ignoring JVM argument(s) ["
|
||||
+ this.jvmArguments + "]");
|
||||
}
|
||||
runWithMavenJvm(startClassName, resolveApplicationArguments().asArray());
|
||||
}
|
||||
}
|
||||
|
||||
private void doRunWithForkedJvm(String startClassName) throws MojoExecutionException,
|
||||
MojoFailureException {
|
||||
private void doRunWithForkedJvm(String startClassName)
|
||||
throws MojoExecutionException, MojoFailureException {
|
||||
List<String> args = new ArrayList<String>();
|
||||
addAgents(args);
|
||||
addJvmArgs(args);
|
||||
@@ -277,8 +278,9 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
||||
try {
|
||||
StringBuilder classpath = new StringBuilder();
|
||||
for (URL ele : getClassPathUrls()) {
|
||||
classpath = classpath.append((classpath.length() > 0 ? File.pathSeparator
|
||||
: "") + new File(ele.toURI()));
|
||||
classpath = classpath
|
||||
.append((classpath.length() > 0 ? File.pathSeparator : "")
|
||||
+ new File(ele.toURI()));
|
||||
}
|
||||
getLog().debug("Classpath for forked process: " + classpath);
|
||||
args.add("-cp");
|
||||
@@ -346,11 +348,12 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
||||
urls.add(this.classesDirectory.toURI().toURL());
|
||||
}
|
||||
|
||||
private void addDependencies(List<URL> urls) throws MalformedURLException,
|
||||
MojoExecutionException {
|
||||
private void addDependencies(List<URL> urls)
|
||||
throws MalformedURLException, MojoExecutionException {
|
||||
FilterArtifacts filters = this.useTestClasspath ? getFilters()
|
||||
: getFilters(new TestArtifactFilter());
|
||||
Set<Artifact> artifacts = filterDependencies(this.project.getArtifacts(), filters);
|
||||
Set<Artifact> artifacts = filterDependencies(this.project.getArtifacts(),
|
||||
filters);
|
||||
for (Artifact artifact : artifacts) {
|
||||
if (artifact.getFile() != null) {
|
||||
urls.add(artifact.getFile().toURI().toURL());
|
||||
@@ -400,7 +403,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void rethrowUncaughtException() throws MojoExecutionException {
|
||||
public synchronized void rethrowUncaughtException()
|
||||
throws MojoExecutionException {
|
||||
if (this.exception != null) {
|
||||
throw new MojoExecutionException("An exception occured while running. "
|
||||
+ this.exception.getMessage(), this.exception);
|
||||
@@ -437,7 +441,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
|
||||
catch (NoSuchMethodException ex) {
|
||||
Exception wrappedEx = new Exception(
|
||||
"The specified mainClass doesn't contain a "
|
||||
+ "main method with appropriate signature.", ex);
|
||||
+ "main method with appropriate signature.",
|
||||
ex);
|
||||
thread.getThreadGroup().uncaughtException(thread, wrappedEx);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
||||
@@ -176,10 +176,9 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
|
||||
finally {
|
||||
long duration = System.currentTimeMillis() - startTime;
|
||||
if (duration > FIND_WARNING_TIMEOUT) {
|
||||
getLog().warn(
|
||||
"Searching for the main-class is taking some time, "
|
||||
+ "consider using the mainClass configuration "
|
||||
+ "parameter");
|
||||
getLog().warn("Searching for the main-class is taking some time, "
|
||||
+ "consider using the mainClass configuration "
|
||||
+ "parameter");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,9 +202,8 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
|
||||
throw new MojoExecutionException(ex.getMessage(), ex);
|
||||
}
|
||||
if (this.classifier != null) {
|
||||
getLog().info(
|
||||
"Attaching archive: " + target + ", with classifier: "
|
||||
+ this.classifier);
|
||||
getLog().info("Attaching archive: " + target + ", with classifier: "
|
||||
+ this.classifier);
|
||||
this.projectHelper.attachArtifact(this.project, this.project.getPackaging(),
|
||||
this.classifier, target);
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ public class RunMojo extends AbstractRunMojo {
|
||||
protected void runWithMavenJvm(String startClassName, String... arguments)
|
||||
throws MojoExecutionException {
|
||||
IsolatedThreadGroup threadGroup = new IsolatedThreadGroup(startClassName);
|
||||
Thread launchThread = new Thread(threadGroup, new LaunchRunner(startClassName,
|
||||
arguments), "main");
|
||||
Thread launchThread = new Thread(threadGroup,
|
||||
new LaunchRunner(startClassName, arguments), "main");
|
||||
launchThread.setContextClassLoader(new URLClassLoader(getClassPathUrls()));
|
||||
launchThread.start();
|
||||
join(threadGroup);
|
||||
|
||||
@@ -66,8 +66,8 @@ class SpringApplicationAdminClient {
|
||||
return false; // Instance not available yet
|
||||
}
|
||||
catch (AttributeNotFoundException ex) {
|
||||
throw new IllegalStateException(
|
||||
"Unexpected: attribute 'Ready' not available", ex);
|
||||
throw new IllegalStateException("Unexpected: attribute 'Ready' not available",
|
||||
ex);
|
||||
}
|
||||
catch (ReflectionException ex) {
|
||||
throw new MojoExecutionException("Failed to retrieve Ready attribute",
|
||||
@@ -87,8 +87,8 @@ class SpringApplicationAdminClient {
|
||||
* @throws IOException if an I/O error occurs
|
||||
* @throws InstanceNotFoundException if the lifecycle mbean cannot be found
|
||||
*/
|
||||
public void stop() throws MojoExecutionException, IOException,
|
||||
InstanceNotFoundException {
|
||||
public void stop()
|
||||
throws MojoExecutionException, IOException, InstanceNotFoundException {
|
||||
try {
|
||||
this.connection.invoke(this.objectName, "shutdown", null, null);
|
||||
}
|
||||
|
||||
@@ -86,8 +86,8 @@ public class StartMojo extends AbstractRunMojo {
|
||||
private final Object lock = new Object();
|
||||
|
||||
@Override
|
||||
protected void runWithForkedJvm(List<String> args) throws MojoExecutionException,
|
||||
MojoFailureException {
|
||||
protected void runWithForkedJvm(List<String> args)
|
||||
throws MojoExecutionException, MojoFailureException {
|
||||
RunProcess runProcess = runProcess(args);
|
||||
try {
|
||||
waitForSpringApplication();
|
||||
@@ -118,8 +118,8 @@ public class StartMojo extends AbstractRunMojo {
|
||||
RunArguments applicationArguments = super.resolveApplicationArguments();
|
||||
applicationArguments.getArgs().addLast(ENABLE_MBEAN_PROPERTY);
|
||||
if (isFork()) {
|
||||
applicationArguments.getArgs().addLast(
|
||||
JMX_NAME_PROPERTY_PREFIX + this.jmxName);
|
||||
applicationArguments.getArgs()
|
||||
.addLast(JMX_NAME_PROPERTY_PREFIX + this.jmxName);
|
||||
}
|
||||
return applicationArguments;
|
||||
}
|
||||
@@ -142,8 +142,8 @@ public class StartMojo extends AbstractRunMojo {
|
||||
protected void runWithMavenJvm(String startClassName, String... arguments)
|
||||
throws MojoExecutionException {
|
||||
IsolatedThreadGroup threadGroup = new IsolatedThreadGroup(startClassName);
|
||||
Thread launchThread = new Thread(threadGroup, new LaunchRunner(startClassName,
|
||||
arguments), startClassName + ".main()");
|
||||
Thread launchThread = new Thread(threadGroup,
|
||||
new LaunchRunner(startClassName, arguments), startClassName + ".main()");
|
||||
launchThread.setContextClassLoader(new URLClassLoader(getClassPathUrls()));
|
||||
launchThread.start();
|
||||
waitForSpringApplication(this.wait, this.maxAttempts);
|
||||
@@ -176,8 +176,8 @@ public class StartMojo extends AbstractRunMojo {
|
||||
+ (wait * maxAttempts) + "ms");
|
||||
}
|
||||
|
||||
private void waitForSpringApplication() throws MojoFailureException,
|
||||
MojoExecutionException {
|
||||
private void waitForSpringApplication()
|
||||
throws MojoFailureException, MojoExecutionException {
|
||||
try {
|
||||
if (Boolean.TRUE.equals(isFork())) {
|
||||
waitForForkedSpringApplication();
|
||||
@@ -196,8 +196,8 @@ public class StartMojo extends AbstractRunMojo {
|
||||
}
|
||||
}
|
||||
|
||||
private void waitForForkedSpringApplication() throws IOException,
|
||||
MojoFailureException, MojoExecutionException {
|
||||
private void waitForForkedSpringApplication()
|
||||
throws IOException, MojoFailureException, MojoExecutionException {
|
||||
try {
|
||||
getLog().debug("Connecting to local MBeanServer at port " + this.jmxPort);
|
||||
JMXConnector connector = execute(this.wait, this.maxAttempts,
|
||||
@@ -220,8 +220,8 @@ public class StartMojo extends AbstractRunMojo {
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new MojoExecutionException("Failed to connect to MBean server at port "
|
||||
+ this.jmxPort, ex);
|
||||
throw new MojoExecutionException(
|
||||
"Failed to connect to MBean server at port " + this.jmxPort, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,8 +309,8 @@ public class StartMojo extends AbstractRunMojo {
|
||||
}
|
||||
|
||||
private boolean hasCauseWithType(Throwable t, Class<? extends Exception> type) {
|
||||
return type.isAssignableFrom(t.getClass()) || t.getCause() != null
|
||||
&& hasCauseWithType(t.getCause(), type);
|
||||
return type.isAssignableFrom(t.getClass())
|
||||
|| t.getCause() != null && hasCauseWithType(t.getCause(), type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@ public class StopMojo extends AbstractMojo {
|
||||
}
|
||||
}
|
||||
|
||||
private void stopForkedProcess() throws IOException, MojoFailureException,
|
||||
MojoExecutionException {
|
||||
private void stopForkedProcess()
|
||||
throws IOException, MojoFailureException, MojoExecutionException {
|
||||
JMXConnector connector = SpringApplicationAdminClient.connect(this.jmxPort);
|
||||
try {
|
||||
MBeanServerConnection connection = connector.getMBeanServerConnection();
|
||||
@@ -95,15 +95,16 @@ public class StopMojo extends AbstractMojo {
|
||||
doStop(ManagementFactory.getPlatformMBeanServer());
|
||||
}
|
||||
|
||||
private void doStop(MBeanServerConnection connection) throws IOException,
|
||||
MojoExecutionException {
|
||||
private void doStop(MBeanServerConnection connection)
|
||||
throws IOException, MojoExecutionException {
|
||||
try {
|
||||
new SpringApplicationAdminClient(connection, this.jmxName).stop();
|
||||
}
|
||||
catch (InstanceNotFoundException ex) {
|
||||
throw new MojoExecutionException(
|
||||
"Spring application lifecycle JMX bean not found (fork is " + ""
|
||||
+ this.fork + "). Could not stop application gracefully", ex);
|
||||
+ this.fork + "). Could not stop application gracefully",
|
||||
ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,8 +72,8 @@ public class DependencyFilterMojoTests {
|
||||
return a;
|
||||
}
|
||||
|
||||
private static final class TestableDependencyFilterMojo extends
|
||||
AbstractDependencyFilterMojo {
|
||||
private static final class TestableDependencyFilterMojo
|
||||
extends AbstractDependencyFilterMojo {
|
||||
|
||||
private TestableDependencyFilterMojo(List<Exclude> excludes,
|
||||
String excludeGroupIds, String excludeArtifactIds) {
|
||||
|
||||
@@ -165,14 +165,15 @@ public final class Verify {
|
||||
verify(true);
|
||||
}
|
||||
|
||||
public void verify(boolean executable, String... scriptContents) throws Exception {
|
||||
public void verify(boolean executable, String... scriptContents)
|
||||
throws Exception {
|
||||
assertTrue("Archive missing", this.file.exists());
|
||||
assertTrue("Archive not a file", this.file.isFile());
|
||||
|
||||
if (scriptContents.length > 0 && executable) {
|
||||
String contents = new String(FileCopyUtils.copyToByteArray(this.file));
|
||||
contents = contents.substring(0, contents.indexOf(new String(new byte[] {
|
||||
0x50, 0x4b, 0x03, 0x04 })));
|
||||
contents = contents.substring(0, contents
|
||||
.indexOf(new String(new byte[] { 0x50, 0x4b, 0x03, 0x04 })));
|
||||
for (String content : scriptContents) {
|
||||
assertThat(contents, containsString(content));
|
||||
}
|
||||
@@ -180,10 +181,8 @@ public final class Verify {
|
||||
|
||||
if (!executable) {
|
||||
String contents = new String(FileCopyUtils.copyToByteArray(this.file));
|
||||
assertTrue(
|
||||
"Is executable",
|
||||
contents.startsWith(new String(new byte[] { 0x50, 0x4b, 0x03,
|
||||
0x04 })));
|
||||
assertTrue("Is executable", contents
|
||||
.startsWith(new String(new byte[] { 0x50, 0x4b, 0x03, 0x04 })));
|
||||
}
|
||||
|
||||
ZipFile zipFile = new ZipFile(this.file);
|
||||
|
||||
Reference in New Issue
Block a user