Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-enable slides project #739

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java temurin-11.0.24+8
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ class DefaultAsciidoctorFileOperations implements AsciidoctorTaskFileOperations,
* @param backendName Name of backend
* @return Output directory.
*/
protected File getOutputDirFor(final String backendName) {
File getOutputDirFor(final String backendName) {
if (outputDir == null) {
throw new GradleException("outputDir has not been defined for task '${taskName}'")
}
Expand Down
48 changes: 35 additions & 13 deletions jvm-slides/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,51 @@
import org.ysb33r.gradle.gradletest.GradleTest

agProject {
withOfflineTestConfigurations()

configurePlugin(
'org.asciidoctor.jvm.revealjs.base',
'AsciidoctorJ Reveal.js Base Plugin',
'Base plugin for all AsciidoctorJ Reveal.js tasks & extensions. Provides the revealjs and revealjsPlugins project extensions.',
'org.asciidoctor.gradle.jvm.slides.AsciidoctorRevealJSBasePlugin',
['asciidoctorj', 'reveal.js', 'slides']
)

configurePlugin(
'org.asciidoctor.jvm.revealjs',
'AsciidoctorJ Reveal.js Plugin',
'Plugin for generating Reveal.JS based slides from Asciidoc source using AsciidoctorJ. Provides the asciidoctorRevealJs task.',
'org.asciidoctor.gradle.jvm.slides.AsciidoctorRevealJSPlugin',
['asciidoctorj', 'reveal.js', 'slides']
)
}

generateModuleVersions {
basename = 'revealjs-extension'
propertyNames ~/^revealjs\./
}

dependencies {
api project(':asciidoctor-gradle-jvm')
implementation project(':asciidoctor-gradle-base')
implementation project(':asciidoctor-gradle-jvm-gems')
implementation "com.github.jruby-gradle:jruby-gradle-core-plugin:${jrubyGradleVersion}"
implementation "org.ysb33r.gradle.jruby:jrubygradle-resolver:${pluginJrubySimpleVersion}"
}

intTest {
enabled = !gradle.startParameter.isOffline()
tasks.named('intTest', Test) {
systemProperties TEST_PROJECTS_DIR: file('src/intTest/projects')
maxParallelForks = 4
forkEvery = 7
}

gradleTest {
enabled = !gradle.startParameter.isOffline()
tasks.named('test', Test) {
dependsOn ':testfixtures-offline-repo:buildOfflineRepositories'
systemProperties OFFLINE_REPO: offlineRepoRoot.absolutePath
}

configurePlugin 'org.asciidoctor.jvm.revealjs.base',
'AsciidoctorJ Reveal.js Base Plugin',
'Base plugin for all AsciidoctorJ Reveal.js tasks & extensions. Provides the revealjs and revealjsPlugins project extensions.',
['asciidoctorj', 'reveal.js', 'slides']
tasks.named('gradleTest', GradleTest) {
systemProperties ASCIIDOCTORJ_VERSION: compileOnlyAsciidoctorJVersion
systemProperties GROOVY_VERSION: GroovySystem.version

configurePlugin 'org.asciidoctor.jvm.revealjs',
'AsciidoctorJ Reveal.js Plugin',
'Plugin for generating Reveal.JS based slides from Asciidoc source using AsciidoctorJ. Provides the ascidoctorRevealJs task.',
['asciidoctorj', 'reveal.js', 'slides']
gradleArguments '-i', '-s'
}
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -16,14 +16,14 @@
package org.asciidoctor.gradle.jvm.slides

import org.asciidoctor.gradle.jvm.slides.internal.FunctionalSpecification
import org.asciidoctor.gradle.testfixtures.CachingTest
import org.asciidoctor.gradle.testfixtures.CachingTestFixture
import spock.lang.Issue
import spock.lang.PendingFeature

import static java.util.Collections.emptyList
import static org.asciidoctor.gradle.testfixtures.JRubyTestVersions.AJ20_SAFE_MAXIMUM

@SuppressWarnings(['UnnecessaryGetter'])
class AsciidoctorRevealJSTaskCachingFunctionalSpec extends FunctionalSpecification implements CachingTest {
class AsciidoctorRevealJSTaskCachingFunctionalSpec extends FunctionalSpecification implements CachingTestFixture {
private static final String DEFAULT_TASK = 'asciidoctorRevealJs'
private static final String JRUBY_TEST_VERSION = AJ20_SAFE_MAXIMUM
private static final String DEFAULT_REVEALJS_PATH = 'build/docs/asciidocRevealJs'
Expand All @@ -37,7 +37,7 @@ class AsciidoctorRevealJSTaskCachingFunctionalSpec extends FunctionalSpecificati
@Issue('https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/485')
void "Revealjs task is cacheable and relocatable"() {
given:
getBuildFile()
buildFile

when:
assertDefaultTaskExecutes()
Expand All @@ -57,7 +57,7 @@ class AsciidoctorRevealJSTaskCachingFunctionalSpec extends FunctionalSpecificati
@Issue('https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/485')
void "Revealjs task is cached when only output directory is changed"() {
given:
getBuildFile()
buildFile

when:
assertDefaultTaskExecutes()
Expand All @@ -84,7 +84,7 @@ class AsciidoctorRevealJSTaskCachingFunctionalSpec extends FunctionalSpecificati
@Issue('https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/485')
void "Revealjs task is not cached when templates are added"() {
given:
getBuildFile()
buildFile

when:
assertDefaultTaskExecutes()
Expand Down Expand Up @@ -195,7 +195,6 @@ class AsciidoctorRevealJSTaskCachingFunctionalSpec extends FunctionalSpecificati

@Override
File getBuildFile(String extraContent) {
File buildFile = testProjectDir.newFile('build.gradle')
buildFile << """
plugins {
id 'org.asciidoctor.jvm.revealjs'
Expand Down Expand Up @@ -234,4 +233,9 @@ class AsciidoctorRevealJSTaskCachingFunctionalSpec extends FunctionalSpecificati
String getDefaultTask() {
":${DEFAULT_TASK}"
}

@Override
List<String> getBuildScanArguments() {
emptyList()
}
}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -38,12 +38,12 @@ class AsciidoctorRevealJSTaskFunctionalSpec extends FunctionalSpecification {

then:
verifyAll {
new File(testProjectDir.root, 'build/docs/asciidocRevealJs/revealjs.html').exists()
new File(testProjectDir.root, 'build/docs/asciidocRevealJs/subdir/revealjs2.html').exists()
new File(testProjectDir.root, "${DEFAULT_REVEALJS_PATH}/css").exists()
new File(testProjectDir.root, "${DEFAULT_REVEALJS_PATH}/lib").exists()
new File(testProjectDir.root, "${DEFAULT_REVEALJS_PATH}/plugin").exists()
new File(testProjectDir.root, "${DEFAULT_REVEALJS_PATH}/js").exists()
new File(projectDir, 'build/docs/asciidocRevealJs/revealjs.html').exists()
new File(projectDir, 'build/docs/asciidocRevealJs/subdir/revealjs2.html').exists()
new File(projectDir, "${DEFAULT_REVEALJS_PATH}/css").exists()
new File(projectDir, "${DEFAULT_REVEALJS_PATH}/lib").exists()
new File(projectDir, "${DEFAULT_REVEALJS_PATH}/plugin").exists()
new File(projectDir, "${DEFAULT_REVEALJS_PATH}/js").exists()
}
}

Expand All @@ -64,9 +64,9 @@ class AsciidoctorRevealJSTaskFunctionalSpec extends FunctionalSpecification {

then:
verifyAll {
new File(testProjectDir.root, 'build/docs/asciidocRevealJs/revealjs.html').exists()
new File(testProjectDir.root, 'build/github-cache/hakimel/reveal.js/3.6.0').exists()
new File(testProjectDir.root, "${DEFAULT_REVEALJS_PATH}/js/reveal.js").
new File(projectDir, 'build/docs/asciidocRevealJs/revealjs.html').exists()
new File(projectDir, 'build/github-cache/hakimel/reveal.js/3.6.0').exists()
new File(projectDir, "${DEFAULT_REVEALJS_PATH}/js/reveal.js").
text.contains('var VERSION = \'3.6.0\';')
}
}
Expand All @@ -93,9 +93,9 @@ class AsciidoctorRevealJSTaskFunctionalSpec extends FunctionalSpecification {

when:
build()
String revealjsHtml = new File(testProjectDir.root, 'build/docs/asciidocRevealJs/revealjs.html').text
String pluginConfig = new File(testProjectDir.root, 'src/docs/asciidoc/empty-plugin-configuration.js').text
File pluginList = new File(testProjectDir.root, "${DEFAULT_REVEALJS_PATH}/revealjs-plugins.js")
String revealjsHtml = new File(projectDir, 'build/docs/asciidocRevealJs/revealjs.html').text
String pluginConfig = new File(projectDir, 'src/docs/asciidoc/empty-plugin-configuration.js').text
File pluginList = new File(projectDir, "${DEFAULT_REVEALJS_PATH}/revealjs-plugins.js")

then:
verifyAll {
Expand All @@ -104,7 +104,7 @@ class AsciidoctorRevealJSTaskFunctionalSpec extends FunctionalSpecification {
revealjsHtml.contains("src: '${REVEALJS_DIR_NAME}/plugin/print-pdf/")
revealjsHtml.contains("src: '${REVEALJS_DIR_NAME}/plugin/rajgoel/chart/plugin.js'")
revealjsHtml.contains(pluginConfig)
new File(testProjectDir.root, "${DEFAULT_REVEALJS_PATH}/plugin/rajgoel/chart/plugin.js").exists()
new File(projectDir, "${DEFAULT_REVEALJS_PATH}/plugin/rajgoel/chart/plugin.js").exists()
}
}

Expand All @@ -113,7 +113,6 @@ class AsciidoctorRevealJSTaskFunctionalSpec extends FunctionalSpecification {
}

File getBuildFile(String extraContent) {
File buildFile = testProjectDir.newFile('build.gradle')
buildFile << """
plugins {
id 'org.asciidoctor.jvm.revealjs'
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -35,7 +35,7 @@ class AsciidoctorSlidesAndConvertPluginsCoexistFunctionalSpec extends Functional

then:
verifyAll {
new File(testProjectDir.root, 'build/docs/asciidoc/sample.html').exists()
new File(projectDir, 'build/docs/asciidoc/sample.html').exists()
}
}

Expand All @@ -44,7 +44,6 @@ class AsciidoctorSlidesAndConvertPluginsCoexistFunctionalSpec extends Functional
}

File createBuildFile(String extraContent = '') {
File buildFile = testProjectDir.newFile('build.gradle')
buildFile << """
plugins {
id 'org.asciidoctor.jvm.revealjs'
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -15,42 +15,44 @@
*/
package org.asciidoctor.gradle.jvm.slides.internal

import groovy.transform.CompileStatic
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.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 {
public static final String TEST_PROJECTS_DIR = System.getProperty(
'TEST_PROJECTS_DIR',
'./src/intTest/projects'
)
public static final String TEST_REPO_DIR = System.getProperty(
'OFFLINE_REPO',
'../testfixtures/offline-repo/build/repo'
)
import static org.asciidoctor.gradle.testfixtures.DslType.GROOVY_DSL

class FunctionalSpecification extends Specification implements FunctionalTestFixture {

@SuppressWarnings('LineLength')
static
final String TEST_PROJECTS_DIR = System.getProperty('TEST_PROJECTS_DIR', './src/intTest/projects')
static
final String TEST_REPO_DIR = FunctionalTestSetup.offlineRepo.absolutePath
public static final OperatingSystem OS = OperatingSystem.current()

@Rule
TemporaryFolder testProjectDir
@TempDir
File testProjectDir

@Rule
TemporaryFolder alternateProjectDir
@TempDir
File alternateProjectDir

void setup() {
projectDir.mkdirs()
}

GradleRunner getGradleRunner(List<String> taskNames) {
GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withArguments(taskNames)
.withPluginClasspath()
.forwardOutput()
.withDebug(true)
@CompileStatic
GradleRunner getGradleRunner(List<String> taskNames = ['asciidoctor']) {
FunctionalTestSetup.getGradleRunner(GROOVY_DSL, projectDir, taskNames)//.withTestKitDir(testKitDir)
}

@SuppressWarnings(['BuilderMethodWithSideEffects'])
void createTestProject(String docGroup) {
FileUtils.copyDirectory(new File(TEST_PROJECTS_DIR, docGroup), testProjectDir.root)
void createTestProject(String docGroup = 'normal') {
FileUtils.copyDirectory(new File(TEST_PROJECTS_DIR, docGroup), projectDir)
}

String getOfflineRepositories() {
Expand All @@ -67,4 +69,4 @@ class FunctionalSpecification extends Specification {
"apply from: '${repo.absolutePath}'"
}
}
}
}
Loading
Loading