How to configure build.gradle using Junit5 and Jacoco for test coverage - gradle

I am trying to configure the build.gradle file so that it supports both Junit 5 and Jacoco. I was using useJunitPlatform before, but it generates another errors. I also tried some other ways, but none can successfully generate Jacoco report. This configuration however, sucessfully generated Jacoco report for me, but it also gave me an exception. Below is my build.gradle file.
plugins {
// Build "fat" jars for deployment
id 'com.github.johnrengelman.shadow' version '5.2.0'
// Apply the java plugin to add support for Java
id 'java'
// Apply the application plugin to add support for building a CLI application.
id 'application'
// Deploy directly to heroku without using Git
id "com.heroku.sdk.heroku-gradle" version "1.0.4"
// Lombok provides shorthand for repetitive Java tasks
id "io.freefair.lombok" version "4.1.6"
// Spotless to format code easily
id "com.diffplug.gradle.spotless" version "3.27.1"
// Jacoco test coverage
id 'jacoco'
}
repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
dependencies {
// Simple HTTP framework - http://sparkjava.com/
implementation 'com.sparkjava:spark-core:2.9.1'
// Basic logging support; used by Spark
implementation "org.slf4j:slf4j-simple:1.7.25"
// Jackson to serialize/deserialize JSON
implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.2'
// Use JUnit Jupiter API for testing.
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
testImplementation 'org.junit.platform:junit-platform-launcher:1.5.2'
// Use JUnit Jupiter Engine for testing.
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.2'
// Use dagger for dependency injection
implementation 'com.google.dagger:dagger:2.26'
annotationProcessor 'com.google.dagger:dagger-compiler:2.26'
// Annotations such as Nullable
implementation 'com.google.code.findbugs:annotations:3.0.1'
// Force JRE Guava to work around issues with Truth
testImplementation "com.google.guava:guava:28.2-jre"
// Fluent assertions for testing
testImplementation 'com.google.truth:truth:1.0.1'
// MongoDB client
implementation 'org.mongodb:mongodb-driver:3.12.1'
}
application {
// Define the main class for the application.
mainClassName = 'edu.northeastern.cs5500.delivery.App'
}
jacoco {
toolVersion = "0.8.5"
reportsDir = file("$buildDir/customJacocoReportDir")
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination file("${buildDir}/jacocoHtml")
}
afterEvaluate {
classDirectories.from = files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'**/model/**',
'**/view/**',
'**/utils/**',
'**/service/**'
])
})
}
doLast {
println "file://$buildDir/jacocoHtml/index.html"
}
}
test {
// Use junit platform for unit tests
useJUnit()
finalizedBy jacocoTestReport
}
// Heroku will run the 'stage' task on deployment via git
task stage(dependsOn: ['clean', 'shadowJar'])
shadowJar.mustRunAfter clean
// Force all builds to be clean builds due to Dagger problems
build.mustRunAfter clean
build.dependsOn += 'clean'
run.mustRunAfter clean
run.dependsOn += 'clean'
// Target Java 1.11 - make sure system.properties matches this as well
sourceCompatibility = 1.11
targetCompatibility = 1.11
sourceSets {
main {
java {
srcDirs 'src/main/java'
srcDirs 'build/generated/sources/annotationProcessor/java/main'
}
}
test {
java {
srcDirs 'src/test/java'
srcDirs 'build/generated/sources/annotationProcessor/java/test'
}
}
}
spotless {
format 'misc', {
target '**/*.gradle', '**/*.md', '**/.gitignore'
targetExclude 'build/**'
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
paddedCell()
}
java {
targetExclude 'build/**'
googleJavaFormat().aosp()
}
}
The error that occurs every time I built is shown below
java.lang.instrument.IllegalClassFormatException: Error while instrumenting sun/util/resources/cldr/provider/CLDRLocaleDataMetaInfo.
at org.jacoco.agent.rt.internal_43f5073.CoverageTransformer.transform(CoverageTransformer.java:94)
at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:246)
at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:563)
at java.base/java.lang.ClassLoader.defineClass2(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1108)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:183)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:784)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassInModuleOrNull(BuiltinClassLoader.java:705)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClass(BuiltinClassLoader.java:586)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:634)
at java.base/java.lang.Class.forName(Class.java:546)
at java.base/java.util.ServiceLoader.loadProvider(ServiceLoader.java:854)
at java.base/java.util.ServiceLoader$ModuleServicesLookupIterator.hasNext(ServiceLoader.java:1078)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1301)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1386)
at java.base/sun.util.cldr.CLDRLocaleProviderAdapter$1.run(CLDRLocaleProviderAdapter.java:89)
at java.base/sun.util.cldr.CLDRLocaleProviderAdapter$1.run(CLDRLocaleProviderAdapter.java:86)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:554)
at java.base/sun.util.cldr.CLDRLocaleProviderAdapter.<init>(CLDRLocaleProviderAdapter.java:86)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at java.base/sun.util.locale.provider.LocaleProviderAdapter.forType(LocaleProviderAdapter.java:188)
at java.base/sun.util.locale.provider.LocaleProviderAdapter.findAdapter(LocaleProviderAdapter.java:287)
at java.base/sun.util.locale.provider.LocaleProviderAdapter.getAdapter(LocaleProviderAdapter.java:258)
at java.base/java.util.Calendar.createCalendar(Calendar.java:1693)
at java.base/java.util.Calendar.getInstance(Calendar.java:1661)
at java.base/java.text.SimpleDateFormat.initializeCalendar(SimpleDateFormat.java:677)
at java.base/java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:621)
at java.base/java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:600)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.getLastResortErrorLogFile(SystemApplicationClassLoaderWorker.java:162)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:111)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by: java.io.IOException: Error while instrumenting sun/util/resources/cldr/provider/CLDRLocaleDataMetaInfo.
at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrumentError(Instrumenter.java:159)
at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrument(Instrumenter.java:109)
at org.jacoco.agent.rt.internal_43f5073.CoverageTransformer.transform(CoverageTransformer.java:92)
... 37 more
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 59
at org.jacoco.agent.rt.internal_43f5073.asm.ClassReader.<init>(ClassReader.java:195)
at org.jacoco.agent.rt.internal_43f5073.asm.ClassReader.<init>(ClassReader.java:176)
at org.jacoco.agent.rt.internal_43f5073.asm.ClassReader.<init>(ClassReader.java:162)
at org.jacoco.agent.rt.internal_43f5073.core.internal.instr.InstrSupport.classReaderFor(InstrSupport.java:280)
at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrument(Instrumenter.java:75)
at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrument(Instrumenter.java:107)
... 38 more
Thanks for any help!

Based on your error message
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 59
and according to https://en.wikipedia.org/wiki/Java_class_file
you're using Java 15.
According to https://www.jacoco.org/jacoco/trunk/doc/changes.html
support for Java 15 was added in JaCoCo version 0.8.6
So either you don't need Java 15 and can use earlier version such as 11 (LTS), or you need to change
jacoco {
toolVersion = "0.8.5"
on
jacoco {
toolVersion = "0.8.6"

For me the problem was with com.github.johnrengelman.shadow version, after upgrade to version 6.1.0 everting work out

Related

How to include transiant depedency of springboot inside fabric mod

I want to use spring boot inside fabric mod. And it works while I'm runing my minecraft server with gradlew.bat runServer command. But when I'm using gradlew.bat build and put the production jar inside a real server I got no class deff found error. Like that :
java.lang.RuntimeException: Could not execute entrypoint stage 'server' due to errors, provided by 'litopia_services'!
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
at fr.litopia.services.LitopiaServices.onInitializeServer(LitopiaServices.java:23) ~[litopia-services-1.0.0.jar:?]
And it's seems leagite cause inside the jar that gradle build there is'nt spring boot transiant depencency.
So to prevent this issue I have to use api insted of include or implement include but none of that have work actually my build.gradle looks like that :
plugins {
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'org.springframework.boot' version '2.5.14'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven { url 'https://jitpack.io' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://mvnrepository.com/artifac' }
maven { url 'https://zoidberg.ukp.informatik.tu-darmstadt.de/artifactory/public-releases' }
maven { url 'https://maven.terraformersmc.com/releases' }
mavenCentral()
}
configurations {
springBom
compileOnly.extendsFrom(springBom)
annotationProcessor.extendsFrom(springBom)
implementation.extendsFrom(springBom)
all {
// We need to use fabric implementation of log4j
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
}
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Spring boot dependencies
springBom enforcedPlatform('org.springframework.boot:spring-boot-dependencies:2.5.14')
api include('org.springframework.boot:spring-boot-starter')
implementation include('org.springframework.boot:spring-boot-dependencies:2.5.14')
implementation include('org.springframework.boot:spring-boot-starter-web')
implementation include('org.springframework.boot:spring-boot-starter-websocket')
// OpenAPI swagger
implementation include('org.springdoc:springdoc-openapi-ui:1.6.13')
// Spring discord api
implementation include('com.discord4j:discord4j-core:3.2.3')
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
tasks.withType(JavaCompile).configureEach {
it.options.release = 17
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}

The legacy `maven` plugin was removed in Gradle 7. Please use the `maven-publish` plugin in instead

I´m trying to run a project using gradle but I´m getting the following error.
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\ISEP\ODSOFT\Projects\odsoft-21-22-nmb-g311\odsoft-21-22-nmb-g311\project\build.gradle' line: 4
* What went wrong:
An exception occurred applying plugin request [id: 'fr.putnami.gwt', version: '0.4.0']
> Failed to apply plugin class 'org.gradle.api.plugins.MavenPlugin'.
> The legacy `maven` plugin was removed in Gradle 7. Please use the `maven-publish` plugin instead. See https://docs.gradle.org/7.2/userguide/publishing_maven.html#publishing_maven for details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
The command I´m using to run project is gradle gwtRun.
I leave below my gradle bulid file
plugins {
id "fr.putnami.gwt" version "0.4.0"
id "maven-publish"
}
apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
//Java version compatibility to use when compiling Java source.
sourceCompatibility = 1.8
//Java version to generate classes for.
targetCompatibility = 1.8
//Script Version
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
//testCompile 'junit:junit:4.12'
//testCompile group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation 'org.easymock:easymock:2.5.2'
testImplementation 'com.google.gwt:gwt-dev:2.8.1'
implementation 'net.sourceforge.plantuml:plantuml:8001'
//compile 'net.sourceforge.plantuml:plantuml:8001'
}
javadoc {
options.addStringOption("sourcepath", "")
}
// If we woant to use the default ant build inside gradle
// ant.importBuild "build.xml"
putnami{
module 'pt.isep.cms.Showcase'
//module 'com.google.gwt.sample.contacts.Contacts'
/** add gwt nature on eclipse project. require apply plugin: 'eclipse' to work. default : false*/
googlePluginEclipse = true
gwtVersion='2.8.1'
compile {
sourceLevel = '1.8'
}
jetty {
/** enable debugging. */
debugJava = true
/** debug port to listen. */
debugPort = 8000
/** wait for debugger attachment. */
debugSuspend = false
}
}
// Jacoco
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
}
}
// This task generates the coverage report for the integration tests.
// Notice that it only includes data about the server code sice Jaccoco is not able to get data about cliente code that is transpiled to javascript
task jacocoIntegrationReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
sourceSets sourceSets.main
executionData = files("${buildDir}/jacoco/integrationTest.exec")
reports {
html.enabled = true
xml.enabled = false
csv.enabled = false
}
}
// Integration Tests
task integrationTest(type: Test) {
filter {
//all GWT unit tests, by naming convention
includeTestsMatching "*GWTTest*"
}
jacoco {
append = true
enabled = true
//classDumpFile = file("${buildDir}/jacoco/classpathdumps")
excludes = ["com/steadystate/**"]
}
// These Properties are required to run gwt integration tests
systemProperties['gwt.args'] = "-devMode -logLevel WARN -war www-test"
}
tasks.withType(Test) {
reports.html.destination = file("${reporting.baseDir}/${name}")
}
// Unit Tests
test {
filter {
//all JRE unit tests, by naming convention
includeTestsMatching "*JRETest*"
}
jacoco {
append = true
enabled = true
//classDumpFile = file("${buildDir}/jacoco/classpathdumps")
}
}
From what I understood the plugin maven was removed in the version 7 of gradle. Is this sentence correct? Or is the putnami plugin that was removed?
What should I do to make it to work?
The plugin fr.putnami.gwt applies the maven plugin internally:
https://github.com/Putnami/putnami-gradle-plugin/blob/master/src/main/java/fr/putnami/gwt/gradle/PwtLibPlugin.java#L47
Therefore, fr.putnami.gwt is not compatible with Gradle 7.
As stated in the README in the repo:
A fork of it that is still supported and has a newer release is available at https://github.com/esoco/gwt-gradle-plugin. Please use the new version if you need GWT support for Gradle.
So, then the following should work:
plugins {
id "de.esoco.gwt" version "1.1.1"
}

Updated Gradle Now compileGoovy failing with "unable to resolve class"

This is some of the errors. The XXXX represents personal or confidential information.
/Users/XXXXXXX/Documents/XXXX/XXXX/internal-tools/grails-app/utils/com/XXXXXX/utils/DomainUtils.groovy: 3: unable to resolve class com.XXXXXX.util.DateHelper
# line 3, column 1.
import com.XXXXXXX.util.DateHelper
^
/Users/XXXXXXX/Documents/XXXX/XXXXX/internal-tools/grails-app/utils/com/XXXXXXXX/utils/TemporalUtil.groovy: 4: unable to resolve class com.XXXXXXX.util.DateHelper
# line 4, column 1.
import com.XXXXXXX.util.DateHelper
^
/Users/XXXXXX/Documents/XXXX/XXXX/internal-tools/grails-app/utils/com/XXXXX/utils/TemporalUtil.groovy: 3: unable to resolve class com.XXXXXXX.data.JodaTemporal
# line 3, column 1.
import com.XXXXXXX.data.JodaTemporal
^
851 errors
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':internal-tools:compileGroovy'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:184)
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:57)
at org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:77)
at org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:65)
at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerCallable.call(AbstractDaemonCompiler.java:88)
at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerCallable.call(AbstractDaemonCompiler.java:76)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:42)
at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:46)
at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:30)
at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:101)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:155)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:137)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
... 3 more
This is the build.gradle
//
// Basic project info
//
description = 'Root Project Build'
ext {
//
// Boilerplate gradle CM support
//
buildMajorVersion = 195
isWindows = org.gradle.internal.os.OperatingSystem.current().windows
}
// Make library versions are available in all projects
allprojects {
ext {
springVersion = '4.1.4.RELEASE'
// Scala versions
scalaVersion = '2.12.3'
scalaBinaryVersion = scalaVersion.tokenize('.').take(2).join('.')
}
}
apply from: 'cm.gradle'
apply from: 'config.gradle'
apply from: 'db.gradle'
apply from: 'test.gradle'
subprojects {
//
// project specific dependencies
//
def springVersion = ext.springVersion
//
// Grails is VERY picky about spring version, so we will
// hold all versions to that defined above regardless of
// transitive dependencies
//
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.springframework' && details.requested.name != 'springloaded') {
details.useVersion springVersion
}
}
}
}
//
// Locations for common configuration
//
ext {
springJndiFile = "$rootDir/dev/jndi/data-source.xml"
}
configurations.all {
// already provided by the JVM, Grails complains if classes show up twice in the classpath
exclude group: 'log4j', module: 'log4j'
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
exclude group: 'commons-logging'
}
//
// Ensure files are compiled with the proper encoding
//
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
tasks.withType(ScalaCompile) {
options.encoding = "UTF-8"
}
afterEvaluate {
if (plugins.hasPlugin('java')) {
dependencies {
// Logback (http://logback.qos.ch/)
runtime 'ch.qos.logback:logback-classic:1.1.3'
// SLF4J (http://www.slf4j.org/)
compile 'org.slf4j:log4j-over-slf4j:1.7.7' // and the log4j bridge
runtime 'org.slf4j:jcl-over-slf4j:1.7.2' // and the commons-logging bridge
runtime "p6spy:p6spy:1.3"
// Spring support (http://www.springsource.org/)
compile "org.springframework:spring-core:${springVersion}"
compile "org.springframework:spring-web:${springVersion}"
compile "org.springframework:spring-webmvc:${springVersion}"
compile "org.springframework:spring-jdbc:${springVersion}"
compile "org.springframework:spring-context-support:${springVersion}"
compile "org.springframework:spring-orm:${springVersion}"
compile "org.springframework:spring-aspects:${springVersion}"
testCompile "org.springframework:spring-test:${springVersion}"
// JPA2 annotations to satisfy a dependency of the spring-aspects
compile 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final'
// Apache Commons (http://commons.apache.org/)
compile 'commons-cli:commons-cli:1.2'
compile 'commons-collections:commons-collections:3.2.1'
compile 'commons-configuration:commons-configuration:1.6'
compile 'commons-io:commons-io:1.4'
compile 'commons-validator:commons-validator:1.6'
// Database connection pooling (https://github.com/brettwooldridge/HikariCP)
compile 'com.zaxxer:HikariCP:2.3.7'
// Joda Time (http://joda-time.sourceforge.net/)
compile 'joda-time:joda-time:2.6'
// Guava (https://code.google.com/p/guava-libraries/)
compile 'com.google.guava:guava:18.0'
// Persistent Collections (http://code.google.com/p/pcollections/)
compile 'org.pcollections:pcollections:2.1.2'
// For removing HTML from error responses
compile "org.jsoup:jsoup:1.7.2"
// Tuples for Java (http://www.javatuples.org)
compile 'org.javatuples:javatuples:1.2'
// Jackson XML (https://github.com/FasterXML/jackson)
compile 'com.fasterxml.jackson.core:jackson-core:2.5.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.0'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.5.0'
// Jackson XML data binding for Joda Time (https://github.com/FasterXML/jackson-datatype-joda)
compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.5.0'
// Jackson Java 8 types (https://github.com/FasterXML/jackson-datatype-jdk8)
compile 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.5.0'
compile 'org.codehaus.groovy:groovy-all:2.4.11'
}
//
// Enable lint compilation for compile output
//
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked"
// Uncomment to display deprecated classes and usage
// options.compilerArgs << "-Xlint:deprecation"
}
//
// Add source jars to the build
//
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
}
}
}
//
// Include the IDE after the block defining the 'provided' configuration
// since that configuration is used for IntelliJ support.
//
apply from: 'ide.gradle'
// So IntelliJ doesn't complain about the output dirs in non-Java projects
idea.module {
outputDir = file("$buildDir/classes/main")
testOutputDir = file("$buildDir/classes/test")
}
task showStatus {
doFirst {
println "Current buildinfo properties: " + buildvcs.getInfo().toString()
}
}
uploadArchives.dependsOn(showStatus)
//
// Do some ordering for clean task for baseline subprojects
//
clean.dependsOn("business-logic:clean")
//
// build script dependency settings
//
buildscript {
repositories {
maven { url "https://repo1.maven.org/maven2/" }
maven { url "http://kercheval.org/mvn-repo/releases/" }
mavenCentral()
}
dependencies {
classpath 'org.kercheval:GradleCMPlugin:1.+'
classpath 'com.jcraft:jsch:0.1.+' // Force a newer version for the CM plugin to fix Github auth issues
classpath 'org.gradle.api.plugins:gradle-nexus-plugin:0.2'
}
}
This is the internal-tools.gradle
description = 'Internal Tools'
ext {
grailsVersion = "3.3.10"
}
apply plugin: "org.grails.grails-web"
apply plugin: "war"
//apply plugin: 'groovy' //Did not help
grails {
grailsVersion = "3.3.10"
// springLoadedVersion = '1.2.4.RELEASE'
}
configurations.all {
// already provided by the JVM, Grails complains if classes show up twice in the classpath
exclude group: 'xml-apis', module: 'xml-apis'
exclude module: 'grails-plugin-log4j'
//provided servlet container
exclude group: 'javax.el', module: 'el-api'
exclude group: 'org.glassfish.web', module: 'el-impl'
}
dependencies {
compile project(':business-logic')
// test(project(path: ':business-logic', configuration: 'testArtifacts'))
def slf4jVersion = '1.7.2'
compile "org.slf4j:jcl-over-slf4j:${slf4jVersion}"
compile "org.slf4j:jul-to-slf4j:${slf4jVersion}"
compile "org.slf4j:slf4j-api:${slf4jVersion}"
// We force a newer version of Ant to work around a bug in the Oracle JRE. This can be removed when Grails upgrades Ant
// See Ant 'Bug 54641' for more details
runtime "org.apache.ant:ant:1.9.2"
runtime "org.apache.ant:ant-junit:1.9.2"
// compile 'org.codehaus.groovy:groovy-all:2.4.15' //Did not help
// Grails
runtime "org.grails:grails-dependencies:$grailsVersion"
// Grails plugins
compile "org.grails.plugins:hibernate4:6.+"
compile "org.grails.plugins:tomcat:7.0.+"
compile "org.grails.plugins:export:1.6"
compile "org.grails.plugins:webflow:2.1.0"
compile 'org.grails.plugins:logback:0.3.1'
runtime "org.grails:grails-plugin-validation:$grailsVersion"
// test "org.grails:grails-test:$grailsVersion"
// test "org.grails:grails-plugin-testing:$grailsVersion"
// test 'org.hamcrest:hamcrest-all:1.1'
// test 'org.mockito:mockito-all:1.8.0'
// test 'nekohtml:nekohtml:1.9.6.2'
// bootstrap 'ch.qos.logback:logback-classic:1.1.3'
}
test {
doFirst {
tasks.getByPath(':dbTestCreate').ext.testDatabase.create()
}
dependsOn(':configProperties')
jvmArgs '-XX:MaxMetaspaceSize=256m'
systemProperty 'XXXXX.conf.file', "$configOutputDir/XXXXX_test.properties"
String protocol = "file:"
systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}
bootRun {
dependsOn(':configProperties', ':dbValidate')
jvmArgs '-XX:MaxMetaspaceSize=256m'
systemProperty 'XXXXX.conf.file', "$configOutputDir/XXXXX_dev.properties"
String protocol = "file:"
systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}
war {
String protocol = "file:"
// systemProperty 'logback.configurationFile', protocol + new File(rootProject.projectDir,"dev/log/logback.xml").getAbsolutePath()
}
// We re-package the war so it will include the extra GradleCM meta-info.
// We use a zip task rather than a war task because the war task adds extra files such as a second web.xml
task reWar(type: Zip, dependsOn: ['war']) {
destinationDir = file("$buildDir/libs")
extension = 'war'
// HACK: the input needs to be wrapped in a closure so it is evaluated lazily. This is because the 'war' task output
// file changes once the version is set
from { zipTree(war.archiveName) }
//
// Build info file
//
from (rootProject.buildinfo.filedir) {
include rootProject.buildinfo.filename
into 'META-INF'
}
}
artifacts {
archives reWar
}
// Ensure tests are run for uploadArchives
uploadArchives.dependsOn('check')
buildscript {
repositories {
maven { url "https://repo1.maven.org/maven2/" }
maven { url "https://dl.bintray.com/jfrog/jfrog-jars/" }
maven { url "https://repo.gradle.org/gradle/libs-releases-local/" }
maven { url "https://repo.spring.io/plugins-release/" }
maven { url "https://repo.maven.apache.org/maven2/" }
mavenCentral()
}
dependencies {
classpath "org.grails:grails-gradle-plugin:3.+"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+"
classpath "org.gradle:gradle-tooling-api:5.+"
classpath "org.codehaus.groovy.modules.http-builder:http-builder:0.7.+"
}
}
Any help is appreciated. This happened when we went from gradle 2.2 to gradle 4.10.2. I'm not sure if I need to upgrade groovy, or grails, or both. If I should post our other .gradle files I can but the other ones are building fine so I did not include them.
I tried adding the apply groovy plugin but that didn't help. I also added the compile 'org.codehaus.groovy:groovy-all:2.4.11' dependency and that did not help either. Has anyone ran into this problem when they upgraded gradle and have groovy/grails in their project?
This built fine with gradle 2.2. I really don't want to upgrade to a higher version than gradle 4.10.2 and I don't want to go below gradle 3.X, but I'm fine changing the version to something in between if that will help. I did try some other versions but that did not help either.

How do I use the native JUnit 5 support in Gradle with the Kotlin DSL?

I want to use the built-in JUnit 5 with the Gradle Kotlin DSL, because during build I get this warning:
WARNING: The junit-platform-gradle-plugin is deprecated and will be discontinued in JUnit Platform 1.3.
Please use Gradle's native support for running tests on the JUnit Platform (requires Gradle 4.6 or higher):
https://junit.org/junit5/docs/current/user-guide/#running-tests-build-gradle
That links tells me to put
test {
useJUnitPlatform()
}
in my build.gradle, but what is the syntax for build.gradle.kts?
My current build file is
import org.gradle.api.plugins.ExtensionAware
import org.junit.platform.gradle.plugin.FiltersExtension
import org.junit.platform.gradle.plugin.EnginesExtension
import org.junit.platform.gradle.plugin.JUnitPlatformExtension
group = "com.example"
version = "0.0"
// JUnit 5
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.junit.platform:junit-platform-gradle-plugin:1.2.0")
}
}
apply {
plugin("org.junit.platform.gradle.plugin")
}
// Kotlin configuration.
plugins {
val kotlinVersion = "1.2.41"
application
kotlin("jvm") version kotlinVersion
java // Required by at least JUnit.
// Plugin which checks for dependency updates with help/dependencyUpdates task.
id("com.github.ben-manes.versions") version "0.17.0"
// Plugin which can update Gradle dependencies, use help/useLatestVersions
id("se.patrikerdes.use-latest-versions") version "0.2.1"
}
application {
mainClassName = "com.example.HelloWorld"
}
dependencies {
compile(kotlin("stdlib"))
// To "prevent strange errors".
compile(kotlin("reflect"))
// Kotlin reflection.
compile(kotlin("test"))
compile(kotlin("test-junit"))
// JUnit 5
testImplementation("org.junit.jupiter:junit-jupiter-api:5.2.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.2.0")
testRuntime("org.junit.platform:junit-platform-console:1.2.0")
// Kotlintest
testCompile("io.kotlintest:kotlintest-core:3.1.0-RC2")
testCompile("io.kotlintest:kotlintest-assertions:3.1.0-RC2")
testCompile("io.kotlintest:kotlintest-runner-junit5:3.1.0-RC2")
}
repositories {
mavenCentral()
mavenLocal()
jcenter()
}
(The following is some blabla because this question 'contains mostly code').
I tried to find documentation on how to customize tasks in the Kotlin DSL, but I couldn't find any. In normal Groovy you can just write the name of the task and then change things in the block, but the Kotlin DSL doesn't recognise the task as such, unresolved reference.
Also, this question is related but asks for creating of new tasks, instead of customize existing tasks: How do I overwrite a task in gradle kotlin-dsl
Here is a solution for normal Gradle.
[Edit april 2019] As Pedro has found, three months after I asked this question Gradle actually created a user guide for the Kotlin DSL which can be visited at https://docs.gradle.org/current/userguide/kotlin_dsl.html
They also added a migration guide from Groovy to Kotlin at https://guides.gradle.org/migrating-build-logic-from-groovy-to-kotlin/
Answer:
The syntax you ask for is
tasks.test {
// Use the built-in JUnit support of Gradle.
useJUnitPlatform()
}
which I figured out from this example file from the Kotlin DSL GitHub, or you can use
tasks.withType<Test> {
useJUnitPlatform()
}
which is used in the this official userguide which was created a couple of months after this answer was written (thanks to Pedro's answer for noting this).
But in any case you actually are still using the buildscript block, which is a bit deprecated itself, use the new plugins DSL instead (docs). New build.gradle.kts becomes
group = "com.example"
version = "0.0"
plugins {
val kotlinVersion = "1.2.41"
application
kotlin("jvm") version kotlinVersion
java // Required by at least JUnit.
// Plugin which checks for dependency updates with help/dependencyUpdates task.
id("com.github.ben-manes.versions") version "0.17.0"
// Plugin which can update Gradle dependencies, use help/useLatestVersions
id("se.patrikerdes.use-latest-versions") version "0.2.1"
}
application {
mainClassName = "com.example.HelloWorld"
}
dependencies {
compile(kotlin("stdlib"))
// To "prevent strange errors".
compile(kotlin("reflect"))
// Kotlin reflection.
compile(kotlin("test"))
compile(kotlin("test-junit"))
// JUnit 5
testImplementation("org.junit.jupiter:junit-jupiter-api:5.2.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.2.0")
testRuntime("org.junit.platform:junit-platform-console:1.2.0")
// Kotlintest
testCompile("io.kotlintest:kotlintest-core:3.1.0-RC2")
testCompile("io.kotlintest:kotlintest-assertions:3.1.0-RC2")
testCompile("io.kotlintest:kotlintest-runner-junit5:3.1.0-RC2")
}
repositories {
mavenCentral()
mavenLocal()
jcenter()
}
tasks {
// Use the native JUnit support of Gradle.
"test"(Test::class) {
useJUnitPlatform()
}
}
(Since the Gradle Kotlin DSL has almost no documentation at all except a few (undocumented) example files on GitHub, I'm documenting a few common examples here.)
(Complete example project at GitHub, self-promotion...)
Adding on top of accepted answer, it is also possible to use typed task configuration like:
tasks.withType<Test> {
useJUnitPlatform()
}
Update:
Gradle docs for reference here. Specifically Example 19 which has:
tasks.withType<JavaCompile> {
options.isWarnings = true
// ...
}
this worked for me till now...
plugins {
kotlin("jvm") version "1.7.10"
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation(kotlin("test"))
testImplementation("org.junit.jupiter:junit-jupiter:5.9.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0")
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}

Error using Gradle Vaadin Plugin

I am trying to add Gradle Vaadin Plugin to my project, but I get the below error.
Errors in 'jar:file:/C:/Users/DEMO/.gradle/caches/modules-2/files-2.1/com.google.gwt/gwt-user/2.8.1/9a13fbee70848f1f1cddd3ae33ad180af3392d9e/gwt-user-2.8.1.jar!/com/google/gwt/vali
dation/client/impl/GwtValidatorContext.java'
Line 29: The type GwtValidatorContext must implement the inherited abstract method ValidatorContext.parameterNameProvider(ParameterNameProvider)
Tracing compile failure path for type 'com.vaadin.client.communication.AtmospherePushConnection'
Errors in 'jar:file:/C:/Users/DEMO/.m2/repository/com/vaadin/vaadin-client/8.0.6/vaadin-client-8.0.6.jar!/com/vaadin/client/communication/AtmospherePushConnection.java'
Line 212: PUSH_ID_PARAMETER cannot be resolved or is not a field
Tracing compile failure path for type 'javax.validation.executable.ExecutableValidator'
Errors in 'jar:file:/C:/Users/DEMO/.gradle/caches/modules-2/files-2.1/javax.validation/validation-api/1.1.0.Final/7d49b53caed9bd81d172807c3e096d24f3c57090/validation-api-1.1.0.Fina
l-sources.jar!/javax/validation/executable/ExecutableValidator.java'
Line 53: No source code is available for type java.lang.reflect.Method; did you forget to inherit a required module?
Line 94: No source code is available for type java.lang.reflect.Constructor<T>; did you forget to inherit a required module?
Tracing compile failure path for type 'com.vaadin.client.communication.MessageHandler'
Errors in 'jar:file:/C:/Users/DEMO/.m2/repository/com/vaadin/vaadin-client/8.0.6/vaadin-client-8.0.6.jar!/com/vaadin/client/communication/MessageHandler.java'
Line 358: UIDL_PUSH_ID cannot be resolved or is not a field
Line 359: UIDL_PUSH_ID cannot be resolved or is not a field
Tracing compile failure path for type 'com.google.gwt.validation.client.impl.PropertyDescriptorImpl'
Errors in 'jar:file:/C:/Users/DEMO/.gradle/caches/modules-2/files-2.1/com.google.gwt/gwt-user/2.8.1/9a13fbee70848f1f1cddd3ae33ad180af3392d9e/gwt-user-2.8.1.jar!/com/google/gwt/vali
dation/client/impl/PropertyDescriptorImpl.java'
Line 31: The type PropertyDescriptorImpl must implement the inherited abstract method CascadableDescriptor.getGroupConversions()
Errors in 'jar:file:/C:/Users/DEMO/.gradle/caches/modules-2/files-2.1/com.google.gwt/gwt-user/2.8.1/9a13fbee70848f1f1cddd3ae33ad180af3392d9e/gwt-user-2.8.1.jar!/com/google/gwt/vali
dation/client/impl/ConstraintDescriptorImpl.java'
Line 35: The type ConstraintDescriptorImpl<T> must implement the inherited abstract method ConstraintDescriptor<T>.getMessageTemplate()
Line 35: The type ConstraintDescriptorImpl<T> must implement the inherited abstract method ConstraintDescriptor<T>.getValidationAppliesTo()
Tracing compile failure path for type 'com.google.gwt.validation.client.impl.GwtBeanDescriptorImpl'
Here is the page for the plugin: https://github.com/johndevs/gradle-vaadin-plugin/wiki
And, here is my build.gradle file:
buildscript {
ext {
springBootVersion = '1.5.3.RELEASE'
}
repositories {
mavenCentral()
maven {
url "http://maven.vaadin.com/vaadin-addons"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id 'com.devsoap.plugin.vaadin' version '1.2.1'
id 'org.springframework.boot' version '1.5.3.RELEASE'
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'jacoco'
apply plugin: 'application'
jar {
baseName = 'testapp'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
maven {
url "http://maven.vaadin.com/vaadin-addons"
}
}
sourceSets {
main {
output.resourcesDir = "build/classes/main"
}
uiTest {
java.srcDirs=['src/ui-test/java','src/main/java']
resources.srcDir 'src/ui-test/resources'
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-jersey')
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')
// Spring Boot Security
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.security.oauth:spring-security-oauth2")
compile('org.springframework.security:spring-security-ldap')
// Spring Actuator
compile("org.springframework.boot:spring-boot-starter-actuator")
// Spring Boot JDBC Starter
compile("org.springframework.boot:spring-boot-starter-jdbc")
// Vaadin
compile('com.vaadin:vaadin-spring-boot-starter')
compile('com.vaadin:vaadin-push')
// Vaadin add-ons
compile("org.vaadin.spring.addons:vaadin-spring-addon-eventbus:2.0.0.RELEASE")
//Vaadin extentions
compile("org.vaadin.spring.extensions:vaadin-spring-ext-security:2.0.0.RELEASE")
// Lombok
compile("org.projectlombok:lombok")
// MyBatis
compile("org.mybatis:mybatis-spring:1.2.3")
compile("org.mybatis:mybatis:3.3.0")
// BoneCP - Connection Pooling
compile("com.jolbox:bonecp:0.8.0.RELEASE")
// PostgreSQL
compile("org.postgresql:postgresql:9.4-1204-jdbc42")
//Vaadin Testbench
uiTestCompile("com.vaadin:vaadin-testbench:5.0.0")
//TypeAhead widget
compile name: 'typeaheadSearchBox-1.0-SNAPSHOT'
}
// Create a new task called uiTest and set its type to Test.
// Configure the location of the compiled test classes.
// Configure the classpath that is used when our integration tests are run.
configurations {
uiTestCompile.extendsFrom testCompile
uiTestRuntime.extendsFrom testRuntime
}
task uiTest(type: Test) {
testClassesDir = sourceSets.uiTest.output.classesDir
classpath = sourceSets.uiTest.runtimeClasspath
}
dependencyManagement {
imports {
mavenBom "com.vaadin:vaadin-bom:8.0.3"
}
}
jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}
check.dependsOn jacocoTestReport
springBoot {
// Main class of #SpringBootApplication
mainClass = 'com.sample.test.Application'
}
When I check the gradle dependencies, I see 2 version of the "javax.validation:validation-api".
I believe that is causing the problem, but I could not find a way to force vaadin-client to use "javax.validation:validation-api:1.0.0.GA".
I appreciate if you can help me to correct the build.gradle.
The Gradle Vaadin plugin must see the Springboot plugin to do a proper setup. So you have to first use the Springboot plugin, then afterwards the Vaadin plugin.
The reason for the error you see there is, that the dep for javax.validation 1.1 from Springboot overrides all configurations (also the one used to build the client for Vaadin)
On a side note: you apply the Springboot plugin twice -- once in plugins, once with apply. I'd get rid of the buildscript-block and the apply. Then swap the items in plugins.

Resources