use of org.apache.maven.plugins.javadoc.options.TagletArtifact in project maven-plugins by apache.
the class AbstractJavadocMojo method getTagletPath.
/**
* Method to get the path of the taglet artifacts used in the <code>-tagletpath</code> option.
*
* @return a string that contains taglet path, separated by the System pathSeparator string
* (colon (<code>:</code>) on Solaris or semi-colon (<code>;</code>) on Windows).
* @throws MavenReportException if any
* @see File#pathSeparator
*/
private String getTagletPath() throws MavenReportException {
Set<TagletArtifact> tArtifacts = collectTagletArtifacts();
Collection<String> pathParts = new ArrayList<>();
for (TagletArtifact tagletArtifact : tArtifacts) {
if ((tagletArtifact != null) && (StringUtils.isNotEmpty(tagletArtifact.getGroupId())) && (StringUtils.isNotEmpty(tagletArtifact.getArtifactId())) && (StringUtils.isNotEmpty(tagletArtifact.getVersion()))) {
pathParts.addAll(getArtifactsAbsolutePath(tagletArtifact));
}
}
Set<Taglet> taglets = collectTaglets();
for (Taglet taglet : taglets) {
if (taglet == null) {
continue;
}
if ((taglet.getTagletArtifact() != null) && (StringUtils.isNotEmpty(taglet.getTagletArtifact().getGroupId())) && (StringUtils.isNotEmpty(taglet.getTagletArtifact().getArtifactId())) && (StringUtils.isNotEmpty(taglet.getTagletArtifact().getVersion()))) {
pathParts.addAll(getArtifactsAbsolutePath(taglet.getTagletArtifact()));
pathParts = JavadocUtil.pruneFiles(pathParts);
} else if (StringUtils.isNotEmpty(taglet.getTagletpath())) {
pathParts.add(taglet.getTagletpath());
pathParts = JavadocUtil.pruneDirs(project, pathParts);
}
}
StringBuilder path = new StringBuilder();
path.append(StringUtils.join(pathParts.iterator(), File.pathSeparator));
if (StringUtils.isNotEmpty(tagletpath)) {
path.append(JavadocUtil.unifyPathSeparator(tagletpath));
}
return path.toString();
}
use of org.apache.maven.plugins.javadoc.options.TagletArtifact in project maven-plugins by apache.
the class AbstractJavadocMojo method addTagletsFromTagletArtifacts.
/**
* Auto-detect taglets class name from <code>tagletArtifacts</code> and add them to arguments.
*
* @param arguments not null
* @throws MavenReportException if any
* @see JavadocUtil#getTagletClassNames(File)
*/
private void addTagletsFromTagletArtifacts(List<String> arguments) throws MavenReportException {
Set<TagletArtifact> tArtifacts = new LinkedHashSet<>();
if (tagletArtifacts != null && tagletArtifacts.length > 0) {
tArtifacts.addAll(Arrays.asList(tagletArtifacts));
}
if (includeDependencySources) {
try {
resolveDependencyBundles();
} catch (IOException e) {
throw new MavenReportException("Failed to resolve javadoc bundles from dependencies: " + e.getMessage(), e);
}
if (isNotEmpty(dependencyJavadocBundles)) {
for (JavadocBundle bundle : dependencyJavadocBundles) {
JavadocOptions options = bundle.getOptions();
if (options != null && isNotEmpty(options.getTagletArtifacts())) {
tArtifacts.addAll(options.getTagletArtifacts());
}
}
}
}
if (isEmpty(tArtifacts)) {
return;
}
List<String> tagletsPath = new ArrayList<>();
for (TagletArtifact aTagletArtifact : tArtifacts) {
if ((StringUtils.isNotEmpty(aTagletArtifact.getGroupId())) && (StringUtils.isNotEmpty(aTagletArtifact.getArtifactId())) && (StringUtils.isNotEmpty(aTagletArtifact.getVersion()))) {
Artifact artifact;
try {
artifact = createAndResolveArtifact(aTagletArtifact);
} catch (ArtifactResolverException e) {
throw new MavenReportException("Unable to resolve artifact:" + aTagletArtifact, e);
}
tagletsPath.add(artifact.getFile().getAbsolutePath());
}
}
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), SINCE_JAVADOC_1_4);
}
}
}
}
Aggregations