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
Original file line number Diff line number Diff line change
Expand Up @@ -2472,10 +2472,9 @@ private static List<String> trimValues(List<String> items) {
List<String> result = new ArrayList<>(items.size());
for (String item : items) {
String trimmed = item.trim();
if (trimmed == null || trimmed.isEmpty()) {
continue;
if (!trimmed.isEmpty()) {
result.add(trimmed);
}
result.add(trimmed);
}
return result;
}
Expand Down Expand Up @@ -3658,7 +3657,7 @@ private void addArgIfNotEmpty(
while (token.hasMoreTokens()) {
String current = token.nextToken().trim();

if (current != null && !current.isEmpty()) {
if (!current.isEmpty()) {
arguments.add(current);

if (token.hasMoreTokens() && repeatKey) {
Expand Down Expand Up @@ -3891,9 +3890,6 @@ private synchronized void resolveDependencyBundles() throws IOException {
if (dependencyJavadocBundles == null) {
dependencyJavadocBundles =
resourceResolver.resolveDependencyJavadocBundles(getDependencySourceResolverConfig());
if (dependencyJavadocBundles == null) {
dependencyJavadocBundles = new ArrayList<>();
}
}
}

Expand Down Expand Up @@ -4930,45 +4926,38 @@ private void addTagletsFromTagletArtifacts(List<String> arguments) throws MavenR
tagletsPath = JavadocUtil.pruneFiles(tagletsPath);

for (String tagletJar : tagletsPath) {
if (!tagletJar.toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
continue;
}

List<String> tagletClasses;
try {
tagletClasses = JavadocUtil.getTagletClassNames(new File(tagletJar));
} catch (IOException e) {
if (getLog().isWarnEnabled()) {
getLog().warn("Unable to auto-detect Taglet class names from '" + tagletJar
+ "'. Try to specify them with <taglets/>.");
}
if (getLog().isDebugEnabled()) {
getLog().debug("IOException: " + e.getMessage(), e);
}
continue;
} catch (ClassNotFoundException e) {
if (getLog().isWarnEnabled()) {
getLog().warn("Unable to auto-detect Taglet class names from '" + tagletJar
+ "'. Try to specify them with <taglets/>.");
}
if (getLog().isDebugEnabled()) {
getLog().debug("ClassNotFoundException: " + e.getMessage(), e);
}
continue;
} catch (NoClassDefFoundError e) {
if (getLog().isWarnEnabled()) {
getLog().warn("Unable to auto-detect Taglet class names from '" + tagletJar
+ "'. Try to specify them with <taglets/>.");
}
if (getLog().isDebugEnabled()) {
getLog().debug("NoClassDefFoundError: " + e.getMessage(), e);
}
continue;
}

if (tagletClasses != null && !tagletClasses.isEmpty()) {
for (String tagletClass : tagletClasses) {
addArgIfNotEmpty(arguments, "-taglet", JavadocUtil.quotedArgument(tagletClass));
if (tagletJar.toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
try {
List<String> tagletClasses = JavadocUtil.getTagletClassNames(new File(tagletJar));
if (!tagletClasses.isEmpty()) {
for (String tagletClass : tagletClasses) {
addArgIfNotEmpty(arguments, "-taglet", JavadocUtil.quotedArgument(tagletClass));
}
}
} catch (IOException e) {
if (getLog().isWarnEnabled()) {
getLog().warn("Unable to auto-detect Taglet class names from '" + tagletJar
+ "'. Try to specify them with <taglets/>.");
}
if (getLog().isDebugEnabled()) {
getLog().debug("IOException: " + e.getMessage(), e);
}
} catch (ClassNotFoundException e) {
if (getLog().isWarnEnabled()) {
getLog().warn("Unable to auto-detect Taglet class names from '" + tagletJar
+ "'. Try to specify them with <taglets/>.");
}
if (getLog().isDebugEnabled()) {
getLog().debug("ClassNotFoundException: " + e.getMessage(), e);
}
} catch (NoClassDefFoundError e) {
if (getLog().isWarnEnabled()) {
getLog().warn("Unable to auto-detect Taglet class names from '" + tagletJar
+ "'. Try to specify them with <taglets/>.");
}
if (getLog().isDebugEnabled()) {
getLog().debug("NoClassDefFoundError: " + e.getMessage(), e);
}
}
}
}
Expand Down Expand Up @@ -5072,9 +5061,7 @@ private void doExecuteJavadocCommandLine(Commandline cmd, File javadocOutputDire
}
writeDebugJavadocScript(cmdLine, javadocOutputDirectory);

if ((output != null && !output.isEmpty())
&& StringUtils.isEmpty(err.getOutput())
&& isJavadocVMInitError(output)) {
if (output != null && StringUtils.isEmpty(err.getOutput()) && isJavadocVMInitError(output)) {
throw new MavenReportException(output + '\n' + '\n' + JavadocUtil.ERROR_INIT_VM + '\n'
+ "Or, try to reduce the Java heap size for the Javadoc goal using "
+ "-Dminmemory=<size> and -Dmaxmemory=<size>." + '\n' + '\n' + "Command line was: "
Expand All @@ -5083,7 +5070,7 @@ && isJavadocVMInitError(output)) {
+ "' dir.\n");
}

if (output != null && !output.isEmpty()) {
if (output != null) {
getLog().info(output);
}

Expand Down Expand Up @@ -5114,7 +5101,7 @@ && isJavadocVMInitError(output)) {
throw new MavenReportException(msg.toString());
}

if (output != null && !output.isEmpty()) {
if (output != null) {
getLog().info(output);
}
} catch (CommandLineException e) {
Expand Down
16 changes: 5 additions & 11 deletions src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ protected static String quotedArgument(String value) {
List<String> list = Arrays.stream(arg.split("\n")).map(String::trim).collect(Collectors.toList());
arg = String.join("", list);

if (arg != null && !arg.isEmpty()) {
if (!arg.isEmpty()) {
arg = arg.replace("'", "\\'");
arg = "'" + arg + "'";
}
Expand Down Expand Up @@ -815,9 +815,7 @@ protected static void invokeMaven(
request.setProperties(properties);
}
File javaHome = getJavaHome(log);
if (javaHome != null) {
request.setJavaHome(javaHome);
}
request.setJavaHome(javaHome);

if (log != null && log.isDebugEnabled()) {
log.debug("Invoking Maven for the goals: " + goals + " with "
Expand Down Expand Up @@ -1106,7 +1104,7 @@ private static File getJavaHome(Log log) {
javaHome = new File(javaHomeValue);
}

if (javaHome == null || !javaHome.exists()) {
if (!javaHome.exists()) {
if (log != null && log.isErrorEnabled()) {
log.error("Cannot find Java application directory. Either specify 'java.home' system property, or "
+ "JAVA_HOME environment variable.");
Expand Down Expand Up @@ -1464,12 +1462,8 @@ private static BufferedReader getReader(URL url, Settings settings) throws IOExc
public void close() throws IOException {
super.close();

if (httpMethod != null) {
httpMethod.releaseConnection();
}
if (httpClient != null) {
httpClient.close();
}
httpMethod.releaseConnection();
httpClient.close();
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1033,9 +1033,7 @@ public void testProxy() throws Exception {
// see comment above (line 829)
// assertTrue( optionsContent.contains( "-link 'http://commons.apache.org/logging/apidocs'" ) );
} finally {
if (proxyServer != null) {
proxyServer.stop();
}
proxyServer.stop();
}
}

Expand Down
Loading