Skip to content

Commit

Permalink
refactor build using a jbake specific java-common convention plugin a…
Browse files Browse the repository at this point in the history
…nd put stuff where it belongs
  • Loading branch information
ancho committed Dec 29, 2021
1 parent 4e94cf2 commit 2bc0d50
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 171 deletions.
55 changes: 14 additions & 41 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
plugins {
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
id 'com.github.ben-manes.versions' version '0.38.0'
id "eclipse"
id "idea"
}
Expand All @@ -17,50 +19,21 @@ ext {
sonarProjectKey = System.getenv("SONARPROJECTKEY") ?: sonarDefaultProjectKey
}

allprojects {
nexusPublishing {
repositories {
mavenCentral()
sonatype()
}
}

task jacocoMerge(type: JacocoMerge) {
description 'Merge all testreport execution data from subprojects excluding jbake-dist'
dependsOn subprojects.test
executionData subprojects.findAll{it.name!="jbake-dist"}.jacocoTestReport.executionData
}

task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'
dependsOn jacocoMerge

sourceDirectories.from files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories.from files(subprojects.sourceSets.main.output)
executionData.from jacocoMerge.executionData

reports {
html.enabled = true
xml.enabled = true
dependencyUpdates.resolutionStrategy {
componentSelection { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm'].any { qualifier ->
selection.candidate.version ==~ /(?i).*[.-]?${qualifier}[.\d-]*/
}
if (rejected) {
selection.reject('Release candidate')
}
}
}
}

task testReport(type: TestReport) {
description "Generate an aggregated Testreport for all projects"

destinationDir = file("$buildDir/reports/allTests")
// Include the results from the `test` task in all subprojects
reportOn subprojects*.test
}

coveralls {
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}

tasks.coveralls {
group = 'Coverage reports'
description = 'Uploads the aggregated coverage report to Coveralls'

dependsOn jacocoRootReport
// Skip Task if not run on CI Server

onlyIf { System.env.'CI' }
}
3 changes: 3 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id 'groovy-gradle-plugin'
}
Empty file added buildSrc/settings.gradle
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
plugins {
id 'java'
id 'jacoco'
id 'checkstyle'
}

repositories {
mavenCentral()
}

dependencies {
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"
implementation "ch.qos.logback:logback-core:$logbackVersion"

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
testCompileOnly "junit:junit:$junit4Version"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$junit5Version"

testImplementation "org.assertj:assertj-core:$assertjCoreVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "org.mockito:mockito-junit-jupiter:$mockitoVersion"
testImplementation 'org.itsallcode:junit5-system-extensions:1.1.0'
}

tasks.withType(JavaCompile) {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

//set jvm for all Test tasks (like test and smokeTest)
tasks.withType(Test) {

def args = ['-Xms512m', '-Xmx3g', '-Dorientdb.installCustomFormatter=false=false', '-Djna.nosys=true']

/**
* jdk9 build is unable to determine the amount of MaxDirectMemorySize
* See https://pastebin.com/ECvQeHx0
*/
if (JavaVersion.current().java9Compatible) {
args << '-XX:MaxDirectMemorySize=2g'
}
jvmArgs args
}

tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}

test {
useJUnitPlatform()

testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
}

jacoco {
excludes = ["**/*OrientSqlTokenManager*"]
}
}

jacoco {
toolVersion = jacocoVersion
}

jacocoTestReport {
reports {
xml.required.set true // coveralls plugin depends on xml format report
html.required.set true
}
}

jacocoTestReport.dependsOn test

tasks.withType(Checkstyle) {
reports {
xml.enabled false
html.enabled true
}
}
8 changes: 0 additions & 8 deletions gradle/publishing.gradle

This file was deleted.

110 changes: 16 additions & 94 deletions jbake-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,91 +1,42 @@
import java.time.format.DateTimeFormatter

plugins {
id "org.jbake.convention.java-common"
id 'java-library'
id 'jacoco'
id 'org.ajoberstar.grgit' version "$grgitVersion"
id 'checkstyle'
}

description = "The core library of JBake"

// add source and target compatibility for all JavaCompile tasks
tasks.withType(JavaCompile) {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

//set jvm for all Test tasks (like test and smokeTest)
tasks.withType(Test) {

def args = ['-Xms512m', '-Xmx3g', '-Dorientdb.installCustomFormatter=false=false', '-Djna.nosys=true']

/**
* jdk9 build is unable to determine the amount of MaxDirectMemorySize
* See https://pastebin.com/ECvQeHx0
*/
if (JavaVersion.current().java9Compatible) {
args << '-XX:MaxDirectMemorySize=2g'
}
jvmArgs args
}

jacocoTestReport {
reports {
xml.enabled = true // coveralls plugin depends on xml format report
html.enabled = true
}
}

jacocoTestReport.dependsOn test
apply from: "$rootDir/gradle/maven-publishing.gradle"
apply from: "$rootDir/gradle/signing.gradle"

description = "The core library of JBake"

dependencies {
implementation "commons-io:commons-io:$commonsIoVersion"
implementation "org.apache.commons:commons-configuration2:$commonsConfigurationVersion"
api "commons-io:commons-io:$commonsIoVersion"
api "org.apache.commons:commons-configuration2:$commonsConfigurationVersion"
implementation "commons-beanutils:commons-beanutils:$commonsBeanutilsVersion"
implementation "org.apache.commons:commons-vfs2:$commonsVfs2Version"
implementation "org.apache.commons:commons-lang3:$commonsLangVersion"
implementation("com.googlecode.json-simple:json-simple:$jsonSimpleVersion") {
exclude group: "junit", module: "junit"
}
implementation "com.orientechnologies:orientdb-core:$orientDbVersion"
implementation "org.asciidoctor:asciidoctorj:$asciidoctorjVersion"
implementation "org.codehaus.groovy:groovy:$groovyVersion"
implementation "org.codehaus.groovy:groovy-templates:$groovyVersion"
implementation "org.codehaus.groovy:groovy-dateutil:$groovyVersion"
implementation "org.freemarker:freemarker:$freemarkerVersion"
implementation "org.thymeleaf:thymeleaf:$thymeleafVersion"
implementation "de.neuland-bfi:jade4j:$jade4jVersion"
implementation "com.vladsch.flexmark:flexmark:$flexmarkVersion"
implementation "com.vladsch.flexmark:flexmark-profile-pegdown:$flexmarkVersion"
api "org.asciidoctor:asciidoctorj:$asciidoctorjVersion"
api "org.codehaus.groovy:groovy:$groovyVersion"
api "org.codehaus.groovy:groovy-templates:$groovyVersion"
api "org.codehaus.groovy:groovy-dateutil:$groovyVersion"
api "org.freemarker:freemarker:$freemarkerVersion"
api "org.thymeleaf:thymeleaf:$thymeleafVersion"
api "de.neuland-bfi:jade4j:$jade4jVersion"
api "com.vladsch.flexmark:flexmark:$flexmarkVersion"
api "com.vladsch.flexmark:flexmark-profile-pegdown:$flexmarkVersion"
api "io.pebbletemplates:pebble:$pebbleVersion"
implementation "org.jsoup:jsoup:$jsoupVersion"
implementation "io.pebbletemplates:pebble:$pebbleVersion"
implementation "org.yaml:snakeyaml:$snakeYamlVersion"

// cli specific dependencies
implementation "org.eclipse.jetty:jetty-server:$jettyServerVersion"
implementation "info.picocli:picocli:$picocli"


/// ----- TESTING DEPS ----- TODO: candidate for convention plugin
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"
implementation "ch.qos.logback:logback-core:$logbackVersion"

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
testCompileOnly "junit:junit:$junit4Version"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$junit5Version"

testImplementation "org.assertj:assertj-core:$assertjCoreVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "org.mockito:mockito-junit-jupiter:$mockitoVersion"
testImplementation 'org.itsallcode:junit5-system-extensions:1.1.0'
}

processResources {
Expand All @@ -97,32 +48,3 @@ processResources {
gitHash: grgit.head().abbreviatedId
}
}

tasks.withType(Checkstyle) {
reports {
xml.enabled false
html.enabled true
}
}

tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}

test {
useJUnitPlatform()

testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
}

jacoco {
excludes = ["**/*OrientSqlTokenManager*"]
}
}

jacoco {
toolVersion = jacocoVersion
}
21 changes: 2 additions & 19 deletions jbake-dist/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ plugins {
id "io.sdkman.vendors" version "2.0.0"
id "com.github.breadmoirai.github-release" version "2.2.12"
id 'org.ajoberstar.grgit' version "$grgitVersion"
id "org.jbake.convention.java-common"
id 'application'
}

apply from: "$rootDir/gradle/application.gradle"
apply from: "$rootDir/gradle/sdkman.gradle"
apply from: "$rootDir/gradle/signing.gradle"
Expand Down Expand Up @@ -40,25 +42,6 @@ dependencies {

smokeTestImplementation "org.eclipse.jgit:org.eclipse.jgit:$jgitVersion"
smokeTestImplementation "org.apache.commons:commons-vfs2:$commonsVfs2Version"

/// ----- TESTING DEPS ----- TODO: candidate for convention plugin
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"
implementation "ch.qos.logback:logback-core:$logbackVersion"

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
testCompileOnly "junit:junit:$junit4Version"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$junit5Version"

testImplementation "org.assertj:assertj-core:$assertjCoreVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "org.mockito:mockito-junit-jupiter:$mockitoVersion"
testImplementation 'org.itsallcode:junit5-system-extensions:1.1.0'
}

task smokeTest(type: Test, dependsOn: installDist) {
Expand Down
10 changes: 2 additions & 8 deletions jbake-maven-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
plugins {
id "io.freefair.maven-plugin" version "6.3.0"
id "org.jbake.convention.java-common"
}

group = "org.jbake.maven"
group = "org.jbake"
version = "2.7.0"

repositories {
mavenCentral()
}

dependencies {
//implementation 'org.jbake:jbake-core:2.7.0-rc.5'
implementation project(":jbake-core")

compileOnly "org.apache.maven:maven-core:3.8.1"
compileOnly "org.apache.maven.plugin-tools:maven-plugin-annotations:3.6.2"

implementation 'commons-io:commons-io:2.6'
implementation "org.apache.commons:commons-configuration2:2.7"
implementation "com.sparkjava:spark-core:2.9.3"

// Include all optional dependencies by default
Expand Down
1 change: 0 additions & 1 deletion jbake-maven-plugin/settings.gradle

This file was deleted.

0 comments on commit 2bc0d50

Please sign in to comment.