-
Notifications
You must be signed in to change notification settings - Fork 122
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
Unable the access Maven Site properties from Asciidoctor Maven Plugin #170
Comments
@abelsromero From what you seen, is it possible to pass on this configuration? |
Not that I know of, but this could be an options definetly worth looking into. Worst case scenario we just reverse engineer the whole plugin and confirm it does not work. |
I found a workarount. I use the resouces plugin to write all properties to a file and include this file in my documents. A workaround. A direkt access to defined attributes would be more convenient. |
@obfischer Neat workaround. I understand it's not ideal, but that at least gives us something to do to solve the problem in the meantime. |
After a lot of trial and error, I've figured out how to get access to the configuration properties from parser. Pull request on the way. This is going to open a lot of doors. |
…or#168 & asciidoctor#160 enable configuratino for site parser - rewrite Maven Site parser to make more organized and extensible - pass AsciiDoc configuration in Maven Site plugin to Asciidoctor API - enhance Maven Site integration test - add custom template - add include - add source highlighting - make validation code compatible with Java 6 - enable integration tests on Travis - remove unused legacy site module
…or#168 & asciidoctor#160 enable configuration for site parser - rewrite Maven Site parser to make more organized and extensible - pass AsciiDoc configuration in Maven Site plugin to Asciidoctor API - enhance Maven Site integration test - add custom template - add include - add source highlighting - make validation code compatible with Java 6 - enable integration tests on Travis - remove unused legacy site module
I finally figured out how to read the Maven model from within the site parser. This enables us to read the configuration block inside the site plugin declaration and pass those options and attributes on to Asciidoctor, just like with the main plugin. (The primary difference from the main plugin is that we have to process the entire configuration ourselves). Since the site configuration is used for other purposes, I decided to move all the configuration under the <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version> <!-- 3.4 also works -->
<configuration>
<asciidoc>
<templateDir>src/site/asciidoc/templates</templateDir>
<requires>
<require>time</require>
</requires>
<attributes>
<source-highlighter>coderay</source-highlighter>
<coderay-css>style</coderay-css>
</attributes>
</asciidoc>
<moduleExcludes>
<asciidoc>**/_*.adoc</asciidoc>
</moduleExcludes>
</configuration>
<dependencies>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>1.5.3</version>
</dependency>
</dependencies>
</plugin> You'll notice that I added excludes for AsciiDoc. This prevents the site integration from processing include files as individual pages. You can tune this pattern to your liking. There is currently no way (that I can tell) to configure this automatically. Here's how I made it all work. First, I use the Plexus IoC container to inject the MavenProject instance into the AsciidoctorParser class (which took me several hours to figure out, btw): @Requirement
protected MavenProject project; Next, I use the MavenProject to access the configuration of the site plugin (which seems to work fine with the integration test project): project.getGoalConfiguration("org.apache.maven.plugins", "maven-site-plugin", "site", "site"); From there, we have to walk the DOM to extract information and pass it on to the Asciidoctor API. You can refer to the integration test project to see the full setup. https://github.com/asciidoctor/asciidoctor-maven-plugin/tree/master/src/it/maven-site-plugin This change lays the groundwork for configuring the Asciidoctor instance used by the site plugin. There may be a better way to do it. The parser may not be passing on all the necessary configuration. But it's a starting point. We can improve on it from here. Below is a list of the features that are now available from the site plugin:
|
…or#168 & asciidoctor#160 enable configuration for site parser - rewrite AsciidoctorParser (used by Maven Site Plugin) to make it more organized and extensible - pass AsciiDoc configuration defined in Maven Site plugin to the Asciidoctor API - enhance Maven Site integration test - add custom template - add include - add source highlighting - make validation code compatible with Java 6 - enable integration tests on Travis CI - remove unused legacy site module - fix license headers - minor cleanups
…or#168 & asciidoctor#160 enable configuration for site parser - rewrite AsciidoctorParser (used by Maven Site Plugin) to make it more organized and extensible - pass AsciiDoc configuration defined in Maven Site plugin to the Asciidoctor API - enhance Maven Site integration test - add custom template - add include - add source highlighting - make validation code compatible with Java 6 - enable integration tests on Travis CI - remove unused legacy site module - fix license headers - minor cleanups
…or#168 & asciidoctor#160 enable configuration for site parser - rewrite AsciidoctorParser (used by Maven Site Plugin) to make it more organized and extensible - specify baseDir by default when invoking Asciidoctor API - pass AsciiDoc configuration defined in Maven Site plugin to the Asciidoctor API - API options (e.g., templateDir) - Ruby options (e.g., requires) - AsciiDoc attributes (e.g., icons=font) - enhance Maven Site integration test - add custom template - add include - add source highlighting - make validation code compatible with Java 6 - enable integration tests on Travis CI - remove unused legacy site module - fix license headers - minor cleanups
…or#168 & asciidoctor#160 enable configuration for site parser - rewrite AsciidoctorParser (used by Maven Site Plugin) to make it more organized and extensible - specify baseDir by default when invoking Asciidoctor API - pass AsciiDoc configuration defined in Maven Site plugin to the Asciidoctor API - API options (e.g., templateDir) - Ruby options (e.g., requires) - AsciiDoc attributes (e.g., icons=font) - enhance Maven Site integration test - add custom template - add include - add source highlighting - make validation code compatible with Java 6 - enable integration tests on Travis CI and Appveyor - remove unused legacy site module - fix license headers - minor cleanups
…or#168 & asciidoctor#160 enable configuration for site parser - rewrite AsciidoctorParser (used by Maven Site Plugin) to make it more organized and extensible - specify baseDir by default when invoking Asciidoctor API - pass AsciiDoc configuration defined in Maven Site plugin to the Asciidoctor API - API options (e.g., templateDir) - Ruby options (e.g., requires) - AsciiDoc attributes (e.g., icons=font) - enhance Maven Site integration test - add custom template - add include - add source highlighting - make validation code compatible with Java 6 - enable integration tests on Travis CI and Appveyor - remove unused legacy site module - fix license headers - minor cleanups
The Asciidoctor Maven Plugin does not have access to the attributes for Maven Site defined in the configuration section of the Maven Site plugin. Here is an example configuration:
I can't in an Asciidoctor document now use any of there attributes while it is possible to do it when using the Maven plugin only to render Asciidoctor documents.
The text was updated successfully, but these errors were encountered: