-
Notifications
You must be signed in to change notification settings - Fork 123
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
Reinstate Asciidoctor configuration #403
Comments
Thanks @wilkinsona. I am unable to move to version 2.x of the Gradle plugin as I rely heavily on spring-asciidoctor-extensions. As you say, I could "create a custom configuration and then configure the asciidoctor task to use it." Any instructions on how to do that would be very welcome. |
The proposal I've made here won't help you there, I'm afraid. What you need is for me to fix spring-io/spring-asciidoctor-extensions#9 that you opened. Now that I've tackled spring-projects/spring-restdocs#581, I can make a similar change to |
Instructions on how to set an additional configuration can be found in the README of this project. I believe the reason to remove the |
It wouldn't have to be named |
The boilerplate in question is then
When a OTOH having a provided configuration allows power users to hook into the magic, but can trip new users. I think it’s better to keep configurations explicit. |
@aalmiray is correct. Under certain conditions this will cause a problem. Not everybody sees this, but the plugin ecosystem is now quite complex and has been written to maintain compatibility over a large range of Gradle versions.
I think we can help you on that, but I have to think about a good solution. (and still keep with what @aalmiray said in #403 (comment)) I have also looked at the example that @jnizet has posted in spring-projects/spring-restdocs#581 (comment). That is a concrete example to work from. Some of the issues will be covered in #404 instead. |
I'd argue that it's 6 lines. I would expect the implicit configuration to be used by the
Need it be wired into every Asciidoctor task? I think it would be reasonable to only wire it into the default |
@wilkinsona Where is the source of the spring-restdocs gradle plugin? I have an idea but I would like to see what the best implementation would be. |
REST Docs doesn't have a Gradle plugin. It does have an Asciidoctor extension, however. Its source is in the various |
Aha, so it just an extension that has to end up on the classpath. As I don't want to mess with the standard line of Gradle plugins with this, I might have a better solution to deal with this, it just depends on where it is going to find a home. Assuming that there is a plugin called apply plugin : 'org.asciidoctor.jvm.convert'
apply plugin : 'org.asciidoctor.jvm.pdf'
configurations {
asciidoctorSpring
}
dependencies {
asciidoctorSpring "org.springframework.restdocs:spring-restdocs-asciidoctor:${SpringVersion}"
}
asciidoctor {
configurations 'asciidoctorSpring'
t.outputDir "${buildDir}/docs/html5"
baseDirFollowsSourceDir()
}
asciidoctorPdf {
configurations 'asciidoctorSpring'
t.outputDir "${buildDir}/docs/pdf"
baseDirFollowsSourceDir()
}
This could either live somewhere in Spring, or maybe there can a plugin for it within Asciidoctor Gradle. As I said it will need a home somewhere. (I added PDF as well as someone mentioned it in the passing). |
AFAIK, the output dir and base dir follows source dir customisation are specific to @jnizet's needs. They aren't something that Spring REST Docs needs in general. The benefits of having an implicitly created configuration that can be used to add dependencies to the |
The reason why we don;t want single global configuration is all about classpath pollution. As a simple example, if anyone drops something on the classpath that has a snakeyaml transitive dependency, there is a good chance that it will break PDF generation. What happily works for one backend, might not work for another. In addition, since 2.x, build script authors now have to option of using Gradle workers instead of an external JVM process(*). Gradle workers are very sensitive to classpaths - not our fault, it is due to an issue in Gradle. Binary extensions and custom backends are about the only reason why an additional configuration is still needed. The reason why @aalmiray and I are loathe to just add the implicit configuration back is that it removes the explicit notion of saying here is an additional configuration that will be required. Unfortunately there is the drawback that it affects some users, especially now a decent base such as for spring-restdocs. Having said all of that we do add special configurations already. People who need to use additional GEMs that are not already packed as JARs now has to apply the To some extent this is what I suggested using a special contention for spring-restdocs, whereby the configuration is called Having looked at some of the Spring examples now, I think a small conventions plugin could also strip a number of lines out of those Gradle scripts. (*) We had to add an external process in 1.5 because Gradle daemon did not work with the way extensions were handled in earlier versions of the plugin. |
Yeah, they certainly could. It's an idea that I've toyed with for a while but have never done anything about. Perhaps this can give me the necessary impetus to do something. For simplicity's sake, I could just target the new Asciidoctor Gradle plugin. I've opened spring-projects/spring-restdocs#625. |
Here is an example of what a conventions plugin could look like. I just put it on a branch of mine and added it as an extra plugin in the Asciidoctor Gradle project. |
Very interesting, thank you. Just to be clear, I'd really want any such plugin to be part of Spring REST Docs. I doubt that you intended anything different, but just wanted to be sure to avoid any confusion. |
I had a quick look at the example plugin, and although I find it nice to correctly set the inputs and outputs of the asciidoctor task, I would be wary of being too opinionated. For example, assuming that the test task is what generates the snippets, and that the generated docs should be in the jar would be too much for me. |
Great. I'll leave it there as a reference point. Just mention me on the spring-projects/spring-restdocs#625 issue when you have something ready and can to see whether it will be compatible with both 2.x & 3.x Gradle plugins. |
@jnizet Could you comment on spring-projects/spring-restdocs#625, please? FWIW, I agree about not including the docs in the jar by default. |
@wilkinsona Can I close this issue? |
I would still prefer that a configuration be created by default. It could only be wired into the |
I revisited this today to see how feasible it will be in 3.0, but there are a number of opposing designs, none of which are a clear winner: Single configuration: One configuration per task instance:
OR
will be required. Lazy creation of configurations:
it will eagerly create all tasks even if not required. I don;t think there is currently a method on the NamedDomainContainer to add rules when objects are registered (not created). It is possible to work around this by creating a configuration for each known task within the plugin, but it does not allow for additional configurations to be automatically created when new tasks are added. I'm still not the wiser as to the best solution to this. |
I've just become aware of the
asciidoctor
configuration being removed in the latest versions of the Gradle plugin. I'd like to see if it could be reinstated as I think its removal is a small step backwards for users that want to use extensions. They now need to create a custom configuration and then configure theasciidoctor
task to use it. This is quite a bit of boiler plate that was avoided in previous releases. I can't see a benefit for users that are not using extensions that offsets the cost for users that are. I've looked at this commit where, I think, the configuration was removed, but haven't been able to discern the reasoning. Apologies if I have missed something.In addition to now requiring additional boilerplate, I think the removal of the
asciidoctor
configuration also makes this plugin less idiomatic. It's typical for Gradle plugins to have a configuration that allows dependencies to be added to their tasks' classpath. For example, Gradle's own Checkstyle plugin has acheckstyle
configuration for this purpose.If you are in agreement with the configuration being reinstated, I would be happy to try and contribute a pull request that does so.
The text was updated successfully, but these errors were encountered: