Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support supply a complete folder instead of a singular project file #2980

Merged
merged 1 commit into from
Oct 31, 2023
Merged
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 @@ -13,10 +13,15 @@
package org.eclipse.tycho.extras.docbundle;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import java.util.stream.Stream.Builder;

import org.apache.maven.model.Repository;
import org.apache.maven.plugin.AbstractMojo;
Expand Down Expand Up @@ -83,7 +88,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
// now add all reactor projects,
for (MavenProject reactorProject : reactorProjects) {
if (reactorProject != project) {
if (PackagingType.TYPE_ECLIPSE_PLUGIN.equals(reactorProject.getPackaging())) {
if (isValidProject(reactorProject)) {
// due to how the search works we need to add the
// parent (!) directory!
String parent = reactorProject.getBasedir().getParent();
Expand All @@ -93,8 +98,30 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}
}
}
List<File> manifestList = getManifestList().stream().flatMap(file -> {
if (file.isDirectory()) {
Builder<File> builder = Stream.builder();
File[] files = file.listFiles();
for (File dir : files) {
File pluginXml = new File(dir, "plugin.xml");
if (pluginXml.isFile()) {
MavenProject mp = getReactor(dir);
if (mp != null && isValidProject(mp)) {
try {
pluginXml = pluginXml.getCanonicalFile();
} catch (IOException e) {
}
builder.add(pluginXml);
}
}
}
return builder.build();
} else {
return Stream.of(file);
}
}).toList();
try (EclipseFramework framework = application.startFramework(workspace, List.of())) {
ConvertSchemaToHtmlResult result = framework.execute(new ConvertSchemaToHtmlRunner(getManifestList(),
ConvertSchemaToHtmlResult result = framework.execute(new ConvertSchemaToHtmlRunner(manifestList,
destination, cssURL, searchPaths, project.getBasedir()));
Log log = getLog();
List<String> list = result.errors().toList();
Expand All @@ -113,6 +140,25 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}
}

private boolean isValidProject(MavenProject mp) {

return PackagingType.TYPE_ECLIPSE_PLUGIN.equals(mp.getPackaging());
}

private MavenProject getReactor(File dir) {
Path path = dir.toPath();
for (MavenProject mavenProject : reactorProjects) {
Path project = mavenProject.getBasedir().toPath();
try {
if (Files.isSameFile(path, project)) {
return mavenProject;
}
} catch (IOException e) {
}
}
return null;
}

List<String> getSearchPaths() {
if (additionalSearchPaths == null || additionalSearchPaths.isBlank()) {
return List.of();
Expand Down
Loading