[
https://issues.apache.org/jira/browse/NIFI-5859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16715540#comment-16715540
]
ASF GitHub Bot commented on NIFI-5859:
--------------------------------------
Github user bbende commented on a diff in the pull request:
https://github.com/apache/nifi-maven/pull/7#discussion_r240310495
--- Diff: src/main/java/org/apache/nifi/NarMojo.java ---
@@ -426,12 +479,260 @@
protected boolean cloneDuringInstanceClassLoading;
+ /**
+ * The {@link RepositorySystemSession} used for obtaining the local
and remote artifact repositories.
+ */
+ @Parameter(defaultValue = "${repositorySystemSession}", readonly =
true)
+ private RepositorySystemSession repoSession;
+
+
+ /**
+ * The {@link ProjectBuilder} used to generate the {@link
MavenProject} for the nar artifact the dependency tree is being generated for.
+ */
+ @Component
+ private ProjectBuilder projectBuilder;
+
+
+
@Override
- public void execute() throws MojoExecutionException,
MojoFailureException {
+ public void execute() throws MojoExecutionException {
copyDependencies();
+
+ try {
+ generateDocumentation();
+ } catch (final Throwable t) { // Catch Throwable in case a linkage
error such as NoClassDefFoundError occurs
+ getLog().warn("Could not generate extensions' documentation",
t);
+ }
+
makeNar();
}
+ private File getExtensionsDocumentationFile() {
+ final File directory = new File(projectBuildDirectory,
"META-INF/docs");
+ return new File(directory, "extension-docs.xml");
+ }
+
+ private void generateDocumentation() throws MojoExecutionException {
+ getLog().info("Generating documentation for NiFi extensions in the
NAR...");
+
+ // Create the ClassLoader for the NAR
+ final ExtensionClassLoaderFactory classLoaderFactory =
createClassLoaderFactory();
+
+ final ExtensionClassLoader extensionClassLoader;
+ try {
+ extensionClassLoader =
classLoaderFactory.createExtensionClassLoader();
+ } catch (final Exception e) {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Unable to create a ClassLoader for
documenting extensions. If this NAR contains any NiFi Extensions, those
extensions will not be documented.", e);
+ } else {
+ getLog().warn("Unable to create a ClassLoader for
documenting extensions. If this NAR contains any NiFi Extensions, those
extensions will not be documented. " +
+ "Enable mvn DEBUG output for more information (mvn
-X).");
+ }
+
+ return;
+ }
+
+
+ final File docsFile = getExtensionsDocumentationFile();
+ createDirectory(docsFile.getParentFile());
+
+ final File additionalDetailsDir = new
File(docsFile.getParentFile(), "additional-details");
+ createDirectory(additionalDetailsDir);
+
+ try (final OutputStream out = new FileOutputStream(docsFile)) {
+
+ final XMLStreamWriter xmlWriter =
XMLOutputFactory.newInstance().createXMLStreamWriter(out, "UTF-8");
+ try {
+ xmlWriter.writeStartElement("extensions");
+
+ final String nifiApiVersion =
extensionClassLoader.getNiFiApiVersion();
+ xmlWriter.writeStartElement("nifiApiVersion");
+ xmlWriter.writeCharacters(nifiApiVersion);
+ xmlWriter.writeEndElement();
+
+ final Class<?> docWriterClass;
+ try {
+ docWriterClass =
Class.forName(DOCUMENTATION_WRITER_CLASS_NAME, false, extensionClassLoader);
--- End diff --
Should we do this before entering the try block on line 542 so that if the
doc writer class can't be found we won't write anything to the docs file?
> Update NAR maven plugin to include information about Extensions
> ---------------------------------------------------------------
>
> Key: NIFI-5859
> URL: https://issues.apache.org/jira/browse/NIFI-5859
> Project: Apache NiFi
> Issue Type: New Feature
> Components: Tools and Build
> Reporter: Mark Payne
> Assignee: Mark Payne
> Priority: Major
>
> In order to have the NiFi Registry host any extensions, the registry will
> need a way to know what extensions exist in a given NAR. Currently, that
> information is not available directly.
> The NAR maven plugin should be updated to provide a list of extensions and
> for each one, provide at least the following minimal information:
> * Extension Type
> * Extension Name
> * Capability Description
> * Whether or not the component is Restricted, "sub-restrictions" it has, and
> explanations of both
> * Any Tags that the component has
> * If the component is a Controller Service, any Controller Service API's
> that it provides
> Additionally, it would be ideal to provide all documentation for the
> component within the NAR. It is best, though, not to write the documentation
> in HTML as is done now but rather in XML or some sort of form that provides
> the information in a structured way without any styling. This would allow the
> documentation to be rendered consistently, even if the styling changes from 1
> version to the next.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)