From 2f374b93350dd500ee820440decc61978f166541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Schalk=20W=2E=20Cronj=C3=A9?= Date: Fri, 29 Dec 2023 00:33:15 +0100 Subject: [PATCH] Prepare 4.0.0 final release This release filly integrates with Grolifant 2.2 and adopts the newer JVM execution models to. This allows for better integration with Gradle workers. THis has been so successful that the default execution model is no a worker with classpath isolation as previously it always has been javaexec. JRuby: jruby-gradle plugin has been replaced with jruby-simple-plugin. This eliminates a number of issues with the previous plugin in terms of functionality and compatibiliy. It also restores plugin compatibility with JDK8 whereas the older plugin requires JDK11. GEMs: The issues with load errors for external GEMs has been resolved, but eliminating the use of GEM_PATH and rather compiling a custom GEM Jar on the fly and placing it on the classpath. Disabled plugins: Some plugsin were disabled for this release and will probably be fixed for future releases. Due to their limited usage, it was thought better to get a release out now and fix these later. The plugins are: - Leanpub - Slides - Slides export Other: - `asciidoctorEditorConfig` is now lazy-created Closes: #628, #626, #655, #658, #664, #671, #673, #684, i#692, #693 --- README.adoc | 6 +- .../AsciidoctorEditorConfigPlugin.groovy | 14 +- base/build.gradle | 1 + .../internal/FunctionalSpecification.groovy | 14 +- .../base/AbstractDownloadableComponent.java | 17 +- .../base/AsciidoctorTaskOutputOptions.java | 9 + .../internal/AsciidoctorAttributes.groovy | 5 +- .../DefaultAsciidoctorOutputOptions.groovy | 10 + build.gradle | 13 +- buildSrc/build.gradle | 1 + .../AsciidoctorGradlePluginProject.groovy | 2 + .../AsciidoctorGradleProjectExtension.groovy | 39 ++++ docs/src/docs/asciidoc/index.adoc | 2 +- gems/build.gradle | 28 +-- .../src/gradleTest/external-gems/build.gradle | 8 +- ...GemPrepareTaskCachingFunctionalSpec.groovy | 28 +-- .../internal/FunctionalSpecification.groovy | 68 +++--- .../jvm/gems/AsciidoctorGemPrepare.groovy | 50 ++--- .../gems/AsciidoctorGemSupportPlugin.groovy | 49 +++-- .../org.asciidoctor.jvm.gems.properties | 17 -- .../AsciidoctorGemSupportPluginSpec.groovy | 5 +- gradle.properties | 4 +- gradle/gradle-plugin-dependencies.gradle | 3 +- gradle/integration-tests.gradle | 20 +- gradle/publishing.gradle | 4 +- js/build.gradle | 1 + .../internal/FunctionalSpecification.groovy | 8 +- jvm-epub/build.gradle | 25 +-- jvm-epub/src/gradleTest/epub3/build.gradle | 2 +- .../src/docs/asciidoc/chapter1.adoc | 6 - .../src/docs/asciidoc/chapter2.adoc | 9 - .../src/docs/asciidoc/epub3.adoc | 6 - ...doctorEpubTaskCachingFunctionalSpec.groovy | 22 +- .../AsciidoctorEpubTaskFunctionalSpec.groovy | 21 +- .../epub/LinkedChaptersFunctionalSpec.groovy | 16 +- .../internal/FunctionalSpecification.groovy | 37 ++-- .../jvm/epub/AsciidoctorEpubTask.groovy | 76 +++---- .../jvm/epub/AsciidoctorJEpubPlugin.groovy | 30 ++- .../org.asciidoctor.jvm.epub.properties | 17 -- jvm-leanpub/build.gradle | 35 ++-- ...sciidoctorLeanpubTaskFunctionalSpec.groovy | 47 +---- .../internal/FunctionalSpecification.groovy | 64 ++---- ...sciidoctorJLeanpubDropboxCopyPlugin.groovy | 31 +-- .../leanpub/AsciidoctorJLeanpubPlugin.groovy | 32 ++- .../jvm/leanpub/AsciidoctorLeanpubTask.groovy | 22 +- .../gradle/jvm/leanpub/DropboxCopyTask.groovy | 22 +- ...doctor.jvm.leanpub.dropbox-copy.properties | 17 -- .../org.asciidoctor.jvm.leanpub.properties | 17 -- .../AsciidoctorJLeanpubPluginSpec.groovy | 2 +- .../jvm/leanpub/DropboxCopyTaskSpec.groovy | 2 +- jvm-pdf/build.gradle | 34 ++- .../gradleTest/complex-jvm-setup/build.gradle | 2 +- .../complex-jvm-setup/build.gradle.kts | 5 +- ...idoctorPdfTaskCachingFunctionalSpec.groovy | 30 ++- .../AsciidoctorPdfTaskFunctionalSpec.groovy | 47 ++--- .../internal/FunctionalSpecification.groovy | 61 ++---- .../jvm/pdf/AsciidoctorJPdfPlugin.groovy | 2 +- .../gradle/jvm/pdf/AsciidoctorPdfTask.groovy | 133 ++++-------- .../pdf/AsciidoctorPdfThemesExtension.groovy | 34 +-- .../gradle/jvm/pdf/PdfFontDirException.groovy | 2 +- .../AsciidoctorPdfThemeExtensionSpec.groovy | 7 +- jvm/build.gradle | 1 + .../internal/FunctionalSpecification.groovy | 5 +- ...sciidoctorTaskCachingFunctionalSpec.groovy | 61 +++--- .../DefaultAsciidoctorJModules.groovy | 2 + .../internal/ExecutorConfiguration.groovy | 2 - .../gradle/jvm/AbstractAsciidoctorTask.groovy | 195 +++++------------- .../gradle/jvm/AsciidoctorJExtension.groovy | 168 ++++++++------- .../gradle/jvm/AsciidoctorTask.groovy | 6 +- .../gradle/remote/AsciidoctorJavaExec.groovy | 10 +- .../remote/AsciidoctorWorkerExecutor.groovy | 12 +- .../remote/AsciidoctorJavaExecSpec.groovy | 2 +- .../internal/RemoteSpecification.groovy | 2 +- .../internal/ExecutorConfigurationSpec.groovy | 1 - .../gradle/jvm/AsciidoctorTaskSpec.groovy | 45 ---- module-versions.properties | 2 +- settings.gradle | 20 +- .../testfixtures/CachingTestFixture.groovy | 2 +- .../testfixtures/FunctionalTestFixture.groovy | 42 +++- .../testfixtures/GradleTestVersions.groovy | 6 +- 80 files changed, 815 insertions(+), 1110 deletions(-) delete mode 100644 gems/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.gems.properties delete mode 100644 jvm-epub/src/gradleTest/issue-409-link-regression/src/docs/asciidoc/chapter1.adoc delete mode 100644 jvm-epub/src/gradleTest/issue-409-link-regression/src/docs/asciidoc/chapter2.adoc delete mode 100644 jvm-epub/src/gradleTest/issue-409-link-regression/src/docs/asciidoc/epub3.adoc delete mode 100644 jvm-epub/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.epub.properties delete mode 100644 jvm-leanpub/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.leanpub.dropbox-copy.properties delete mode 100644 jvm-leanpub/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.leanpub.properties diff --git a/README.adoc b/README.adoc index 14288d6bd..12ec96d94 100644 --- a/README.adoc +++ b/README.adoc @@ -1,7 +1,7 @@ = Asciidoctor Gradle Plugin Andres Almiray -:version: 3.3.2 -:version-published: 3.3.2 +:version: 4.0.0 +:version-published: 4.0.0-alpha.1 :asciidoc-url: http://asciidoc.org :asciidoctor-url: http://asciidoctor.org :issues: https://github.com/asciidoctor/asciidoctor-maven-plugin/issues @@ -20,7 +20,7 @@ Andres Almiray :plugin-name: Asciidoctor Gradle plugin :project-name: asciidoctor-gradle-plugin :project-full-path: asciidoctor/asciidoctor-gradle-plugin -:github-branch: development-3.x +:github-branch: development-4.x :linkattrs: ifndef::env-github[:icons: font] ifdef::env-github,env-browser[] diff --git a/asciidoctoreditorconfig/src/main/groovy/org/asciidoctor/gradle/editorconfig/AsciidoctorEditorConfigPlugin.groovy b/asciidoctoreditorconfig/src/main/groovy/org/asciidoctor/gradle/editorconfig/AsciidoctorEditorConfigPlugin.groovy index b958b74d5..a64686184 100644 --- a/asciidoctoreditorconfig/src/main/groovy/org/asciidoctor/gradle/editorconfig/AsciidoctorEditorConfigPlugin.groovy +++ b/asciidoctoreditorconfig/src/main/groovy/org/asciidoctor/gradle/editorconfig/AsciidoctorEditorConfigPlugin.groovy @@ -33,17 +33,9 @@ class AsciidoctorEditorConfigPlugin implements Plugin { @Override void apply(Project project) { ProjectOperations.maybeCreateExtension(project) - AsciidoctorEditorConfigGenerator task = project.tasks.create( - DEFAULT_TASK_NAME, - AsciidoctorEditorConfigGenerator + project.tasks.register( + DEFAULT_TASK_NAME, + AsciidoctorEditorConfigGenerator ) - configureIdea(task) - } - - void configureIdea(AsciidoctorEditorConfigGenerator aecg) { - Project project = aecg.project - project.pluginManager.withPlugin('idea') { - project.tasks.getByName('ideaModule').dependsOn aecg - } } } diff --git a/base/build.gradle b/base/build.gradle index fa0fbf2af..c97543c6c 100644 --- a/base/build.gradle +++ b/base/build.gradle @@ -27,6 +27,7 @@ configurations { gradleTestCompile.transitive = false } +// TODO: Use configurePlugin instead gradlePlugin { plugins { basePlugin { diff --git a/base/src/intTest/groovy/org/asciidoctor/gradle/base/internal/FunctionalSpecification.groovy b/base/src/intTest/groovy/org/asciidoctor/gradle/base/internal/FunctionalSpecification.groovy index 79b3e13e6..c27477697 100644 --- a/base/src/intTest/groovy/org/asciidoctor/gradle/base/internal/FunctionalSpecification.groovy +++ b/base/src/intTest/groovy/org/asciidoctor/gradle/base/internal/FunctionalSpecification.groovy @@ -31,13 +31,13 @@ import static org.asciidoctor.gradle.testfixtures.FunctionalTestSetup.getOffline class FunctionalSpecification extends Specification { public static final String TEST_PROJECTS_DIR = System.getProperty( - 'TEST_PROJECTS_DIR', - './asciidoctor-gradle-base/src/intTest/projects' + 'TEST_PROJECTS_DIR', + './asciidoctor-gradle-base/src/intTest/projects' ) public static final String TEST_REPO_DIR = System.getProperty( - 'OFFLINE_REPO', - './testfixtures/offline-repo/build/repo' + 'OFFLINE_REPO', + './testfixtures/offline-repo/build/repo' ) @TempDir @@ -61,11 +61,11 @@ class FunctionalSpecification extends Specification { @CompileStatic String getOfflineRepositories(DslType dslType = GROOVY_DSL) { dslType == GROOVY_DSL ? getOfflineRepositoriesGroovyDsl(new File(TEST_REPO_DIR)) : - getOfflineRepositoriesKotlinDsl(new File(TEST_REPO_DIR)) + getOfflineRepositoriesKotlinDsl(new File(TEST_REPO_DIR)) } File getGroovyBuildFile(String extraContent, String plugin = 'org.asciidoctor.base') { - File buildFile = new File(testProjectDir,'build.gradle') + File buildFile = new File(testProjectDir, 'build.gradle') buildFile << """ plugins { id '${plugin}' @@ -79,7 +79,7 @@ class FunctionalSpecification extends Specification { } File getKotlinBuildFile(String extraContent, String plugin = 'org.asciidoctor.base') { - File buildFile = new File(testProjectDir,'build.gradle.kts') + File buildFile = new File(testProjectDir, 'build.gradle.kts') buildFile << """ plugins { id("${plugin}") diff --git a/base/src/main/groovy/org/asciidoctor/gradle/base/AbstractDownloadableComponent.java b/base/src/main/groovy/org/asciidoctor/gradle/base/AbstractDownloadableComponent.java index 33a721135..8d06beec3 100644 --- a/base/src/main/groovy/org/asciidoctor/gradle/base/AbstractDownloadableComponent.java +++ b/base/src/main/groovy/org/asciidoctor/gradle/base/AbstractDownloadableComponent.java @@ -21,6 +21,7 @@ import org.gradle.api.Project; import org.gradle.api.UnknownDomainObjectException; import org.gradle.api.provider.Provider; +import org.ysb33r.grolifant.api.core.ClosureUtils; import org.ysb33r.grolifant.api.core.ProjectOperations; import org.ysb33r.grolifant.api.core.git.AbstractCloudGit; import org.ysb33r.grolifant.api.core.git.GitLabArchive; @@ -40,6 +41,13 @@ * @since 2.0 */ public abstract class AbstractDownloadableComponent { + + protected final ProjectOperations projectOperations; + private final Map> components = + new LinkedHashMap<>(); + + private final Provider downloadRootProvider; + /** * Adds a component source that is available on the local filesystem. *

@@ -75,7 +83,9 @@ public void github(final String name, Action githubConfig) { * @param gitlabConfig Closure to configure a {@link AscGitLabArchive}. */ public void gitlab(final String name, @DelegatesTo(GitLabArchive.class) Closure gitlabConfig) { - gitlab(name, x -> gitlabConfig.call(x)); + AscGitLabArchive archive = new AscGitLabArchive(projectOperations); + ClosureUtils.configureItem(archive,gitlabConfig); + this.components.put(name, convertible(name, archive)); } /** @@ -179,9 +189,4 @@ private void addCloudGitArchive( private String getRelativePathInsideArchive(AbstractCloudGit theme) { return ((String) (theme.getProperty("relativePath"))); } - - private final Map> components = - new LinkedHashMap<>(); - private final ProjectOperations projectOperations; - private final Provider downloadRootProvider; } diff --git a/base/src/main/groovy/org/asciidoctor/gradle/base/AsciidoctorTaskOutputOptions.java b/base/src/main/groovy/org/asciidoctor/gradle/base/AsciidoctorTaskOutputOptions.java index d921b9deb..4de1102b6 100644 --- a/base/src/main/groovy/org/asciidoctor/gradle/base/AsciidoctorTaskOutputOptions.java +++ b/base/src/main/groovy/org/asciidoctor/gradle/base/AsciidoctorTaskOutputOptions.java @@ -16,6 +16,7 @@ package org.asciidoctor.gradle.base; import org.gradle.api.tasks.Internal; +import org.gradle.api.tasks.Nested; import org.gradle.api.tasks.OutputDirectories; import java.io.File; @@ -109,4 +110,12 @@ void copyResourcesByBackend( * @return Output directory. */ File getOutputDirForBackend(final String backendName, final String language); + + /** + * Access to the underlying {@link OutputOptions}. + * + * @return {@link OutputOptions} instance. + */ + @Nested + OutputOptions getOutputOptions(); } diff --git a/base/src/main/groovy/org/asciidoctor/gradle/base/internal/AsciidoctorAttributes.groovy b/base/src/main/groovy/org/asciidoctor/gradle/base/internal/AsciidoctorAttributes.groovy index 80381bb1e..3472cbe97 100644 --- a/base/src/main/groovy/org/asciidoctor/gradle/base/internal/AsciidoctorAttributes.groovy +++ b/base/src/main/groovy/org/asciidoctor/gradle/base/internal/AsciidoctorAttributes.groovy @@ -90,6 +90,7 @@ class AsciidoctorAttributes { * @param workingSourceDir Working source directory from which source documents will be made available. * @param seedAttributes Initial attributes set on the task. * @param langAttributes Any language specific attributes. + * @param tdsAttributes Task-specific default attributes. * @param attributeProviders Additional attribute providers. * @param lang Language being processed. Can be unset if multi-language feature is not used. * @return Attributes ready for serialisation. @@ -101,7 +102,7 @@ class AsciidoctorAttributes { final StringTools stringTools, Map seedAttributes, Map langAttributes, - Map taskSpecificDefaultAttributes, + Map tsdAttributes, List attributeProviders, Optional lang ) { @@ -115,7 +116,7 @@ class AsciidoctorAttributes { Map defaultAttrs = prepareDefaultAttributes( stringTools, attrs, - taskSpecificDefaultAttributes, + tsdAttributes, lang ) attrs.putAll(defaultAttrs) diff --git a/base/src/main/groovy/org/asciidoctor/gradle/base/internal/DefaultAsciidoctorOutputOptions.groovy b/base/src/main/groovy/org/asciidoctor/gradle/base/internal/DefaultAsciidoctorOutputOptions.groovy index 1d4d653d2..fa8f4189b 100644 --- a/base/src/main/groovy/org/asciidoctor/gradle/base/internal/DefaultAsciidoctorOutputOptions.groovy +++ b/base/src/main/groovy/org/asciidoctor/gradle/base/internal/DefaultAsciidoctorOutputOptions.groovy @@ -229,4 +229,14 @@ class DefaultAsciidoctorOutputOptions implements AsciidoctorTaskOutputOptions { new File(fileOperations.outputDir, "${language}/${backendName}") : new File(fileOperations.outputDir, language) } + + /** + * Access to the underlying {@link OutputOptions}. + * + * @return {@link OutputOptions} instance. + */ + @Override + OutputOptions getOutputOptions() { + this.configuredOutputOptions + } } diff --git a/build.gradle b/build.gradle index 0dae16f88..5df351178 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ plugins { // id 'com.gradle.build-scan' version '3.11.1' id 'net.nemerosa.versioning' version '2.6.1' apply false id 'com.github.ben-manes.versions' version '0.17.0' apply false - id 'com.gradle.plugin-publish' version '1.2.1' apply false +// id 'com.gradle.plugin-publish' version "" apply false id 'com.github.hierynomus.license' version '0.16.1' apply false id 'com.github.kt3k.coveralls' version '2.8.2' apply false id 'net.ossindex.audit' version '0.1.1' apply false @@ -136,6 +136,17 @@ subprojects { } } + configurations.all { + resolutionStrategy { + eachDependency { DependencyResolveDetails details -> + if (details.requested.group == 'org.codehaus.groovy') { + details.useVersion GroovySystem.version + details.because 'THe same version as Grodale Groovy is required' + } + } + } + } + audit { failOnError = false } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 7ff125fd8..4767c2aa1 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -17,6 +17,7 @@ repositories { dependencies { implementation localGroovy() implementation gradleApi() + implementation "com.gradle.publish:plugin-publish-plugin:${gradleProperties.pluginPublishPlugin}" api "org.ysb33r.gradle:nodejs-gradle-plugin:${gradleProperties.nodejsGradleVersion}" api "org.ysb33r.gradle:grolifant-herd:${gradleProperties.grolifantVersion}" } diff --git a/buildSrc/src/main/groovy/AsciidoctorGradlePluginProject.groovy b/buildSrc/src/main/groovy/AsciidoctorGradlePluginProject.groovy index 12e68ae3d..cfbf46abd 100644 --- a/buildSrc/src/main/groovy/AsciidoctorGradlePluginProject.groovy +++ b/buildSrc/src/main/groovy/AsciidoctorGradlePluginProject.groovy @@ -16,6 +16,8 @@ class AsciidoctorGradlePluginProject implements Plugin { project.pluginManager.identity { apply 'maven-publish' apply 'groovy-gradle-plugin' + apply 'java-gradle-plugin' + apply 'com.gradle.plugin-publish' apply AsciidoctorGradleGroovyProject } diff --git a/buildSrc/src/main/groovy/AsciidoctorGradleProjectExtension.groovy b/buildSrc/src/main/groovy/AsciidoctorGradleProjectExtension.groovy index bb5f5ff07..ee7216698 100644 --- a/buildSrc/src/main/groovy/AsciidoctorGradleProjectExtension.groovy +++ b/buildSrc/src/main/groovy/AsciidoctorGradleProjectExtension.groovy @@ -1,6 +1,11 @@ +import com.gradle.publish.PluginBundleExtension import groovy.transform.CompileStatic import org.gradle.api.Project import org.gradle.api.artifacts.ConfigurationContainer +import org.gradle.api.plugins.ExtensionContainer +import org.gradle.api.provider.Provider +import org.gradle.plugin.devel.GradlePluginDevelopmentExtension +import org.gradle.plugin.devel.PluginDeclaration import org.gradle.plugin.devel.tasks.PluginUnderTestMetadata import org.ysb33r.grolifant.api.core.ProjectOperations @@ -9,10 +14,19 @@ class AsciidoctorGradleProjectExtension { private final ProjectOperations projectOperations private final ConfigurationContainer configurations + private final ExtensionContainer extensions + private final Provider pluginExtraTextProvider AsciidoctorGradleProjectExtension(Project project) { this.projectOperations = ProjectOperations.find(project) this.configurations = project.configurations + this.extensions = project.extensions + + this.pluginExtraTextProvider = projectOperations.versionProvider.map { version -> + (version.contains('-alpha') || version.contains('-beta')) ? + ". (If you need a production-ready version of the AsciidoctorJ plugin for Gradle use a 3.x release of this plugin instead)." + : '' + } } void withOfflineTestConfigurations() { @@ -47,4 +61,29 @@ class AsciidoctorGradleProjectExtension { projectOperations.atConfigurationTime() ).get() } + + void configurePlugin( + String pluginId, + String providedDisplayName, + String providedDescription, + String implClass, + List providedTags + ) { + final gradlePlugin = extensions.getByType(GradlePluginDevelopmentExtension) + final pluginBundle = extensions.getByType(PluginBundleExtension) + final providedName = "${pluginId.replaceAll(~/\./, '')}Plugin".toString() + final extraText = pluginExtraTextProvider.get() + gradlePlugin.plugins.create(providedName) { PluginDeclaration pd -> + pd.tap { + id = pluginId + displayName = providedDisplayName + description = extraText ? "${providedDescription}. ${extraText}" : "${extraText}." + implementationClass = implClass + } + } + if (pluginBundle.pluginTags.isEmpty()) { + pluginBundle.pluginTags = [(providedName): (Collection)(['asciidoctor'] + providedTags)] + } + pluginBundle.pluginTags.putAll([(providedName): (['asciidoctor'] + providedTags)]) + } } diff --git a/docs/src/docs/asciidoc/index.adoc b/docs/src/docs/asciidoc/index.adoc index 628a8e4a7..a8b39ede8 100644 --- a/docs/src/docs/asciidoc/index.adoc +++ b/docs/src/docs/asciidoc/index.adoc @@ -27,7 +27,7 @@ include::parts/asciidoctorj-epub-plugin.adoc[] include::parts/asciidoctorj-revealjs-plugin.adoc[] -include::parts/asciidoctorj-leanpub-plugin.adoc[] +// include::parts/asciidoctorj-leanpub-plugin.adoc[] include::parts/asciidoctor-diagram.adoc[] diff --git a/gems/build.gradle b/gems/build.gradle index 4c563efa6..a297434e4 100644 --- a/gems/build.gradle +++ b/gems/build.gradle @@ -1,30 +1,32 @@ +import org.ysb33r.gradle.gradletest.GradleTest + +agProject { + configurePlugin 'org.asciidoctor.jvm.gems', + 'Simplifies support for using external GEMs with AsciidoctorJ', + 'Provides appropriate tasks and configurations for adding GEMs to AsciidoctorJ conversions', + 'org.asciidoctor.gradle.jvm.gems.AsciidoctorGemSupportPlugin', + ['asciidoctorj', 'gems', 'jruby'] +} dependencies { - implementation "com.github.jruby-gradle:jruby-gradle-core-plugin:${jrubyGradleVersion}" + implementation "org.ysb33r.gradle.jruby:jrubygradle-resolver:${pluginJrubySimpleVersion}" api project(':asciidoctor-gradle-jvm') } -test { +tasks.named('test', Test) { dependsOn ':testfixtures-offline-repo:buildOfflineRepositories' systemProperties OFFLINE_REPO: offlineRepoRoot.absolutePath } -gradleTest { +tasks.named('gradleTest', GradleTest) { // gradleArguments '-d' - if(OS.windows) { + if (OS.windows) { // Expecting external-gems to fail due to JRuby issue expectFailure ~/external-gems/ } - gradleArguments '-d' - // TODO: Re-enable this test - enabled = false - println "************ :asciidoctor-gradle-jvm-gems:gradleTest is disabled due to potential bug in asciidoctorj *********" +// enabled = false +// println "************ :asciidoctor-gradle-jvm-gems:gradleTest is disabled due to potential bug in asciidoctorj *********" } -configurePlugin 'org.asciidoctor.jvm.gems', - 'Simplifies support for using external GEMs with AsciidoctorJ', - 'Provides appropriate tasks and configurations for adding GEMs to AsciidoctorJ conversions', - [ 'asciidoctorj', 'gems', 'jruby'] - diff --git a/gems/src/gradleTest/external-gems/build.gradle b/gems/src/gradleTest/external-gems/build.gradle index c5a24ebd2..6bd634747 100644 --- a/gems/src/gradleTest/external-gems/build.gradle +++ b/gems/src/gradleTest/external-gems/build.gradle @@ -18,12 +18,8 @@ dependencies { } } -asciidoctorj { - requires 'asciidoctor-bibtex' -} - asciidoctor { - dependsOn asciidoctorGemsPrepare + withGemJar 'asciidoctorGemsJar' secondarySources { include 'biblio.bib' @@ -34,6 +30,6 @@ asciidoctor { // end::use-gems[] task runGradleTest { - dependsOn asciidoctor + dependsOn 'asciidoctor' } diff --git a/gems/src/intTest/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemPrepareTaskCachingFunctionalSpec.groovy b/gems/src/intTest/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemPrepareTaskCachingFunctionalSpec.groovy index f36aae8ce..b8ef8fc50 100644 --- a/gems/src/intTest/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemPrepareTaskCachingFunctionalSpec.groovy +++ b/gems/src/intTest/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemPrepareTaskCachingFunctionalSpec.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +16,14 @@ package org.asciidoctor.gradle.jvm.gems import org.asciidoctor.gradle.jvm.gems.internal.FunctionalSpecification -import org.asciidoctor.gradle.testfixtures.CachingTest +import org.asciidoctor.gradle.testfixtures.BuildScanFixture +import org.asciidoctor.gradle.testfixtures.CachingTestFixture import spock.lang.Issue import spock.lang.Timeout -class AsciidoctorGemPrepareTaskCachingFunctionalSpec extends FunctionalSpecification implements CachingTest { +class AsciidoctorGemPrepareTaskCachingFunctionalSpec extends FunctionalSpecification + implements CachingTestFixture, BuildScanFixture { + private static final String DEFAULT_TASK = 'asciidoctorGemsPrepare' private static final String OUTPUT_DIR_PATH = 'build/.asciidoctorGems' private static final String DEFAULT_GEM_NAME = 'asciidoctor-revealjs' @@ -136,23 +139,22 @@ class AsciidoctorGemPrepareTaskCachingFunctionalSpec extends FunctionalSpecifica @Override File getBuildFile(String extraContent) { - File buildFile = testProjectDir.newFile('build.gradle') - buildFile << """ - plugins { - id 'org.asciidoctor.jvm.gems' + writeGroovyBuildFile( + 'org.asciidoctor.jvm.gems', + extraContent + ).withWriterAppend { w -> + if (performBuildScan) { + w.println(buildScanConfiguration) } - ${ -> scan ? buildScanConfiguration : '' } - ${offlineRepositories} - + w.println ''' repositories { ruby { gems() } } - - ${extraContent} - """ + '''.stripIndent() + } buildFile } diff --git a/gems/src/intTest/groovy/org/asciidoctor/gradle/jvm/gems/internal/FunctionalSpecification.groovy b/gems/src/intTest/groovy/org/asciidoctor/gradle/jvm/gems/internal/FunctionalSpecification.groovy index 27f2e304b..9fb6780bb 100644 --- a/gems/src/intTest/groovy/org/asciidoctor/gradle/jvm/gems/internal/FunctionalSpecification.groovy +++ b/gems/src/intTest/groovy/org/asciidoctor/gradle/jvm/gems/internal/FunctionalSpecification.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,55 +16,51 @@ package org.asciidoctor.gradle.jvm.gems.internal import org.apache.commons.io.FileUtils +import org.asciidoctor.gradle.testfixtures.FunctionalTestFixture import org.gradle.testkit.runner.GradleRunner -import org.junit.Rule -import org.junit.rules.TemporaryFolder import org.ysb33r.grolifant.api.core.OperatingSystem import spock.lang.Specification +import spock.lang.TempDir -class FunctionalSpecification extends Specification { +class FunctionalSpecification extends Specification implements FunctionalTestFixture { public static final String TEST_PROJECTS_DIR = System.getProperty( - 'TEST_PROJECTS_DIR', - './asciidoctor-gradle-jvm-gems/src/intTest/projects' + 'TEST_PROJECTS_DIR', + './asciidoctor-gradle-jvm-gems/src/intTest/projects' ) public static final String TEST_REPO_DIR = System.getProperty( - 'OFFLINE_REPO', - './testfixtures/offline-repo/build/repo' + 'OFFLINE_REPO', + './testfixtures/offline-repo/build/repo' ) public static final OperatingSystem OS = OperatingSystem.current() - @Rule - TemporaryFolder testProjectDir + @TempDir + File testProjectDir - @Rule - TemporaryFolder alternateProjectDir - - GradleRunner getGradleRunner(List taskNames) { - GradleRunner.create() - .withProjectDir(testProjectDir.root) - .withArguments(taskNames) - .withPluginClasspath() - .forwardOutput() - .withDebug(true) + void setup() { + projectDir.mkdirs() } - @SuppressWarnings(['BuilderMethodWithSideEffects']) - void createTestProject(String docGroup) { - FileUtils.copyDirectory(new File(TEST_PROJECTS_DIR, docGroup), testProjectDir.root) + GradleRunner getGradleRunner(List taskNames) { + getGroovyGradleRunner(taskNames) } - String getOfflineRepositories() { - File repo = new File(TEST_REPO_DIR, 'repositories.gradle') - if (!repo.exists()) { - throw new FileNotFoundException( - "${repo} not found. Run ':testfixture-offline-repo:buildOfflineRepositories' build task" - ) - } +// @SuppressWarnings(['BuilderMethodWithSideEffects']) +// void createTestProject(String docGroup) { +// FileUtils.copyDirectory(new File(TEST_PROJECTS_DIR, docGroup), projectDir) +// } - if (OS.windows) { - "apply from: /${repo.absolutePath}/" - } else { - "apply from: '${repo.absolutePath}'" - } - } +// String getOfflineRepositories() { +// File repo = new File(TEST_REPO_DIR, 'repositories.gradle') +// if (!repo.exists()) { +// throw new FileNotFoundException( +// "${repo} not found. Run ':testfixture-offline-repo:buildOfflineRepositories' build task" +// ) +// } +// +// if (OS.windows) { +// "apply from: /${repo.absolutePath}/" +// } else { +// "apply from: '${repo.absolutePath}'" +// } +// } } \ No newline at end of file diff --git a/gems/src/main/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemPrepare.groovy b/gems/src/main/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemPrepare.groovy index 932e1c751..14907b9f5 100644 --- a/gems/src/main/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemPrepare.groovy +++ b/gems/src/main/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemPrepare.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,48 +15,38 @@ */ package org.asciidoctor.gradle.jvm.gems -import com.github.jrubygradle.api.core.AbstractJRubyPrepare import groovy.transform.CompileStatic import org.asciidoctor.gradle.jvm.AsciidoctorJExtension -import org.gradle.api.provider.Provider import org.gradle.api.tasks.CacheableTask +import org.gradle.workers.WorkerExecutor +import org.ysb33r.gradle.jruby.api.tasks.AbstractGemPrepareTask +import javax.inject.Inject import java.util.concurrent.Callable -import static com.github.jrubygradle.api.gems.GemUtils.JRUBY_ARCHIVE_NAME - -/** Prepare additional GEMs for AsciidoctorJ. +/** + * Prepare additional GEMs for AsciidoctorJ. * * @since 2.0 */ @CacheableTask @CompileStatic -class AsciidoctorGemPrepare extends AbstractJRubyPrepare { +class AsciidoctorGemPrepare extends AbstractGemPrepareTask { - /** Location of {@code jruby-complete} JAR. - * - * @return Path on local filesystem - */ - @Override - protected Provider getJrubyJarLocation() { - project.provider({ AsciidoctorJExtension jruby -> - jruby.configuration.files.find { it.name.startsWith(JRUBY_ARCHIVE_NAME) } - }.curry(jruby) as Callable) - } +// private final Provider jrubyJarLocationProvider + private final AsciidoctorJExtension jruby - /** Version of JRuby that will be used if explicitly set - * - * This method does not resolve any files to obtain the version. - * - * @return Explicitly configured project global version of JRuby or - * {@code null} if inferred from the asciidoctorj dependency. - */ - @Override - protected String getProposedJRubyVersion() { - jruby.jrubyVersion - } + @Inject + @SuppressWarnings('UnnecessarySetter') + AsciidoctorGemPrepare(WorkerExecutor we) { + super(we) + this.jruby = project.extensions.getByType(AsciidoctorJExtension) + setJrubyJarProvider(project.provider({ AsciidoctorJExtension jruby -> + jruby.configuration.files.find { it.name.startsWith(JRUBY_COMPLETE_NAME) } + }.curry(jruby) as Callable)) - private AsciidoctorJExtension getJruby() { - project.extensions.getByType(AsciidoctorJExtension) +// this.jrubyJarLocationProvider = project.provider({ AsciidoctorJExtension jruby -> +// jruby.configuration.files.find { it.name.startsWith(JRUBY_ARCHIVE_NAME) } +// }.curry(jruby) as Callable) } } diff --git a/gems/src/main/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemSupportPlugin.groovy b/gems/src/main/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemSupportPlugin.groovy index da548ace8..8162fe9d6 100644 --- a/gems/src/main/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemSupportPlugin.groovy +++ b/gems/src/main/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemSupportPlugin.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,17 +15,15 @@ */ package org.asciidoctor.gradle.jvm.gems -import com.github.jrubygradle.api.core.JRubyCorePlugin import groovy.transform.CompileStatic import org.asciidoctor.gradle.jvm.AsciidoctorJBasePlugin -import org.asciidoctor.gradle.jvm.AsciidoctorJExtension import org.gradle.api.Action import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.artifacts.Configuration -import org.ysb33r.grolifant.api.v4.TaskProvider - -import static org.ysb33r.grolifant.api.v4.TaskProvider.registerTask +import org.gradle.api.tasks.bundling.Jar +import org.ysb33r.gradle.jruby.api.plugins.JRubyResolverPlugin +import org.ysb33r.grolifant.api.core.ProjectOperations /** Plugin that simplifies that management of external GEMs. * @@ -44,19 +42,25 @@ import static org.ysb33r.grolifant.api.v4.TaskProvider.registerTask class AsciidoctorGemSupportPlugin implements Plugin { public static final String GEM_CONFIGURATION = 'asciidoctorGems' - public static final String GEMPREP_TASK = 'asciidoctorGemsPrepare' + public static final String GEMPREP_TASK = "${GEM_CONFIGURATION}Prepare" + public static final String JAR_TASK = "${GEM_CONFIGURATION}Jar" @Override void apply(Project project) { - project.apply plugin: AsciidoctorJBasePlugin - project.apply plugin: JRubyCorePlugin + project.pluginManager.tap { + apply AsciidoctorJBasePlugin + apply JRubyResolverPlugin + } + final po = ProjectOperations.find(project) Configuration gemConfig = project.configurations.maybeCreate(GEM_CONFIGURATION) + gemConfig.canBeResolved = true + gemConfig.canBeConsumed = false Action gemPrepDefaults = new Action() { @Override void execute(AsciidoctorGemPrepare asciidoctorGemPrepare) { - asciidoctorGemPrepare.with { - dependencies gemConfig + asciidoctorGemPrepare.tap { + gemConfiguration = gemConfig group = 'dependencies' description = 'Prepare additional GEMs for AsciidoctorJ' outputDir = "${project.buildDir}/.asciidoctorGems" @@ -64,12 +68,23 @@ class AsciidoctorGemSupportPlugin implements Plugin { } } - TaskProvider prepTask = registerTask( - project, - GEMPREP_TASK, - AsciidoctorGemPrepare, - gemPrepDefaults + final prepTask = project.tasks.register( + GEMPREP_TASK, + AsciidoctorGemPrepare, + gemPrepDefaults ) - project.extensions.getByType(AsciidoctorJExtension).gemPaths { prepTask.get().outputDir } + + project.tasks.register(JAR_TASK, Jar) { jar -> + jar.tap { + from(prepTask.map { it.outputDir }) + archiveFileName.set("${GEM_CONFIGURATION}.jar".toString()) + destinationDirectory.set( + project.objects + .directoryProperty() + .fileProvider(po.buildDirDescendant('.asciidoctorGemsJars')) + ) + dependsOn(prepTask) + } + } } } diff --git a/gems/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.gems.properties b/gems/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.gems.properties deleted file mode 100644 index 104a2e15a..000000000 --- a/gems/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.gems.properties +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright 2013-2023 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -implementation-class=org.asciidoctor.gradle.jvm.gems.AsciidoctorGemSupportPlugin diff --git a/gems/src/test/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemSupportPluginSpec.groovy b/gems/src/test/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemSupportPluginSpec.groovy index d2fa75b6e..664d7db6b 100644 --- a/gems/src/test/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemSupportPluginSpec.groovy +++ b/gems/src/test/groovy/org/asciidoctor/gradle/jvm/gems/AsciidoctorGemSupportPluginSpec.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,6 @@ class AsciidoctorGemSupportPluginSpec extends Specification { then: project.configurations.getByName(GEM_CONFIGURATION) - project.tasks.getByName(GEMPREP_TASK).outputDir == project.file( "${project.buildDir}/.asciidoctorGems" ) - !project.tasks.getByName(GEMPREP_TASK).dependencies.empty + project.tasks.getByName(GEMPREP_TASK).outputDir.get() == project.file( "${project.buildDir}/.asciidoctorGems" ) } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 369371951..b6200eee1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,10 +14,10 @@ jsoupVersion = 1.13.1 spockVersion = 2.3-groovy-3.0 grolifantVersion = 2.2.1 jacocoVersion = 0.8.6 -jrubyGradleVersion = 2.0.2 codenarcVersion = 3.3.0 nodejsGradleVersion = 2.2.0 -pluginJrubySimpleVersion = 1.0.0-alpha.1 +pluginJrubySimpleVersion = 1.0.0-alpha.2-SNAPSHOT +pluginPublishPlugin = 1.2.1 org.gradle.daemon = true org.gradle.parallel = true diff --git a/gradle/gradle-plugin-dependencies.gradle b/gradle/gradle-plugin-dependencies.gradle index 61212a03d..879304514 100644 --- a/gradle/gradle-plugin-dependencies.gradle +++ b/gradle/gradle-plugin-dependencies.gradle @@ -7,7 +7,7 @@ dependencies { exclude group: 'org.hamcrest', module: 'hamcrest-core' } - if(configurations.findByName('intTestCompile')) { + if (configurations.findByName('intTestCompile')) { intTestImplementation project(':testfixtures-jvm') intTestImplementation("org.spockframework:spock-core:$spockVersion") { exclude group: 'org.codehaus.groovy' @@ -15,3 +15,4 @@ dependencies { } } } + diff --git a/gradle/integration-tests.gradle b/gradle/integration-tests.gradle index b6fe11c74..16f30260f 100644 --- a/gradle/integration-tests.gradle +++ b/gradle/integration-tests.gradle @@ -1,14 +1,17 @@ + sourceSets { intTest } configurations { - intTestOfflineRepo + intTestOfflineRepo { + canBeConsumed = false + canBeResolved = true + } } - // For a single test, you can run "gradle intTest --tests " -task intTest(type: Test) { +tasks.register('intTest', Test) { description = "Runs the plugin's integration tests" group = "verification" @@ -20,17 +23,18 @@ task intTest(type: Test) { classpath = sourceSets.intTest.runtimeClasspath dependsOn ':testfixtures-offline-repo:buildOfflineRepositories' - systemProperties OFFLINE_REPO: offlineRepoRoot.absolutePath + systemProperties OFFLINE_REPO: offlineRepoRoot.absolutePath, + TEST_PROJECTS_DIR: file('src/intTest/projects') } -check { - dependsOn intTest +tasks.named('check') { + dependsOn 'intTest' } pluginManager.withPlugin('jacoco') { jacocoTestReport { - executionData intTest - mustRunAfter intTest + executionData tasks.intTest + mustRunAfter 'intTest' } } diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle index 8424491ea..e834fee2a 100644 --- a/gradle/publishing.gradle +++ b/gradle/publishing.gradle @@ -14,8 +14,8 @@ * limitations under the License. */ -apply plugin: 'java-gradle-plugin' -apply plugin: 'com.gradle.plugin-publish' +//apply plugin: 'java-gradle-plugin' +//apply plugin: 'com.gradle.plugin-publish' ext { pluginIdPrefix = 'org.asciidoctor' diff --git a/js/build.gradle b/js/build.gradle index fdd118c23..6a6b440a8 100644 --- a/js/build.gradle +++ b/js/build.gradle @@ -79,6 +79,7 @@ tasks.withType(Test).configureEach { systemProperties 'org.ysb33r.gradle.nodejs.uri': file(nodejsCacheDir).absoluteFile.toURI() } +// TODO: Use configurePlugin instead gradlePlugin { plugins { basePlugin { diff --git a/js/src/intTest/groovy/org/asciidoctor/gradle/js/nodejs/internal/FunctionalSpecification.groovy b/js/src/intTest/groovy/org/asciidoctor/gradle/js/nodejs/internal/FunctionalSpecification.groovy index 4b4777744..6758c0c7f 100644 --- a/js/src/intTest/groovy/org/asciidoctor/gradle/js/nodejs/internal/FunctionalSpecification.groovy +++ b/js/src/intTest/groovy/org/asciidoctor/gradle/js/nodejs/internal/FunctionalSpecification.groovy @@ -15,21 +15,16 @@ */ package org.asciidoctor.gradle.js.nodejs.internal -import groovy.transform.CompileStatic import org.apache.commons.io.FileUtils import org.asciidoctor.gradle.testfixtures.DslType import org.asciidoctor.gradle.testfixtures.FunctionalTestFixture -import org.asciidoctor.gradle.testfixtures.FunctionalTestSetup -import org.gradle.testkit.runner.GradleRunner import spock.lang.Specification import spock.lang.TempDir import static org.asciidoctor.gradle.testfixtures.DslType.GROOVY_DSL import static org.asciidoctor.gradle.testfixtures.DslType.KOTLIN_DSL -import static org.asciidoctor.gradle.testfixtures.FunctionalTestSetup.getOfflineRepositoriesGroovyDsl -import static org.asciidoctor.gradle.testfixtures.FunctionalTestSetup.getOfflineRepositoriesKotlinDsl -class FunctionalSpecification extends Specification implements FunctionalTestFixture{ +class FunctionalSpecification extends Specification implements FunctionalTestFixture { public static final String TEST_PROJECTS_DIR = System.getProperty( 'TEST_PROJECTS_DIR', @@ -39,7 +34,6 @@ class FunctionalSpecification extends Specification implements FunctionalTestFix @TempDir File testProjectDir - void setup() { initializeProjectLayout() } diff --git a/jvm-epub/build.gradle b/jvm-epub/build.gradle index 572c788ec..1225dbb18 100644 --- a/jvm-epub/build.gradle +++ b/jvm-epub/build.gradle @@ -1,10 +1,22 @@ +agProject { + withOfflineTestConfigurations() + + configurePlugin( + 'org.asciidoctor.jvm.epub', + 'AsciidoctorJ EPUB Plugin', + 'Asciidoctor task for creating EPUB3 documents', + 'org.asciidoctor.gradle.jvm.epub.AsciidoctorJEpubPlugin', + ['asciidoctorj', 'epub', 'epub3'] + ) +} + generateModuleVersions { basename = 'asciidoctorj-epub' propertyNames ~/^kindlegen$/ } dependencies { - compile project(':asciidoctor-gradle-jvm') + implementation project(':asciidoctor-gradle-jvm') intTestOfflineRepo "org.asciidoctor:asciidoctorj:${compileOnlyAsciidoctorJVersion}" intTestOfflineRepo "org.asciidoctor:asciidoctorj-epub3:${downloadOnlyEpubVersion}" @@ -13,14 +25,3 @@ dependencies { intTest { systemProperties TEST_PROJECTS_DIR: file('src/intTest/projects') } - -configurePlugin 'org.asciidoctor.jvm.epub', - 'AsciidoctorJ EPUB Plugin', - 'Asciidoctor task for creating EPUB3 documents', - ['asciidoctorj', 'epub', 'epub3'] - -gradleTest { -// TODO: Re-enable this test -// enabled = false -// println "************ :asciidoctor-gradle-jvm-epub:gradleTest is disabled due to potential bug in asciidoctorj *********" -} \ No newline at end of file diff --git a/jvm-epub/src/gradleTest/epub3/build.gradle b/jvm-epub/src/gradleTest/epub3/build.gradle index 108b2136c..74c8e40b5 100644 --- a/jvm-epub/src/gradleTest/epub3/build.gradle +++ b/jvm-epub/src/gradleTest/epub3/build.gradle @@ -12,7 +12,7 @@ asciidoctorEpub { include 'epub3.adoc' } - inProcess IN_PROCESS + executionMode = IN_PROCESS } task runGradleTest { diff --git a/jvm-epub/src/gradleTest/issue-409-link-regression/src/docs/asciidoc/chapter1.adoc b/jvm-epub/src/gradleTest/issue-409-link-regression/src/docs/asciidoc/chapter1.adoc deleted file mode 100644 index 202e1d8f7..000000000 --- a/jvm-epub/src/gradleTest/issue-409-link-regression/src/docs/asciidoc/chapter1.adoc +++ /dev/null @@ -1,6 +0,0 @@ -[[chapter1]] -= Chapter 1 - -Some text. - -<> diff --git a/jvm-epub/src/gradleTest/issue-409-link-regression/src/docs/asciidoc/chapter2.adoc b/jvm-epub/src/gradleTest/issue-409-link-regression/src/docs/asciidoc/chapter2.adoc deleted file mode 100644 index 59b93f91c..000000000 --- a/jvm-epub/src/gradleTest/issue-409-link-regression/src/docs/asciidoc/chapter2.adoc +++ /dev/null @@ -1,9 +0,0 @@ -[[chapter2]] -= Chapter 2 - -Some text. - -[[subtitle]] -== Subtitle - -More text. diff --git a/jvm-epub/src/gradleTest/issue-409-link-regression/src/docs/asciidoc/epub3.adoc b/jvm-epub/src/gradleTest/issue-409-link-regression/src/docs/asciidoc/epub3.adoc deleted file mode 100644 index 7172f3e25..000000000 --- a/jvm-epub/src/gradleTest/issue-409-link-regression/src/docs/asciidoc/epub3.adoc +++ /dev/null @@ -1,6 +0,0 @@ -// Taken from https://github.com/slonopotamus/asciidoc-epub3-link-regression/tree/master/src/docs/asciidoc -= Project Euler -:doctype: book - -include::chapter1.adoc[leveloffset=+1] -include::chapter2.adoc[leveloffset=+1] diff --git a/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorEpubTaskCachingFunctionalSpec.groovy b/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorEpubTaskCachingFunctionalSpec.groovy index a299c5119..3d69d32e1 100644 --- a/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorEpubTaskCachingFunctionalSpec.groovy +++ b/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorEpubTaskCachingFunctionalSpec.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +16,13 @@ package org.asciidoctor.gradle.jvm.epub import org.asciidoctor.gradle.jvm.epub.internal.FunctionalSpecification -import org.asciidoctor.gradle.testfixtures.CachingTest +import org.asciidoctor.gradle.testfixtures.BuildScanFixture +import org.asciidoctor.gradle.testfixtures.CachingTestFixture import static org.asciidoctor.gradle.testfixtures.JRubyTestVersions.AJ20_SAFE_MAXIMUM -class AsciidoctorEpubTaskCachingFunctionalSpec extends FunctionalSpecification implements CachingTest { +class AsciidoctorEpubTaskCachingFunctionalSpec extends FunctionalSpecification + implements CachingTestFixture, BuildScanFixture { private static final String DEFAULT_TASK = 'asciidoctorEpub' private static final String DEFAULT_OUTPUT_FILE = 'build/docs/asciidocEpub/epub3.epub' private static final String JRUBY_TEST_VERSION = AJ20_SAFE_MAXIMUM @@ -59,17 +61,11 @@ class AsciidoctorEpubTaskCachingFunctionalSpec extends FunctionalSpecification i } File getBuildFile(String extraContent) { - File buildFile = testProjectDir.newFile('build.gradle') - buildFile << """ - plugins { - id 'org.asciidoctor.jvm.epub' + writeGroovyBuildFile('org.asciidoctor.jvm.epub', extraContent).withWriterAppend { w -> + if (performBuildScan) { + w.println buildScanConfiguration } - - ${scan ? buildScanConfiguration : ''} - ${offlineRepositories} - - ${extraContent} - """ + } buildFile } diff --git a/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorEpubTaskFunctionalSpec.groovy b/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorEpubTaskFunctionalSpec.groovy index 31c7d98a4..87002866a 100644 --- a/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorEpubTaskFunctionalSpec.groovy +++ b/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorEpubTaskFunctionalSpec.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ class AsciidoctorEpubTaskFunctionalSpec extends FunctionalSpecification { then: verifyAll { - new File(testProjectDir.root, 'build/docs/asciidocEpub/epub3.epub').exists() + new File(projectDir, 'build/docs/asciidocEpub/epub3.epub').exists() !result.output.contains('include file not found:') } } @@ -57,7 +57,7 @@ class AsciidoctorEpubTaskFunctionalSpec extends FunctionalSpecification { then: verifyAll { - new File(testProjectDir.root, 'build/docs/asciidocEpub/epub3.mobi').exists() + new File(projectDir, 'build/docs/asciidocEpub/epub3.mobi').exists() !result.output.contains('include file not found:') } } @@ -86,7 +86,7 @@ class AsciidoctorEpubTaskFunctionalSpec extends FunctionalSpecification { then: verifyAll { - new File(testProjectDir.root, 'build/docs/asciidocEpub/epub3.epub').exists() + new File(projectDir, 'build/docs/asciidocEpub/epub3.epub').exists() !result.output.contains('include file not found:') } @@ -132,17 +132,6 @@ class AsciidoctorEpubTaskFunctionalSpec extends FunctionalSpecification { } File getBuildFile(String extraContent) { - File buildFile = testProjectDir.newFile('build.gradle') - buildFile << """ -plugins { - id 'org.asciidoctor.jvm.epub' -} - -${offlineRepositories} - -${extraContent} -""" - buildFile + writeGroovyBuildFile('org.asciidoctor.jvm.epub', extraContent) } - } \ No newline at end of file diff --git a/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/LinkedChaptersFunctionalSpec.groovy b/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/LinkedChaptersFunctionalSpec.groovy index c117b92d9..d49dc44bb 100644 --- a/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/LinkedChaptersFunctionalSpec.groovy +++ b/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/LinkedChaptersFunctionalSpec.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,24 +50,14 @@ class LinkedChaptersFunctionalSpec extends FunctionalSpecification { then: verifyAll { - new File(testProjectDir.root, 'build/docs/asciidocEpub/epub3.epub').exists() + new File(projectDir, 'build/docs/asciidocEpub/epub3.epub').exists() !result.output.contains('invalid reference to anchor') !result.output.contains('invalid reference to unknown anchor') } } File getBuildFile(String extraContent) { - File buildFile = testProjectDir.newFile('build.gradle') - buildFile << """ -plugins { - id 'org.asciidoctor.jvm.epub' -} - -${offlineRepositories} - -${extraContent} -""" - buildFile + writeGroovyBuildFile('org.asciidoctor.jvm.epub', extraContent) } } \ No newline at end of file diff --git a/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/internal/FunctionalSpecification.groovy b/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/internal/FunctionalSpecification.groovy index 5f5105dac..82e761855 100644 --- a/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/internal/FunctionalSpecification.groovy +++ b/jvm-epub/src/intTest/groovy/org/asciidoctor/gradle/jvm/epub/internal/FunctionalSpecification.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,15 +16,15 @@ package org.asciidoctor.gradle.jvm.epub.internal import org.apache.commons.io.FileUtils +import org.asciidoctor.gradle.testfixtures.FunctionalTestFixture import org.asciidoctor.gradle.testfixtures.FunctionalTestSetup import org.gradle.testkit.runner.GradleRunner import org.gradle.util.VersionNumber -import org.junit.Rule -import org.junit.rules.TemporaryFolder import org.ysb33r.grolifant.api.core.OperatingSystem import spock.lang.Specification +import spock.lang.TempDir -class FunctionalSpecification extends Specification { +class FunctionalSpecification extends Specification implements FunctionalTestFixture { @SuppressWarnings('LineLength') static @@ -34,24 +34,25 @@ class FunctionalSpecification extends Specification { static final OperatingSystem OS = OperatingSystem.current() - @Rule - TemporaryFolder testProjectDir + @TempDir + File testProjectDir - @Rule - TemporaryFolder alternateProjectDir + void setup() { + projectDir.mkdirs() + } GradleRunner getGradleRunner(List taskNames = ['asciidoctor']) { GradleRunner.create() - .withProjectDir(testProjectDir.root) - .withArguments(taskNames) - .withPluginClasspath() - .forwardOutput() - .withDebug(true) + .withProjectDir(projectDir) + .withArguments(taskNames) + .withPluginClasspath() + .forwardOutput() + .withDebug(true) } @SuppressWarnings(['BuilderMethodWithSideEffects']) void createTestProject(String docGroup = 'epub3') { - FileUtils.copyDirectory(new File(TEST_PROJECTS_DIR, docGroup), testProjectDir.root) + FileUtils.copyDirectory(new File(TEST_PROJECTS_DIR, docGroup), projectDir) } @SuppressWarnings('LineLength') @@ -68,8 +69,8 @@ class FunctionalSpecification extends Specification { } } - static boolean isWindowsOr64bitOnlyMacOS() { - VersionNumber version = VersionNumber.parse(OS.version) - OS.windows || (OS.macOsX && version.major >= 10 && version.minor >= 15) - } +// static boolean isWindowsOr64bitOnlyMacOS() { +// VersionNumber version = VersionNumber.parse(OS.version) +// OS.windows || (OS.macOsX && version.major >= 10 && version.minor >= 15) +// } } \ No newline at end of file diff --git a/jvm-epub/src/main/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorEpubTask.groovy b/jvm-epub/src/main/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorEpubTask.groovy index 17b7be0e0..604ee2dd4 100644 --- a/jvm-epub/src/main/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorEpubTask.groovy +++ b/jvm-epub/src/main/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorEpubTask.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,20 +19,19 @@ import groovy.transform.CompileDynamic import groovy.transform.CompileStatic import org.asciidoctor.gradle.base.AsciidoctorExecutionException import org.asciidoctor.gradle.base.Transform -import org.asciidoctor.gradle.base.process.ProcessMode import org.asciidoctor.gradle.internal.ExecutorConfiguration import org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask import org.gradle.api.tasks.CacheableTask import org.gradle.api.tasks.Input import org.gradle.api.tasks.util.PatternSet -import org.gradle.util.GradleVersion import org.gradle.workers.WorkerExecutor import org.ysb33r.grolifant.api.core.Version import javax.inject.Inject import java.util.regex.Matcher -/** Builds EPUB documents using the epub3 backend. +/** + * Builds EPUB documents using the epub3 backend. * * @author Schalk W. Cronjé * @author Gary Hale @@ -44,22 +43,21 @@ import java.util.regex.Matcher class AsciidoctorEpubTask extends AbstractAsciidoctorTask { public static final String EPUB3 = 'epub3' - private static final String BACKEND = 'epub3' private static final String EBOOK_FORMAT_ATTR = 'ebook-format' - private final Set ebookFormats = [] @Inject AsciidoctorEpubTask(WorkerExecutor we) { super(we) - configuredOutputOptions.backends = [BACKEND] + outputOptions.backends = [BACKEND] copyNoResources() - inProcess = JAVA_EXEC +// inProcess = JAVA_EXEC } - /** The eBook formats that needs to be generated. + /** + * The eBook formats that needs to be generated. * * @return eBook formats that needs to be generated. */ @@ -68,7 +66,8 @@ class AsciidoctorEpubTask extends AbstractAsciidoctorTask { this.ebookFormats } - /** Resets the list of formats that needs to be generated + /** + * Resets the list of formats that needs to be generated * * Any format supported by asciidoctorj-epub can be listed here. * This method will overide any {@code ebook-format} that is set via {@link #attributes}. @@ -82,7 +81,8 @@ class AsciidoctorEpubTask extends AbstractAsciidoctorTask { this.ebookFormats.addAll(Transform.toSet(formats) { String it -> it.toLowerCase() } as Set) } - /** Adds aditional eBook formats + /** + * Adds aditional eBook formats * * @param formats List of formats. The plugin does not verify whether the eBook format * is valid. @@ -91,29 +91,31 @@ class AsciidoctorEpubTask extends AbstractAsciidoctorTask { this.ebookFormats.addAll(formats*.toLowerCase() as List) } - /** The default pattern set for secondary sources. + /** + * The default pattern set for secondary sources. * * @return {@link #getDefaultSourceDocumentPattern} + `*docinfo*`. */ @Override - protected PatternSet getDefaultSecondarySourceDocumentPattern() { + PatternSet getDefaultSecondarySourceDocumentPattern() { defaultSourceDocumentPattern } - /** Returns all of the executor configurations for this task + /** + * Returns all of the executor configurations for this task * * @return Executor configurations */ @Override protected Map getExecutorConfigurations( - File workingSourceDir, - Set sourceFiles, - Optional lang + File workingSourceDir, + Set sourceFiles, + Optional lang ) { Map executorConfigurations = super.getExecutorConfigurations( - workingSourceDir, - sourceFiles, - lang + workingSourceDir, + sourceFiles, + lang ) final Closure backendName = { String fmt -> @@ -147,23 +149,23 @@ class AsciidoctorEpubTask extends AbstractAsciidoctorTask { } } - /** Selects a final process mode. - * - * Selects JAVA_EXEC on any Gradle version that has classpath ;eakage issues. - * - * @return Process mode to use for execution. - */ - @Override - protected ProcessMode getFinalProcessMode() { - if (GradleVersion.current() <= LAST_GRADLE_WITH_CLASSPATH_LEAKAGE) { - if (inProcess != JAVA_EXEC) { - logger.warn 'EPUB processing on this version of Gradle will fail due to classpath issues. ' + - 'Switching to JAVA_EXEC instead.' - } - return JAVA_EXEC - } - super.finalProcessMode - } +// /** Selects a final process mode. +// * +// * Selects JAVA_EXEC on any Gradle version that has classpath ;eakage issues. +// * +// * @return Process mode to use for execution. +// */ +// @Override +// protected ProcessMode getFinalProcessMode() { +// if (GradleVersion.current() <= LAST_GRADLE_WITH_CLASSPATH_LEAKAGE) { +// if (inProcess != JAVA_EXEC) { +// logger.warn 'EPUB processing on this version of Gradle will fail due to classpath issues. ' + +// 'Switching to JAVA_EXEC instead.' +// } +// return JAVA_EXEC +// } +// super.finalProcessMode +// } @CompileDynamic private Version getVersion(Matcher matcher) { diff --git a/jvm-epub/src/main/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorJEpubPlugin.groovy b/jvm-epub/src/main/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorJEpubPlugin.groovy index b47a8e7a5..34b2b50a5 100644 --- a/jvm-epub/src/main/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorJEpubPlugin.groovy +++ b/jvm-epub/src/main/groovy/org/asciidoctor/gradle/jvm/epub/AsciidoctorJEpubPlugin.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,11 +21,11 @@ import org.asciidoctor.gradle.jvm.AsciidoctorJExtension import org.gradle.api.Action import org.gradle.api.Plugin import org.gradle.api.Project -import org.ysb33r.grolifant.api.v4.TaskProvider import static org.asciidoctor.gradle.base.AsciidoctorUtils.setConvention -/** Provides additional conventions for building EPUBs. +/** + * Provides additional conventions for building EPUBs. * *

    *
  • Creates a task called {@code asciidoctorEpub}. @@ -41,23 +41,21 @@ import static org.asciidoctor.gradle.base.AsciidoctorUtils.setConvention class AsciidoctorJEpubPlugin implements Plugin { void apply(Project project) { - project.with { - apply plugin: AsciidoctorJBasePlugin - extensions.getByType(AsciidoctorJExtension).modules.epub.use() + project.pluginManager.apply(AsciidoctorJBasePlugin) + project.extensions.getByType(AsciidoctorJExtension).modules.epub.use() - Action epubDefaults = new Action() { - @Override - void execute(AsciidoctorEpubTask task) { - task.group = AsciidoctorJBasePlugin.TASK_GROUP - task.description = 'Convert AsciiDoc files to EPUB3 formats' - setConvention(project, task.sourceDirProperty, + Action epubDefaults = new Action() { + @Override + void execute(AsciidoctorEpubTask task) { + task.group = AsciidoctorJBasePlugin.TASK_GROUP + task.description = 'Convert AsciiDoc files to EPUB3 formats' + setConvention(project, task.sourceDirProperty, project.layout.projectDirectory.dir('src/docs/asciidoc')) - setConvention(task.outputDirProperty, + setConvention(task.outputDirProperty, task.project.layout.buildDirectory.dir('docs/asciidocEpub')) - } } - - TaskProvider.registerTask(project, 'asciidoctorEpub', AsciidoctorEpubTask, epubDefaults) } + + project.tasks.register('asciidoctorEpub', AsciidoctorEpubTask, epubDefaults) } } diff --git a/jvm-epub/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.epub.properties b/jvm-epub/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.epub.properties deleted file mode 100644 index 278786f73..000000000 --- a/jvm-epub/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.epub.properties +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright 2013-2023 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -implementation-class=org.asciidoctor.gradle.jvm.epub.AsciidoctorJEpubPlugin \ No newline at end of file diff --git a/jvm-leanpub/build.gradle b/jvm-leanpub/build.gradle index 7b723a1f9..e5da5f53d 100644 --- a/jvm-leanpub/build.gradle +++ b/jvm-leanpub/build.gradle @@ -1,23 +1,24 @@ -dependencies { - compile project(':asciidoctor-gradle-jvm') +agProject { + withOfflineTestConfigurations() - intTestOfflineRepo "org.asciidoctor:asciidoctorj:${compileOnlyAsciidoctorJVersion}" - intTestOfflineRepo "org.asciidoctor:asciidoctor-leanpub-markdown:${downloadOnlyLeanpubVersion}" -} + configurePlugin 'org.asciidoctor.jvm.leanpub', + 'AsciidoctorJ Leanpub Plugin', + 'Asciidoctor task for creating content suitable for Leanpub', + 'org.asciidoctor.gradle.jvm.leanpub.AsciidoctorJLeanpubPlugin', + ['asciidoctorj', 'leanpub', 'markdown', 'markuva'] + + configurePlugin 'org.asciidoctor.jvm.leanpub.dropbox-copy', + 'Dropbox support for AsciidoctorJ Leanpub Plugin', + 'Provides local Dropbox support for Asciidoctor Leanpub plugin', + 'org.asciidoctor.gradle.jvm.leanpub.AsciidoctorJLeanpubDropboxCopyPlugin', + ['asciidoctorj', 'leanpub', 'markdown', 'markuva', 'dropbox'] -intTest { - systemProperties TEST_PROJECTS_DIR: file('src/intTest/projects') } -configurePlugin 'org.asciidoctor.jvm.leanpub', - 'AsciidoctorJ Leanpub Plugin', - 'Asciidoctor task for creating content suitable for Leanpub', - ['asciidoctorj', 'leanpub', 'markdown', 'markuva'] +dependencies { + implementation project(':asciidoctor-gradle-jvm') -configurePlugin 'org.asciidoctor.jvm.leanpub.dropbox-copy', - 'Dropbox support for AsciidoctorJ Leanpub Plugin', - 'Provides local Dropbox support for Asciidoctor Leanpub plugin', - ['asciidoctorj', 'leanpub', 'markdown', 'markuva', 'dropbox'] + intTestOfflineRepo "org.asciidoctor:asciidoctorj:${compileOnlyAsciidoctorJVersion}" + intTestOfflineRepo "org.asciidoctor:asciidoctor-leanpub-markdown:${downloadOnlyLeanpubVersion}" +} -// TODO: Re-enable this after leanpub artifact appears on MavenCentral -gradleTest.enabled = false \ No newline at end of file diff --git a/jvm-leanpub/src/intTest/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorLeanpubTaskFunctionalSpec.groovy b/jvm-leanpub/src/intTest/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorLeanpubTaskFunctionalSpec.groovy index 32c8b579c..77e393450 100644 --- a/jvm-leanpub/src/intTest/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorLeanpubTaskFunctionalSpec.groovy +++ b/jvm-leanpub/src/intTest/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorLeanpubTaskFunctionalSpec.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,49 +36,22 @@ class AsciidoctorLeanpubTaskFunctionalSpec extends FunctionalSpecification { then: verifyAll { - new File(testProjectDir.root, 'build/docs/asciidocLeanpub/manuscript/Book.txt').exists() + new File(projectDir, 'build/docs/asciidocLeanpub/manuscript/Book.txt').exists() } where: processMode << ProcessGenerator.get() } -// File getSingleFormatBuildFile(final String format) { -// getBuildFile( """ -// -// asciidoctorEpub { -// sourceDir 'src/docs/asciidoc' -// ebookFormats ${format} -// -// kindlegen { -// agreeToTermsOfUse = true -// } -// -// asciidoctorj { -// jrubyVersion = '${JRUBY_TEST_VERSION}' -// } -// -// sources { -// include 'epub3.adoc' -// } -// } -// """) -// } - File getBuildFile(String extraContent, boolean withDropbox = false) { - File buildFile = testProjectDir.newFile('build.gradle') - buildFile << """ -plugins { - id 'org.asciidoctor.jvm.leanpub' - - ${withDropbox ? "id 'org.asciidoctor.jvm.leanpub.dropbox-copy'" : ''} -} - -${offlineRepositories} - -${extraContent} -""" - buildFile + if (withDropbox) { + writeGroovyBuildFile( + ['org.asciidoctor.jvm.leanpub', 'org.asciidoctor.jvm.leanpub.dropbox-copy'], + extraContent + ) + } else { + getJvmConvertGroovyBuildFile(extraContent) + } } } \ No newline at end of file diff --git a/jvm-leanpub/src/intTest/groovy/org/asciidoctor/gradle/jvm/leanpub/internal/FunctionalSpecification.groovy b/jvm-leanpub/src/intTest/groovy/org/asciidoctor/gradle/jvm/leanpub/internal/FunctionalSpecification.groovy index f13d3aacf..68b0b7424 100644 --- a/jvm-leanpub/src/intTest/groovy/org/asciidoctor/gradle/jvm/leanpub/internal/FunctionalSpecification.groovy +++ b/jvm-leanpub/src/intTest/groovy/org/asciidoctor/gradle/jvm/leanpub/internal/FunctionalSpecification.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,72 +17,44 @@ package org.asciidoctor.gradle.jvm.leanpub.internal import groovy.transform.CompileStatic import org.apache.commons.io.FileUtils -import org.asciidoctor.gradle.testfixtures.DslType +import org.asciidoctor.gradle.testfixtures.FunctionalTestFixture import org.asciidoctor.gradle.testfixtures.FunctionalTestSetup import org.gradle.testkit.runner.GradleRunner -import org.junit.Rule -import org.junit.rules.TemporaryFolder -import org.ysb33r.grolifant.api.core.OperatingSystem import spock.lang.Specification +import spock.lang.TempDir import static org.asciidoctor.gradle.testfixtures.DslType.GROOVY_DSL -import static org.asciidoctor.gradle.testfixtures.DslType.KOTLIN_DSL -import static org.asciidoctor.gradle.testfixtures.FunctionalTestSetup.getOfflineRepositoriesGroovyDsl -import static org.asciidoctor.gradle.testfixtures.FunctionalTestSetup.getOfflineRepositoriesKotlinDsl -class FunctionalSpecification extends Specification { +class FunctionalSpecification extends Specification implements FunctionalTestFixture { public static final String TEST_PROJECTS_DIR = System.getProperty( - 'TEST_PROJECTS_DIR', - './src/intTest/projects' + 'TEST_PROJECTS_DIR', + './src/intTest/projects' ) public static final String TEST_REPO_DIR = FunctionalTestSetup.offlineRepo.absolutePath -// public static final OperatingSystem OS = OperatingSystem.current() - @Rule - TemporaryFolder testProjectDir = new TemporaryFolder() + @TempDir + File testProjectDir + + void setup() { + projectDir.mkdirs() + } @CompileStatic GradleRunner getGradleRunner(List taskNames = ['asciidoctor']) { - FunctionalTestSetup.getGradleRunner(GROOVY_DSL, testProjectDir.root, taskNames) + FunctionalTestSetup.getGradleRunner(GROOVY_DSL, projectDir, taskNames) } @SuppressWarnings(['BuilderMethodWithSideEffects']) void createTestProject(String docGroup = 'leanpub') { - FileUtils.copyDirectory(new File(TEST_PROJECTS_DIR, docGroup), testProjectDir.root) + FileUtils.copyDirectory(new File(TEST_PROJECTS_DIR, docGroup), projectDir) } - @CompileStatic - String getOfflineRepositories(DslType dslType = GROOVY_DSL) { - dslType == GROOVY_DSL ? getOfflineRepositoriesGroovyDsl(new File(TEST_REPO_DIR)) : - getOfflineRepositoriesKotlinDsl(new File(TEST_REPO_DIR)) + File getJvmConvertGroovyBuildFile(String extraContent) { + writeGroovyBuildFile('org.asciidoctor.jvm.leanpub', extraContent) } - File getJvmConvertGroovyBuildFile(String extraContent, String plugin = 'org.asciidoctor.jvm.leanpub') { - File buildFile = testProjectDir.newFile('build.gradle') - buildFile << """ - plugins { - id '${plugin}' - } - - ${offlineRepositories} - - ${extraContent} - """ - buildFile - } - - File getJvmConvertKotlinBuildFile(String extraContent, String plugin = 'org.asciidoctor.jvm.leanpub') { - File buildFile = testProjectDir.newFile('build.gradle.kts') - buildFile << """ - plugins { - id ("${plugin}") - } - - ${getOfflineRepositories(KOTLIN_DSL)} - - ${extraContent} - """ - buildFile + File getJvmConvertKotlinBuildFile(String extraContent) { + writeKotlinBuildFile('org.asciidoctor.jvm.leanpub', extraContent) } } \ No newline at end of file diff --git a/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorJLeanpubDropboxCopyPlugin.groovy b/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorJLeanpubDropboxCopyPlugin.groovy index 9df4298e2..9be6aa331 100644 --- a/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorJLeanpubDropboxCopyPlugin.groovy +++ b/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorJLeanpubDropboxCopyPlugin.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +16,8 @@ package org.asciidoctor.gradle.jvm.leanpub import groovy.transform.CompileStatic -import org.gradle.api.Action import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.Task -import org.ysb33r.grolifant.api.v4.TaskProvider /** Adds a task to copy Leanpub task output to a Dropbox folder. * @@ -30,28 +27,20 @@ import org.ysb33r.grolifant.api.v4.TaskProvider */ @CompileStatic class AsciidoctorJLeanpubDropboxCopyPlugin implements Plugin { - public final static String LEANPUB_TASK_NAME = AsciidoctorJLeanpubPlugin.TASK_NAME public final static String COPY_TASK_NAME = "copy${LEANPUB_TASK_NAME.capitalize()}ToDropbox" @Override void apply(Project project) { - project.apply plugin: AsciidoctorJLeanpubPlugin - Action copyConfig = new Action() { - @Override - void execute(DropboxCopyTask dropboxCopyTask) { - dropboxCopyTask.with { - dependsOn(LEANPUB_TASK_NAME) - sourceDir = { - Task task = project.tasks.getByName(LEANPUB_TASK_NAME.toString()) - new File( - ((AsciidoctorLeanpubTask) task).outputDir, - 'manuscript' - ) - } - } - } + project.pluginManager.apply(AsciidoctorJLeanpubPlugin) + final leanpubTask = project.tasks.named(LEANPUB_TASK_NAME, AsciidoctorLeanpubTask) + final leanpubSourceDir = leanpubTask.map { + new File(it.outputDir, 'manuscript') + } + + project.tasks.register(COPY_TASK_NAME, DropboxCopyTask) { t -> + t.dependsOn(leanpubTask) + t.sourceDir = leanpubSourceDir } - TaskProvider.registerTask(project, COPY_TASK_NAME, DropboxCopyTask, copyConfig) } } diff --git a/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorJLeanpubPlugin.groovy b/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorJLeanpubPlugin.groovy index c08203805..a1bedad98 100644 --- a/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorJLeanpubPlugin.groovy +++ b/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorJLeanpubPlugin.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ import org.asciidoctor.gradle.jvm.AsciidoctorJExtension import org.gradle.api.Action import org.gradle.api.Plugin import org.gradle.api.Project -import org.ysb33r.grolifant.api.v4.TaskProvider import static org.asciidoctor.gradle.base.AsciidoctorUtils.setConvention @@ -43,23 +42,22 @@ class AsciidoctorJLeanpubPlugin implements Plugin { public final static String TASK_NAME = 'asciidoctorLeanpub' void apply(Project project) { - project.with { - apply plugin: AsciidoctorJBasePlugin + project.pluginManager.apply(AsciidoctorJBasePlugin) - Action leanpubDefaults = new Action() { - @Override - void execute(AsciidoctorLeanpubTask task) { - task.group = AsciidoctorJBasePlugin.TASK_GROUP - task.description = 'Convert AsciiDoc files to Leanpub-structured Markdown' - setConvention(task.project, task.sourceDirProperty, - project.layout.projectDirectory.dir('src/docs/asciidoc')) - setConvention(task.outputDirProperty, - task.project.layout.buildDirectory.dir('docs/asciidocLeanpub')) - } + Action leanpubDefaults = new Action() { + @Override + void execute(AsciidoctorLeanpubTask task) { + task.group = AsciidoctorJBasePlugin.TASK_GROUP + task.description = 'Convert AsciiDoc files to Leanpub-structured Markdown' + setConvention(task.project, task.sourceDirProperty, + project.layout.projectDirectory.dir('src/docs/asciidoc')) + setConvention(task.outputDirProperty, + task.project.layout.buildDirectory.dir('docs/asciidocLeanpub')) } - - TaskProvider.registerTask(project, TASK_NAME, AsciidoctorLeanpubTask, leanpubDefaults) - extensions.getByType(AsciidoctorJExtension).modules.leanpub.use() } + + project.tasks.register(TASK_NAME, AsciidoctorLeanpubTask, leanpubDefaults) + project.extensions.getByType(AsciidoctorJExtension).modules.leanpub.use() } } + diff --git a/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorLeanpubTask.groovy b/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorLeanpubTask.groovy index 7b7f7f820..5953cbd77 100644 --- a/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorLeanpubTask.groovy +++ b/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorLeanpubTask.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,12 +47,13 @@ class AsciidoctorLeanpubTask extends AbstractAsciidoctorTask { AsciidoctorLeanpubTask(WorkerExecutor we) { super(we) - configuredOutputOptions.backends = [BACKEND] + outputOptions.backends = [BACKEND] copyNoResources() asciidoctorj.options.put('doctype', 'book') } - /** The style used to format colists. + /** + * The style used to format colists. * * @return Colist style */ @@ -74,7 +75,8 @@ class AsciidoctorLeanpubTask extends AbstractAsciidoctorTask { this.colistPrefix = val } - /** A task may add some default attributes. + /** + * A task may add some default attributes. * * If the user specifies any of the attributes, then these attributes will not be utilised. * @@ -85,11 +87,13 @@ class AsciidoctorLeanpubTask extends AbstractAsciidoctorTask { * @return A collection of default attributes. */ @Override - protected Map getTaskSpecificDefaultAttributes(File workingSourceDir) { - Map attrs = super.getTaskSpecificDefaultAttributes(workingSourceDir) -// attrs.put 'front-cover-image', getFrontCoverImage() - attrs.put 'leanpub-colist-style', getColistStyle() - attrs.put 'leanpub-colist-prefix', getColistPrefix() + Map getTaskSpecificDefaultAttributes(File workingSourceDir) { + Map attrs = super.getTaskSpecificDefaultAttributes(workingSourceDir) + attrs.putAll([ + // 'front-cover-image': getFrontCoverImage(), + 'leanpub-colist-style' : colistStyle, + 'leanpub-colist-prefix': colistPrefix + ]) attrs } } diff --git a/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/DropboxCopyTask.groovy b/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/DropboxCopyTask.groovy index 688da5b3e..45cfdf365 100644 --- a/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/DropboxCopyTask.groovy +++ b/jvm-leanpub/src/main/groovy/org/asciidoctor/gradle/jvm/leanpub/DropboxCopyTask.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,9 +26,10 @@ import org.gradle.api.tasks.OutputDirectory import org.gradle.api.tasks.PathSensitive import org.gradle.api.tasks.PathSensitivity import org.gradle.api.tasks.TaskAction -import org.ysb33r.grolifant.api.v4.StringUtils +import org.ysb33r.grolifant.api.core.ProjectOperations -/** Copies Leanpub Asciidoctor task output to a Dropbox folder. +/** + * Copies Leanpub Asciidoctor task output to a Dropbox folder. * * @author Schalk W. Cronjé * @@ -37,6 +38,7 @@ import org.ysb33r.grolifant.api.v4.StringUtils @CompileStatic class DropboxCopyTask extends DefaultTask { + private final ProjectOperations projectOperations private Object dropboxRoot = "${System.getProperty('user.home')}/Dropbox" private Object bookPath private Object sourceDir @@ -50,13 +52,17 @@ class DropboxCopyTask extends DefaultTask { } } + DropboxCopyTask() { + this.projectOperations = ProjectOperations.find(project) + } + /** Root directory on filesystem where Dropbox synchronises all files. * * @return Path to Dropbox root on local filesystem. */ @Internal File getDropboxRoot() { - project.file(this.dropboxRoot) + projectOperations.fsOperations.file(this.dropboxRoot) } /** Override location of Dropbox root @@ -75,7 +81,7 @@ class DropboxCopyTask extends DefaultTask { */ @Input String getBookPath() { - this.bookPath != null ? StringUtils.stringize(this.bookPath) : null + this.bookPath != null ? projectOperations.stringTools.stringize(this.bookPath) : null } /** Sets the relative path of the Leanpub book in Dropbox. @@ -95,7 +101,7 @@ class DropboxCopyTask extends DefaultTask { @InputDirectory @PathSensitive(PathSensitivity.RELATIVE) File getSourceDir() { - project.file(this.sourceDir) + projectOperations.fsOperations.file(this.sourceDir) } void setSourceDir(Object s) { @@ -108,11 +114,11 @@ class DropboxCopyTask extends DefaultTask { */ @OutputDirectory File getDestinationDir() { - project.file("${getDropboxRoot()}/${getBookPath()}/manuscript") + projectOperations.fsOperations.file("${getDropboxRoot()}/${getBookPath()}/manuscript") } @TaskAction void copy() { - project.copy(copySpec) + projectOperations.copy(copySpec) } } diff --git a/jvm-leanpub/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.leanpub.dropbox-copy.properties b/jvm-leanpub/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.leanpub.dropbox-copy.properties deleted file mode 100644 index 7262db0de..000000000 --- a/jvm-leanpub/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.leanpub.dropbox-copy.properties +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright 2013-2023 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -implementation-class=org.asciidoctor.gradle.jvm.leanpub.AsciidoctorJLeanpubDropboxCopyPlugin \ No newline at end of file diff --git a/jvm-leanpub/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.leanpub.properties b/jvm-leanpub/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.leanpub.properties deleted file mode 100644 index aa3f3cf02..000000000 --- a/jvm-leanpub/src/main/resources/META-INF/gradle-plugins/org.asciidoctor.jvm.leanpub.properties +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright 2013-2023 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -implementation-class=org.asciidoctor.gradle.jvm.leanpub.AsciidoctorJLeanpubPlugin \ No newline at end of file diff --git a/jvm-leanpub/src/test/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorJLeanpubPluginSpec.groovy b/jvm-leanpub/src/test/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorJLeanpubPluginSpec.groovy index 709f0b18e..31c53e54b 100644 --- a/jvm-leanpub/src/test/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorJLeanpubPluginSpec.groovy +++ b/jvm-leanpub/src/test/groovy/org/asciidoctor/gradle/jvm/leanpub/AsciidoctorJLeanpubPluginSpec.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/jvm-leanpub/src/test/groovy/org/asciidoctor/gradle/jvm/leanpub/DropboxCopyTaskSpec.groovy b/jvm-leanpub/src/test/groovy/org/asciidoctor/gradle/jvm/leanpub/DropboxCopyTaskSpec.groovy index 730993ced..fba6170bd 100644 --- a/jvm-leanpub/src/test/groovy/org/asciidoctor/gradle/jvm/leanpub/DropboxCopyTaskSpec.groovy +++ b/jvm-leanpub/src/test/groovy/org/asciidoctor/gradle/jvm/leanpub/DropboxCopyTaskSpec.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/jvm-pdf/build.gradle b/jvm-pdf/build.gradle index 0daf68860..4cef309e6 100644 --- a/jvm-pdf/build.gradle +++ b/jvm-pdf/build.gradle @@ -1,32 +1,28 @@ - -agpProject { +agProject { withOfflineTestConfigurations() + + configurePlugin( + 'org.asciidoctor.jvm.pdf', + 'AsciidoctorJ PDF Conversion Plugin', + 'Simplifies conversion of asciidoc documents to PDF', + 'org.asciidoctor.gradle.jvm.pdf.AsciidoctorJPdfPlugin', + ['asciidoctorj', 'pdf'] + ) } + dependencies { implementation project(':asciidoctor-gradle-jvm') intTestOfflineRepo "org.asciidoctor:asciidoctorj:${compileOnlyAsciidoctorJVersion}" intTestOfflineRepo "org.asciidoctor:asciidoctorj-pdf:${downloadOnlyPdfVersion}" } -test { +tasks.named('test', Test) { systemProperties TEST_THEMES_DIR: file('src/test/resources/themes') } -intTest { - systemProperties TEST_PROJECTS_DIR: file('src/intTest/projects') +tasks.named('intTest', Test) { + maxParallelForks = 2 + forkEvery = 1 + maxHeapSize = '2048m' } -gradlePlugin { - plugins { - convertPlugin { - id = 'org.asciidoctor.jvm.pdf' - displayName = 'AsciidoctorJ PDF Conversion Plugin' - description = "Simplifies conversion of asciidoc documents to PDF${pluginExtraText}" -// tags.set(['asciidoctorj', 'pdf']) - implementationClass = 'org.asciidoctor.gradle.jvm.pdf.AsciidoctorJPdfPlugin' - } - } -} - - -//gradleTest.gradleArguments '-s' \ No newline at end of file diff --git a/jvm-pdf/src/gradleTest/complex-jvm-setup/build.gradle b/jvm-pdf/src/gradleTest/complex-jvm-setup/build.gradle index 0d61ef1f5..f09ad7438 100644 --- a/jvm-pdf/src/gradleTest/complex-jvm-setup/build.gradle +++ b/jvm-pdf/src/gradleTest/complex-jvm-setup/build.gradle @@ -15,7 +15,7 @@ asciidoctorj { } asciidoctorPdf { - inProcess OUT_OF_PROCESS + executionMode = OUT_OF_PROCESS logDocuments true sourceDir 'src/docs/asciidoc' diff --git a/jvm-pdf/src/gradleTest/complex-jvm-setup/build.gradle.kts b/jvm-pdf/src/gradleTest/complex-jvm-setup/build.gradle.kts index 4151fcfb1..d154c6d64 100644 --- a/jvm-pdf/src/gradleTest/complex-jvm-setup/build.gradle.kts +++ b/jvm-pdf/src/gradleTest/complex-jvm-setup/build.gradle.kts @@ -4,11 +4,10 @@ import org.asciidoctor.gradle.base.process.ProcessMode // tag::using-two-plugins-three-backends[] plugins { id("org.asciidoctor.jvm.pdf") -// id("com.gradle.build-scan") version "1.16" } repositories { - jcenter() + mavenCentral() } asciidoctorj { @@ -17,7 +16,7 @@ asciidoctorj { } tasks.named("asciidoctorPdf") { - inProcess = ProcessMode.OUT_OF_PROCESS + setExecutionMode("OUT_OF_PROCESS") logDocuments = true setSourceDir("src/docs/asciidoc") diff --git a/jvm-pdf/src/intTest/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfTaskCachingFunctionalSpec.groovy b/jvm-pdf/src/intTest/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfTaskCachingFunctionalSpec.groovy index 634450f78..7b4bf03f5 100644 --- a/jvm-pdf/src/intTest/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfTaskCachingFunctionalSpec.groovy +++ b/jvm-pdf/src/intTest/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfTaskCachingFunctionalSpec.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +16,16 @@ package org.asciidoctor.gradle.jvm.pdf import org.asciidoctor.gradle.jvm.pdf.internal.FunctionalSpecification -import org.asciidoctor.gradle.testfixtures.CachingTest +import org.asciidoctor.gradle.testfixtures.BuildScanFixture +import org.asciidoctor.gradle.testfixtures.CachingTestFixture import spock.lang.PendingFeature /** AsciidoctorPdfTaskCachingFunctionalSpec * * @author Gary Hale */ -class AsciidoctorPdfTaskCachingFunctionalSpec extends FunctionalSpecification implements CachingTest { +class AsciidoctorPdfTaskCachingFunctionalSpec extends FunctionalSpecification + implements CachingTestFixture, BuildScanFixture { static final String DEFAULT_TASK = 'asciidoctorPdf' static final String DEFAULT_OUTPUT_FILE = 'build/docs/asciidocPdf/sample.pdf' @@ -54,7 +56,8 @@ class AsciidoctorPdfTaskCachingFunctionalSpec extends FunctionalSpecification im outputFileInRelocatedDirectory.exists() } - @PendingFeature // TODO: Come back and fix caching + @PendingFeature + // TODO: Come back and fix caching void "PDF task is not cached when pdf-specific inputs change"() { given: getBuildFile(""" @@ -80,8 +83,8 @@ class AsciidoctorPdfTaskCachingFunctionalSpec extends FunctionalSpecification im when: file('src/docs/themes/pdf-theme').mkdirs() file('src/docs/themes/pdf-theme/basic-theme.yml').text = - file('src/docs/asciidoc/pdf-theme/basic-theme.yml').text - .replace('333333', '333334') + file('src/docs/asciidoc/pdf-theme/basic-theme.yml').text + .replace('333333', '333334') changeBuildConfigurationTo(""" pdfThemes { @@ -109,18 +112,9 @@ class AsciidoctorPdfTaskCachingFunctionalSpec extends FunctionalSpecification im } File getBuildFile(String extraContent) { - File buildFile = testProjectDir.newFile('build.gradle') - buildFile << """ - plugins { - id 'org.asciidoctor.jvm.pdf' - } - - ${ -> scan ? buildScanConfiguration : '' } - ${offlineRepositories} - - ${extraContent} - """ - buildFile + writeGroovyBuildFile('org.asciidoctor.jvm.pdf', extraContent).withWriterAppend { w -> + w.println(performBuildScan ? buildScanConfiguration : '') + } } String getDefaultTask() { diff --git a/jvm-pdf/src/intTest/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfTaskFunctionalSpec.groovy b/jvm-pdf/src/intTest/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfTaskFunctionalSpec.groovy index f9767a95c..1d7b29678 100644 --- a/jvm-pdf/src/intTest/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfTaskFunctionalSpec.groovy +++ b/jvm-pdf/src/intTest/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfTaskFunctionalSpec.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ asciidoctorPdf { then: verifyAll { - new File(testProjectDir.root, DEFAULT_OUTPUT_FILE).exists() + new File(projectDir, DEFAULT_OUTPUT_FILE).exists() } where: @@ -91,7 +91,7 @@ asciidoctorPdf { combination.compatible ? runner.build() : runner.buildAndFail() then: - combination.compatible && new File(testProjectDir.root, DEFAULT_OUTPUT_FILE).exists() || !combination.compatible + combination.compatible && new File(projectDir, DEFAULT_OUTPUT_FILE).exists() || !combination.compatible where: combination << PdfBackendJRubyAsciidoctorJCombinationGenerator.get() @@ -103,7 +103,7 @@ asciidoctorPdf { asciidoctorPdf { sourceDir 'src/docs/asciidoc' - inProcess = JAVA_EXEC + executionMode = JAVA_EXEC } """) @@ -112,7 +112,7 @@ asciidoctorPdf { then: verifyAll { - new File(testProjectDir.root, DEFAULT_OUTPUT_FILE).exists() + new File(projectDir, DEFAULT_OUTPUT_FILE).exists() } } @@ -137,7 +137,7 @@ asciidoctorPdf { then: verifyAll { - new File(testProjectDir.root, DEFAULT_OUTPUT_FILE).exists() + new File(projectDir, DEFAULT_OUTPUT_FILE).exists() } } @@ -156,6 +156,7 @@ asciidoctorPdf { sourceDir 'src/docs/asciidoc' fontsDirs 'src/docs/asciidoc/pdf-theme', file('src/docs/asciidoc/path') fontsDirs 'src/docs/asciidoc/pdf-theme-path' + executionMode = JAVA_EXEC } """) @@ -164,7 +165,7 @@ asciidoctorPdf { then: verifyAll { - new File(testProjectDir.root, DEFAULT_OUTPUT_FILE).exists() + new File(projectDir, DEFAULT_OUTPUT_FILE).exists() } } @@ -182,15 +183,16 @@ asciidoctorPdf { theme 'basic' sourceDir 'src/docs/asciidoc' fontsDirs 'src/docs/asciidoc/pdf-theme' + executionMode = JAVA_EXEC } - """) + """.stripIndent()) when: getGradleRunner([DEFAULT_TASK, '-i']).build() then: verifyAll { - new File(testProjectDir.root, DEFAULT_OUTPUT_FILE).exists() + new File(projectDir, DEFAULT_OUTPUT_FILE).exists() } } @@ -198,22 +200,23 @@ asciidoctorPdf { @Unroll void 'can apply a task configuration rule to set source and output directory (Gradle #gradleVersion)'() { given: - File newSourceDir = new File(testProjectDir.root, 'src/asciidoc') - assert new File(testProjectDir.root, 'src/docs/asciidoc').renameTo(newSourceDir) - testProjectDir.newFile('build.gradle') << """ + File newSourceDir = new File(projectDir, 'src/asciidoc') + assert new File(projectDir, 'src/docs/asciidoc').renameTo(newSourceDir) + buildFile.text = """ plugins { id 'org.asciidoctor.jvm.pdf' apply false } - tasks.withType(org.asciidoctor.gradle.jvm.pdf.AsciidoctorPdfTask) { + tasks.withType(org.asciidoctor.gradle.jvm.pdf.AsciidoctorPdfTask).configureEach { sourceDir = 'src/asciidoc' outputDir = "\${buildDir}/output" + executionMode = JAVA_EXEC } apply plugin: 'org.asciidoctor.jvm.pdf' ${offlineRepositories} - """ + """.stripIndent() when: getGradleRunner([DEFAULT_TASK, '-s']) @@ -222,11 +225,11 @@ asciidoctorPdf { then: verifyAll { - new File(testProjectDir.root, 'build/output/sample.pdf').exists() + new File(projectDir, 'build/output/sample.pdf').exists() } where: - gradleVersion << [latestMinimumOrThis('6.0.1'), latestMinimumOrThis('6.9.1'), GradleTestVersions.MAX_VERSION] + gradleVersion << [latestMinimumOrThis('7.0.1'), GradleTestVersions.MAX_VERSION] } @Issue('https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/579') @@ -250,17 +253,7 @@ asciidoctorPdf { } File getBuildFile(String extraContent) { - File buildFile = testProjectDir.newFile('build.gradle') - buildFile << """ -plugins { - id 'org.asciidoctor.jvm.pdf' -} - -${offlineRepositories} - -${extraContent} -""" - buildFile + writeGroovyBuildFile('org.asciidoctor.jvm.pdf', extraContent) } String getResolutionStrategy(final String asciidoctorjVer, final String jrubyVer) { diff --git a/jvm-pdf/src/intTest/groovy/org/asciidoctor/gradle/jvm/pdf/internal/FunctionalSpecification.groovy b/jvm-pdf/src/intTest/groovy/org/asciidoctor/gradle/jvm/pdf/internal/FunctionalSpecification.groovy index 3b2a0384e..bcd4c0b81 100644 --- a/jvm-pdf/src/intTest/groovy/org/asciidoctor/gradle/jvm/pdf/internal/FunctionalSpecification.groovy +++ b/jvm-pdf/src/intTest/groovy/org/asciidoctor/gradle/jvm/pdf/internal/FunctionalSpecification.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,18 +18,15 @@ package org.asciidoctor.gradle.jvm.pdf.internal import groovy.transform.CompileStatic import org.apache.commons.io.FileUtils import org.asciidoctor.gradle.testfixtures.DslType +import org.asciidoctor.gradle.testfixtures.FunctionalTestFixture import org.asciidoctor.gradle.testfixtures.FunctionalTestSetup import org.gradle.testkit.runner.GradleRunner -import org.junit.Rule -import org.junit.rules.TemporaryFolder import spock.lang.Specification +import spock.lang.TempDir import static org.asciidoctor.gradle.testfixtures.DslType.GROOVY_DSL -import static org.asciidoctor.gradle.testfixtures.DslType.KOTLIN_DSL -import static org.asciidoctor.gradle.testfixtures.FunctionalTestSetup.getOfflineRepositoriesGroovyDsl -import static org.asciidoctor.gradle.testfixtures.FunctionalTestSetup.getOfflineRepositoriesKotlinDsl -class FunctionalSpecification extends Specification { +class FunctionalSpecification extends Specification implements FunctionalTestFixture { @SuppressWarnings('LineLength') static @@ -37,54 +34,24 @@ class FunctionalSpecification extends Specification { static final String TEST_REPO_DIR = FunctionalTestSetup.offlineRepo.absolutePath - @Rule - TemporaryFolder testProjectDir + @TempDir + File testProjectDir - @Rule - TemporaryFolder alternateProjectDir + File testKitDir + + void setup() { + testKitDir = new File(testProjectDir, ".testkit-${UUID.randomUUID()}") + projectDir.mkdirs() + } @CompileStatic GradleRunner getGradleRunner(List taskNames = ['asciidoctor']) { - FunctionalTestSetup.getGradleRunner(GROOVY_DSL, testProjectDir.root, taskNames) + FunctionalTestSetup.getGradleRunner(GROOVY_DSL, projectDir, taskNames).withTestKitDir(testKitDir) } @SuppressWarnings(['BuilderMethodWithSideEffects']) void createTestProject(String docGroup = 'normal') { - FileUtils.copyDirectory(new File(TEST_PROJECTS_DIR, docGroup), testProjectDir.root) - } - - @CompileStatic - String getOfflineRepositories(DslType dslType = GROOVY_DSL) { - dslType == GROOVY_DSL ? getOfflineRepositoriesGroovyDsl(new File(TEST_REPO_DIR)) : - getOfflineRepositoriesKotlinDsl(new File(TEST_REPO_DIR)) - } - - File getJvmConvertGroovyBuildFile(String extraContent, String plugin = 'org.asciidoctor.jvm.pdf') { - File buildFile = testProjectDir.newFile('build.gradle') - buildFile << """ - plugins { - id '${plugin}' - } - - ${offlineRepositories} - - ${extraContent} - """ - buildFile - } - - File getJvmConvertKotlinBuildFile(String extraContent, String plugin = 'org.asciidoctor.jvm.pdf') { - File buildFile = testProjectDir.newFile('build.gradle.kts') - buildFile << """ - plugins { - id ("${plugin}") - } - - ${getOfflineRepositories(KOTLIN_DSL)} - - ${extraContent} - """ - buildFile + FileUtils.copyDirectory(new File(TEST_PROJECTS_DIR, docGroup), projectDir) } String getDefaultProcessModeForAppveyor(final DslType dslType = GROOVY_DSL) { diff --git a/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorJPdfPlugin.groovy b/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorJPdfPlugin.groovy index a22d8a661..9e835d4d6 100644 --- a/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorJPdfPlugin.groovy +++ b/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorJPdfPlugin.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfTask.groovy b/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfTask.groovy index 2fd9e17a3..0345b4766 100644 --- a/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfTask.groovy +++ b/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfTask.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,19 +15,14 @@ */ package org.asciidoctor.gradle.jvm.pdf -import groovy.transform.CompileDynamic import groovy.transform.CompileStatic -import org.asciidoctor.gradle.base.process.ProcessMode import org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask -import org.asciidoctor.gradle.jvm.AsciidoctorJExtension import org.gradle.api.Project import org.gradle.api.UnknownDomainObjectException import org.gradle.api.file.FileCollection -import org.gradle.api.model.ReplacedBy @java.lang.SuppressWarnings('NoWildcardImports') import org.gradle.api.tasks.* import org.gradle.api.tasks.util.PatternSet -import org.gradle.util.GradleVersion import org.gradle.workers.WorkerExecutor import javax.inject.Inject @@ -48,61 +43,29 @@ import static org.ysb33r.grolifant.api.core.TaskInputFileOptions.OPTIONAL class AsciidoctorPdfTask extends AbstractAsciidoctorTask { private String theme - private final List fontDirs = [] + private final List pdfFontDirs = [] @Inject AsciidoctorPdfTask(WorkerExecutor we) { super(we) - configuredOutputOptions.backends = ['pdf'] + outputOptions.backends = ['pdf'] copyNoResources() projectOperations.tasks.inputFiles( inputs, - { -> fontDirs }, + { -> pdfFontDirs }, PathSensitivity.RELATIVE, IGNORE_EMPTY_DIRECTORIES, OPTIONAL ) } - /** @Deprecated Use{@link #getFontsDirs()} instead - * - * @return Pdf font directory as a file - * @throws {@link PdfFontDirException} if there are either multiple directories or no directory for pdf font - * */ - @Deprecated - @ReplacedBy('getFontsDirs') - File getFontsDir() { - if (this.fontDirs.size() > 1) { - throw new PdfFontDirException('There is more than 1 file in the fonts directory') - } - if (this.fontDirs.empty) { - throw new PdfFontDirException('No directory is specified') - } - this.project.file(this.fontDirs.first()) - } - - /** @Deprecated Use{@link #setFontsDirs(java.lang.Iterable)} instead and specify the single directory - * - * Specify a directory where to load custom fonts from. - * - * This will set the {@code pdf-fontsdir} attribute - * - * @param f Directory where custom fonts can be found. anything convertible with {@link Project#file} - * can be used. - */ - @SuppressWarnings('UnnecessarySetter') - @Deprecated - void setFontsDir(Object f) { - setFontsDirs([f]) - } - /** Returns the directories or single directory for the fonts * * @return Directories for the pdf fonts * */ @Internal FileCollection getFontsDirs() { - projectOperations.fsOperations.files(this.fontDirs) + projectOperations.fsOperations.files(this.pdfFontDirs) } /** Specify a directory or directories where to load custom fonts from. @@ -113,8 +76,8 @@ class AsciidoctorPdfTask extends AbstractAsciidoctorTask { * can be used. */ void setFontsDirs(Iterable paths) { - this.fontDirs.clear() - this.fontDirs.addAll(paths) + this.pdfFontDirs.clear() + this.pdfFontDirs.addAll(paths) } /** Add files paths for the custom fonts @@ -123,7 +86,7 @@ class AsciidoctorPdfTask extends AbstractAsciidoctorTask { * */ @SuppressWarnings('UnnecessarySetter') void fontsDirs(Object... f) { - this.fontDirs.addAll(f.toList()) + this.pdfFontDirs.addAll(f.toList()) } /** Set the theme to be used from the {@code pdfThemes} extension. @@ -156,32 +119,33 @@ class AsciidoctorPdfTask extends AbstractAsciidoctorTask { themeDescriptor?.themeName } - /** Selects a final process mode of PDF processing. - * - * If the system is running on Windows with a Gradle version which still has classpath leakage problems - * it will switch to using {@link #JAVA_EXEC}. - * - * @return Process mode to use for execution. - */ - @Override - protected ProcessMode getFinalProcessMode() { - if (GradleVersion.current() <= LAST_GRADLE_WITH_CLASSPATH_LEAKAGE) { - if (inProcess != AbstractAsciidoctorTask.JAVA_EXEC) { - logger.warn 'This version of Gradle leaks snakeyaml on to worker classpaths which breaks ' + - 'PDF processing. Switching to JAVA_EXEC instead.' - } - AbstractAsciidoctorTask.JAVA_EXEC - } else { - super.finalProcessMode - } - } - - /** The default pattern set for secondary sources. +// /** Selects a final process mode of PDF processing. +// * +// * If the system is running on Windows with a Gradle version which still has classpath leakage problems +// * it will switch to using {@link #JAVA_EXEC}. +// * +// * @return Process mode to use for execution. +// */ +// @Override +// protected ProcessMode getFinalProcessMode() { +// if (GradleVersion.current() <= LAST_GRADLE_WITH_CLASSPATH_LEAKAGE) { +// if (inProcess != AbstractAsciidoctorTask.JAVA_EXEC) { +// logger.warn 'This version of Gradle leaks snakeyaml on to worker classpaths which breaks ' + +// 'PDF processing. Switching to JAVA_EXEC instead.' +// } +// AbstractAsciidoctorTask.JAVA_EXEC +// } else { +// super.finalProcessMode +// } +// } + + /** + * The default pattern set for secondary sources. * * @return {@link #getDefaultSourceDocumentPattern} + `*docinfo*`. */ @Override - protected PatternSet getDefaultSecondarySourceDocumentPattern() { + PatternSet getDefaultSecondarySourceDocumentPattern() { PatternSet ps = defaultSourceDocumentPattern ps.include '*-theme.y*ml' ps @@ -197,32 +161,19 @@ class AsciidoctorPdfTask extends AbstractAsciidoctorTask { * * @return A collection of default attributes. */ - @SuppressWarnings('UnnecessaryGetter') @Override - protected Map getTaskSpecificDefaultAttributes(File workingSourceDir) { - Map attrs = super.getTaskSpecificDefaultAttributes(workingSourceDir) - - boolean useOldAttributes = pdfVersion.startsWith('1.5.0-alpha') - - FileCollection fonts = getFontsDirs() - if (!fonts?.empty) { - attrs['pdf-fontsdir'] = fonts.asPath - } - - File styles = themesDir - if (styles != null) { - attrs[useOldAttributes ? 'pdf-stylesdir' : 'pdf-themesdir'] = styles.absolutePath - } - - String selectedTheme = themeName - if (selectedTheme != null) { - attrs[useOldAttributes ? 'pdf-style' : 'pdf-theme'] = selectedTheme - } - + Map getTaskSpecificDefaultAttributes(File workingSourceDir) { + final attrs = super.getTaskSpecificDefaultAttributes(workingSourceDir) + final fonts = fontsDirs + attrs.putAll([ + 'pdf-fontsdir' : fonts.empty ? null : fonts.asPath, + 'pdf-themesdir': themesDir?.absolutePath, + 'pdf-theme' : themeName + ].findAll { k, v -> v != null }) attrs } - @CompileDynamic +// @CompileDynamic private AsciidoctorPdfThemesExtension.PdfThemeDescriptor getThemeDescriptor() { if (this.theme) { AsciidoctorPdfThemesExtension pdfThemes = project.extensions.getByType(AsciidoctorPdfThemesExtension) @@ -231,8 +182,4 @@ class AsciidoctorPdfTask extends AbstractAsciidoctorTask { null } } - - private String getPdfVersion() { - asciidoctorj.modules.pdf.version ?: project.extensions.getByType(AsciidoctorJExtension).modules.pdf.version - } } diff --git a/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfThemesExtension.groovy b/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfThemesExtension.groovy index a2d9d1b74..ac7177623 100644 --- a/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfThemesExtension.groovy +++ b/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfThemesExtension.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,11 +18,15 @@ package org.asciidoctor.gradle.jvm.pdf import groovy.transform.CompileStatic import org.asciidoctor.gradle.base.AbstractDownloadableComponent import org.gradle.api.Project -import org.ysb33r.grolifant.api.v4.StringUtils -/** Easy way to configure themes for Asciidoctor PDF either as local themes or +import java.util.concurrent.Callable + +/** + * Easy way to configure themes for Asciidoctor PDF either as local themes or * as downloadable. * + * @author Schalk W. Cronjé + * * @since 2.0 */ @CompileStatic @@ -30,8 +34,8 @@ class AsciidoctorPdfThemesExtension extends AbstractDownloadableComponent convertible(PdfLocalTheme theme) { return { -> - new PdfThemeDescriptor(StringUtils.stringize(theme.themeName), project.file(theme.themeDir)) + new PdfThemeDescriptor( + projectOperations.stringTools.stringize(theme.themeName), + projectOperations.fsOperations.file(theme.themeDir) + ) } } diff --git a/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/PdfFontDirException.groovy b/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/PdfFontDirException.groovy index e7dd3c568..2ac2b5558 100644 --- a/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/PdfFontDirException.groovy +++ b/jvm-pdf/src/main/groovy/org/asciidoctor/gradle/jvm/pdf/PdfFontDirException.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/jvm-pdf/src/test/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfThemeExtensionSpec.groovy b/jvm-pdf/src/test/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfThemeExtensionSpec.groovy index d5d465636..ab23aaf47 100644 --- a/jvm-pdf/src/test/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfThemeExtensionSpec.groovy +++ b/jvm-pdf/src/test/groovy/org/asciidoctor/gradle/jvm/pdf/AsciidoctorPdfThemeExtensionSpec.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2013-2023 the original author or authors. + * Copyright 2013-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -106,7 +106,8 @@ class AsciidoctorPdfThemeExtensionSpec extends Specification { } File determineUnpackedDir(String cacheSubDir, String pattern) { - File baseDir = project.file("${project.buildDir}/${cacheSubDir}/foo/bar/${pattern}") - FileUtils.listDirs(baseDir)[0] + File baseDir = project.file("${project.buildDir}/cloud-archives/${cacheSubDir}/foo/bar/${pattern}") + final x = projectOperations.fsOperations.listDirs(baseDir)[0] + x } } \ No newline at end of file diff --git a/jvm/build.gradle b/jvm/build.gradle index 8c4a4843c..f71bb154d 100644 --- a/jvm/build.gradle +++ b/jvm/build.gradle @@ -81,6 +81,7 @@ tasks.named('check') { dependsOn remoteTest } +// TODO: Use configurePlugin instead gradlePlugin { plugins { basePlugin { diff --git a/jvm/src/intTest/groovy/org/asciidoctor/gradle/internal/FunctionalSpecification.groovy b/jvm/src/intTest/groovy/org/asciidoctor/gradle/internal/FunctionalSpecification.groovy index 973c85f4a..220094faf 100644 --- a/jvm/src/intTest/groovy/org/asciidoctor/gradle/internal/FunctionalSpecification.groovy +++ b/jvm/src/intTest/groovy/org/asciidoctor/gradle/internal/FunctionalSpecification.groovy @@ -21,7 +21,6 @@ import org.asciidoctor.gradle.testfixtures.DslType import org.asciidoctor.gradle.testfixtures.FunctionalTestFixture import org.asciidoctor.gradle.testfixtures.FunctionalTestSetup import org.gradle.testkit.runner.GradleRunner -import spock.lang.Shared import spock.lang.Specification import spock.lang.TempDir @@ -44,11 +43,11 @@ class FunctionalSpecification extends Specification implements FunctionalTestFix void setup() { projectDir.mkdirs() - testKitDir = new File(testProjectDir,".testkit-${UUID.randomUUID().toString()}") + testKitDir = new File(testProjectDir, ".testkit-${UUID.randomUUID()}") } void cleanup() { - if(testKitDir && testKitDir.exists()) { + if (testKitDir && testKitDir.exists()) { testKitDir.deleteDir() } } diff --git a/jvm/src/intTest/groovy/org/asciidoctor/gradle/jvm/AsciidoctorTaskCachingFunctionalSpec.groovy b/jvm/src/intTest/groovy/org/asciidoctor/gradle/jvm/AsciidoctorTaskCachingFunctionalSpec.groovy index 19148dcd9..74062f778 100644 --- a/jvm/src/intTest/groovy/org/asciidoctor/gradle/jvm/AsciidoctorTaskCachingFunctionalSpec.groovy +++ b/jvm/src/intTest/groovy/org/asciidoctor/gradle/jvm/AsciidoctorTaskCachingFunctionalSpec.groovy @@ -37,7 +37,6 @@ class AsciidoctorTaskCachingFunctionalSpec extends FunctionalSpecification public static final String DEFAULT_OUTPUT_FILE = 'build/docs/asciidoc/html5/sample.html' public static final String DOCBOOK_OUTPUT_FILE = 'build/docs/asciidoc/docbook/sample.xml' - void setup() { setupCache() createTestProject() @@ -72,36 +71,36 @@ class AsciidoctorTaskCachingFunctionalSpec extends FunctionalSpecification fileInRelocatedDirectory(DOCBOOK_OUTPUT_FILE).exists() } - @Issue('https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/671') - void "asciidoctor task is cacheable and relocatable when gemPaths is configured"() { - given: - getBuildFile(""" - asciidoctorj { - gemPaths 'gems1', 'gems2' - } - - asciidoctor { - sourceDir 'src/docs/asciidoc' - - outputOptions { - backends 'html5', 'docbook' - } - } - """) - - when: - assertDefaultTaskExecutes() - - then: - outputFile.exists() - - when: - assertDefaultTaskIsCachedAndRelocatable() - - then: - outputFile.exists() - outputFileInRelocatedDirectory.exists() - } +// @Issue('https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/671') +// void "asciidoctor task is cacheable and relocatable when gemPaths is configured"() { +// given: +// getBuildFile(""" +// asciidoctorj { +// gemPaths 'gems1', 'gems2' +// } +// +// asciidoctor { +// sourceDir 'src/docs/asciidoc' +// +// outputOptions { +// backends 'html5', 'docbook' +// } +// } +// """) +// +// when: +// assertDefaultTaskExecutes() +// +// then: +// outputFile.exists() +// +// when: +// assertDefaultTaskIsCachedAndRelocatable() +// +// then: +// outputFile.exists() +// outputFileInRelocatedDirectory.exists() +// } void "Asciidoctor task is cached when only output directory is changed"() { given: diff --git a/jvm/src/main/groovy/org/asciidoctor/gradle/internal/DefaultAsciidoctorJModules.groovy b/jvm/src/main/groovy/org/asciidoctor/gradle/internal/DefaultAsciidoctorJModules.groovy index e8a3e6d04..d18b3d25d 100644 --- a/jvm/src/main/groovy/org/asciidoctor/gradle/internal/DefaultAsciidoctorJModules.groovy +++ b/jvm/src/main/groovy/org/asciidoctor/gradle/internal/DefaultAsciidoctorJModules.groovy @@ -44,6 +44,8 @@ class DefaultAsciidoctorJModules implements AsciidoctorJModules { private final AsciidoctorModuleDefinition groovyDsl private Action updater + // TODO: Remove this warning - it is only there temporarily. + @SuppressWarnings('UnusedMethodParameter') DefaultAsciidoctorJModules( ProjectOperations po, AsciidoctorJExtension asciidoctorjs, diff --git a/jvm/src/main/groovy/org/asciidoctor/gradle/internal/ExecutorConfiguration.groovy b/jvm/src/main/groovy/org/asciidoctor/gradle/internal/ExecutorConfiguration.groovy index b67d772f1..fd3c7d62b 100644 --- a/jvm/src/main/groovy/org/asciidoctor/gradle/internal/ExecutorConfiguration.groovy +++ b/jvm/src/main/groovy/org/asciidoctor/gradle/internal/ExecutorConfiguration.groovy @@ -38,7 +38,6 @@ class ExecutorConfiguration implements Serializable, Cloneable { List fatalMessagePatterns String backendName - String gemPath boolean logDocuments boolean copyResources @@ -66,7 +65,6 @@ File locations: baseDir = ${baseDir} JRuby: - GEMPATH = ${gemPath} requires = ${requires} Asciidoctor: diff --git a/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AbstractAsciidoctorTask.groovy b/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AbstractAsciidoctorTask.groovy index 836c5d776..e91ba916a 100644 --- a/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AbstractAsciidoctorTask.groovy +++ b/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AbstractAsciidoctorTask.groovy @@ -43,10 +43,13 @@ import org.gradle.api.artifacts.ConfigurationContainer import org.gradle.api.artifacts.Dependency import org.gradle.api.file.FileCollection import org.gradle.api.provider.Property +import org.gradle.api.provider.Provider import org.gradle.api.tasks.Classpath import org.gradle.api.tasks.Input import org.gradle.api.tasks.Internal import org.gradle.api.tasks.Nested +import org.gradle.api.tasks.TaskProvider +import org.gradle.api.tasks.bundling.Jar import org.gradle.process.JavaForkOptions import org.gradle.workers.WorkerExecutor import org.ysb33r.grolifant.api.core.jvm.ExecutionMode @@ -97,6 +100,7 @@ class AbstractAsciidoctorTask extends AbstractJvmModelExecTask, Configuration> detachedConfigurationCreator private final Property jvmClasspath + private final List> gemJarProviders = [] @Delegate private final DefaultAsciidoctorFileOperations asciidoctorTaskFileOperations @@ -105,7 +109,7 @@ class AbstractAsciidoctorTask extends AbstractJvmModelExecTask seed + projectOperations.configurations.asConfiguration(it) } - precompiledExtensions ? fc + precompiledExtensions : fc + final gjp = projectOperations.fsOperations.files([gemJarProviders, fc]) + precompiledExtensions ? gjp + precompiledExtensions : gjp } /** Override any existing configurations except the ones available via the {@code asciidoctorj} task extension. @@ -346,15 +351,42 @@ class AbstractAsciidoctorTask extends AbstractJvmModelExecTask gemJar) { + dependsOn(gemJar) + this.gemJarProviders.add(gemJar.map { it.archiveFile.get().asFile }) + } + + /** + * Adds a Jar of GEMs to the classpath. + * + * @param gemJar name of a {@link Jar} task which contain GEMs. + * + * @since 4.0 + */ + void withGemJar(String taskName) { + dependsOn(taskName) + final gemJar = project.tasks.named(taskName, Jar) + this.gemJarProviders.add(gemJar.map { it.archiveFile.get().asFile }) + } + + /** + * Adds a directory to the classpath. THe directory will contain unpacked GEMs. + * + * @param gemPath A provider to a directory containing unpakcing GEMs. + * + * @param builtBy THe name of the task that prepares this directory. + * + * @since 4.0 + */ + void withGemPath(Provider gemPath, String builtBy) { + dependsOn(builtBy) + this.gemJarProviders.add(gemPath) } /** @@ -428,7 +460,11 @@ class AbstractAsciidoctorTask extends AbstractJvmModelExecTask, Configuration> inputs.files(this.asciidoctorj.configuration) - inputs.files { asciidoctorj.gemPaths }.withPathSensitivity(RELATIVE) + inputs.files { gemJarProviders }.withPathSensitivity(RELATIVE) inputs.property 'backends', { -> backends() } inputs.property 'asciidoctorj-version', { -> asciidoctorj.version } inputs.property 'jruby-version', { -> asciidoctorj.jrubyVersion ?: '' } @@ -548,10 +584,9 @@ class AbstractAsciidoctorTask extends AbstractJvmModelExecTask getRequires() { - asciidoctorj.requires - } - @Nested protected AsciidoctorTaskFileOperations getAsciidoctorTaskFileOperations() { this.asciidoctorTaskFileOperations @@ -601,8 +625,8 @@ class AbstractAsciidoctorTask extends AbstractJvmModelExecTask lang) { -// if (lang.present) { -// workspacePreparation.prepareWorkspace(lang.get()) -// } else { -// workspacePreparation.prepareWorkspace() -// } -// } -// private List> getLanguagesAsOptionals() { if (this.languages.empty) { [Optional.empty() as Optional] @@ -681,99 +677,6 @@ class AbstractAsciidoctorTask extends AbstractJvmModelExecTask runWithWorkers( -// final File workingSourceDir, -// final Set sourceFiles, -// Optional lang -// ) { -// FileCollection asciidoctorClasspath = configurations -// logger.info "Running AsciidoctorJ with workers. Classpath = ${asciidoctorClasspath.files}" -// -// Map executorConfigurations = getExecutorConfigurations( -// workingSourceDir, -// sourceFiles, -// lang -// ) -// -// if (parallelMode) { -// WorkQueue queue = getWorkQueue(asciidoctorClasspath) -// executorConfigurations.each { String configName, ExecutorConfiguration executorConfiguration -> -// copyResourcesByBackend(executorConfiguration, lang) -// queue.submit(AsciidoctorJExecuterWorker) { params -> -// params.extensionConfigurationContainer = -// new ExecutorConfigurationContainer(executorConfiguration) -// } -// } -// } else { -// copyResourcesByBackend(executorConfigurations.values(), lang) -// getWorkQueue(asciidoctorClasspath).submit(AsciidoctorJExecuterWorker) { params -> -// params.extensionConfigurationContainer = -// new ExecutorConfigurationContainer(executorConfigurations.values()) -// } -// } -// executorConfigurations -// } - -// private WorkQueue getWorkQueue(FileCollection asciidoctorClasspath) { -// IN_PROCESS ? -// worker.classLoaderIsolation(configureClassloaderIsolatedWorker(asciidoctorClasspath)) : -// worker.processIsolation(configureProcessIsolatedWorker(asciidoctorClasspath)) -// } -// -// private Closure configureClassloaderIsolatedWorker(FileCollection asciidoctorClasspath) { -// return { ClassLoaderWorkerSpec spec -> -// spec.classpath.from(asciidoctorClasspath) -// } -// } -// -// private Closure configureProcessIsolatedWorker(FileCollection asciidoctorClasspath) { -// return { ProcessWorkerSpec spec -> -// spec.classpath.from(asciidoctorClasspath) -// configureForkOptions(spec.forkOptions) -// } -// } - -// private Map runWithJavaExec( -// final File workingSourceDir, -// final Set sourceFiles, -// Optional lang -// ) { -// FileCollection javaExecClasspath = JavaExecUtils.getJavaExecClasspath( -// project, -// configurations, -// asciidoctorj.injectInternalGuavaJar -// ) -// Map executorConfigurations = getExecutorConfigurations( -// workingSourceDir, -// sourceFiles, -// lang -// ) -// File execConfigurationData = JavaExecUtils.writeExecConfigurationData(this, executorConfigurations.values()) -// copyResourcesByBackend(executorConfigurations.values(), lang) -// -// logger.debug("Serialised AsciidoctorJ configuration to ${execConfigurationData}") -// logger.info "Running AsciidoctorJ instance with classpath ${javaExecClasspath.files}" -// -// try { -// projectOperations.javaexec { JavaExecSpec jes -> -// configureForkOptions(jes) -// logger.debug "Running AsciidoctorJ instance with environment: ${jes.environment}" -// jes.with { -// setExecClass(jes, AsciidoctorJavaExec.canonicalName) -// classpath = javaExecClasspath -// args execConfigurationData.absolutePath -// } -// } -// } catch (GradleException e) { -// throw new AsciidoctorRemoteExecutionException( -// 'Remote Asciidoctor process failed to complete successfully', -// e -// ) -// } -// -// executorConfigurations -// } - private void copyResourcesByExecutorConfiguration( Iterable executorConfigurations, Optional lang diff --git a/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AsciidoctorJExtension.groovy b/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AsciidoctorJExtension.groovy index ab7c842d2..8d986c72a 100644 --- a/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AsciidoctorJExtension.groovy +++ b/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AsciidoctorJExtension.groovy @@ -27,10 +27,7 @@ import org.gradle.api.* @java.lang.SuppressWarnings('NoWildcardImports') import org.gradle.api.artifacts.* import org.gradle.api.artifacts.dsl.DependencyHandler -import org.gradle.api.file.FileCollection import org.gradle.api.logging.LogLevel -import org.ysb33r.grolifant.api.core.LegacyLevel -import org.ysb33r.grolifant.api.core.OperatingSystem import java.util.concurrent.Callable import java.util.function.BiConsumer @@ -65,11 +62,11 @@ class AsciidoctorJExtension extends AbstractImplementationEngineExtension { private static final String ASCIIDOCTORJ_LEANPUB_DEPENDENCY = "${ASCIIDOCTORJ_GROUP}:asciidoctor-leanpub-markdown" private static final String JRUBY_COMPLETE_DEPENDENCY = JavaExecUtils.JRUBY_COMPLETE_DEPENDENCY private static final String ASCIIDOCTOR_DEPENDENCY_PROPERTY_NAME = 'asciidoctorj' - private static final OperatingSystem OS = OperatingSystem.current() - // TODO: Kill this off - private static final boolean GUAVA_REQUIRED_FOR_EXTERNALS = !LegacyLevel.PRE_4_8 private static final String CONFIGURATION_NAME = "__\$\$${NAME}\$\$__" + // TODO: Kill this off +// private static final boolean GUAVA_REQUIRED_FOR_EXTERNALS = !LegacyLevel.PRE_4_8 + private static final BiConsumer> DRD_VERSION_RESOLVER = { DependencyResolveDetails drd, Callable versionResolver -> drd.useVersion(versionResolver.call()) @@ -79,24 +76,22 @@ class AsciidoctorJExtension extends AbstractImplementationEngineExtension { private final Map options = [:] private final List jrubyRequires = [] private final List asciidoctorExtensions = [] - private final List gemPaths = [] +// private final List gemPaths = [] private final List warningsAsErrors = [] private final DefaultAsciidoctorJModules modules private final Configuration publicConfiguration private final Configuration privateConfiguration private final BiFunction dependencyCreator private final Function projectDependency - private Object version private Optional jrubyVersion - private Boolean injectGuavaJar private boolean onlyTaskOptions = false - private boolean onlyTaskRequires = false private boolean onlyTaskExtensions = false - private boolean onlyTaskGems = false private boolean onlyTaskWarnings = false - private LogLevel logLevel +// private Boolean injectGuavaJar + private boolean onlyTaskRequires = false +// private boolean onlyTaskGems = false /** Attach extension to a project. * @@ -266,56 +261,57 @@ class AsciidoctorJExtension extends AbstractImplementationEngineExtension { ~/include file not found/ } - /* ------------------------- - tag::extension-property[] - gemPaths:: One or more gem installation directories (separated by the system path separator). - Use `gemPaths` to append. Use `setGemPaths` or `gemPaths=['path1','path2']` to overwrite. - Use `asGemPath` to obtain a path string, separated by platform-specific separator. - Type: `FileCollection`, but any collection of objects convertible with `project.files` can be passed - Default: empty - end::extension-property[] - ------------------------- */ - - /** Returns the list of paths to be used for {@code GEM_HOME} - * - */ - FileCollection getGemPaths() { - if (!task || onlyTaskGems) { - projectOperations.fsOperations.files(this.gemPaths) - } else { - projectOperations.fsOperations.files(this.gemPaths).from(extFromProject.gemPaths) - } - } - - /** Sets a new list of GEM paths to be used. - * - * @param paths Paths resolvable by {@ocde project.files} - */ - void setGemPaths(Iterable paths) { - this.gemPaths.clear() - this.gemPaths.addAll(paths) - - if (task) { - this.onlyTaskGems = true - } - } - - /** Adds more paths for discovering GEMs. - * - * @param f Path objects that can be be converted with {@code project.file}. - */ - void gemPaths(Object... f) { - this.gemPaths.addAll(f) - } - - /** Returns the list of paths to be used for GEM installations in a format that is - * suitable for assignment to {@code GEM_HOME} - * - * Calling this will cause gemPath to be resolved immediately. - */ - String asGemPath() { - getGemPaths().files*.toString().join(OS.pathSeparator) - } +// /* ------------------------- +// tag::extension-property[] +// gemPaths:: One or more gem installation directories (separated by the system path separator). +// Use `gemPaths` to append. Use `setGemPaths` or `gemPaths=['path1','path2']` to overwrite. +// Use `asGemPath` to obtain a path string, separated by platform-specific separator. +// Type: `FileCollection`, but any collection of objects convertible with `project.files` can be passed +// Default: empty +// end::extension-property[] +// ------------------------- */ +// +// /** Returns the list of paths to be used for {@code GEM_HOME} +// * +// */ +// FileCollection getGemPaths() { +// if (!task || onlyTaskGems) { +// projectOperations.fsOperations.files(this.gemPaths) +// } else { +// projectOperations.fsOperations.files(this.gemPaths).from(extFromProject.gemPaths) +// } +// } +// +// /** Sets a new list of GEM paths to be used. +// * +// * @param paths Paths resolvable by {@ocde project.files} +// */ +// void setGemPaths(Iterable paths) { +// this.gemPaths.clear() +// this.gemPaths.addAll(paths) +// +// if (task) { +// this.onlyTaskGems = true +// } +// } +// +// /** Adds more paths for discovering GEMs. +// * +// * @param f Path objects that can be be converted with {@code project.file}. +// */ +// void gemPaths(Object... f) { +// this.gemPaths.addAll(f) +// } +// +// /** +// * Returns the list of paths to be used for GEM installations in a format that is +// * suitable for assignment to {@code GEM_HOME} +// * +// * Calling this will cause gemPath to be resolved immediately. +// */ +// String asGemPath() { +// getGemPaths().files*.toString().join(OS.pathSeparator) +// } /* ------------------------- tag::extension-property[] @@ -580,30 +576,30 @@ class AsciidoctorJExtension extends AbstractImplementationEngineExtension { this.version = v } - /** Whether the Guava JAR that ships with the Gradle distribution should be injected into the - * classpath for external AsciidoctorJ processes. - * - * If not set previously via {@link #setInjectInternalGuavaJar} then a default version depending of the version of - * the Gradle distribution will be used. - * - * @return {@code true} if JAR should be injected. - */ - boolean getInjectInternalGuavaJar() { - if (task) { - this.injectGuavaJar == null ? extFromProject.injectInternalGuavaJar : this.injectGuavaJar - } else { - this.injectGuavaJar == null ? GUAVA_REQUIRED_FOR_EXTERNALS : this.injectGuavaJar - } - } - - /** Whether the Guava JAR that ships with the Gradle distribution should be injected into the - * classpath for external AsciidoctorJ processes. - * - * @param inject {@code true} if JAR should be injected. - */ - void setInjectInternalGuavaJar(boolean inject) { - this.injectGuavaJar = inject - } +// /** Whether the Guava JAR that ships with the Gradle distribution should be injected into the +// * classpath for external AsciidoctorJ processes. +// * +// * If not set previously via {@link #setInjectInternalGuavaJar} then a default version depending of the version of +// * the Gradle distribution will be used. +// * +// * @return {@code true} if JAR should be injected. +// */ +// boolean getInjectInternalGuavaJar() { +// if (task) { +// this.injectGuavaJar == null ? extFromProject.injectInternalGuavaJar : this.injectGuavaJar +// } else { +// this.injectGuavaJar == null ? GUAVA_REQUIRED_FOR_EXTERNALS : this.injectGuavaJar +// } +// } + +// /** Whether the Guava JAR that ships with the Gradle distribution should be injected into the +// * classpath for external AsciidoctorJ processes. +// * +// * @param inject {@code true} if JAR should be injected. +// */ +// void setInjectInternalGuavaJar(boolean inject) { +// this.injectGuavaJar = inject +// } /** * Returns a runConfiguration of the configured AsciidoctorJ dependencies. diff --git a/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AsciidoctorTask.groovy b/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AsciidoctorTask.groovy index 7e6b4af47..66abfb77b 100755 --- a/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AsciidoctorTask.groovy +++ b/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AsciidoctorTask.groovy @@ -21,6 +21,7 @@ import org.gradle.api.Action import org.gradle.api.tasks.CacheableTask import org.gradle.api.tasks.util.PatternSet import org.gradle.workers.WorkerExecutor +import org.ysb33r.grolifant.api.core.ClosureUtils import javax.inject.Inject @@ -61,7 +62,7 @@ class AsciidoctorTask extends AbstractAsciidoctorTask { * @param cfg Closure which will delegate to a {@link org.asciidoctor.gradle.base.OutputOptions} instance. */ void outputOptions(@DelegatesTo(OutputOptions) Closure cfg) { - outputOptions.configureOutputOptions(cfg) + ClosureUtils.configureItem(outputOptions, cfg) } /** Configures output options for this task. @@ -70,13 +71,14 @@ class AsciidoctorTask extends AbstractAsciidoctorTask { * to configure. */ void outputOptions(Action cfg) { - outputOptions.configureOutputOptions(cfg) + cfg.execute(outputOptions) } @Inject AsciidoctorTask(WorkerExecutor we) { super(we) final String taskPrefix = 'asciidoctor' + executionMode = JAVA_EXEC // TODO: Remove this as it is just for testing String folderName if (name.startsWith(taskPrefix)) { folderName = name.replaceFirst(taskPrefix, 'asciidoc') diff --git a/jvm/src/main/groovy/org/asciidoctor/gradle/remote/AsciidoctorJavaExec.groovy b/jvm/src/main/groovy/org/asciidoctor/gradle/remote/AsciidoctorJavaExec.groovy index f6c2be8b4..97688b4aa 100644 --- a/jvm/src/main/groovy/org/asciidoctor/gradle/remote/AsciidoctorJavaExec.groovy +++ b/jvm/src/main/groovy/org/asciidoctor/gradle/remote/AsciidoctorJavaExec.groovy @@ -116,15 +116,13 @@ class AsciidoctorJavaExec extends ExecutorBase { extensionRegistry.registerExtensionsWith((Asciidoctor) asciidoctor) } - private Asciidoctor getAsciidoctorInstance() { - String combinedGemPath = runConfigurations*.gemPath.findAll { it }.join(File.pathSeparator) - boolean noGemPath = combinedGemPath.empty || combinedGemPath == File.pathSeparator - noGemPath ? create() : create(combinedGemPath) - } - private void addRequires(Asciidoctor asciidoctor) { runConfigurations.each { runConfiguration -> asciidoctor.requireLibraries(runConfiguration.requires) } } + + private Asciidoctor getAsciidoctorInstance() { + create() + } } diff --git a/jvm/src/main/groovy/org/asciidoctor/gradle/remote/AsciidoctorWorkerExecutor.groovy b/jvm/src/main/groovy/org/asciidoctor/gradle/remote/AsciidoctorWorkerExecutor.groovy index 519eeb6dd..27fc226b5 100644 --- a/jvm/src/main/groovy/org/asciidoctor/gradle/remote/AsciidoctorWorkerExecutor.groovy +++ b/jvm/src/main/groovy/org/asciidoctor/gradle/remote/AsciidoctorWorkerExecutor.groovy @@ -65,12 +65,10 @@ class AsciidoctorWorkerExecutor implements WorkerAppExecutor +// asciidoctor.requireLibraries(runConfiguration.requires) +// } +// } } diff --git a/jvm/src/remoteTest/groovy/org/asciidoctor/gradle/remote/AsciidoctorJavaExecSpec.groovy b/jvm/src/remoteTest/groovy/org/asciidoctor/gradle/remote/AsciidoctorJavaExecSpec.groovy index f3668a294..cf2233c44 100644 --- a/jvm/src/remoteTest/groovy/org/asciidoctor/gradle/remote/AsciidoctorJavaExecSpec.groovy +++ b/jvm/src/remoteTest/groovy/org/asciidoctor/gradle/remote/AsciidoctorJavaExecSpec.groovy @@ -40,7 +40,7 @@ class AsciidoctorJavaExecSpec extends RemoteSpecification { ExecutorConfigurationContainer ecc = getContainerMultipleEntries( asciidoc.src, asciidoc.outputDir, - asciidoc.gemPath + null // asciidoc.gemPath ) ecc.toFile(executionData, ecc.configurations) diff --git a/jvm/src/remoteTest/groovy/org/asciidoctor/gradle/remote/internal/RemoteSpecification.groovy b/jvm/src/remoteTest/groovy/org/asciidoctor/gradle/remote/internal/RemoteSpecification.groovy index dec699174..d2570b767 100644 --- a/jvm/src/remoteTest/groovy/org/asciidoctor/gradle/remote/internal/RemoteSpecification.groovy +++ b/jvm/src/remoteTest/groovy/org/asciidoctor/gradle/remote/internal/RemoteSpecification.groovy @@ -107,7 +107,7 @@ in a subdirectory executorLogLevel: ExecutorLogLevel.DEBUG, failureLevel: failureLevel, requires: requires, - gemPath: (altOptions ? gemDir.absolutePath : '') +// gemPath: (altOptions ? gemDir.absolutePath : '') ) } } diff --git a/jvm/src/test/groovy/org/asciidoctor/gradle/internal/ExecutorConfigurationSpec.groovy b/jvm/src/test/groovy/org/asciidoctor/gradle/internal/ExecutorConfigurationSpec.groovy index 657850299..bbe343191 100644 --- a/jvm/src/test/groovy/org/asciidoctor/gradle/internal/ExecutorConfigurationSpec.groovy +++ b/jvm/src/test/groovy/org/asciidoctor/gradle/internal/ExecutorConfigurationSpec.groovy @@ -32,7 +32,6 @@ class ExecutorConfigurationSpec extends Specification { sourceTree: [fake] as Set, fatalMessagePatterns: [~/./], backendName: 'backend', - gemPath : 'gem:path', logDocuments: true, copyResources: true, legacyAttributes: true, diff --git a/jvm/src/test/groovy/org/asciidoctor/gradle/jvm/AsciidoctorTaskSpec.groovy b/jvm/src/test/groovy/org/asciidoctor/gradle/jvm/AsciidoctorTaskSpec.groovy index 4aadb289e..8aebb614a 100755 --- a/jvm/src/test/groovy/org/asciidoctor/gradle/jvm/AsciidoctorTaskSpec.groovy +++ b/jvm/src/test/groovy/org/asciidoctor/gradle/jvm/AsciidoctorTaskSpec.groovy @@ -410,47 +410,6 @@ class AsciidoctorTaskSpec extends Specification { !systemOut.toString().contains('deprecated') } - void "Allow setting of gemPath via method"() { - when: - final task = createTask { - asciidoctorj { - gemPaths project.projectDir - } - } - - then: - !systemOut.toString().contains('deprecated') - task.asciidoctorj.asGemPath() == project.projectDir.absolutePath - } - - void "When setting gemPath via assignment"() { - when: - final task = createTask { - asciidoctorj { - gemPaths = [project.projectDir] - } - } - - then: - task.asciidoctorj.asGemPath() == project.projectDir.absolutePath - !systemOut.toString().contains('deprecated') - } - - void "When setting gemPath via setGemPaths"() { - when: - project.allprojects { - asciidoctorj { - gemPaths = [project.projectDir] - } - } - final task = createTask { - } - - then: - task.asciidoctorj.asGemPath() == project.projectDir.absolutePath - !systemOut.toString().contains('deprecated') - } - void 'When attribute providers are registered on the task, then global ones will not be used.'() { when: final task = createTask { @@ -465,10 +424,6 @@ class AsciidoctorTaskSpec extends Specification { task.attributeProviders != project.extensions.getByType(AsciidoctorJExtension).attributeProviders } - void 'Set processMode via string'() { - c - } - void 'Asciidoctor task with non-default name has different source directory'() { when: AsciidoctorTask task = project.tasks.create(name: 'kilowatt', type: AsciidoctorTask) diff --git a/module-versions.properties b/module-versions.properties index 2b6483500..e8c4fdf71 100644 --- a/module-versions.properties +++ b/module-versions.properties @@ -4,7 +4,7 @@ asciidoctorj=2.5.7 asciidoctorj.groovydsl=2.0.2 asciidoctorj.diagram=2.2.3 -asciidoctorj.pdf=2.3.4 +asciidoctorj.pdf=2.3.10 asciidoctorj.epub=1.5.1 asciidoctorj.leanpub=2.0-alpha.2 diff --git a/settings.gradle b/settings.gradle index e3a175964..5092d0b05 100644 --- a/settings.gradle +++ b/settings.gradle @@ -19,17 +19,19 @@ include 'asciidoctoreditorconfig' project(":${it}").name = "asciidoctor-gradle-${it}" } +[ 'pdf','epub'/*, 'leanpub' */ ].each { + include "jvm-${it}" + project(":jvm-${it}").name = "asciidoctor-gradle-jvm-${it}" +} + ////[ 'slides-export' ].each { //// include it //// project(":${it}").name = "asciidoctor-gradle-${it}" ////} // -//[ 'epub', 'pdf', 'leanpub' ].each { -// include "jvm-${it}" -// project(":jvm-${it}").name = "asciidoctor-gradle-jvm-${it}" -//} -// -//[ 'gems' /*, 'slides'*/ ].each { -// include it -// project(":${it}").name = "asciidoctor-gradle-jvm-${it}" -//} + + +[ 'gems' /*, 'slides'*/ ].each { + include it + project(":${it}").name = "asciidoctor-gradle-jvm-${it}" +} diff --git a/testfixtures/jvm/src/main/groovy/org/asciidoctor/gradle/testfixtures/CachingTestFixture.groovy b/testfixtures/jvm/src/main/groovy/org/asciidoctor/gradle/testfixtures/CachingTestFixture.groovy index 1be37704e..74d9604b9 100644 --- a/testfixtures/jvm/src/main/groovy/org/asciidoctor/gradle/testfixtures/CachingTestFixture.groovy +++ b/testfixtures/jvm/src/main/groovy/org/asciidoctor/gradle/testfixtures/CachingTestFixture.groovy @@ -61,7 +61,7 @@ trait CachingTestFixture { dslType, projectDir, ['clean', task, '--build-cache', '-s'] + buildScanArguments ).build() - assert result.task(task).outcome == outcome + assert result.task(task)?.outcome == outcome } void assertTaskRunsWithOutcome(String task, TaskOutcome outcome) { diff --git a/testfixtures/jvm/src/main/groovy/org/asciidoctor/gradle/testfixtures/FunctionalTestFixture.groovy b/testfixtures/jvm/src/main/groovy/org/asciidoctor/gradle/testfixtures/FunctionalTestFixture.groovy index 29037d631..03eb23963 100644 --- a/testfixtures/jvm/src/main/groovy/org/asciidoctor/gradle/testfixtures/FunctionalTestFixture.groovy +++ b/testfixtures/jvm/src/main/groovy/org/asciidoctor/gradle/testfixtures/FunctionalTestFixture.groovy @@ -27,6 +27,7 @@ import static org.asciidoctor.gradle.testfixtures.FunctionalTestSetup.getOffline * Apply this trait to integration tests. */ @CompileStatic +@SuppressWarnings('DuplicateStringLiteral') trait FunctionalTestFixture { public static final String TEST_REPO_DIR = System.getProperty( @@ -34,8 +35,6 @@ trait FunctionalTestFixture { './testfixtures/offline-repo/build/repo' ) - abstract File getTestProjectDir() - File getProjectDir() { new File(testProjectDir, 'test-project') } File getBuildFile() { new File(projectDir, 'build.gradle') } @@ -66,4 +65,43 @@ trait FunctionalTestFixture { FunctionalTestSetup.getGradleRunner(KOTLIN_DSL, projectDir, taskNames) } + File writeGroovyBuildFile(Collection plugins, String extraContent) { + buildFile.withWriter { w -> + w.println 'plugins {' + plugins.each { p -> + w.println " id '${p}'" + } + w.println '}' + w.println() + w.println(offlineRepositories) + w.println() + w.println(extraContent) + } + buildFile + } + + File writeGroovyBuildFile(String plugin, String extraContent) { + writeGroovyBuildFile([plugin], extraContent) + } + + File writeKotlinBuildFile(Collection plugins, String extraContent) { + buildFileKts.withWriter { w -> + w.println 'plugins {' + plugins.each { p -> + w.println " id (\"${p}\")" + } + w.println '}' + w.println() + w.println(getOfflineRepositories(KOTLIN_DSL)) + w.println() + w.println(extraContent) + } + buildFileKts + } + + File writeKotlinBuildFile(String plugin, String extraContent) { + writeKotlinBuildFile([plugin], extraContent) + } + + abstract File getTestProjectDir() } \ No newline at end of file diff --git a/testfixtures/jvm/src/main/groovy/org/asciidoctor/gradle/testfixtures/GradleTestVersions.groovy b/testfixtures/jvm/src/main/groovy/org/asciidoctor/gradle/testfixtures/GradleTestVersions.groovy index 199fa14b4..7cfe220c8 100644 --- a/testfixtures/jvm/src/main/groovy/org/asciidoctor/gradle/testfixtures/GradleTestVersions.groovy +++ b/testfixtures/jvm/src/main/groovy/org/asciidoctor/gradle/testfixtures/GradleTestVersions.groovy @@ -19,7 +19,7 @@ import groovy.transform.CompileStatic import org.gradle.util.GradleVersion /** - * Verions of Gradle that can be used for testing with TestKit. + * Verisons of Gradle that can be used for testing with TestKit. * * @author Schalk W. Cronjé * @@ -27,8 +27,8 @@ import org.gradle.util.GradleVersion */ @CompileStatic class GradleTestVersions { - public final static String MIN_VERSION = '6.0.1' - public final static String MAX_VERSION = '7.6' + public final static String MIN_VERSION = '7.0.1' + public final static String MAX_VERSION = '8.5' static String latestMinimumOrThis(final String ver) { [GradleVersion.version(MIN_VERSION), GradleVersion.version(ver)].max().version