Skip to content

Commit

Permalink
Update dependencies' versions and improve logging (#4)
Browse files Browse the repository at this point in the history
* Update markdown-page-generator-plugin to 2.3.1

* Update Gradle to 7.1.1

* Update com.gradle.plugin-publish plugin to 0.15

* Remove deprecated config method usages

* Add a test case for Gradle 7.1.1

* Delegate logging from Mojo to Gradle task's logger

* Switch from Travis CI to github actions

* Update build badge

* Update spock to 2.0

* Add test report step to the build

* Change workflow name

* Bump the version to 2.3.1.0 and update compatibility table
  • Loading branch information
monosoul authored Jul 12, 2021
1 parent 51f2d6d commit bf56e3e
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 61 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Build with Gradle
run: ./gradlew build
- name: Publish Test Report
uses: mikepenz/action-junit-report@v2
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Markdown to HTML Page Generator Gradle Plugin
This Gradle plugin's goal is to provide a way of using [the maven markdown-page-generator-plugin by walokra](https://github.com/walokra/markdown-page-generator-plugin).

[![Build Status](https://travis-ci.com/monosoul/markdown-page-generator-gradle-plugin.svg?branch=master)](https://travis-ci.com/monosoul/markdown-page-generator-gradle-plugin)
![Build Status](https://github.com/monosoul/markdown-page-generator-gradle-plugin/actions/workflows/build.yaml/badge.svg)
![GitHub release](https://img.shields.io/github/release/monosoul/markdown-page-generator-gradle-plugin.svg)
![license](https://img.shields.io/github/license/monosoul/markdown-page-generator-gradle-plugin.svg)

Expand All @@ -10,6 +10,7 @@ This Gradle plugin's goal is to provide a way of using [the maven markdown-page-
## Gradle compatibility table
| Plugin version | Gradle version |
|:----------------:|:--------------:|
| 2.3.1.0 | \>= 6.8.3 |
| 2.3.0.0 | \>= 4.9 |
| 2.1.0.1 | \>= 4.9 |
| 2.1.0 | \>= 5.0 |
Expand Down
16 changes: 6 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

group = "com.github.monosoul"
version = "2.3.0.0"
version = "2.3.1.0"

plugins {
`kotlin-dsl`
id("com.gradle.plugin-publish") version "0.14.0"
id("com.gradle.plugin-publish") version "0.15.0"
groovy
}

Expand All @@ -19,16 +19,12 @@ java {
}

repositories {
jcenter()
}

kotlinDslPluginOptions {
experimentalWarning.set(false)
mavenCentral()
}

dependencies {
implementation("com.ruleoftech:markdown-page-generator-plugin:2.3.0")
testImplementation("org.spockframework", "spock-core", "1.3-groovy-2.5") {
implementation("com.ruleoftech:markdown-page-generator-plugin:2.3.1")
testImplementation("org.spockframework:spock-core:2.0-groovy-3.0") {
exclude("org.codehaus.groovy")
}
testImplementation(gradleTestKit())
Expand Down Expand Up @@ -64,7 +60,7 @@ pluginBundle {

tasks {
withType<Test> {
useJUnit()
useJUnitPlatform()

testLogging {
events = setOf(PASSED, SKIPPED, FAILED)
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand Down Expand Up @@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
22 changes: 4 additions & 18 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -64,28 +64,14 @@ echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ open class GenerateHtmlTask : DefaultTask() {
@TaskAction
fun callMavenPlugin() {
val pageGenMojo = MdPageGeneratorMojo()
pageGenMojo.log = LoggerAdapter(logger)
defaultTitle?.let {
pageGenMojo.defaultTitle = it
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.github.monosoul.markdown.page.generator.gradle.plugin

import org.apache.maven.plugin.logging.Log
import org.gradle.api.logging.Logger

class LoggerAdapter(
private val logger: Logger
) : Log {
override fun isDebugEnabled() = logger.isDebugEnabled

override fun debug(content: CharSequence?) = logger.debug(content?.toString())

override fun debug(content: CharSequence?, error: Throwable?) = logger.debug(content?.toString(), error)

override fun debug(error: Throwable?) = logger.debug(null, error)

override fun isInfoEnabled(): Boolean = logger.isInfoEnabled

override fun info(content: CharSequence?) = logger.info(content?.toString())

override fun info(content: CharSequence?, error: Throwable?) = logger.info(content?.toString(), error)

override fun info(error: Throwable?) = logger.info(null, error)

override fun isWarnEnabled(): Boolean = logger.isWarnEnabled

override fun warn(content: CharSequence?) = logger.warn(content?.toString())

override fun warn(content: CharSequence?, error: Throwable?) = logger.warn(content?.toString(), error)

override fun warn(error: Throwable?) = logger.warn(null, error)

override fun isErrorEnabled(): Boolean = logger.isErrorEnabled

override fun error(content: CharSequence?) = logger.error(content?.toString())

override fun error(content: CharSequence?, error: Throwable?) = logger.error(content?.toString(), error)

override fun error(error: Throwable?) = logger.error(null, error)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package com.github.monosoul.markdown.page.generator.gradle.plugin


import org.gradle.testkit.runner.GradleRunner
import org.junit.Rule
import org.junit.rules.TemporaryFolder
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.TempDir
import spock.lang.Unroll

import static org.apache.commons.io.FileUtils.copyDirectory
Expand All @@ -16,29 +15,19 @@ class PluginApplicationSpec extends Specification {

@Shared
def gradleVersions = [
'6.8.3',
'6.2.2',
'6.1.1',
'6.0.1',
'5.6.4',
'5.5.1',
'5.4.1',
'5.3.1',
'5.2.1',
'5.1.1',
'5.0',
'4.10.3',
'4.9'
'7.1.1',
'6.8.3'
]
@Shared
def exampleFileName = 'example'
@Rule
final TemporaryFolder testProjectDir = new TemporaryFolder()

@TempDir
File testProjectDir

def "should work with kotlin dsl and Gradle #gradleVersion"() {
setup:
def buildFile = testProjectDir.newFile('build.gradle.kts')
testProjectDir.newFile('settings.gradle.kts') << "rootProject.name = \"markdownGeneratorTest\""
def buildFile = new File(testProjectDir, 'build.gradle.kts')
new File(testProjectDir, 'settings.gradle.kts') << "rootProject.name = \"markdownGeneratorTest\""
buildFile << """
import com.github.monosoul.markdown.page.generator.gradle.plugin.GenerateHtmlTask
Expand All @@ -63,7 +52,7 @@ class PluginApplicationSpec extends Specification {
copyResources()
when:
def result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withProjectDir(testProjectDir)
.withGradleVersion(gradleVersion)
.withArguments('generateHtml', '--stacktrace')
.withPluginClasspath()
Expand All @@ -72,16 +61,16 @@ class PluginApplicationSpec extends Specification {
result.task(':generateHtml').outcome == SUCCESS
and:
def expectedHtml = new File(getClass().getResource("/html/${exampleFileName}.html").toURI()).text
def actualHtml = new File(testProjectDir.root, "/build/html/${exampleFileName}.html").text
def actualHtml = new File(testProjectDir, "/build/html/${exampleFileName}.html").text
actualHtml == expectedHtml
where:
gradleVersion << gradleVersions
}

def "should work with groovy dsl and Gradle #gradleVersion"() {
setup:
def buildFile = testProjectDir.newFile('build.gradle')
testProjectDir.newFile('settings.gradle') << "rootProject.name = \"markdownGeneratorTest\""
def buildFile = new File(testProjectDir, 'build.gradle')
new File(testProjectDir, 'settings.gradle') << "rootProject.name = \"markdownGeneratorTest\""
buildFile << """
import com.github.monosoul.markdown.page.generator.gradle.plugin.GenerateHtmlTask
Expand All @@ -102,7 +91,7 @@ class PluginApplicationSpec extends Specification {
copyResources()
when:
def result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withProjectDir(testProjectDir)
.withGradleVersion(gradleVersion)
.withArguments('generateHtml', '--stacktrace')
.withPluginClasspath()
Expand All @@ -111,15 +100,15 @@ class PluginApplicationSpec extends Specification {
result.task(':generateHtml').outcome == SUCCESS
and:
def expectedHtml = new File(getClass().getResource("/html/${exampleFileName}.html").toURI()).text
def actualHtml = new File(testProjectDir.root, "/build/html/${exampleFileName}.html").text
def actualHtml = new File(testProjectDir, "/build/html/${exampleFileName}.html").text
actualHtml == expectedHtml
where:
gradleVersion << gradleVersions
}

def copyResources() {
def markdown = new File(getClass().getResource('/markdown').toURI())
def target = testProjectDir.newFolder('src', 'main', 'resources', 'markdown')
def target = new File(testProjectDir, 'src/main/resources/markdown')
copyDirectory(markdown, target)
}
}

0 comments on commit bf56e3e

Please sign in to comment.