Gradle asciidoctor plugin v2 not working

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

Gradle asciidoctor plugin v2 not working

DocEvaluator
We successfully got Asciidoctor working, with version 1.5.x inside our Gradle script (build.gradle).

I now wanted to try the 2.0 version of the plugin, but it just doesn't do anything.
I tried to follow the instructions here: https://github.com/asciidoctor/asciidoctor-gradle-plugin
The build.gradle looks like this:

buildscript {
    repositories {
        jcenter()
    }
}

plugins {
    id 'org.asciidoctor.jvm.base' version '2.0.0' // (1)
    id 'org.asciidoctor.jvm.convert' version '2.0.0' // (2)
}

asciidoctor {
  println ("asciidoctor task")
  sourceDir  file('src/asciidoc')
  sources {
    include 'test.adoc'
  }
  outputDir  file('build/docs')
}

I see the message "asciidoctor task" get printed, but the task does not do anything!
I also deleted the task attributes, so that the standard attributes of the generic task are taken, but with no effect either.
I also tried other syntax options (Gradle gives you some freedom/options), but with no effect.
What am I doing wrong?
Reply | Threaded
Open this post in threaded view
|

Re: Gradle asciidoctor plugin v2 not working

mojavelinux
Administrator
First, 2.1.0 of the plugin is available. You'll want to upgrade as that addressed several bugs that were discovered. See https://github.com/asciidoctor/asciidoctor-gradle-plugin/releases/tag/release_2_1_0 for details.

Although more advanced then just a simple build, this example should help you get your feet wet.


What we really need is 2.1.0 supported in the gradle examples here: https://github.com/asciidoctor/asciidoctor-gradle-examples (In fact, there's already an open request).

Cheers,

-Dan

On Thu, Apr 25, 2019 at 1:52 AM DocEvaluator [via Asciidoctor :: Discussion] <[hidden email]> wrote:
We successfully got Asciidoctor working, with version 1.5.x inside our Gradle script (build.gradle).

I now wanted to try the 2.0 version of the plugin, but it just doesn't do anything.
I tried to follow the instructions here: https://github.com/asciidoctor/asciidoctor-gradle-plugin
The build.gradle looks like this:

buildscript {
    repositories {
        jcenter()
    }
}

plugins {
    id 'org.asciidoctor.jvm.base' version '2.0.0' // (1)
    id 'org.asciidoctor.jvm.convert' version '2.0.0' // (2)
}

asciidoctor {
  println ("asciidoctor task")
  sourceDir  file('src/asciidoc')
  sources {
    include 'test.adoc'
  }
  outputDir  file('build/docs')
}

I see the message "asciidoctor task" get printed, but the task does not do anything!
I also deleted the task attributes, so that the standard attributes of the generic task are taken, but with no effect either.
I also tried other syntax options (Gradle gives you some freedom/options), but with no effect.
What am I doing wrong?


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Gradle-asciidoctor-plugin-v2-not-working-tp6865.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Gradle asciidoctor plugin v2 not working

DocEvaluator
Thank you Dan, for the hints.
First of all, I upgraded to 2.1.0 and I also corrected (my mistake ) the .adoc file name. The upgrade to 2.1.0 did not make any difference, but because of the wrong file name, the task was not doing anything. Now it does something.
So, here's my updated "build.gradle":
buildscript {
    repositories {
        jcenter()
    }
}

plugins {
    id 'org.asciidoctor.jvm.base' version '2.1.0' // (1)
    id 'org.asciidoctor.jvm.convert' version '2.1.0' // (2)
}

asciidoctorj {
    version = '1.6.2' 
}

asciidoctor {
  println ("asciidoctor task")
  sourceDir  file('src/asciidoc')
  sources {
    include 'index.adoc'
  }
  outputDir  file('build/docs')
}

but Gradle gives me this ouput:

asciidoctor task

