Skip to content

Commit

Permalink
Merge pull request #740 from ge0ffrey/merge-repo-jbake-maven-plugin
Browse files Browse the repository at this point in the history
Add repo jbake-maven-plugin into repo jbake + upgrade to gradle 7
  • Loading branch information
jonbullock authored Jan 2, 2022
2 parents fd74675 + c242757 commit 6461eba
Show file tree
Hide file tree
Showing 26 changed files with 1,109 additions and 294 deletions.
22 changes: 11 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ jobs:
- jdk: openjdk11
os: osx

- stage: Quality Check
name: sonarqube
jdk: openjdk11
script:
- "./gradlew jacocoRootReport sonarqube -i --stacktrace"

- stage: Quality Check
name: coveralls
jdk: openjdk11
script:
- "./gradlew -PskipSigning jacocoRootReport coveralls -i --stacktrace"
# - stage: Quality Check
# name: sonarqube
# jdk: openjdk11
# script:
# - "./gradlew jacocoRootReport sonarqube -i --stacktrace"
#
# - stage: Quality Check
# name: coveralls
# jdk: openjdk11
# script:
# - "./gradlew -PskipSigning jacocoRootReport coveralls -i --stacktrace"

notifications:
irc: "irc.freenode.org#jbake"
Expand Down
5 changes: 4 additions & 1 deletion BUILD.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To get an overview of all available tasks with a short description run `./gradle

== Structure

There are 3 projects
There are 4 projects:

root aka. jbake-base::
configures subprojects, jacoco execution aggregation and coveralls
Expand All @@ -34,6 +34,9 @@ jbake-core::
- the core library. produces jbake-core-{version}.jar (`build/libs`)
- publishes to bintray maven repository jbake-core

jbake-maven-plugin::
- the JBake maven plugin, build by Gradle too

jbake-dist::
- bundles the cli to an distribution (`build/distribution`)
- publishes to bintray binary repository jbake
Expand Down
192 changes: 20 additions & 172 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import java.time.format.DateTimeFormatter

plugins {
id "eclipse"
id "idea"
id "io.sdkman.vendors" version "2.0.0" apply false
id "com.github.kt3k.coveralls" version "2.10.2" apply false
id "org.sonarqube" version "3.1.1" apply false
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
id 'com.github.ben-manes.versions' version '0.38.0'
id "nebula.optional-base" version "5.0.3" apply false
id 'org.ajoberstar.grgit' version "$grgitVersion"
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
id "com.github.breadmoirai.github-release" version "2.2.12"
id "eclipse"
id "idea"
}

def buildTimeAndDate = grgit.head().dateTime

// common variables
ext {
isTravis = (System.getenv("TRAVIS") == "true")
Expand All @@ -23,177 +22,26 @@ ext {
sonarDefaultProjectKey = "org.jbake:jbake-base:jbake-core"
sonarURL = System.getenv("SONARHOST") ?: sonarDefaultURL
sonarProjectKey = System.getenv("SONARPROJECTKEY") ?: sonarDefaultProjectKey
buildDate = buildTimeAndDate.format(DateTimeFormatter.ofPattern('yyyy-MM-dd'))
buildTime = buildTimeAndDate.format(DateTimeFormatter.ofPattern('HH:mm:ss.SSSZ'))
isReleaseVersion = !version.endsWith("SNAPSHOT")
}

/**
* Apply coveralls to the root project as we just need it here to send the
* aggregated coverage execution data from the jacocoRootReport task
*/
apply plugin: 'com.github.kt3k.coveralls'

/**
* Apply jacoco plugin to all projects and add jcenter as default repository
*/
allprojects {
apply plugin: 'jacoco'

if (JavaVersion.current().isJava8Compatible()) {

apply plugin: 'checkstyle'

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

}

nexusPublishing {
repositories {
mavenCentral()
}

jacoco {
toolVersion = jacocoVersion
}

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

/**
* Common setup for all subprojects
*/
subprojects {

apply plugin: 'java'
apply plugin: 'nebula.optional-base'

// 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/publishing.gradle"
apply from: "$rootDir/gradle/signing.gradle"
}

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

test {
useJUnitPlatform()

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

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

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", 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
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'
}

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')
}
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')
}
}
}

//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
}

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
}
}

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,97 @@
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
}

task javadocJar(type: Jar) {
archiveClassifier.set('javadoc')
from javadoc
}

task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}

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
}
}
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configureondemand = true
org.gradle.vfs.watch = true

# jbake-maven-plugin dependencies
mavenVersion = 3.8.1
mavenAnnotationsVersion = 3.6.2
sparkVersion = 2.9.3
2 changes: 0 additions & 2 deletions gradle/application.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
apply plugin: 'application'

mainClassName = "org.jbake.launcher.Main"
applicationName = "jbake"

Expand Down
Loading

0 comments on commit 6461eba

Please sign in to comment.