Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automate binary distribution publishing #422

Merged
merged 1 commit into from
Mar 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
language: java

dist: precise
os: linux
dist: trusty

addons:
hostname: short-hostname

jdk:
- openjdk7
- oraclejdk7
- oraclejdk8
hosts:
- jbake-builder
hostname: jbake-builder

matrix:
include:
- jdk: oraclejdk9
- jdk: oraclejdk8
- jdk: openjdk8
- jdk: openjdk7
dist: precise
- os: osx

install: true

script:
- ./gradlew check
- ./gradlew check -i

after_success:
- ./gradlew jacocoTestReport coveralls || ./gradlew clean
- ./gradlew -PskipSigning jacocoRootReport coveralls || ./gradlew clean

after_failure:
- ./gradlew clean check --debug
Expand Down
13 changes: 11 additions & 2 deletions BUILD.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,26 @@ Total time: 0.996 secs
Waiting for changes to input files of tasks... (ctrl-d to exit)
----

=== smoke tests

The `jbake-dist` module has a task called `smokeTest`.
It executes the produced application, initializes a jbake project for each supported example project and bake it.

The `check` task depends on the `smokeTest` task and is part of the travis CI execution.

=== code coverage

To generate a nice code coverage report run the following task.

----
./gradlew jacocoTestReport
./gradlew jacocoRootTestReport
----

It compiles your code, execute your tests, collect data and generate a report with {jacoco-web}. It produces XML and html reports. The xml file is used to trigger the {coveralls} service with the `coveralls` task.

The reports can be found at `build/reports/jacoco/test/`.
The reports can be found at `build/reports/jacoco/jacocoRootReport/html`.

NOTE: This is an aggregation of all project modules. You can generate coverage reports for each module with `./gradlew jacocoTestReport` or for a particular module `./gradlew :jbake-cli:jacocoTestReport`

plugin:: https://docs.gradle.org/current/userguide/jacoco_plugin.html
// TODO: write something about smokeTests and check
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ environment:
matrix:
- JAVA_HOME: C:\Program Files\Java\jdk1.7.0
- JAVA_HOME: C:\Program Files\Java\jdk1.8.0
- JAVA_HOME: C:\Program Files\Java\jdk9
install:
- SET PATH=%JAVA_HOME%\bin;%PATH%
- echo %PATH%
Expand Down
192 changes: 102 additions & 90 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
plugins {
id "java"
id "eclipse"
id "idea"
id "jacoco"
id "io.sdkman.vendors" version "1.1.1" apply false
id "com.jfrog.bintray" version "1.7.3" apply false
id "com.github.kt3k.coveralls" version "2.8.1" apply false
id 'com.github.ben-manes.versions' version '0.15.0'
}


if( JavaVersion.current().java7Compatible ) {
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'com.jfrog.bintray'
apply from: 'gradle/application.gradle'
apply from: 'gradle/signing.gradle'
apply from: 'gradle/maven-publishing.gradle'
apply from: 'gradle/publishing.gradle'
apply from: 'gradle/sdkman.gradle'
}

sourceCompatibility = 1.7
targetCompatibility = 1.7

repositories {
jcenter()
}

// common variables
ext {
asciidoctorjVersion = '1.5.6'
asciidoctorjDiagramVersion = '1.5.4.1'
Expand All @@ -51,92 +32,123 @@ ext {
jsoupVersion = '1.10.3'
}

sourceSets {
smokeTest {
java {
srcDir file('src/smoke-test/java')
}
resources {
srcDir file('src/smoke-test/resources')
}
/**
* 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'

repositories {
jcenter()
}
}

configurations {
dist
jacoco {
toolVersion = jacocoVersion
}

runtime.extendsFrom dist
}

dependencies {
compile group: 'commons-io', name: 'commons-io', version: commonsIoVersion
compile group: 'commons-configuration', name: 'commons-configuration', version: commonsConfigurationVersion
compile group: 'org.apache.commons', name: 'commons-vfs2', version: commonsVfs2Version
compile group: 'org.apache.commons', name: 'commons-lang3', version: commonsLangVersion
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: jsonSimpleVersion
compile group: 'args4j', name: 'args4j', version: args4jVersion
compile group: 'org.freemarker', name: 'freemarker', version: freemarkerVersion
compile group: 'com.orientechnologies', name: 'orientdb-graphdb', version: orientDbVersion
compile group: 'org.asciidoctor', name: 'asciidoctorj', version: asciidoctorjVersion
compile group: 'org.eclipse.jetty', name: 'jetty-server', version: jettyServerVersion
compile group: 'org.codehaus.groovy', name: 'groovy', version: groovyVersion
compile group: 'org.codehaus.groovy', name: 'groovy-templates', version: groovyVersion
compile group: 'org.thymeleaf', name: 'thymeleaf', version: thymeleafVersion
compile group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
compile group: 'org.slf4j', name: 'jul-to-slf4j', version: slf4jVersion
compile group: 'ch.qos.logback', name: 'logback-classic', version: logbackVersion
compile group: 'ch.qos.logback', name: 'logback-core', version: logbackVersion
compile group: 'de.neuland-bfi', name: 'jade4j', version: jade4jVersion
compile group: 'org.jsoup', name:'jsoup', version: jsoupVersion
compile "com.vladsch.flexmark:flexmark-all:$flexmarkVersion"

dist group: 'org.asciidoctor', name: 'asciidoctorj-diagram', version: asciidoctorjDiagramVersion

testCompile group: 'junit', name: 'junit', version: junit4Version
testCompile group: 'org.assertj', name: 'assertj-core', version: assertjCoreVersion
testCompile group: 'org.mockito', name: 'mockito-core', version: mockitoVersion

smokeTestCompile configurations.testCompile
smokeTestCompile sourceSets.test.output
smokeTestRuntime configurations.testRuntime
}
/**
* Common setup for all subprojects
*/
subprojects {

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')
}
apply plugin: 'java'

if( JavaVersion.current().java7Compatible ) {
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"
}
// bintray setup
apply from: "$rootDir/gradle/publishing.gradle"
}

sourceCompatibility = 1.7
targetCompatibility = 1.7

dependencies {
compile "org.slf4j:slf4j-api:$slf4jVersion"
compile "org.slf4j:jul-to-slf4j:$slf4jVersion"
compile "ch.qos.logback:logback-classic:$logbackVersion"
compile "ch.qos.logback:logback-core:$logbackVersion"
testCompile "junit:junit:$junit4Version"
testCompile "org.assertj:assertj-core:$assertjCoreVersion"
testCompile "org.mockito:mockito-core:$mockitoVersion"
}

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

test {
jvmArgs '-XX:MaxPermSize=2048m', '-XX:MaxDirectMemorySize=512m', '-Dorientdb.installCustomFormatter=false=false'
}

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

test {
jvmArgs '-Xmx512m', '-XX:MaxPermSize=512m', '-XX:MaxDirectMemorySize=128m', '-Dorientdb.installCustomFormatter=false=false'
jacocoTestReport.dependsOn test
}

task smokeTest(type: Test, dependsOn: installDist) {
group 'Verification'
description 'Runs the integration tests.'
setTestClassesDirs sourceSets.smokeTest.output.classesDirs
classpath = sourceSets.smokeTest.runtimeClasspath
shouldRunAfter 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
}

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

jacoco {
toolVersion = jacocoVersion
}
sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories = files(subprojects.sourceSets.main.output)
executionData = jacocoMerge.executionData

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

jacocoTestReport.dependsOn test
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 {
sourceDirs = subprojects.sourceSets.main.allSource.srcDirs.flatten()
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' }
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jacocoVersion=0.7.9
bintrayDryRun=false
bintrayOrg=jbake
bintrayRepo=maven

bintrayBinaryRepo=binary
26 changes: 25 additions & 1 deletion gradle/maven-publishing.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import java.text.SimpleDateFormat

apply plugin: 'maven'

ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
Date buildTimeAndDate = new Date()
ext {
buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate)
buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate)
isReleaseVersion = !version.endsWith("SNAPSHOT")
}

def jbakePom = pom {
project {
Expand Down Expand Up @@ -49,6 +56,23 @@ def jbakePom = pom {
}
}

jar {
manifest {
attributes(
'Built-By': System.properties['user.name'],
'Created-By': "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})".toString(),
'Build-Date': buildDate,
'Build-Time': buildTime,
'Specification-Title': project.name,
'Specification-Version': project.version,
'Specification-Vendor': project.name,
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor': project.name
)
}
}

task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
Expand Down
Loading