Skip to content

Commit

Permalink
Update JVM & JS core plugins to work with Grolifant 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ysb33r committed Dec 28, 2023
1 parent 0fbe887 commit 719c951
Show file tree
Hide file tree
Showing 181 changed files with 5,997 additions and 2,781 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ out
buildSrc/gradle/wrapper
buildSrc/gradlew*
.asciidoctor-module-versions.generated

.generated-src/
# Because we auto-generate this from the main project
# and it is only needed for IntelliJ
docs/gradle/wrapper
Expand Down
3 changes: 3 additions & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=8.0.302-open
20 changes: 12 additions & 8 deletions asciidoctoreditorconfig/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
configurations {
additionalPluginClasspath
agProject {
withAdditionalPluginClasspath()
}

dependencies {
implementation project(':asciidoctor-gradle-base')
additionalPluginClasspath project(':asciidoctor-gradle-jvm')
}

pluginUnderTestMetadata {
pluginClasspath.from configurations.additionalPluginClasspath
gradlePlugin {
plugins {
aecPlugin {
id = 'org.asciidoctor.editorconfig'
displayName = 'Asciidoctor Editor Config Plugin'
description = "Generate .asciidoctorconfig files for use by supported IDEs${pluginExtraText}"
// tags.set(['asciidoctor', 'intellij', 'idea'])
implementationClass = 'org.asciidoctor.gradle.editorconfig.AsciidoctorEditorConfigPlugin'
}
}
}

configurePlugin 'org.asciidoctor.editorconfig',
'Asciidoctor Editor Config Plugin',
'Generate .asciidoctorconfig files for use by supported IDEs',
['asciidoctor', 'intellij', 'idea']

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 @@ -31,7 +31,7 @@ class AsciidoctorEditorConfigIntegrationSpec extends FunctionalSpecification {
String groupName = 'the.group'
String projVer = '1.0.0'

File attrFile = new File(testProjectDir.root, 'inputs.adoc')
File attrFile = new File(projectDir, 'inputs.adoc')
attrFile.text = ":${key3}: ${value3}\n"

getGroovyBuildFile("""
Expand All @@ -51,8 +51,8 @@ class AsciidoctorEditorConfigIntegrationSpec extends FunctionalSpecification {
}
""")

File outputFile = new File(testProjectDir.root, '.asciidoctorconfig')
new File(testProjectDir.root, 'settings.gradle').text = "rootProject.name='${projName}'"
File outputFile = new File(projectDir, '.asciidoctorconfig')
settingsFile.text = "rootProject.name='${projName}'"

when:
getGradleRunner(['asciidoctorEditorConfig']).build()
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 @@ -17,56 +17,50 @@ package org.asciidoctor.gradle.editorconfig.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 {

public static final String TEST_PROJECTS_DIR = System.getProperty(
'TEST_PROJECTS_DIR',
'./asciidoctoreditorconfig/src/intTest/projects'
'TEST_PROJECTS_DIR',
'./asciidoctoreditorconfig/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'
)

@Rule
TemporaryFolder testProjectDir
@TempDir
File testProjectDir

void setup() {
projectDir.mkdirs()
}

@CompileStatic
GradleRunner getGradleRunner(List<String> taskNames = ['tasks']) {
FunctionalTestSetup.getGradleRunner(GROOVY_DSL, testProjectDir.root, taskNames)
FunctionalTestSetup.getGradleRunner(GROOVY_DSL, projectDir, taskNames)
}

@CompileStatic
GradleRunner getGradleRunnerForKotlin(List<String> taskNames = ['tasks']) {
FunctionalTestSetup.getGradleRunner(KOTLIN_DSL, testProjectDir.root, taskNames)
FunctionalTestSetup.getGradleRunner(KOTLIN_DSL, projectDir, taskNames)
}

@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))
FileUtils.copyDirectory(new File(TEST_PROJECTS_DIR, docGroup), projectDir)
}

File getGroovyBuildFile(String extraContent, String plugin = 'org.asciidoctor.editorconfig') {
File buildFile = testProjectDir.newFile('build.gradle')
buildFile << """
plugins {
id '${plugin}'
Expand All @@ -80,8 +74,7 @@ class FunctionalSpecification extends Specification {
}

File getKotlinBuildFile(String extraContent, String plugin = 'org.asciidoctor.editorconfig') {
File buildFile = testProjectDir.newFile('build.gradle.kts')
buildFile << """
buildFileKts << """
plugins {
id("${plugin}")
}
Expand All @@ -90,7 +83,7 @@ class FunctionalSpecification extends Specification {
${extraContent}
"""
buildFile
buildFileKts
}

}
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 @@ -30,7 +30,8 @@ import org.ysb33r.grolifant.api.core.ProjectOperations

import java.util.concurrent.Callable

/** Generates {@code .asciidoctorconfig} file.
/**
* Generates {@code .asciidoctorconfig} file.
*
* When the file is generated attributes are applied in the following order.
* <ol>
Expand Down Expand Up @@ -61,7 +62,8 @@ class AsciidoctorEditorConfigGenerator extends DefaultTask {
} as Callable<File>)
}

/** Replace existing attributes with a new set.
/**
* Replace existing attributes with a new set.
*
* @param attrs Replacement attributes
*/
Expand All @@ -70,7 +72,8 @@ class AsciidoctorEditorConfigGenerator extends DefaultTask {
this.attributes.putAll(attrs)
}

/** Add more attributes to the existing set
/**
* Add more attributes to the existing set
*
* @param attrs Additional attributes.
*/
Expand All @@ -87,19 +90,19 @@ class AsciidoctorEditorConfigGenerator extends DefaultTask {
projectOperations.stringTools.stringizeValues(this.attributes)
}

/** Add an additional attribute provider.
/**
* Add an additional attribute provider.
*
* A provider can be a file of something that implements {@link AsciidoctorAttributeProvider} (such as
* an {@code asciidoctorj} or {@code asciidoctorjs extension}).
*
*
* @param attrs Anything convertible to a file using {@code project.file} or that implements
* {@link AsciidoctorAttributeProvider}.
*/
void additionalAttributes(Object attrs) {
switch (attrs) {
case AsciidoctorAttributeProvider:
this.attributeProviders.add(project.provider({
this.attributeProviders.add(projectOperations.provider({
projectOperations.stringTools.stringizeValues(((AsciidoctorAttributeProvider) attrs).attributes)
} as Callable<Map<String, String>>))
break
Expand All @@ -110,7 +113,8 @@ class AsciidoctorEditorConfigGenerator extends DefaultTask {
}
}

/** Returns list of file providers.
/**
* Returns list of file providers.
*
* Content of these files will simply be appended to the genrated content.
*
Expand All @@ -122,7 +126,8 @@ class AsciidoctorEditorConfigGenerator extends DefaultTask {
this.fileProviders
}

/** Returns list of attribute providers. THese providers will return attributes as key-value pairs.
/**
* Returns list of attribute providers. THese providers will return attributes as key-value pairs.
*
* @return List of attribute providers
*/
Expand All @@ -131,24 +136,27 @@ class AsciidoctorEditorConfigGenerator extends DefaultTask {
this.attributeProviders
}

/** Destination directory. Defaults to the project directory.
/**
* Destination directory. Defaults to the project directory.
*
* @return Directory
*/
@Internal
File getDestinationDir() {
project.file(this.outputDir)
projectOperations.fsOperations.file(this.outputDir)
}

/** Sets destination directory.
/**
* Sets destination directory.
*
* @param dir Anything convertible to a directory using {@code project.file}.
*/
void setDestinationDir(Object dir) {
this.outputDir = dir
}

/** Location of generated {@code .asciidoctorconfig} file.
/**
* Location of generated {@code .asciidoctorconfig} file.
*
* @return File location.
*/
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

This file was deleted.

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
22 changes: 14 additions & 8 deletions base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
* limitations under the License.
*/

configurePlugin 'org.asciidoctor.base',
'Asciidoctor Base Plugin',
'Base plugin for all asciidoctor document conversion plugins (AsciidoctorJ & AsciidoctorJS)',
[ ]


pluginManager.withPlugin('jacoco') {
jacocoTestReport {
executionData.setFrom(fileTree('.') { exclude '**' })
Expand All @@ -29,6 +23,18 @@ pluginManager.withPlugin('jacoco') {
}
}

configurations.gradleTestCompile.transitive = false
configurations {
gradleTestCompile.transitive = false
}

validateTaskProperties.enabled = false
gradlePlugin {
plugins {
basePlugin {
id = "org.asciidoctor.base"
displayName = 'Asciidoctor Base Plugin'
description = "Base plugin for all asciidoctor document conversion plugins (AsciidoctorJ & AsciidoctorJS)${pluginExtraText}"
// tags.set(['asciidoctor'])
implementationClass = 'org.asciidoctor.gradle.base.AsciidoctorBasePlugin'
}
}
}
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
Loading

0 comments on commit 719c951

Please sign in to comment.