use of org.apache.maven.artifact.handler.ArtifactHandler in project maven-plugins by apache.
the class AbstractJavadocMojo method getSourcePaths.
/**
* Method to get the source paths. If no source path is specified in the parameter, the compile source roots
* of the project will be used.
*
* @return a Collection of the project absolute source paths as <code>String</code>
* @throws MavenReportException {@link MavenReportException}
* @see JavadocUtil#pruneDirs(MavenProject, List)
*/
protected Map<String, Collection<String>> getSourcePaths() throws MavenReportException {
Map<String, Collection<String>> mappedSourcePaths = new LinkedHashMap<>();
if (StringUtils.isEmpty(sourcepath)) {
Set<String> sourcePaths = new LinkedHashSet<>(JavadocUtil.pruneDirs(project, getProjectSourceRoots(project)));
if (project.getExecutionProject() != null) {
sourcePaths.addAll(JavadocUtil.pruneDirs(project, getExecutionProjectSourceRoots(project)));
}
/*
* Should be after the source path (i.e. -sourcepath '.../src/main/java;.../src/main/javadoc') and
* *not* the opposite. If not, the javadoc tool always copies doc files, even if -docfilessubdirs is
* not setted.
*/
if (getJavadocDirectory() != null) {
File javadocDir = getJavadocDirectory();
if (javadocDir.exists() && javadocDir.isDirectory()) {
Collection<String> l = JavadocUtil.pruneDirs(project, Collections.singletonList(getJavadocDirectory().getAbsolutePath()));
sourcePaths.addAll(l);
}
}
mappedSourcePaths.put(ArtifactUtils.versionlessKey(project.getGroupId(), project.getArtifactId()), sourcePaths);
if (includeDependencySources) {
mappedSourcePaths.putAll(getDependencySourcePaths());
}
if (isAggregator() && project.isExecutionRoot()) {
for (MavenProject subProject : reactorProjects) {
if (subProject != project) {
Collection<String> additionalSourcePaths = new ArrayList<>();
List<String> sourceRoots = getProjectSourceRoots(subProject);
if (subProject.getExecutionProject() != null) {
sourceRoots.addAll(getExecutionProjectSourceRoots(subProject));
}
ArtifactHandler artifactHandler = subProject.getArtifact().getArtifactHandler();
if ("java".equals(artifactHandler.getLanguage())) {
additionalSourcePaths.addAll(JavadocUtil.pruneDirs(subProject, sourceRoots));
}
if (getJavadocDirectory() != null) {
String javadocDirRelative = PathUtils.toRelative(project.getBasedir(), getJavadocDirectory().getAbsolutePath());
File javadocDir = new File(subProject.getBasedir(), javadocDirRelative);
if (javadocDir.exists() && javadocDir.isDirectory()) {
Collection<String> l = JavadocUtil.pruneDirs(subProject, Collections.singletonList(javadocDir.getAbsolutePath()));
additionalSourcePaths.addAll(l);
}
}
mappedSourcePaths.put(ArtifactUtils.versionlessKey(subProject.getGroupId(), subProject.getArtifactId()), additionalSourcePaths);
}
}
}
} else {
Collection<String> sourcePaths = new ArrayList<>(Arrays.asList(JavadocUtil.splitPath(sourcepath)));
sourcePaths = JavadocUtil.pruneDirs(project, sourcePaths);
if (getJavadocDirectory() != null) {
Collection<String> l = JavadocUtil.pruneDirs(project, Collections.singletonList(getJavadocDirectory().getAbsolutePath()));
sourcePaths.addAll(l);
}
mappedSourcePaths.put(ArtifactUtils.versionlessKey(project.getGroupId(), project.getArtifactId()), sourcePaths);
}
return mappedSourcePaths;
}
Aggregations