diff --git a/.travis.yml b/.travis.yml index 9f1ae3386..30affa63f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ before_install: install: true script: -- "./gradlew check -i" +- "./gradlew check" after_failure: - "./gradlew clean check -debug --stacktrace" diff --git a/build.gradle b/build.gradle index 74080ad1e..dcc410da6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,41 +1,16 @@ plugins { id "eclipse" id "idea" - id "io.sdkman.vendors" version "1.1.1" apply false - id "com.jfrog.bintray" version "1.8.4" apply false - id "com.github.kt3k.coveralls" version "2.8.2" apply false - id "org.sonarqube" version "2.7" apply false - id 'com.github.ben-manes.versions' version '0.20.0' - id "nebula.optional-base" version "5.0.0" apply false + id "io.sdkman.vendors" version "1.2.1" apply false + id "com.jfrog.bintray" version "1.8.5" apply false + id "com.github.kt3k.coveralls" version "2.10.1" apply false + id "org.sonarqube" version "2.8" apply false + id 'com.github.ben-manes.versions' version '0.28.0' + id "nebula.optional-base" version "5.0.3" apply false } // common variables ext { - asciidoctorjVersion = '1.5.8.1' - asciidoctorjDiagramVersion = '1.5.11' - commonsIoVersion = '2.6' - commonsConfigurationVersion = '1.10' - commonsLangVersion = '3.8.1' - commonsVfs2Version = '2.2' - args4jVersion = '2.33' - freemarkerVersion = '2.3.28' - junit4Version = '4.12' - junit5Version = '5.3.1' - junitPioneer = '0.2.2' - flexmarkVersion = '0.40.8' - jettyServerVersion = '9.4.12.v20180830' - orientDbVersion = '3.0.14' - groovyVersion = '2.5.5' - slf4jVersion = '1.7.25' - logbackVersion = '1.2.3' - assertjCoreVersion = '2.9.1' - thymeleafVersion = '3.0.11.RELEASE' - jsonSimpleVersion = '1.1.1' - jade4jVersion = '1.2.7' - mockitoVersion = '2.23.4' - jsoupVersion = '1.11.3' - pebbleVersion = '3.0.7' - isTravis = (System.getenv("TRAVIS") == "true") isTravisPullRequest = (System.getenv("TRAVIS_PULL_REQUEST")) != "false" pullRequestId = System.getenv("TRAVIS_PULL_REQUEST") @@ -91,10 +66,11 @@ subprojects { apply plugin: 'java' apply plugin: 'nebula.optional-base' - apply from: "$rootDir/gradle/signing.gradle" // We do not publish any jars from the jbake-dist project if ( project.name != "jbake-dist" ) { apply from: "$rootDir/gradle/maven-publishing.gradle" + apply from: "$rootDir/gradle/signing.gradle" + apply from: "$rootDir/gradle/publishing.gradle" } // add source and target compatibility for all JavaCompile tasks @@ -117,25 +93,25 @@ subprojects { } dependencies { - compile "org.slf4j:slf4j-api:$slf4jVersion" - compile "org.slf4j:jul-to-slf4j:$slf4jVersion" - compile "org.slf4j:jcl-over-slf4j:$slf4jVersion" - compile "ch.qos.logback:logback-classic:$logbackVersion", optional - compile "ch.qos.logback:logback-core:$logbackVersion", optional - - testCompile("org.junit.jupiter:junit-jupiter-api:$junit5Version") - testRuntime("org.junit.jupiter:junit-jupiter-engine:$junit5Version") - testCompile("org.junit-pioneer:junit-pioneer:$junitPioneer") + implementation "org.slf4j:slf4j-api:$slf4jVersion" + implementation "org.slf4j:jul-to-slf4j:$slf4jVersion" + implementation "org.slf4j:jcl-over-slf4j:$slf4jVersion" + implementation "ch.qos.logback:logback-classic:$logbackVersion", optional + implementation "ch.qos.logback:logback-core:$logbackVersion", optional + + testImplementation "org.junit-pioneer:junit-pioneer:$junitPioneer" + testImplementation "org.junit.jupiter:junit-jupiter-api:$junit5Version" + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version" // compatibility for Junit 4 test - testCompile "junit:junit:$junit4Version" - testRuntime("org.junit.vintage:junit-vintage-engine:$junit5Version") + testCompileOnly "junit:junit:$junit4Version" + testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$junit5Version" - testCompile "org.assertj:assertj-core:$assertjCoreVersion" - testCompile "org.mockito:mockito-core:$mockitoVersion" - testCompile "org.mockito:mockito-junit-jupiter:$mockitoVersion" + testImplementation "org.assertj:assertj-core:$assertjCoreVersion" + testImplementation "org.mockito:mockito-core:$mockitoVersion" + testImplementation "org.mockito:mockito-junit-jupiter:$mockitoVersion" } - dependencyUpdates.resolutionStrategy = { + dependencyUpdates.resolutionStrategy { componentSelection { rules -> rules.all { ComponentSelection selection -> boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm'].any { qualifier -> @@ -153,13 +129,6 @@ subprojects { def args = ['-Xms512m', '-Xmx3g', '-Dorientdb.installCustomFormatter=false=false','-Djna.nosys=true'] - /** - * AppVeyor breaks with mockito throwing a java.lang.OutOfMemoryError: PermGen space - */ - if ( JavaVersion.current().java7 ) { - args << '-XX:MaxPermSize=2g' - } - /** * jdk9 build is unable to determine the amount of MaxDirectMemorySize * See https://pastebin.com/ECvQeHx0 diff --git a/gradle.properties b/gradle.properties index 7f22f5274..2a685f5e6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,49 @@ -group=org.jbake -version=2.7.0-SNAPSHOT -description=JBake is a Java based open source static site/blog generator for developers. +group = org.jbake +version = 2.7.0-SNAPSHOT +description = JBake is a Java based open source static site/blog generator for developers. -website=http://jbake.org -issues=https://github.com/jbake-org/jbake/issues -vcs=https://github.com/jbake-org/jbake/ +website = http://jbake.org +issues = https://github.com/jbake-org/jbake/issues +vcs = https://github.com/jbake-org/jbake/ -jacocoVersion=0.8.2 +# runtime dependencies +asciidoctorjVersion = 2.2.0 +asciidoctorjDiagramVersion = 2.0.1 +args4jVersion = 2.33 +commonsIoVersion = 2.6 +commonsConfigurationVersion = 1.10 +commonsLangVersion = 3.10 +commonsVfs2Version = 2.6.0 +freemarkerVersion = 2.3.30 +flexmarkVersion = 0.61.0 +groovyVersion = 3.0.2 +jettyServerVersion = 9.4.27.v20200227 +jsonSimpleVersion = 1.1.1 +jade4jVersion = 1.3.2 +jsoupVersion = 1.13.1 +jgitVersion = 5.7.0.202003110725-r +logbackVersion = 1.2.3 +orientDbVersion = 3.0.30 +pebbleVersion = 3.1.2 +slf4jVersion = 1.7.30 +thymeleafVersion = 3.0.11.RELEASE -bintrayDryRun=false -bintrayOrg=jbake -bintrayRepo=maven -bintrayBinaryRepo=binary +# testing dependencies +junit4Version = 4.13 +junit5Version = 5.6.1 +junitPioneer = 0.5.6 +assertjCoreVersion = 3.15.0 +mockitoVersion = 3.3.3 + +# build dependencies +jacocoVersion = 0.8.3 +grgitVersion = 1.6.0 + + +bintrayDryRun = false +bintrayOrg = jbake +bintrayRepo = maven +bintrayBinaryRepo = binary + +org.gradle.caching=true +org.gradle.parallel=true diff --git a/gradle/application.gradle b/gradle/application.gradle index c5a00d301..ed28737e0 100644 --- a/gradle/application.gradle +++ b/gradle/application.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'org.ajoberstar:grgit:1.6.0' + classpath "org.ajoberstar:grgit:$grgitVersion" } } @@ -16,17 +16,16 @@ apply plugin: 'application' mainClassName = "org.jbake.launcher.Main" applicationName = "jbake" -ext { - examplesBase = "$project.buildDir/examples" - exampleRepositories = [ - "example_project_freemarker": "git://github.com/jbake-org/jbake-example-project-freemarker.git", - "example_project_groovy" : "git://github.com/jbake-org/jbake-example-project-groovy.git", - "example_project_thymeleaf" : "git://github.com/jbake-org/jbake-example-project-thymeleaf.git", - "example_project_groovy-mte": "git://github.com/jbake-org/jbake-example-project-groovy-mte.git", - "example_project_jade" : "git://github.com/jbake-org/jbake-example-project-jade.git" - ] -} +def examplesBase = "$project.buildDir/examples" + +def exampleRepositories = [ + "example_project_freemarker": "git://github.com/jbake-org/jbake-example-project-freemarker.git", + "example_project_groovy" : "git://github.com/jbake-org/jbake-example-project-groovy.git", + "example_project_thymeleaf" : "git://github.com/jbake-org/jbake-example-project-thymeleaf.git", + "example_project_groovy-mte": "git://github.com/jbake-org/jbake-example-project-groovy-mte.git", + "example_project_jade" : "git://github.com/jbake-org/jbake-example-project-jade.git" +] processResources { from("src/main/resources"){ @@ -58,8 +57,8 @@ exampleRepositories.each { name, repository -> group "distribution" description "Zip $name repository" - baseName = name - archiveName = "${baseName}.zip" + archiveBaseName = name + archiveFileName = "${archiveBaseName.get()}.zip" from project.tasks.getByName("clone_${name}Repository").outputs exclude 'README.md' diff --git a/gradle/maven-publishing.gradle b/gradle/maven-publishing.gradle index f47ff010d..a1a518be0 100644 --- a/gradle/maven-publishing.gradle +++ b/gradle/maven-publishing.gradle @@ -1,6 +1,6 @@ import java.text.SimpleDateFormat -apply plugin: 'maven' +apply plugin: 'maven-publish' Date buildTimeAndDate = new Date() ext { @@ -9,65 +9,84 @@ ext { isReleaseVersion = !version.endsWith("SNAPSHOT") } -def jbakePom = pom { - project { - name "jbake" - description project.description - url project.website - developers { - developer { - id 'jonbullock' - name 'Jonathan Bullock' - email 'jonbullock@gmail.com' - url 'http://jonathanbullock.com' - timezone 'Europe/London' - } - developer { - id 'ancho' - name 'Frank Becker' - email 'frank@calmdevelopment.de' - timezone 'Europe/Berlin' - } - developer { - id 'manikmagar' - name 'Manik Magar' - url 'https://manik.magar.me/' - timezone 'America/New_York' - } - } - scm { - url project.vcs - connection 'scm:git:git@github.com:jbake-org/jbake.git' - developerConnection 'scm:git:https://github.com/jbake-org/jbake.git' - } - issueManagement { - system 'GitHub Issues' - url project.issues - } - mailingLists { +task javadocJar(type: Jar) { + archiveClassifier.set('javadoc') + from javadoc +} - mailingList { - name 'jbake-dev' - subscribe 'jbake-dev@googlegroups.com' - unsubscribe 'jbake-dev+unsubscribe@googlegroups.com' - archive 'http://groups.google.com/group/jbake-dev' - } - mailingList { - name 'jbake-user' - subscribe 'jbake-user@googlegroups.com' - unsubscribe 'jbake-user+unsubscribe@googlegroups.com' - archive 'http://groups.google.com/group/jbake-user' - } - } +task sourcesJar(type: Jar) { + archiveClassifier.set('sources') + from sourceSets.main.allSource +} + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java - licenses { - license { - name 'The MIT License (MIT)' - url 'http://opensource.org/licenses/MIT' + artifact javadocJar + artifact sourcesJar + + pom { + name = "jbake" + description = project.description + url = project.website + developers { + developer { + id = 'jonbullock' + name = 'Jonathan Bullock' + email = 'jonbullock@gmail.com' + url = 'http://jonathanbullock.com' + timezone = 'Europe/London' + } + developer { + id = 'ancho' + name = 'Frank Becker' + email = 'frank@calmdevelopment.de' + timezone = 'Europe/Berlin' + } + developer { + id = 'manikmagar' + name = 'Manik Magar' + url = 'https://manik.magar.me/' + timezone = 'America/New_York' + } + } + scm { + url = project.vcs + connection = 'scm:git:git@github.com:jbake-org/jbake.git' + developerConnection = 'scm:git:https://github.com/jbake-org/jbake.git' + } + issueManagement { + system = 'GitHub Issues' + url = project.issues + } + mailingLists { + + mailingList { + name = 'jbake-dev' + subscribe = 'jbake-dev@googlegroups.com' + unsubscribe = 'jbake-dev+unsubscribe@googlegroups.com' + archive = 'http://groups.google.com/group/jbake-dev' + } + mailingList { + name = 'jbake-user' + subscribe = 'jbake-user@googlegroups.com' + unsubscribe = 'jbake-user+unsubscribe@googlegroups.com' + archive = 'http://groups.google.com/group/jbake-user' + } + } + + licenses { + license { + name = 'The MIT License (MIT)' + url = 'http://opensource.org/licenses/MIT' + } + } + } } } } -} jar { manifest { @@ -86,22 +105,4 @@ jar { } } -task javadocJar(type: Jar) { - archiveClassifier.set('javadoc') - from javadoc -} -task sourcesJar(type: Jar) { - archiveClassifier.set('sources') - from sourceSets.main.allSource -} - -artifacts { - archives javadocJar, sourcesJar -} - -install { - repositories.mavenInstaller { - setPom jbakePom - } -} diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle index 29513cd10..38135d261 100644 --- a/gradle/publishing.gradle +++ b/gradle/publishing.gradle @@ -3,6 +3,19 @@ apply plugin: 'com.jfrog.bintray' ext.bintrayUsername = project.hasProperty('bintrayUsername') ? bintrayUsername : '' ext.bintrayKey = project.hasProperty('bintrayKey') ? bintrayKey : '' +/* + UGLY HACK to workaround gradle-bintray-plugin compatibility with Gradle 5+ + https://github.com/asciidoctor/asciidoctorj/issues/861 + https://github.com/bintray/gradle-bintray-plugin/issues/300 + WARNING: since the Groovy Gradle API is modified, this breaks build isolation when sharing a common Gradle daemon instance + This works because gradle-bintray-plugin is using Groovy dynamic compilation hence it is affected by Groovy runtime meta-programming + Tested with: Gradle 5.6.3 / gradle-bintray-plugin 1.8.4 + TODO: remove as soon as bintray/gradle-bintray-plugin#300 is fixed and integrated +*/ +Signature.metaClass.getToSignArtifact = { -> + return (delegate as Signature).source +} + if (project.name == "jbake-dist") { /** @@ -56,16 +69,19 @@ if (project.name == "jbake-dist") { bintray { user = bintrayUsername key = bintrayKey - configurations = ['archives'] + publications = ['mavenJava'] if (!project.hasProperty('skipSigning')) { - // Copy the signed pom to bintrayDestination filesSpec { - from signPom - into signPom.bintrayDestination + from("${buildDir}/libs") { + include '*.jar.asc' + } + from("${buildDir}/publications/mavenJava") { + include 'pom-default.xml.asc' + rename 'pom-default.xml.asc', "${project.name}-${project.version}.pom.asc" + } + into "." } - signPom.dependsOn install - bintrayUpload.dependsOn signPom } dryRun = bintrayDryRun.toBoolean() diff --git a/gradle/signing.gradle b/gradle/signing.gradle index cc2c3ebd3..72cc887bb 100644 --- a/gradle/signing.gradle +++ b/gradle/signing.gradle @@ -6,35 +6,14 @@ if ( !project.hasProperty('skipSigning') ) { ext.skipSigning = true } else { - signing { - sign configurations.archives - } - } - - task signPom(type: Sign) { - group "publishing" - description "Sign the projects pom file" - - ext.pom = file("$buildDir/poms/pom-default.xml") - ext.signedPom = file("$buildDir/poms/${project.name}-${project.version}.pom.asc") - ext.bintrayDestination = "${project.group.replace(".", "/")}/${project.name}/${project.version}" - - inputs.file pom - outputs.file signedPom - - doLast { - - def input = pom.newInputStream() - def output = signedPom.newOutputStream() - try { - signatory.sign(input, output) + if ( project.name != "jbake-dist" ) { + signing { + sign publishing.publications.mavenJava } - catch (Exception e) { - logger.error e.message - } - finally { - input.close() - output.close() + } + else { + signing { + sign configurations.archives } } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 87b738cbd..f3d88b1c2 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 44e7c4d1d..a4b442974 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index af6708ff2..2fe81a7d9 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 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 +# +# https://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. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m"' +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -109,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -138,19 +154,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +175,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 6d57edc70..62bd9b9cc 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/jbake-core/build.gradle b/jbake-core/build.gradle index 3e058f912..d7f886ee7 100644 --- a/jbake-core/build.gradle +++ b/jbake-core/build.gradle @@ -1,33 +1,35 @@ import java.text.SimpleDateFormat apply from: "$rootDir/gradle/sonarqube.gradle" -apply from: "$rootDir/gradle/publishing.gradle" +apply plugin: 'java-library' + description = "The core library of JBake" dependencies { - compile "commons-io:commons-io:$commonsIoVersion" - compile "commons-configuration:commons-configuration:$commonsConfigurationVersion" - compile "org.apache.commons:commons-vfs2:$commonsVfs2Version", optional - compile "org.apache.commons:commons-lang3:$commonsLangVersion" - compile("com.googlecode.json-simple:json-simple:$jsonSimpleVersion") { + implementation "commons-io:commons-io:$commonsIoVersion" + implementation "commons-configuration:commons-configuration:$commonsConfigurationVersion" + implementation "org.apache.commons:commons-vfs2:$commonsVfs2Version", optional + implementation "org.apache.commons:commons-lang3:$commonsLangVersion" + implementation("com.googlecode.json-simple:json-simple:$jsonSimpleVersion") { exclude group: "junit", module: "junit" } - compile "com.orientechnologies:orientdb-core:$orientDbVersion" - compile "org.asciidoctor:asciidoctorj:$asciidoctorjVersion", optional - compile "org.codehaus.groovy:groovy-templates:$groovyVersion", optional - compile "org.codehaus.groovy:groovy-dateutil:$groovyVersion", optional - compile "org.freemarker:freemarker:$freemarkerVersion", optional - compile "org.thymeleaf:thymeleaf:$thymeleafVersion", optional - compile "de.neuland-bfi:jade4j:$jade4jVersion", optional - compile "com.vladsch.flexmark:flexmark:$flexmarkVersion", optional - compile "com.vladsch.flexmark:flexmark-profile-pegdown:$flexmarkVersion", optional - compile "org.jsoup:jsoup:$jsoupVersion" - compile "io.pebbletemplates:pebble:$pebbleVersion", optional + implementation "com.orientechnologies:orientdb-core:$orientDbVersion" + implementation "org.asciidoctor:asciidoctorj:$asciidoctorjVersion", optional + implementation "org.codehaus.groovy:groovy:$groovyVersion", optional + implementation "org.codehaus.groovy:groovy-templates:$groovyVersion", optional + implementation "org.codehaus.groovy:groovy-dateutil:$groovyVersion", optional + implementation "org.freemarker:freemarker:$freemarkerVersion", optional + implementation "org.thymeleaf:thymeleaf:$thymeleafVersion", optional + implementation "de.neuland-bfi:jade4j:$jade4jVersion", optional + implementation "com.vladsch.flexmark:flexmark:$flexmarkVersion", optional + implementation "com.vladsch.flexmark:flexmark-profile-pegdown:$flexmarkVersion", optional + implementation "org.jsoup:jsoup:$jsoupVersion" + implementation "io.pebbletemplates:pebble:$pebbleVersion", optional // cli specific dependencies - compile "org.eclipse.jetty:jetty-server:$jettyServerVersion", optional - compile "args4j:args4j:$args4jVersion", optional + implementation "org.eclipse.jetty:jetty-server:$jettyServerVersion", optional + implementation "args4j:args4j:$args4jVersion", optional } processResources { diff --git a/jbake-core/src/main/java/org/jbake/app/ContentStore.java b/jbake-core/src/main/java/org/jbake/app/ContentStore.java index 2ddabc9c7..7bfb4b5c9 100644 --- a/jbake-core/src/main/java/org/jbake/app/ContentStore.java +++ b/jbake-core/src/main/java/org/jbake/app/ContentStore.java @@ -178,10 +178,11 @@ public void drop() { } private void activateOnCurrentThread() { - if (db != null) + if (db != null) { db.activateOnCurrentThread(); - else + } else { System.out.println("db is null on activate"); + } } @@ -191,21 +192,26 @@ private void activateOnCurrentThread() { * @return The saved document. * @throws IllegalArgumentException if sourceUri or docType are null, or if the document doesn't exist. */ - public ODocument mergeDocument(Map incomingDocMap) - { + public ODocument mergeDocument(Map incomingDocMap) { String sourceUri = (String) incomingDocMap.get(DocumentAttributes.SOURCE_URI.toString()); - if (null == sourceUri) + + if (null == sourceUri) { throw new IllegalArgumentException("Document sourceUri is null."); + } + String docType = (String) incomingDocMap.get(Crawler.Attributes.TYPE); - if (null == docType) + + if (null == docType) { throw new IllegalArgumentException("Document docType is null."); + } // Get a document by sourceUri String sql = "SELECT * FROM " + docType + " WHERE sourceuri=?"; activateOnCurrentThread(); List results = db.command(new OSQLSynchQuery(sql)).execute(sourceUri); - if (results.size() == 0) - throw new JBakeException("No document with sourceUri '"+sourceUri+"'."); + if (results.isEmpty()) { + throw new JBakeException("No document with sourceUri '" + sourceUri + "'."); + } // Update it from the given map. ODocument incomingDoc = new ODocument(docType); diff --git a/jbake-core/src/main/java/org/jbake/app/FileUtil.java b/jbake-core/src/main/java/org/jbake/app/FileUtil.java index ebde763c1..2e1aa9e9d 100644 --- a/jbake-core/src/main/java/org/jbake/app/FileUtil.java +++ b/jbake-core/src/main/java/org/jbake/app/FileUtil.java @@ -201,7 +201,9 @@ public static String asPath(String path) { * Example: /content and /content/tags/blog will return '../..' * * @param sourceFile the file to calculate relative path for - * @return + * @param rootPath the root path + * @param config the jbake configuration + * @return the relative path to get to the root */ static public String getPathToRoot(JBakeConfiguration config, File rootPath, File sourceFile) { diff --git a/jbake-core/src/main/java/org/jbake/parser/AsciidoctorEngine.java b/jbake-core/src/main/java/org/jbake/parser/AsciidoctorEngine.java index f96fb182f..176d403c7 100644 --- a/jbake-core/src/main/java/org/jbake/parser/AsciidoctorEngine.java +++ b/jbake-core/src/main/java/org/jbake/parser/AsciidoctorEngine.java @@ -4,6 +4,7 @@ import org.asciidoctor.AttributesBuilder; import org.asciidoctor.Options; import org.asciidoctor.ast.DocumentHeader; +import org.asciidoctor.jruby.AsciidoctorJRuby; import org.jbake.app.configuration.JBakeConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,7 +56,7 @@ private Asciidoctor getEngine(Options options) { if (engine == null) { LOGGER.info("Initializing Asciidoctor engine..."); if (options.map().containsKey(OPT_GEM_PATH)) { - engine = Asciidoctor.Factory.create(String.valueOf(options.map().get(OPT_GEM_PATH))); + engine = AsciidoctorJRuby.Factory.create(String.valueOf(options.map().get(OPT_GEM_PATH))); } else { engine = Asciidoctor.Factory.create(); } @@ -159,13 +160,13 @@ public void processBody(ParserContext context) { private void processAsciiDoc(ParserContext context) { Options options = getAsciiDocOptionsAndAttributes(context); final Asciidoctor asciidoctor = getEngine(options); - context.setBody(asciidoctor.render(context.getBody(), options)); + context.setBody(asciidoctor.convert(context.getBody(), options)); } private Options getAsciiDocOptionsAndAttributes(ParserContext context) { JBakeConfiguration config = context.getConfig(); List asciidoctorAttributes = config.getAsciidoctorAttributes(); - final AttributesBuilder attributes = attributes(asciidoctorAttributes.toArray(new String[asciidoctorAttributes.size()])); + final AttributesBuilder attributes = attributes(asciidoctorAttributes.toArray(new String[0])); if (config.getExportAsciidoctorAttributes()) { final String prefix = config.getAttributesExportPrefixForAsciidoctor(); @@ -197,6 +198,7 @@ private Options getAsciiDocOptionsAndAttributes(ParserContext context) { return options; } + @SuppressWarnings("unchecked") private List getAsList(Object asciidoctorOption) { List values = new ArrayList<>(); diff --git a/jbake-core/src/main/java/org/jbake/parser/MarkdownEngine.java b/jbake-core/src/main/java/org/jbake/parser/MarkdownEngine.java index 27da6f73f..2f2abacdf 100644 --- a/jbake-core/src/main/java/org/jbake/parser/MarkdownEngine.java +++ b/jbake-core/src/main/java/org/jbake/parser/MarkdownEngine.java @@ -2,10 +2,10 @@ import com.vladsch.flexmark.html.HtmlRenderer; import com.vladsch.flexmark.parser.Parser; -import com.vladsch.flexmark.profiles.pegdown.Extensions; -import com.vladsch.flexmark.profiles.pegdown.PegdownOptionsAdapter; +import com.vladsch.flexmark.parser.PegdownExtensions; +import com.vladsch.flexmark.profile.pegdown.PegdownOptionsAdapter; import com.vladsch.flexmark.util.ast.Document; -import com.vladsch.flexmark.util.options.DataHolder; +import com.vladsch.flexmark.util.data.DataHolder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,7 +25,7 @@ public class MarkdownEngine extends MarkupEngine { public void processBody(final ParserContext context) { List mdExts = context.getConfig().getMarkdownExtensions(); - int extensions = Extensions.NONE; + int extensions = PegdownExtensions.NONE; for (String ext : mdExts) { if (ext.startsWith("-")) { @@ -49,10 +49,10 @@ public void processBody(final ParserContext context) { } private int extensionFor(String name) { - int extension = Extensions.NONE; + int extension = PegdownExtensions.NONE; try { - Field extField = Extensions.class.getDeclaredField(name); + Field extField = PegdownExtensions.class.getDeclaredField(name); extension = extField.getInt(null); } catch (NoSuchFieldException | IllegalAccessException e) { logger.debug("Undeclared extension field '{}', fallback to NONE", name); diff --git a/jbake-core/src/main/java/org/jbake/render/DocumentsRenderer.java b/jbake-core/src/main/java/org/jbake/render/DocumentsRenderer.java index 59fe93e94..78a4a4760 100644 --- a/jbake-core/src/main/java/org/jbake/render/DocumentsRenderer.java +++ b/jbake-core/src/main/java/org/jbake/render/DocumentsRenderer.java @@ -24,7 +24,9 @@ public int render(Renderer renderer, ContentStore db, JBakeConfiguration config) for (String docType : DocumentTypes.getDocumentTypes()) { DocumentList documentList = db.getUnrenderedContent(docType); - if (documentList == null) continue; + if (documentList == null) { + continue; + } int index = 0; @@ -89,4 +91,4 @@ private Map getContentForNav(Map document) { public int render(Renderer renderer, ContentStore db, File destination, File templatesPath, CompositeConfiguration config) throws RenderingException { return render(renderer, db, null); } -} \ No newline at end of file +} diff --git a/jbake-core/src/main/java/org/jbake/template/DelegatingTemplateEngine.java b/jbake-core/src/main/java/org/jbake/template/DelegatingTemplateEngine.java index 4458e018b..a006c51ab 100644 --- a/jbake-core/src/main/java/org/jbake/template/DelegatingTemplateEngine.java +++ b/jbake-core/src/main/java/org/jbake/template/DelegatingTemplateEngine.java @@ -27,6 +27,11 @@ public class DelegatingTemplateEngine extends AbstractTemplateEngine { /** * @deprecated Use {@link #DelegatingTemplateEngine(ContentStore, JBakeConfiguration)} instead. + * + * @param config the {@link CompositeConfiguration} of jbake + * @param db the {@link ContentStore} + * @param destination the destination path + * @param templatesPath the templates path */ @Deprecated public DelegatingTemplateEngine(final CompositeConfiguration config, final ContentStore db, final File destination, final File templatesPath) { @@ -52,8 +57,7 @@ public void renderDocument(final Map model, String templateName, if ( key.equals(JBakeProperty.PAGINATE_INDEX) ){ valueObject = config.getPaginateIndex(); - } - else { + } else { valueObject = config.get(key); } //replace "." in key so you can use dot notation in templates diff --git a/jbake-core/src/main/java/org/jbake/template/GroovyMarkupTemplateEngine.java b/jbake-core/src/main/java/org/jbake/template/GroovyMarkupTemplateEngine.java index cb89bea90..f46b25ce5 100644 --- a/jbake-core/src/main/java/org/jbake/template/GroovyMarkupTemplateEngine.java +++ b/jbake-core/src/main/java/org/jbake/template/GroovyMarkupTemplateEngine.java @@ -27,6 +27,11 @@ public class GroovyMarkupTemplateEngine extends AbstractTemplateEngine { /** * @deprecated Use {@link #GroovyMarkupTemplateEngine(JBakeConfiguration, ContentStore)} instead + * + * @param config the {@link CompositeConfiguration} of jbake + * @param db the {@link ContentStore} + * @param destination the destination path + * @param templatesPath the templates path */ @Deprecated public GroovyMarkupTemplateEngine(final CompositeConfiguration config, final ContentStore db, final File destination, final File templatesPath) { diff --git a/jbake-core/src/main/java/org/jbake/template/GroovyTemplateEngine.java b/jbake-core/src/main/java/org/jbake/template/GroovyTemplateEngine.java index 3799dc89d..58a166038 100644 --- a/jbake-core/src/main/java/org/jbake/template/GroovyTemplateEngine.java +++ b/jbake-core/src/main/java/org/jbake/template/GroovyTemplateEngine.java @@ -36,6 +36,11 @@ public class GroovyTemplateEngine extends AbstractTemplateEngine { /** * @deprecated Use {@link #GroovyTemplateEngine(JBakeConfiguration, ContentStore)} instead + * + * @param config the {@link CompositeConfiguration} of jbake + * @param db the {@link ContentStore} + * @param destination the destination path + * @param templatesPath the templates path */ @Deprecated public GroovyTemplateEngine(final CompositeConfiguration config, final ContentStore db, final File destination, final File templatesPath) { diff --git a/jbake-core/src/main/java/org/jbake/template/ThymeleafTemplateEngine.java b/jbake-core/src/main/java/org/jbake/template/ThymeleafTemplateEngine.java index 4bfb1b1d6..e594e143e 100644 --- a/jbake-core/src/main/java/org/jbake/template/ThymeleafTemplateEngine.java +++ b/jbake-core/src/main/java/org/jbake/template/ThymeleafTemplateEngine.java @@ -42,6 +42,11 @@ public class ThymeleafTemplateEngine extends AbstractTemplateEngine { /** * @deprecated Use {@link #ThymeleafTemplateEngine(JBakeConfiguration, ContentStore)} instead + * + * @param config the {@link CompositeConfiguration} of jbake + * @param db the {@link ContentStore} + * @param destination the destination path + * @param templatesPath the templates path */ @Deprecated public ThymeleafTemplateEngine(final CompositeConfiguration config, final ContentStore db, final File destination, final File templatesPath) { diff --git a/jbake-core/src/main/java/org/jbake/util/PagingHelper.java b/jbake-core/src/main/java/org/jbake/util/PagingHelper.java index 371136110..4b03a301a 100644 --- a/jbake-core/src/main/java/org/jbake/util/PagingHelper.java +++ b/jbake-core/src/main/java/org/jbake/util/PagingHelper.java @@ -33,8 +33,7 @@ public String getPreviousFileName(int currentPageNumber) throws URISyntaxExcepti if ( currentPageNumber == 2 ) { // Returning to first page, return empty string which when prefixed with content.rootpath should get to root of the site. return ""; - } - else { + } else { return new URI((currentPageNumber - 1) + URI_SEPARATOR).toString(); } } @@ -47,8 +46,7 @@ private boolean isFirstPage(int page) { public String getCurrentFileName(int page, String fileName) throws URISyntaxException { if ( isFirstPage(page) ) { return fileName; - } - else { + } else { return new URI(page + URI_SEPARATOR + fileName).toString(); } } diff --git a/jbake-core/src/test/java/org/jbake/app/ContentStoreIntegrationTest.java b/jbake-core/src/test/java/org/jbake/app/ContentStoreIntegrationTest.java index 0e3aa061e..f0a97f6e5 100644 --- a/jbake-core/src/test/java/org/jbake/app/ContentStoreIntegrationTest.java +++ b/jbake-core/src/test/java/org/jbake/app/ContentStoreIntegrationTest.java @@ -67,8 +67,7 @@ protected enum StorageType { MEMORY, PLOCAL; @Override - public String toString() - { + public String toString() { return this.name().toLowerCase(); } } diff --git a/jbake-core/src/test/java/org/jbake/app/DebugUtilTest.java b/jbake-core/src/test/java/org/jbake/app/DebugUtilTest.java index ca4a764ab..c03350b5e 100644 --- a/jbake-core/src/test/java/org/jbake/app/DebugUtilTest.java +++ b/jbake-core/src/test/java/org/jbake/app/DebugUtilTest.java @@ -10,12 +10,10 @@ import org.junit.Assert; import org.junit.Test; -public class DebugUtilTest -{ +public class DebugUtilTest { @Test - public void printMap() throws UnsupportedEncodingException - { + public void printMap() throws UnsupportedEncodingException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (PrintStream ps = new PrintStream(baos, true, "UTF-8")) { HashMap map = new HashMap(); diff --git a/jbake-core/src/test/java/org/jbake/app/MdParserTest.java b/jbake-core/src/test/java/org/jbake/app/MdParserTest.java index 4abf4257a..f18a6c1bc 100644 --- a/jbake-core/src/test/java/org/jbake/app/MdParserTest.java +++ b/jbake-core/src/test/java/org/jbake/app/MdParserTest.java @@ -194,7 +194,7 @@ public void createSampleFile() throws Exception { out.println(""); out.println(" Item 1 paragraph 1"); out.println("Item 1 paragraph 1 lazy continuation"); - out.println(" Item 1 paragraph 1 continuation"); + out.println(" Item 1 paragraph 1 continuation"); out.close(); mdFileRelaxedhrules = folder.newFile("releaxedhrules.md"); diff --git a/jbake-core/src/test/java/org/jbake/launcher/MainTest.java b/jbake-core/src/test/java/org/jbake/launcher/MainTest.java index f13a8b2f0..7713da156 100644 --- a/jbake-core/src/test/java/org/jbake/launcher/MainTest.java +++ b/jbake-core/src/test/java/org/jbake/launcher/MainTest.java @@ -164,8 +164,7 @@ private File mockValidSourceFolder(String sourcePath, boolean withJetty) throws File mockedSourceFolder = folder.newFolder(sourcePath.split("/")); if ( withJetty ) { mockJettyConfiguration(mockedSourceFolder, mockedSourceFolder); - } - else { + } else { mockDefaultJbakeConfiguration(mockedSourceFolder); } return mockedSourceFolder; diff --git a/jbake-core/src/test/java/org/jbake/render/support/MockCompositeConfiguration.java b/jbake-core/src/test/java/org/jbake/render/support/MockCompositeConfiguration.java index b5aecacde..1fb6de047 100644 --- a/jbake-core/src/test/java/org/jbake/render/support/MockCompositeConfiguration.java +++ b/jbake-core/src/test/java/org/jbake/render/support/MockCompositeConfiguration.java @@ -28,9 +28,9 @@ public boolean getBoolean(String key) { @Override public String getString(String key) { - if ( super.containsKey(key) ) { - return super.getString(key); - } + if (super.containsKey(key)) { + return super.getString(key); + } return _string; } } diff --git a/jbake-core/src/test/java/org/jbake/template/ModelExtractorsTest.java b/jbake-core/src/test/java/org/jbake/template/ModelExtractorsTest.java index 9e09a1374..9e9138a10 100644 --- a/jbake-core/src/test/java/org/jbake/template/ModelExtractorsTest.java +++ b/jbake-core/src/test/java/org/jbake/template/ModelExtractorsTest.java @@ -23,21 +23,21 @@ public void shouldLoadExtractorsOnInstantiation() { ModelExtractors.getInstance(); String[] expectedKeys = new String[]{ - "pages", - "posts", - "indexs", - "archives", - "feeds", - "published_posts", - "published_pages", - "published_content", - "published_date", - "all_content", - "alltags", - "db", - "tag_posts", - "tags", - "tagged_documents", + "pages", + "posts", + "indexs", + "archives", + "feeds", + "published_posts", + "published_pages", + "published_content", + "published_date", + "all_content", + "alltags", + "db", + "tag_posts", + "tags", + "tagged_documents", }; for (String aKey : expectedKeys) { diff --git a/jbake-dist/build.gradle b/jbake-dist/build.gradle index dfb3faa26..57576eb85 100644 --- a/jbake-dist/build.gradle +++ b/jbake-dist/build.gradle @@ -1,5 +1,6 @@ apply from: "$rootDir/gradle/application.gradle" apply from: "$rootDir/gradle/sdkman.gradle" +apply from: "$rootDir/gradle/signing.gradle" apply from: "$rootDir/gradle/publishing.gradle" description = "The binary distribution package that bundles JBake cli" @@ -18,24 +19,21 @@ sourceSets { configurations { dist - runtime.extendsFrom dist + runtimeOnly.extendsFrom dist + smokeTestImplementation.extendsFrom testImplementation + smokeTestCompileOnly.extendsFrom testCompileOnly + smokeTestRuntimeOnly.extendsFrom testRuntimeOnly } dependencies { - compile project(':jbake-core') - compile("org.asciidoctor:asciidoctorj-diagram:$asciidoctorjDiagramVersion") { + implementation project(':jbake-core') + implementation("org.asciidoctor:asciidoctorj-diagram:$asciidoctorjDiagramVersion") { exclude group: 'org.asciidoctor', module: 'asciidoctorj' } - smokeTestCompile 'org.eclipse.jgit:org.eclipse.jgit:5.2.1.201812262042-r' - smokeTestCompile configurations.testCompile - smokeTestCompile sourceSets.test.output - smokeTestRuntime configurations.testRuntime -} - -artifacts { - archives distZip + smokeTestImplementation "org.eclipse.jgit:org.eclipse.jgit:$jgitVersion" + smokeTestImplementation "org.apache.commons:commons-vfs2:$commonsVfs2Version", optional } task smokeTest(type: Test, dependsOn: installDist) { diff --git a/jbake-dist/src/smoke-test/java/org/jbake/BuiltInProjectsTest.java b/jbake-dist/src/smoke-test/java/org/jbake/BuiltInProjectsTest.java index a0bdde96a..30b72db70 100644 --- a/jbake-dist/src/smoke-test/java/org/jbake/BuiltInProjectsTest.java +++ b/jbake-dist/src/smoke-test/java/org/jbake/BuiltInProjectsTest.java @@ -10,7 +10,8 @@ import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; -import java.io.*; +import java.io.File; +import java.io.IOException; import java.util.Arrays; import static org.assertj.core.api.Assertions.assertThat; @@ -47,8 +48,7 @@ public static Iterable data() { public void setup() throws IOException { if ( Os.isFamily(Os.OS_FAMILY_WINDOWS) ) { jbakeExecutable = new File("build\\install\\jbake\\bin\\jbake.bat").getAbsolutePath(); - } - else { + } else { jbakeExecutable = new File("build/install/jbake/bin/jbake").getAbsolutePath(); } projectFolder = folder.newFolder("project"); @@ -58,7 +58,7 @@ public void setup() throws IOException { } @Test - public void should_bake_with_project() throws Exception { + public void shouldBakeWithProject() throws Exception { shouldInitProject(projectName, extension); shouldBakeProject(); } diff --git a/jbake-dist/src/smoke-test/java/org/jbake/ProjectWebsiteTest.java b/jbake-dist/src/smoke-test/java/org/jbake/ProjectWebsiteTest.java index 79faa0ee9..561b5a7ae 100644 --- a/jbake-dist/src/smoke-test/java/org/jbake/ProjectWebsiteTest.java +++ b/jbake-dist/src/smoke-test/java/org/jbake/ProjectWebsiteTest.java @@ -23,7 +23,6 @@ public class ProjectWebsiteTest { @Rule public TemporaryFolder folder = new TemporaryFolder(); private File projectFolder; - private File templateFolder; private File outputFolder; private String jbakeExecutable; private BinaryRunner runner; @@ -33,12 +32,11 @@ public void setup() throws IOException, GitAPIException { Assume.assumeTrue("JDK 7 is not supported for this test", !isJava7()); if ( Os.isFamily(Os.OS_FAMILY_WINDOWS) ) { jbakeExecutable = new File("build\\install\\jbake\\bin\\jbake.bat").getAbsolutePath(); - } - else { + } else { jbakeExecutable = new File("build/install/jbake/bin/jbake").getAbsolutePath(); } projectFolder = folder.newFolder("project"); - templateFolder = new File(projectFolder, "templates"); + new File(projectFolder, "templates"); outputFolder = new File(projectFolder, "output"); runner = new BinaryRunner(projectFolder); @@ -58,7 +56,7 @@ private void cloneJbakeWebsite() throws GitAPIException { cmd.setURI(WEBSITE_REPO_URL); cmd.setDirectory(projectFolder); - Git git = cmd.call(); + cmd.call(); assertThat(new File(projectFolder,"README.md").exists()).isTrue(); }