pom.xml example for asciidoctor-extensions-lab

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

pom.xml example for asciidoctor-extensions-lab

gtapper
I've just ported the Apache Trafodion (incubating) documentation from Word to asciidoc. Quite a task.

Now, I'd like to add Google Analytics tracking to the documentation. It's been suggested (thanks!) that I use the Google Analytics Postprocess extension to implement this function. (Over using a code-passthrough block, which doesn't work well with the PDF theme.)

Problem is, I do all the building in Eclipse, which means that I need to configure the document's pom.xml file correctly. Alas, I cannot find an example for how to do that.

Please help.
Reply | Threaded
Open this post in threaded view
|

Re: pom.xml example for asciidoctor-extensions-lab

abelsromero
Welcome Gunnar,

Glad to hear another project is considering Asciidoctor :)

Now, about your issue, here's a simple approach that does the work:
1· Copy the extension ruby file to yout project. For instance, into `src/gems`
2· Add the ruby extension as a required gem using the `<requires>` block. The paths can be tricky here, the dot at teh beginning is important.
3· Add the attribute `google-analytics-account` required by the extension in the `<attributes>` section.
4· run `mvn generate-resoures` and enjoy.

Here it is a full example:
jruby-comple and asciidoctorj dependencies are optional

            <plugin>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
                <version>${asciidoctor.maven.plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>org.jruby</groupId>
                        <artifactId>jruby-complete</artifactId>
                        <version>${jruby.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctorj</artifactId>
                        <version>${asciidoctorj.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>asciidoc-to-html</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>process-asciidoc</goal>
                        </goals>
                        <configuration>
                            <backend>html5</backend>
                            <sourceDirectory>src/docs/asciidoc</sourceDirectory>
                            <requires>
                                <require>./src/gems/google-analytics-postprocessor.rb</require>
                            </requires>
                            <attributes>
                                <google-analytics-account>MY_GOOGLE_ID</google-analytics-account>
                            </attributes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
Reply | Threaded
Open this post in threaded view
|

Re: pom.xml example for asciidoctor-extensions-lab

gtapper
Thanks a bunch.

Just to make sure: I assume that the extensions are MIT License?

Gunnar
Reply | Threaded
Open this post in threaded view
|

Re: pom.xml example for asciidoctor-extensions-lab

gtapper
In reply to this post by abelsromero
Hi,

I tested this and it worked perfectly. If I may suggest, please add this as an example to the asciidoc pom.xml examples.

Thanks,

Gunnar
Reply | Threaded
Open this post in threaded view
|

Re: pom.xml example for asciidoctor-extensions-lab

mojavelinux
Administrator
In reply to this post by gtapper

On Sat, Jan 16, 2016 at 7:47 AM, gtapper [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Just to make sure: I assume that the extensions are MIT License?

Correct. I will update the repository.

-Dan


--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen
Reply | Threaded
Open this post in threaded view
|

Re: pom.xml example for asciidoctor-extensions-lab

mojavelinux
Administrator
In reply to this post by abelsromero


1· Copy the extension ruby file to yout project. For instance, into `src/gems`

I'd recommend using the path src/main/ruby instead. These are just scripts, not gems, so better that we call them by the language name.
 
2· Add the ruby extension as a required gem using the `<requires>` block. The paths can be tricky here, the dot at teh beginning is important.

The dot is important because it tells Ruby that the file is local and not a classpath entry.

-Dan 




--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen