Giter VIP home page Giter VIP logo

asciidoctorj's Introduction

AsciidoctorJ: Java bindings for Asciidoctor

AsciidoctorJ is the official library for running Asciidoctor on the JVM. Using AsciidoctorJ, you can convert AsciiDoc content or analyze the structure of a parsed AsciiDoc document from Java and other JVM languages.

You can find the documentation for integrating Asciidoctor in your JVM based language of choice at the Asciidoctor Docs site.

Build Status (Github Actions) project chat

Distribution

AsciidoctorJ is published to Maven Central. The artifact information can be found in the tables below.

Table 1. Artifact information for AsciidoctorJ in Maven Central
Group Id Artifact Id Version Download

org.asciidoctor

asciidoctorj

2.5.7

pom jar javadoc (jar) sources (jar) distribution (zip tar)

org.asciidoctor

asciidoctorj-api

2.5.7

pom jar javadoc (jar) sources (jar)

org.asciidoctor

asciidoctorj-epub3

1.5.1

org.asciidoctor

asciidoctorj-pdf

1.6.2

🔥
The artifactId changed to asciidoctorj starting in 1.5.0.

Quick win: using the command line interface

If you download from a distribution link above (zip or tar), you can get started straight away from the command line.

First, expand the downloaded file. That puts everything in directory asciidoctorj-2.5.7. Within that directory are bin and lib directories. bin contains the executables — asciidoctorj for Linux and macOS, and asciidoctorj.bat for Windows. lib contains the supporting libraries.

Verify the application runs by specifying the appropriate executable with no parameters; it should display the various run options available (i.e., help).

Linux: asciidoctorj-2.5.7/bin/asciidoctorj
Windows: asciidoctorj-2.5.7\bin\asciidoctorj.bat

Next, say you want to convert an ASCIIDOC (.adoc) file — such as this README — to a pdf.

Linux: asciidoctorj-2.5.7/bin/asciidoctorj -b pdf README.adoc
Windows: asciidoctorj-2.5.7\bin\asciidoctorj.bat -b pdf README.adoc

Boom! That should convert the README to a PDF named README.pdf. To create a PDF with a different name — say, READTHIS.pdf — just add the -o switch:

Linux: asciidoctorj-2.5.7/bin/asciidoctorj -b pdf -o READTHIS.pdf README.adoc
Windows: asciidoctorj-2.5.7\bin\asciidoctorj.bat -b pdf -o READTHIS.pdf README.adoc

The rest of the document addresses the asciidoctorj API, for doing more complex conversions from within a JVM-based application.

Installation

To start using AsciidoctorJ, you need to add the required dependency to the dependency management system of your choice, Maven, Gradle or Apache Ivy. If you don’t use a Dependency Management system please check the dependency graph and add all jars in it to your classpath.

Declaring the dependency in a Maven build file (i.e., pom.xml)
<dependencies>
  <dependency>
    <groupId>org.asciidoctor</groupId>
    <artifactId>asciidoctorj</artifactId>
    <version>2.5.7</version> <!--(1)-->
  </dependency>
</dependencies>
Declaring the dependency in a Gradle build file (e.g., build.gradle)
dependencies {
  compile 'org.asciidoctor:asciidoctorj:2.5.7'
}
Declaring the dependency in an SBT build file (e.g., build.sbt)
libraryDependencies += "org.asciidoctor" % "asciidoctorj" % "2.5.7" // (1)
  1. Specifying the version of AsciidoctorJ implicitly selects the version of Asciidoctor

Declaring the dependency in a Leiningen build file (e.g., project.clj)
:dependencies [[org.asciidoctor/asciidoctorj "2.5.7"]]
💡

In addition to using AsciidoctorJ directly, you can invoke it as part of your build using the Maven or Gradle plugin.

📎
The versions of Asciidoctor and AsciidoctorJ no longer align since version 1.6.0 of AsciidoctorJ. Please check the corresponding release notes to find out which version of Asciidoctor is packaged if you are embedding the library. If you use the distribution you can call asciidoctorj --version to get the version of Asciidoctor that is embedded in AsciidoctorJ.

Windows Installation

A Chocolatey package is available which installs the asciidoctorj-2.5.7-bin.zip Maven artifact along with a binary shim in %ChocolateyInstall%\bin which lets you run AsciidoctorJ from the command line.

C:\> choco install asciidoctorj
C:\> where asciidoctorj
C:\ProgramData\chocolatey\bin\asciidoctorj.exe
C:\> asciidoctorj -b pdf README.adoc

Using a pre-release version

Pre-release versions of AsciidoctorJ are published to oss.sonatype.org. The exact location of the repository will be announced. Final releases are released to both Maven Central.

Here’s how to use a pre-release version in Maven:

    <repositories>
        <repository>
            <id>staging</id>
            <url>https://oss.sonatype.org/content/repositories/orgasciidoctor-1234</url> <!--(1)-->
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
    </repositories>
  1. The exact URL differs for every build

Using a snapshot version

Snapshot versions will be published to https://oss.jfrog.org. To use a snapshot version of the the AsciidoctorJ library add this repository to your project:

<repositories>
    <repository>
        <id>snapshots</id>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <releases>
            <enabled>false</enabled>
        </releases>
        <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
    </repository>
</repositories>

If you build your project using Gradle add the repository like this to your build:

repositories {
    maven {
        url 'https://oss.sonatype.org/content/repositories/snapshots/'
    }
}

Development

AsciidoctorJ is built using Gradle. The project is structured as a multi-module build.

Project layout

The root folder is the root project and there are several subproject folders, each prefixed with asciidoctorj-. Each subproject produces a primary artifact (e.g., jar or zip) and its supporting artifacts (e.g., javadoc, sources, etc).

The subprojects are as follows:

asciidoctorj-api

The common API for AsciidoctorJ. Other implementations for different platforms than JRuby may reuse and implement this API. Produces the asciidoctorj-api.jar

asciidoctorj

The main Java bindings for the Asciidoctor RubyGem (asciidoctor) running on JRuby. Also bundles optional RubyGems needed at runtime, such as coderay, tilt, haml and slim. Produces the asciidoctorj jar.

asciidoctorj-cli

asciidoctorj command Java components. Produces the asciidoctorj-cli.

asciidoctorj-distribution

Produces the distribution zip that provides the standalone asciidoctorj command including Java components, launch scripts and required libraries.

asciidoctorj-arquillian-extension

Bundles an Arquillian extension that allows to inject an Asciidoctor instance or other instances commonly used by Asciidoctor tests into a test case.

asciidoctorj-test-support

Contains some common test classes that are used by multiple other subprojects and the Arquillian extension.

The Gradle build is partitioned into the following files:

build.gradle
gradle.properties
settings.gradle
gradle/
  wrapper/
    ...
  eclipse.gradle
  providedConfiguration.gradle
  publish.gradle
  sign.gradle
asciidoctorj-arquillian-extension/
  build.gradle
asciidoctorj-api/
  build.gradle
asciidoctorj-cli/
  build.gradle
asciidoctorj-core/
  build.gradle
asciidoctorj-distribution/
  build.gradle
asciidoctorj-test-support/
  build.gradle

Build the project

You invoke Gradle on this project using the gradlew command (i.e., the Gradle Wrapper).

💡
We strongly recommend that you use Gradle via the Gradle daemon.

To clone the project, compile the source and build the artifacts (i.e., jars) locally, run:

$ git clone https://github.com/asciidoctor/asciidoctorj
  cd asciidoctorj
  ./gradlew assemble

You can find the built artifacts in the asciidoctorj-*/build/libs folders.

To execute tests when running the build, use:

$ ./gradlew build

To only execute the tests, run:

$ ./gradlew check

You can also run tests for a single module:

$ cd asciidoctorj-core
  ../gradlew check

To run a single test in the asciidoctorj-core subproject, use:

$ ../gradlew -Dsingle.test=NameOfTestClass test

To create the distribution, run:

$ ./gradlew distZip

You can find the distribution in the asciidoctorj-distribution/build/distributions folder.

Develop in an IDE

IntelliJ IDEA

To import the project into IntelliJ IDEA 14, simply import the project using the import wizard. For more information, see the Gradle page in the IntelliJ IDEA Web Help.

Eclipse

To open the project in Eclipse, first generate the Eclipse project files:

$ cd asciidoctorj-core
  ./gradlew eclipse

Then, import the project into Eclipse using File  Import  General  Existing Project into Workspace.

Continuous integration

Continuous integration for the AsciidoctorJ project is performed by GitHub Actions. You can find recent build results, including the build status of pull requests, on the asciidoctor/asciidoctorj page.

Release and publish the artifacts

To build and publish a release the following properties have to be set, for example in the file ~/.gradle/gradle.properties:

~/.gradle/gradle.properties
signing.keyId=...              # (1)
signing.password=...
signing.secretKeyRingFile=/home/YOUR_USERNAME/.gnupg/secring.gpg

sdkman_consumer_key=...        # (2)
sdkman_consumer_token=...

sonatypeUsername=...           # (3)
sonatypePassword=...
  1. Settings for signing the artifacts

  2. Credentials for publishing a new release to sdkman

  3. Credentials for publishing artifacts to oss.sonatype.org

The following steps are necessary to build a new release:

  1. Update the version in gradle.properties to a release version, i.e. from 2.4.4-SNAPSHOT to 2.4.4.

  2. Build the release with

    # ./gradlew clean build
  3. After testing publish all artifacts to a local repository under build/repos with

    # ./gradlew publishAllPublicationsToLocalRepository -i
  4. When everything is fine publish the artifacts to a staging repository on https://oss.sonatype.org and close the repository:

    # ./gradlew publishAllPublicationsToSonatypeRepository -i
    # ./gradlew closeRepository -i
  5. Visit https://oss.sonatype.org/#stagingRepositories and check the staging repository. The artifacts are not published yet. The repository URL shown there can be used for testing this version before publishing to Maven central.

  6. When everything is fine publish the artifacts in the staging repository by clicking the "Release" button. Alternatively you can release it with

    # ./gradlew releaseRepository
  7. Publish the new version to sdkman with

    # ./gradlew asciidoctorj-distribution:sdkMajorRelease
  8. Commit everything and assign a tag:

    # git commit -m "Release v2.x.y"
    # git tag v2.x.y
  9. Upgrade the version to the next version by changing the version property in gradle.properties to version=2.x.y+1-SNAPSHOT and commit:

    git commit -m "Prepare next release"

Resources

The source code for AsciidoctorJ, including the latest developments and issues, can be found in the project’s repository on GitHub. If you identify an issue while using AsciidoctorJ, please don’t hesitate to file a bug report. Also, don’t forget to join the Asciidoctor Zulip community, where you can ask questions and leave comments.

asciidoctorj's People

Contributors

abelsromero avatar ahus1 avatar ancho avatar fiouz avatar geraldcombs avatar ggrossetie avatar iandarwin avatar il-pazzo avatar jmini avatar kduske-n4 avatar leadpony avatar lefou avatar lightguard avatar lordofthejars avatar lread avatar mmews-n4 avatar mojavelinux avatar msgilligan avatar mtolk avatar nicerloop avatar pasieronen avatar programming-wolf avatar robertpanzer avatar slonopotamus avatar sschuberth avatar t-h-a-l-i-s avatar tisoft avatar twasyl avatar vmj avatar ysb33r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asciidoctorj's Issues

Idea: provide a way to cancel rendering ?

This is just an idea I got while trying to integrate asciidoctor into an eclipse builder and found that asciidoctor is pretty fast, but sometimes does take more than a few seconds to complete rendering my docs - and probably will take even longer when users will real big docs come along.

Would it be possible to somehow get programmatic feedback on how far asciidoctor is in its rendering ? and optimally be able to cancel rendering so it doesn't use unnecessary CPU ?

Usecase here is that I plan to add a builder to eclipse that will detect changes to files, start building when a resource (or directory with .adoc files) haven't been saved in a grace period (~1-5s) and then start the rendering - but if the user then starts saving the current running rendering is going to be useless and it would be great to just cancel it instead of having to wait for it to finish.

I can't just start a new rendering since the old one might overwrite files (I could of course overcome this by rendering to a separate file and just move it of to later but it would be nicer if I could just cancel the rendering.

Can't use asciidoctor-java-integration as a gradle dependency

We're trying to retrofit the asciidcotor-gradle-plugin with asciidoctor-java-integration however we've encountered a problem. The following build.gradle fails

repositories {
    mavenCentral()
    mavenRepo(name: 'rubygems-release', url: 'http://rubygems-proxy.torquebox.org/releases')
}

dependencies {
    deployerJars 'org.apache.maven.wagon:wagon-webdav:1.0-beta-2',
            'org.apache.maven:maven-ant-tasks:2.1.0'
    compile gradleApi()
    compile 'org.jruby:jruby-complete:1.7.2'
    compile 'org.asciidoctor:asciidoctor-java-integration:0.1.1'
    testCompile 'org.spockframework:spock-core:0.6-groovy-1.8'
}

The following error gets printed with --stacktrace

gradle build --stacktrace

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> java.lang.NullPointerException (no error message)

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':compile'.
    at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.wrapException(ErrorHandlingArtifactDependencyResolver.java:51)
    at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.access$000(ErrorHandlingArtifactDependencyResolver.java:29)
    at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver$BrokenResolvedConfiguration.rethrowFailure(ErrorHandlingArtifactDependencyResolver.java:131)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:461)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getFiles(DefaultConfiguration.java:202)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getFiles(Unknown Source)
    at org.gradle.api.internal.file.AbstractFileCollection.iterator(AbstractFileCollection.java:60)
    at org.gradle.api.plugins.GroovyBasePlugin.findGroovyJarFile(GroovyBasePlugin.java:172)
    at org.gradle.api.plugins.GroovyBasePlugin.getGroovyClasspath(GroovyBasePlugin.java:143)
    at org.gradle.api.plugins.GroovyBasePlugin.access$000(GroovyBasePlugin.java:50)
    at org.gradle.api.plugins.GroovyBasePlugin$1$1.call(GroovyBasePlugin.java:78)
    at org.gradle.api.internal.ConventionAwareHelper$2.getValue(ConventionAwareHelper.java:87)
    at org.gradle.api.internal.ConventionAwareHelper$MappedPropertyImpl.getValue(ConventionAwareHelper.java:147)
    at org.gradle.api.internal.ConventionAwareHelper.getConventionValue(ConventionAwareHelper.java:117)
    at org.gradle.api.tasks.compile.GroovyCompile_Decorated.getGroovyClasspath(Unknown Source)
    at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:216)
    at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:122)
    at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
    at org.gradle.api.tasks.compile.GroovyCompile_Decorated.invokeMethod(Unknown Source)
    at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$PropertyInfo.getValue(AnnotationProcessingTaskFactory.java:369)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$Validator$1.call(AnnotationProcessingTaskFactory.java:182)
    at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.doResolve(DefaultFileCollectionResolveContext.java:120)
    at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.resolveAsFileTrees(DefaultFileCollectionResolveContext.java:75)
    at org.gradle.api.internal.file.collections.BuildDependenciesOnlyFileCollectionResolveContext$BuildableFileTreeInternalConverter.convertInto(BuildDependenciesOnlyFileCollectionResolveContext.java:50)
    at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.doResolve(DefaultFileCollectionResolveContext.java:98)
    at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext.resolveAsFileCollections(DefaultFileCollectionResolveContext.java:82)
    at org.gradle.api.internal.file.collections.BuildDependenciesOnlyFileCollectionResolveContext.resolveAsBuildables(BuildDependenciesOnlyFileCollectionResolveContext.java:43)
    at org.gradle.api.internal.file.CompositeFileCollection.addDependencies(CompositeFileCollection.java:136)
    at org.gradle.api.internal.file.CompositeFileCollection$3.resolve(CompositeFileCollection.java:124)
    at org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext$TaskGraphImpl.getNodeValues(CachingTaskDependencyResolveContext.java:86)
    at org.gradle.api.internal.CachingDirectedGraphWalker$GraphWithEmpyEdges.getNodeValues(CachingDirectedGraphWalker.java:173)
    at org.gradle.api.internal.CachingDirectedGraphWalker.doSearch(CachingDirectedGraphWalker.java:95)
    at org.gradle.api.internal.CachingDirectedGraphWalker.findValues(CachingDirectedGraphWalker.java:63)
    at org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.doResolve(CachingTaskDependencyResolveContext.java:74)
    at org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.resolve(CachingTaskDependencyResolveContext.java:63)
    at org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.getDependencies(CachingTaskDependencyResolveContext.java:53)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.addToTaskGraph(DefaultTaskExecutionPlan.java:72)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.addTasks(DefaultTaskGraphExecuter.java:72)
    at org.gradle.execution.TaskNameResolvingBuildConfigurationAction.configure(TaskNameResolvingBuildConfigurationAction.java:51)
    at org.gradle.execution.DefaultBuildExecuter.configure(DefaultBuildExecuter.java:42)
    at org.gradle.execution.DefaultBuildExecuter.access$100(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:48)
    at org.gradle.execution.ExcludedTaskFilteringBuildConfigurationAction.configure(ExcludedTaskFilteringBuildConfigurationAction.java:46)
    at org.gradle.execution.DefaultBuildExecuter.configure(DefaultBuildExecuter.java:42)
    at org.gradle.execution.DefaultBuildExecuter.access$100(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:48)
    at org.gradle.execution.DefaultTasksBuildExecutionAction.configure(DefaultTasksBuildExecutionAction.java:38)
    at org.gradle.execution.DefaultBuildExecuter.configure(DefaultBuildExecuter.java:42)
    at org.gradle.execution.DefaultBuildExecuter.select(DefaultBuildExecuter.java:35)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:155)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:38)
    at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:45)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:42)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:70)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:68)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:68)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:59)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:186)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:36)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:48)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:155)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
Caused by: java.lang.NullPointerException
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$ModuleVersionSelectorResolveState.resolve(DependencyGraphBuilder.java:947)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$DependencyEdge.getArtifacts(DependencyGraphBuilder.java:370)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$DependencyEdge.attachToParents(DependencyGraphBuilder.java:380)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$ConfigurationNode.attachToParents(DependencyGraphBuilder.java:831)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder.assembleResult(DependencyGraphBuilder.java:160)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder.resolve(DependencyGraphBuilder.java:72)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDependencyResolver.resolve(DefaultDependencyResolver.java:78)
    at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver$1.create(CacheLockingArtifactDependencyResolver.java:39)
    at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver$1.create(CacheLockingArtifactDependencyResolver.java:37)
    at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:124)
    at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:130)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.useCache(DefaultCacheLockingManager.java:53)
    at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver.resolve(CacheLockingArtifactDependencyResolver.java:37)
    at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyResolver.resolve(SelfResolvingDependencyResolver.java:41)
    at org.gradle.api.internal.artifacts.ivyservice.ShortcircuitEmptyConfigsArtifactDependencyResolver.resolve(ShortcircuitEmptyConfigsArtifactDependencyResolver.java:46)
    at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.resolve(ErrorHandlingArtifactDependencyResolver.java:39)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultConfigurationResolver.resolve(DefaultConfigurationResolver.java:42)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveNow(DefaultConfiguration.java:240)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getResolvedConfiguration(DefaultConfiguration.java:230)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getResolvedConfiguration(Unknown Source)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:459)
    ... 87 more


BUILD FAILED

Total time: 1.088 secs

We tried a local build of a.j.i however gradle failed to find the jar/pom int he local repository as well. same error :-(

Consider using java.io.File as first arg for renderFile()

While doing some work on the gradle plugin we swutched back and forth between render() and renderFile() without changing the value of the first argument. Of course we got a weird error when calling renderFile() as rhe filename did not exist (arg vale was asciidoc content). However, if the first arg was a File the IDE wouls had told us immediately.

Rendering a directory with asciidoctor files

By default Asciidoctor renders only the specified Asciidoctor file. Adding a full scan of directory and subdirectories of all asciidoctor files and render them could be a feature that shall be useful for large projects where documentation can be spread across different directories.

Adding Options and Attributes POJO

Adding Options and Attributes POJO to set Asciidoctor configuration so users can create configuration options from a Map or from a POJO.

Adding date attributes in AttributesBuilder.

AttributesBuilder should include methods for:

  • localdate
  • locatime
  • localdatetime
  • docdate
  • doctime
  • docdatetime

Although in current version you can set them using options(...) method.

Preload specified Ruby libraries

the Asciidoctor Java integration could preload specified libraries when it boots JRuby, removing the possibility of any problems or warnings.

Related with Issue

copycss attribute causes exception

I'm using the Gradle plugin for Asciidoctor and tried to use the copycss attribute as it seems the easiest way to get hold of the stylesheet. But the attribute results in the exception at the end of this report.

I don't think this is a problem with the Gradle plugin but the Java integration. Perhaps JRuby's stat() method can't handle files inside archives? If that's the case, perhaps the JARs need unpacking first?

Caused by: org.jruby.exceptions.RaiseException: (Errno::ENOENT) /Users/pledbrook/dev/tools/ratpack/ratpack-docs/jar:file:/Users/pledbrook/.gradle/caches/artifacts-23/filestore/org.asciidoctor/asciidoctor-java-integration/0.1.2/jar/34e5c3a38e59337da992243afb25185c56462866/asciidoctor-java-integration-0.1.2.jar!/gems/asciidoctor-0.1.2/stylesheets/asciidoctor.css
at org.jruby.RubyFile.stat(org/jruby/RubyFile.java:810)
at RUBY.fu_each_src_dest(jar:file:/Users/pledbrook/.gradle/caches/artifacts-23/filestore/org.jruby/jruby-complete/1.7.3/jar/2273e4c2a2abdd4b25a21bc513bfc05cfba31f3b/jruby-complete-1.7.3.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:1524)
at RUBY.fu_each_src_dest0(jar:file:/Users/pledbrook/.gradle/caches/artifacts-23/filestore/org.jruby/jruby-complete/1.7.3/jar/2273e4c2a2abdd4b25a21bc513bfc05cfba31f3b/jruby-complete-1.7.3.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:1538)
at RUBY.fu_each_src_dest(jar:file:/Users/pledbrook/.gradle/caches/artifacts-23/filestore/org.jruby/jruby-complete/1.7.3/jar/2273e4c2a2abdd4b25a21bc513bfc05cfba31f3b/jruby-complete-1.7.3.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:1522)
at RUBY.cp(jar:file:/Users/pledbrook/.gradle/caches/artifacts-23/filestore/org.jruby/jruby-complete/1.7.3/jar/2273e4c2a2abdd4b25a21bc513bfc05cfba31f3b/jruby-complete-1.7.3.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:395)
at RUBY.render(jar:file:/Users/pledbrook/.gradle/caches/artifacts-23/filestore/org.asciidoctor/asciidoctor-java-integration/0.1.2/jar/34e5c3a38e59337da992243afb25185c56462866/asciidoctor-java-integration-0.1.2.jar!/gems/asciidoctor-0.1.2/lib/asciidoctor.rb:851)
at RUBY.render_file(jar:file:/Users/pledbrook/.gradle/caches/artifacts-23/filestore/org.asciidoctor/asciidoctor-java-integration/0.1.2/jar/34e5c3a38e59337da992243afb25185c56462866/asciidoctor-java-integration-0.1.2.jar!/gems/asciidoctor-0.1.2/lib/asciidoctor.rb:870)
at RUBY.render_file(<script>:8)
at org.jruby.gen.InterfaceImpl1066952373.render_file(org/jruby/gen/InterfaceImpl1066952373.gen:13)
at org.asciidoctor.gradle.AsciidoctorTask$_gititdone_closure1.doCall(AsciidoctorTask.groovy:87)
at org.asciidoctor.gradle.AsciidoctorTask.gititdone(AsciidoctorTask.groovy:74)
at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)

Create a Main class to run the Asciidoctor Java integration as an application

Adding a Main class to the Asciidoctor Java integration would make it possible to run Asciidoctor from the commandline without ever having to install Ruby.

This Main class should accept all the arguments that the asciidoctor command accepts. It could parse the options directly or pass them to the Asciidoctor::Cli::Options class for parsing.

The Main class should be specified in the JAR so that a user can execute the Asciidoctor Java integration as an application. For example:

java -jar asciidoctor-java-integration.jar -b html5 -a toc sample.adoc

See http://asciidoctor.org/man/asciidoctor for a list of arguments.

We also might want to provide a shell script named asciidoctorj that wraps the java -jar command and makes it feel more like commandline tool.

Adapt boolean attributes to Asciidoctor values.

Adapt boolean attributes to Asciidoctor values. In Asciidoctor a boolean attribute can appear or not, but does not hold true/false values.

if attribute is present value should be an empty string, if not present (false) then value should be null.

Remove requirement to invoke asMap() on builders

When using the OptionsBuilder and AttributesBuilder classes to define options and attributes, respectively, it's necessary to call "asMap()" when passing the result to the Asciidoctor API.

For example:

asciidoctor.render(source, OptionsBuilder.options().safe(SafeMode.SAFE).asMap());

We should hide this detail from the client.

One solution is to overload the Asciidoctor API methods to accept the builder types. The implementation would immediately call asMap() to select the state of the collection at the time of the call.

public String render(String content, OptionsBuilder options) {
  return render(content, options.asMap());
}

With the addition of this method, it's possible to drop the explicit call to asMap() in the client code:

asciidoctor.render(source, OptionsBuilder.options().safe(SafeMode.SAFE));

Another (less elegant) solution, would be to have the builder types implement Map. However, my instinct tells me that's not a good option.

Dependency scope issue

From what I can see, the gems are all included in the distributed jar from this project.
But at the same time, they are declared in the POM file in such a way that maven projects that depend on this one will try to resolve the gems, and fail if they can't be resolved.
I'd suggest fixing this by adding scope=provided to the gem dependencies.
Doesn't make sense to both have the gems in the jar and have downstream projects resolve them again on their own?

cannot create asciidoctor in eclipse osgi

I've added asciidoctor.jar and jruby-complete.jar to the classpath of my osgi bundle and runs this code:

asciidoctor = Factory.create();

Creates the following exception:

org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- asciidoctor
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1027)
at RUBY.require(classpath:/METAINF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:36)
at RUBY.(root)(<script>:2)

I've tried finding info on running jruby in osgi but they all seem to bump into this issue when external resources needs loading.

When rendering a string - how to give asciidoctor a dir to resolve images ?

when I do

ad.render(astring);

image::mypicture.png

are not rendered - it is just passed through.

My guess it is because it cannot find the file...how do I tell asciidoctor which "dir" context the string should be rendered in ?

or even better could it provide a callback and let me resolve the locations ?

OutputDirectory problem on Windows

When running on windows ( asciidoctor-maven-plugin), I receive the following issue

Caused by: org.jruby.exceptions.RaiseException: (IOError) target directory does not exist: C:/opensource/StatelessPrime/angularJS/AngularPrime/trunk/C:/opensource/StatelessPrime/angularJS/AngularPrime/trunk/C:/opensource/StatelessPrime/angularJS/AngularPrime/trunk/target/generated-docs
at RUBY.render(jar:file:c:/maven_repository/org/asciidoctor/asciidoctor-java-integration/0.1.2/asciidoctor-java-integration-0.1.2.jar!/gems/asciidoctor-0.1.2/lib/asciidoctor.rb:811)

See also asciidoctor/asciidoctor-maven-plugin#45

Add support for the parse_header_only mode

One of the key features of Asciidoctor is the ability to retrieve information from the header of an AsciiDoc document without parsing or rendering the entire document.

This feature is activated by setting the :parse_header_only option to true. In Asciidoctor, this option is used with the Asciidoctor#load method to return a Document object that only contains header information. This information includes the document title, built-in attributes and attributes from the header.

For example, consider the following document:

= Sample Document
Doc Writer <[email protected]>
v1.0, 2013-05-20: First draft

Preamble...

When loading the document in "parse header only" mode:

doc = Asciidoctor.load_file('sample.adoc', :parse_header_only = true);

the Document contains the following information:

pp doc.blocks.size
=> 0

pp doc.doctitle
=> "Sample Document"

pp doc.attributes
=> {"encoding"=>"UTF-8",
 "sectids"=>"",
 "notitle"=>"",
 "toc-placement"=>"auto",
 "stylesheet"=>"",
 "linkcss"=>"",
 "caution-caption"=>"Caution",
 "important-caption"=>"Important",
 "note-caption"=>"Note",
 "tip-caption"=>"Tip",
 "warning-caption"=>"Warning",
 "appendix-caption"=>"Appendix",
 "example-caption"=>"Example",
 "figure-caption"=>"Figure",
 "table-caption"=>"Table",
 "toc-title"=>"Table of Contents",
 "docfile"=>"sample.adoc",
 "docdir"=>"",
 "docname"=>"sample",
 "docdate"=>"2013-05-20",
 "doctime"=>"23:36:24 MDT",
 "docdatetime"=>"2013-05-20 23:36:24 MDT",
 "asciidoctor"=>"",
 "asciidoctor-version"=>"0.1.2",
 "safe-mode-name"=>"secure",
 "safe-mode-secure"=>"",
 "safe-mode-level"=>20,
 "embedded"=>"",
 "include-depth"=>10,
 "backend"=>"html5",
 "doctype"=>"article",
 "backend-html5"=>"",
 "basebackend"=>"html",
 "basebackend-html"=>"",
 "html5-article"=>"",
 "html-article"=>"",
 "outfilesuffix"=>".html",
 "filetype"=>"html",
 "filetype-html"=>"",
 "localdate"=>"2013-05-20",
 "localtime"=>"23:38:10 MDT",
 "localdatetime"=>"2013-05-20 23:38:10 MDT",
 "stylesdir"=>".",
 "iconsdir"=>"./images/icons",
 "firstname"=>"Doc",
 "author"=>"Doc Writer",
 "authorinitials"=>"DW",
 "lastname"=>"Writer",
 "email"=>"[email protected]",
 "authorcount"=>1,
 "authors"=>"Doc Writer",
 "revdate"=>"2013-05-20",
 "revnumber"=>"1.0",
 "revremark"=>"First draft"}

We see there is lots of good information about the document, yet no time is spent parsing below the header. I could see this being very useful for applications that need to scan for documents by title, author, date, etc.

In order to support this feature, the Asciidoctor Java integration would need to be able to represent an Asciidoctor Document in Java. In the meantime, this could be a lightweight object that just holds the doctitle and attributes.

org.asciidoctor.DirectoryWalker#walkDirectory NPE

java.io.File#listFiles can returns null

org.asciidoctor.DirectoryWalker#walkDirectory is not protected against it

    Caused by: java.lang.NullPointerException
    at org.asciidoctor.DirectoryWalker.walkDirectory(DirectoryWalker.java:38)
    at org.asciidoctor.DirectoryWalker.scan(DirectoryWalker.java:28)
    at org.asciidoc.maven.AsciidoctorMojo.scanSourceFiles(AsciidoctorMojo.java:143)
    at org.asciidoc.maven.AsciidoctorMojo.execute(AsciidoctorMojo.java:123)
    at org.asciidoc.maven.AsciidoctorRefreshMojo.executeAndReturnDuration(AsciidoctorRefreshMojo.java:135)
    at org.asciidoc.maven.AsciidoctorRefreshMojo.doWork(AsciidoctorRefreshMojo.java:81)
    at org.asciidoc.maven.AsciidoctorHttpMojo.doWork(AsciidoctorHttpMojo.java:27)
    at org.asciidoc.maven.AsciidoctorRefreshMojo.execute(AsciidoctorRefreshMojo.java:63)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    ... 20 more

Add baseDir option to OptionsBuilder

The baseDir is a very important security feature of Asciidoctor. In all safe mode levels, it establishes the working directory. In safe mode levels SERVER and above, it establishes a jail that restricts the processor from seeing files in directories outside that path. Without this jail, the safe mode control has reduced capacity.

Given the importance of this option, it should be promoted as a named option in the OptionsBuilder fluent API. We should also recommend its usage in the docs. When Asciidoctor is run from Java, especially in a Servlet environment, the base directory is often not what the developer expects it to be. It is a very good practice to establish the base directory, regardless of safe mode level.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.