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

baseDir should be set when Asciidoctor is invoked from the Maven Site plugin #180

Closed
mojavelinux opened this issue Nov 28, 2015 · 4 comments
Assignees
Labels
Milestone

Comments

@mojavelinux
Copy link
Member

The baseDir option should be set when Asciidoctor is invoked from the Maven Site plugin. Currently, the baseDir is defaulting to the root of the project. This means that top-level includes have to be specified using a relative path from the project root instead of relative to the main file.

The behavior that needs to be emulated is specified here: https://github.com/asciidoctor/asciidoctor-maven-plugin/blob/master/src/main/java/org/asciidoctor/maven/AsciidoctorMojo.java#L213-L222

There's currently no way to provide options to the Maven Site plugin, so it should use the fallback behavior.

@mdlinville
Copy link

Also, if you are trying to use maven-site with Asciidoc, but also to build a PDF payload, the include:: syntax for making the HTML works breaks the PDF.

@mojavelinux
Copy link
Member Author

Technically, there is a way to work around this problem, but I'm only mentioning it for completeness, not because it's elegant.

You can simple define an attribute as the root of the includes in the document header per backend.

ifdef::backend-pdf[]
:includedir: src/site/asciidoc
endif::[]
ifndef::backend-pdf[]
:includedir: .
endif::[]

include::{includedir}/part.adoc[]

Again, we really don't want to have to resort to this, but in the meantime it might help to get you by.

@mojavelinux
Copy link
Member Author

Btw, we should have an attribute set in the Maven Site configuration that indicates that we're in the maven site environment. That would make conditionals like this more clear. Something like env-maven-site.

mojavelinux added a commit to mojavelinux/asciidoctor-maven-plugin that referenced this issue Dec 14, 2015
…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
mojavelinux added a commit to mojavelinux/asciidoctor-maven-plugin that referenced this issue Dec 14, 2015
…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
mojavelinux added a commit to mojavelinux/asciidoctor-maven-plugin that referenced this issue Dec 14, 2015
…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
mojavelinux added a commit to mojavelinux/asciidoctor-maven-plugin that referenced this issue Dec 14, 2015
…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
@mojavelinux mojavelinux self-assigned this Dec 14, 2015
@mojavelinux
Copy link
Member Author

Once I figured out how to inject the MavenProject into the class, I was able to access the basedir of the project and from there the path to the AsciiDoc files in the site. The basedir will be set to the following path by default:

  • ${project.basedir}/src/site/asciidoc

This value can be configured using a configuration property under the site configuration.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-site-plugin</artifactId>
    <version>3.3</version> <!-- 3.4 also works -->
    <configuration>
        <asciidoc>
            <baseDir>${project.basedir}</baseDir>
        </asciidoc>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.asciidoctor</groupId>
            <artifactId>asciidoctor-maven-plugin</artifactId>
            <version>1.5.3</version>
        </dependency>
    </dependencies>
</plugin>

mojavelinux added a commit to mojavelinux/asciidoctor-maven-plugin that referenced this issue Dec 14, 2015
…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
mojavelinux added a commit to mojavelinux/asciidoctor-maven-plugin that referenced this issue Dec 14, 2015
…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
mojavelinux added a commit to mojavelinux/asciidoctor-maven-plugin that referenced this issue Dec 14, 2015
…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
mojavelinux added a commit that referenced this issue Dec 15, 2015
resolves #170, #180, #179, #168 & #160 enable configuration for site parser
abelsromero pushed a commit to abelsromero/asciidoctor-maven-plugin that referenced this issue Jan 8, 2016
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants