Skip to content
Open
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
11 changes: 11 additions & 0 deletions build-conventions/src/main/kotlin/jgiven-checkstyle.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
checkstyle
}

checkstyle {
toolVersion = "12.2.0"
configFile = file("${rootProject.projectDir}/checkstyle.xml")

isShowViolations = true
isIgnoreFailures = true
}
67 changes: 67 additions & 0 deletions build-conventions/src/main/kotlin/jgiven-java.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

plugins {
java
jacoco
}


tasks.withType<Test> {
systemProperty("jgiven.report.dir", "build/reports/jgiven/json")
systemProperty("jgiven.report.text", "false")

testLogging {
showStandardStreams = true
}
}

tasks.withType<JavaCompile>().configureEach {
// needed for DeSzenarioTest.java as it has Umlauts in the code
options.encoding = "UTF-8"
}

tasks.withType<Jar>().configureEach {
val now = LocalDateTime.now()
val dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S")
val yearFormatter = DateTimeFormatter.ofPattern("yyyy")

manifest {
attributes(
"Built-By" to "Gradle ${gradle.gradleVersion}",
"Build-Date" to now.format(dateFormatter),
"Copyright" to "2013-${now.format(yearFormatter)} TNG Technology Consulting GmbH",
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to "TNG Technology Consulting GmbH",
"License" to "Apache License v2.0, January 2004",
"Specification-Title" to project.name,
"Specification-Version" to project.version,
"Specification-Vendor" to "TNG Technology Consulting GmbH",
"Automatic-Module-Name" to "com.tngtech.jgiven.${project.name.replace("-", ".").replace("jgiven.", "")}"
)
}
}

normalization {
runtimeClasspath {
ignore("META-INF/MANIFEST.MF")
}
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}


tasks.withType<Javadoc> {
// exclude("**/impl/**")
}

tasks.named<JacocoReport>("jacocoTestReport") {
reports {
xml.required.set(true) // coveralls plugin depends on xml format report
}
}
69 changes: 0 additions & 69 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,73 +85,13 @@ configure(subprojects.findAll { !it.name.contains("android") }) {
jvmArgs += "-javaagent:${rootProject.projectDir}/jgiven-timing/build/libs/jgiven-timing-1.1.0.jar"
}
}

test {
systemProperty 'jgiven.report.dir', 'build/reports/jgiven/json'
systemProperty 'jgiven.report.text', 'false'

if (jacocoEnabled) {
jacoco {
destinationFile = file("${rootProject.projectDir}/build/jacoco/jacocoTest.exec")
classDumpDir = file("${rootProject.projectDir}/build/jacoco/classpathdumps")
}
}

testLogging {
showStandardStreams = true
}
}

tasks.withType(JavaCompile).configureEach {
// needed for DeSzenarioTest.java as it has Umlauts in the code
options.encoding = 'UTF-8'
}

tasks.withType(Jar) {
def now = new Date()
manifest {
attributes(
'Built-By': "Gradle ${gradle.gradleVersion}",
'Build-Date': now.format('yyyy-MM-dd HH:mm:ss.S'),
'Copyright': "2013-" + now.format('yyyy') + " TNG Technology Consulting GmbH",
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor': 'TNG Technology Consulting GmbH',
'License': 'Apache License v2.0, January 2004',
'Specification-Title': project.name,
'Specification-Version': project.version,
'Specification-Vendor': 'TNG Technology Consulting GmbH',
'Automatic-Module-Name': "com.tngtech.jgiven.${project.name.replaceAll("-", ".").replace("jgiven.", "")}"
)
}
}

normalization {
runtimeClasspath {
ignore "META-INF/MANIFEST.MF"
}
}

javadoc {
exclude '**/impl/**'

onlyIf {
JavaVersion.current().isJava8Compatible()
}
}

java {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
}

if (jacocoEnabled) {
jacocoTestReport {
reports {
xml.required = true // coveralls plugin depends on xml format report
}
}
}

tasks.register("jgivenHtml5Report", JavaExec) {
//noinspection GroovyAccessibility
mainClass = 'com.tngtech.jgiven.report.ReportGenerator'
Expand Down Expand Up @@ -205,20 +145,11 @@ configure(subprojects.findAll { !it.name.contains("android") }) {
}

configure(subprojects) { subproject ->
apply plugin: 'checkstyle'
apply plugin: 'eclipse'
apply plugin: 'idea'

description = "${rootProject.description} - Module ${project.name}"

checkstyle {
toolVersion = "12.2.0"
configFile = file("${rootProject.projectDir}/checkstyle.xml")
showViolations = false
ignoreFailures = true
}


idea {
module {
downloadSources = true
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ aspectj-jrt = { module = "org.aspectj:aspectjrt", version.ref = "aspectj-version
aspectj-jweaver = { module = "org.aspectj:aspectjweaver", version.ref = "aspectj-version" }
byteBuddy = { module = "net.bytebuddy:byte-buddy", version.ref = "byteBuddy-version" }
byteBuddy-agent = { module = "net.bytebuddy:byte-buddy-agent", version.ref = "byteBuddy-version" }
byteBuddy-plugin = { module = "net.bytebuddy:byte-buddy-gradle-plugin", version.ref = "byteBuddy-version" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson-version" }
guava = { module = "com.google.guava:guava", version.ref = "guava-version" }
hypersql-database = { module = "org.hsqldb:hsqldb", version = "2.7.4" }
Expand Down Expand Up @@ -53,4 +54,3 @@ spring-compile = [ "spring-context", "spring-test" ]
aspectj-spring-test = [ "aspectj-jrt", "aspectj-jweaver" ]

[plugins]
byteBuddy-plugin = { id = "net.bytebuddy:byte-buddy-gradle-plugin", version.ref = "byteBuddy-version" }
5 changes: 5 additions & 0 deletions jgiven-android-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ buildscript {
}
}

plugins {
id 'jgiven-checkstyle'
}


repositories {
google()
}
Expand Down
1 change: 1 addition & 0 deletions jgiven-android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("com.android.library")
id("jgiven-publishing")
id("jgiven-checkstyle")
id("maven-publish")
}

Expand Down
2 changes: 2 additions & 0 deletions jgiven-asciidoc-report/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id 'java-library'
id 'jgiven-publishing'
id('jgiven-checkstyle')
id('jgiven-java')
}

dependencies {
Expand Down
3 changes: 3 additions & 0 deletions jgiven-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id 'java-library'
id('jgiven-publishing')
id('jgiven-checkstyle')
id('jgiven-java')
}

description = "JGiven core module"
Expand Down Expand Up @@ -68,3 +70,4 @@ files { file("src/main/translations").listFiles() }.collect {
tasks.register("runShellCommand", Exec){
commandLine 'git', 'rev-parse', '--short', 'HEAD'
}

2 changes: 2 additions & 0 deletions jgiven-examples/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
plugins {
id('jgiven-publishing')
id('jgiven-checkstyle')
id('jgiven-java')
}
dependencies {
implementation project(':jgiven-core')
Expand Down
6 changes: 5 additions & 1 deletion jgiven-future-java-tests/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
plugins {
id 'java'
id('jgiven-checkstyle')
id('jgiven-java')
}
java {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_19
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}

dependencies {
Expand Down
3 changes: 2 additions & 1 deletion jgiven-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ plugins {
id "java-gradle-plugin"
id "com.gradle.plugin-publish" version "2.0.0"
id "groovy"
id('jgiven-checkstyle')
id('jgiven-java')
}

dependencies {
Expand Down Expand Up @@ -41,4 +43,3 @@ gradlePlugin {
}
}
}

2 changes: 2 additions & 0 deletions jgiven-html-app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id('jgiven-publishing')
id('com.github.node-gradle.node')
id('jgiven-checkstyle')
id('jgiven-java')
}

def htmlAppVersion = '1.1.3'
Expand Down
2 changes: 2 additions & 0 deletions jgiven-html5-report/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id 'java-library'
id('jgiven-publishing')
id('jgiven-checkstyle')
id('jgiven-java')
}

dependencies {
Expand Down
2 changes: 2 additions & 0 deletions jgiven-junit/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id('jgiven-publishing')
id 'java-library'
id('jgiven-checkstyle')
id('jgiven-java')
}

description = "Module for writing JGiven tests with JUnit"
Expand Down
2 changes: 2 additions & 0 deletions jgiven-junit5/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id('jgiven-publishing')
id 'java-library'
id('jgiven-checkstyle')
id('jgiven-java')
}
description = "Module for writing JGiven tests with JUnit 5"

Expand Down
2 changes: 2 additions & 0 deletions jgiven-maven-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import java.util.stream.Collectors
plugins {
id "java-gradle-plugin"
id('jgiven-publishing')
id('jgiven-checkstyle')
id('jgiven-java')
}

description = 'JGiven Maven Mojo'
Expand Down
2 changes: 2 additions & 0 deletions jgiven-spock2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ plugins {
id('jgiven-publishing')
id 'java-library'
id 'groovy'
id('jgiven-checkstyle')
id('jgiven-java')
}

description = "Module for writing JGiven tests with Spock 2"
Expand Down
2 changes: 2 additions & 0 deletions jgiven-spring-junit4/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id 'java-library'
id('jgiven-publishing')
id('jgiven-checkstyle')
id('jgiven-java')
}

description = "Module for using Spring dependency injection together with JGiven and JUnit 4"
Expand Down
2 changes: 2 additions & 0 deletions jgiven-spring-junit5/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id 'java-library'
id('jgiven-publishing')
id('jgiven-checkstyle')
id('jgiven-java')
}

description = "Module for using Spring dependency injection together with JGiven and JUnit 5"
Expand Down
2 changes: 2 additions & 0 deletions jgiven-spring/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
plugins {
id('jgiven-publishing')
id('jgiven-checkstyle')
id('jgiven-java')
}
description = "Module for using Spring dependency injection together with JGiven"

Expand Down
2 changes: 2 additions & 0 deletions jgiven-testng/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id 'java-library'
id('jgiven-publishing')
id('jgiven-checkstyle')
id('jgiven-java')
}
description = "Module to write JGiven tests with TestNG"

Expand Down
2 changes: 2 additions & 0 deletions jgiven-tests/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
plugins {
id('jgiven-publishing')
id('jgiven-checkstyle')
id('jgiven-java')
}
description = 'JGiven Tests - Contains BDD tests for JGiven written in JGiven'

Expand Down
2 changes: 2 additions & 0 deletions jgiven-timing/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
plugins {
id 'java-library'
id('jgiven-checkstyle')
id('jgiven-java')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stupid question: those two could not be moved into the conventions for technical reasons? Or are there some modules which would not take kindly to them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite get your question...
Regarding the choice of having extra modules, it is twofold:

  1. many plugins, especially for java don't work with the android package
  2. I wanted to have some sort of thematic grouping of what these plugins do.
    Does that answer it?

}

repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.tngtech.jgiven.timing;

import com.tngtech.jgiven.impl.ScenarioBase;
import java.lang.instrument.Instrumentation;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.implementation.MethodDelegation;
import net.bytebuddy.matcher.ElementMatchers;

import java.lang.instrument.Instrumentation;

/**
* Class that acts as a Java agent and injects code before class for timing the test methods.
*/
Expand All @@ -16,7 +17,7 @@ public class TimerInjectorAgent {
public static void premain(String args, Instrumentation instrumentation) {
new AgentBuilder.Default()
.type(ElementMatchers.isSubTypeOf(ScenarioBase.class))
.transform((builder, type, classLoader, module) ->
.transform((builder, type, classLoader, module, __) ->
builder.method(ElementMatchers.named("initialize")
.or(ElementMatchers.named("finished")))
.intercept(MethodDelegation.to(ManageTimerInterceptor.class))
Expand Down
Loading