> Task :asciidoctor FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':detachedConfiguration2'.
> Cannot resolve external dependency org.asciidoctor:asciidoctorj:1.6.2 because no repositories are defined.
  Required by:
      project :
> Cannot resolve external dependency org.jruby:jruby-complete:9.1.0.0 because no repositories are defined.
  Required by:
      project :

The link of jorge aguilera did not help, because this was referencing some revealJS presentations. jorge was also adding the Maven repositories -- I also tried this, without effect. I would have been surprised, because jcenter() was also the only repository I had to add when I was working with the 1.5.x versions of the Gradle plugin.
(In addition to the missing examples you mentioned, I don't even find any useful examples for the 2.0.0 or 2.1.0 version in the internet...)
Reply | Threaded
Open this post in threaded view
|

Re: Gradle asciidoctor plugin v2 not working

DocEvaluator
Seems to be a Gradle problem (or my lack of deep Gradle understanding).
This works:

plugins {
    id 'org.asciidoctor.jvm.base' version '2.1.0' // (1)
    id 'org.asciidoctor.jvm.convert' version '2.1.0' // (2)
}

repositories {
  jcenter()
}

asciidoctorj {
    version = '1.6.2' 
}

asciidoctor {
  println ("asciidoctor task")
  sourceDir  file('src/asciidoc')
  sources {
    include 'index.adoc'
  }
  outputDir  file('build/docs')
}

So I had to move
repositories {
  jcenter()
}
out of "buildscript" and put it behind the "plugins" stuff.
I will try to look up Gradle doc, why this makes a difference (with 1.5.x we had it inside the "buildscript" block at the very beginning).
Reply | Threaded
Open this post in threaded view
|

Re: Gradle asciidoctor plugin v2 not working

jagedn
Hi

Gradle DSL has 2 different sections where you use `repositories`

First one is in `buildSrc` and is use to find dependencies for plugins. The second is to find dependencies for your project.

in your build.gradle don't need the first one because Gradle can find it in the plugin portal.

The second one is used by the plugin to build a classpath loader with the version you specify in the closure `asciidoctorj`

Reply | Threaded
Open this post in threaded view
|

Re: Gradle asciidoctor plugin v2 not working

DocEvaluator
Thanks for the explanation, this helps me to understand what I did wrong.
Reply | Threaded
Open this post in threaded view
|

Re: Gradle asciidoctor plugin v2 not working

DocEvaluator
Apart from my typo with the wrong filename... I now understand why my original build.gradle (before I made a simple test.adoc example for this forum) was not working:

The Gradle plugin can not work with filenames, which start with underline. So "_index.adoc" is not working, while "index.adoc" works. Funny... I hope to find the time to write a bug report, but I am not sure if I still have a Github account.

Unfortunately all our asciidoc projects have a central "_index.adoc" file, which is just used to include all other adoc files, which represent the main chapters.
Reply | Threaded
Open this post in threaded view
|

Re: Gradle asciidoctor plugin v2 not working

abelsromero
Ignoring "_index" is not an issue.
Files/folders with underscore prefix are considered hidden and are not treated.

This is handy if have "partials" files that are included by others and you don't want to convert them independently.
However, ircc if you setup the file "_index.adoc" in the build script, it should work.

PS: We should probably document that better.
Reply | Threaded
Open this post in threaded view
|

Re: Gradle asciidoctor plugin v2 not working

DocEvaluator
abelsromero wrote
Ignoring "_index" is not an issue.
Files/folders with underscore prefix are considered hidden and are not treated.

This is handy if have "partials" files that are included by others and you don't want to convert them independently.
That's good to know. Maybe I will adjust our file names then. Right now, we have it the other way round, because we were always ONLY building "_index.adoc" which included files which started not with an underscore.

abelsromero wrote
However, ircc if you setup the file "_index.adoc" in the build script, it should work.
No, that's exactly what is not working:
asciidoctor {
  //...
  sources {
    include '_index.adoc'
  }
}
...will just do nothing -- just the same as if I give a non-existing file.